@ticketlayer/elements 0.3.3 → 0.4.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.
Files changed (134) hide show
  1. package/README.md +3 -2
  2. package/dist/cjs/{index-BpfoKd9Q.js → index-I9CoYv3k.js} +1 -1
  3. package/dist/cjs/index.cjs.js +1 -1
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/cjs/money-BtmM2gt-.js +118 -0
  6. package/dist/cjs/{order-summary-ZMkJ5bez.js → order-summary-X3TlZxc2.js} +34 -0
  7. package/dist/cjs/ticketlayer-elements.cjs.js +2 -2
  8. package/dist/cjs/tl-buy-modal.cjs.entry.js +3 -3
  9. package/dist/cjs/tl-buy-tickets-button.cjs.entry.js +10 -7
  10. package/dist/cjs/tl-buy-tickets-wrapper.cjs.entry.js +2 -2
  11. package/dist/cjs/tl-cart-badge.cjs.entry.js +2 -2
  12. package/dist/cjs/tl-cart-drawer.cjs.entry.js +3 -3
  13. package/dist/cjs/tl-cart.cjs.entry.js +10 -4
  14. package/dist/cjs/tl-checkout-wrapper.cjs.entry.js +2 -2
  15. package/dist/cjs/tl-event-card.cjs.entry.js +4 -3
  16. package/dist/cjs/tl-event-list.cjs.entry.js +2 -2
  17. package/dist/cjs/tl-login.cjs.entry.js +4 -3
  18. package/dist/cjs/tl-my-orders.cjs.entry.js +4 -3
  19. package/dist/cjs/tl-occurrence-selector_2.cjs.entry.js +454 -122
  20. package/dist/cjs/tl-order-confirmation.cjs.entry.js +11 -8
  21. package/dist/cjs/tl-order-tickets_2.cjs.entry.js +3 -3
  22. package/dist/cjs/tl-promo-code.cjs.entry.js +4 -3
  23. package/dist/cjs/tl-seat-map.cjs.entry.js +2 -2
  24. package/dist/collection/components/tl-buy-modal/tl-buy-modal.css +12 -19
  25. package/dist/collection/components/tl-buy-modal/tl-buy-modal.js +1 -1
  26. package/dist/collection/components/tl-buy-tickets-button/tl-buy-tickets-button.css +4 -4
  27. package/dist/collection/components/tl-buy-tickets-button/tl-buy-tickets-button.js +8 -5
  28. package/dist/collection/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.css +2 -2
  29. package/dist/collection/components/tl-cart/tl-cart.css +52 -51
  30. package/dist/collection/components/tl-cart/tl-cart.js +8 -2
  31. package/dist/collection/components/tl-cart-badge/tl-cart-badge.css +11 -11
  32. package/dist/collection/components/tl-cart-drawer/tl-cart-drawer.css +6 -6
  33. package/dist/collection/components/tl-cart-drawer/tl-cart-drawer.js +1 -1
  34. package/dist/collection/components/tl-checkout-wrapper/tl-checkout-wrapper.css +2 -2
  35. package/dist/collection/components/tl-event-card/tl-event-card.css +22 -22
  36. package/dist/collection/components/tl-event-list/tl-event-list.css +17 -17
  37. package/dist/collection/components/tl-login/tl-login.css +26 -26
  38. package/dist/collection/components/tl-my-orders/tl-my-orders.css +40 -40
  39. package/dist/collection/components/tl-occurrence-selector/tl-occurrence-selector.css +54 -65
  40. package/dist/collection/components/tl-order-confirmation/tl-order-confirmation.css +38 -38
  41. package/dist/collection/components/tl-order-confirmation/tl-order-confirmation.js +8 -6
  42. package/dist/collection/components/tl-order-tickets/tl-order-tickets.css +9 -9
  43. package/dist/collection/components/tl-promo-code/tl-promo-code.css +25 -25
  44. package/dist/collection/components/tl-seat-map/tl-seat-map.css +10 -10
  45. package/dist/collection/components/tl-ticket/tl-ticket.css +13 -13
  46. package/dist/collection/components/tl-ticket-selector/tl-ticket-selector.css +74 -49
  47. package/dist/collection/components/tl-ticket-selector/tl-ticket-selector.js +72 -126
  48. package/dist/collection/utils/cart-totals.js +9 -0
  49. package/dist/collection/utils/order-summary.js +36 -0
  50. package/dist/components/money.js +1 -0
  51. package/dist/components/order-summary.js +1 -1
  52. package/dist/components/tl-buy-modal.js +1 -1
  53. package/dist/components/tl-buy-tickets-button.js +1 -1
  54. package/dist/components/tl-buy-tickets-wrapper2.js +1 -1
  55. package/dist/components/tl-cart-badge.js +1 -1
  56. package/dist/components/tl-cart-drawer.js +1 -1
  57. package/dist/components/tl-cart2.js +1 -1
  58. package/dist/components/tl-checkout-wrapper2.js +1 -1
  59. package/dist/components/tl-event-card2.js +1 -1
  60. package/dist/components/tl-event-list.js +1 -1
  61. package/dist/components/tl-login2.js +1 -1
  62. package/dist/components/tl-my-orders.js +1 -1
  63. package/dist/components/tl-occurrence-selector2.js +1 -1
  64. package/dist/components/tl-order-confirmation.js +1 -1
  65. package/dist/components/tl-order-tickets2.js +1 -1
  66. package/dist/components/tl-promo-code.js +1 -1
  67. package/dist/components/tl-seat-map.js +1 -1
  68. package/dist/components/tl-ticket-selector2.js +1 -1
  69. package/dist/components/tl-ticket2.js +1 -1
  70. package/dist/elements.docs.json +4 -4
  71. package/dist/esm/{index-CNX8hZa8.js → index-OoYV1faY.js} +1 -1
  72. package/dist/esm/index.js +1 -1
  73. package/dist/esm/loader.js +3 -3
  74. package/dist/esm/money-4ig0-WB6.js +112 -0
  75. package/dist/esm/{order-summary-BGekdjN9.js → order-summary-DiDtvfZM.js} +34 -1
  76. package/dist/esm/ticketlayer-elements.js +3 -3
  77. package/dist/esm/tl-buy-modal.entry.js +3 -3
  78. package/dist/esm/tl-buy-tickets-button.entry.js +10 -7
  79. package/dist/esm/tl-buy-tickets-wrapper.entry.js +2 -2
  80. package/dist/esm/tl-cart-badge.entry.js +2 -2
  81. package/dist/esm/tl-cart-drawer.entry.js +3 -3
  82. package/dist/esm/tl-cart.entry.js +10 -4
  83. package/dist/esm/tl-checkout-wrapper.entry.js +2 -2
  84. package/dist/esm/tl-event-card.entry.js +4 -3
  85. package/dist/esm/tl-event-list.entry.js +2 -2
  86. package/dist/esm/tl-login.entry.js +4 -3
  87. package/dist/esm/tl-my-orders.entry.js +4 -3
  88. package/dist/esm/tl-occurrence-selector_2.entry.js +455 -123
  89. package/dist/esm/tl-order-confirmation.entry.js +11 -8
  90. package/dist/esm/tl-order-tickets_2.entry.js +3 -3
  91. package/dist/esm/tl-promo-code.entry.js +4 -3
  92. package/dist/esm/tl-seat-map.entry.js +2 -2
  93. package/dist/ticketlayer-elements/index.esm.js +1 -1
  94. package/dist/ticketlayer-elements/p-0814420f.entry.js +1 -0
  95. package/dist/ticketlayer-elements/p-0acabc26.entry.js +1 -0
  96. package/dist/ticketlayer-elements/{p-9629029a.entry.js → p-109a3feb.entry.js} +1 -1
  97. package/dist/ticketlayer-elements/{p-e02079fa.entry.js → p-1a4ba71c.entry.js} +1 -1
  98. package/dist/ticketlayer-elements/p-318965c1.entry.js +1 -0
  99. package/dist/ticketlayer-elements/p-347c7fd1.entry.js +1 -0
  100. package/dist/ticketlayer-elements/p-3649c26d.entry.js +1 -0
  101. package/dist/ticketlayer-elements/p-40260cc9.entry.js +1 -0
  102. package/dist/ticketlayer-elements/p-4ig0-WB6.js +1 -0
  103. package/dist/ticketlayer-elements/p-55fd2f9f.entry.js +1 -0
  104. package/dist/ticketlayer-elements/p-62ee659b.entry.js +1 -0
  105. package/dist/ticketlayer-elements/p-7d4ecc2b.entry.js +1 -0
  106. package/dist/ticketlayer-elements/p-7f0abf95.entry.js +1 -0
  107. package/dist/ticketlayer-elements/p-BXpVGW51.js +1 -0
  108. package/dist/ticketlayer-elements/p-OoYV1faY.js +3 -0
  109. package/dist/ticketlayer-elements/p-a3c1b26c.entry.js +1 -0
  110. package/dist/ticketlayer-elements/{p-1c51cbc1.entry.js → p-ac264adc.entry.js} +1 -1
  111. package/dist/ticketlayer-elements/{p-895ba1f3.entry.js → p-aeb4c6fb.entry.js} +1 -1
  112. package/dist/ticketlayer-elements/{p-fa639d88.entry.js → p-ba62541f.entry.js} +1 -1
  113. package/dist/ticketlayer-elements/ticketlayer-elements.css +1 -1
  114. package/dist/ticketlayer-elements/ticketlayer-elements.esm.js +1 -1
  115. package/dist/types/components/tl-cart/tl-cart.d.ts +10 -0
  116. package/dist/types/components/tl-ticket-selector/tl-ticket-selector.d.ts +40 -29
  117. package/dist/types/components.d.ts +32 -0
  118. package/dist/types/utils/cart-totals.d.ts +10 -0
  119. package/dist/types/utils/order-summary.d.ts +34 -0
  120. package/elements.catalogue.json +91 -22
  121. package/package.json +12 -6
  122. package/dist/ticketlayer-elements/p-0b1d16f8.entry.js +0 -1
  123. package/dist/ticketlayer-elements/p-1471f6d8.entry.js +0 -1
  124. package/dist/ticketlayer-elements/p-5169f68b.entry.js +0 -1
  125. package/dist/ticketlayer-elements/p-8d5722e1.entry.js +0 -1
  126. package/dist/ticketlayer-elements/p-917d8e09.entry.js +0 -1
  127. package/dist/ticketlayer-elements/p-BGekdjN9.js +0 -1
  128. package/dist/ticketlayer-elements/p-CNX8hZa8.js +0 -3
  129. package/dist/ticketlayer-elements/p-a22714d0.entry.js +0 -1
  130. package/dist/ticketlayer-elements/p-bf73044b.entry.js +0 -1
  131. package/dist/ticketlayer-elements/p-e04ace15.entry.js +0 -1
  132. package/dist/ticketlayer-elements/p-e6fab1d5.entry.js +0 -1
  133. package/dist/ticketlayer-elements/p-f826b753.entry.js +0 -1
  134. package/dist/ticketlayer-elements/p-fbaca948.entry.js +0 -1
@@ -1,5 +1,15 @@
1
1
  import { h } from "@stencil/core";
2
- import { getSDK, hasSDK, whenSDK } from "../../utils/sdk-connector";
2
+ import { createElement, ticketSelectorCore, } from "@ticketlayer/elements-core";
3
+ import { getSDK, whenSDK } from "../../utils/sdk-connector";
4
+ /**
5
+ * The web harness for `ticketSelectorCore`.
6
+ *
7
+ * It renders and it forwards: every decision, every string and every sum is in
8
+ * `@ticketlayer/elements-core` (AGENTS.md, TKT-11). What is left here is the
9
+ * Stencil surface a host writes HTML against - the tag, the attributes, the
10
+ * three `tl*` events - plus the one thing that is genuinely web: finding the
11
+ * client the page published on `window.Ticketlayer`.
12
+ */
3
13
  export class TlTicketSelector {
4
14
  constructor() {
5
15
  /**
@@ -10,19 +20,49 @@ export class TlTicketSelector {
10
20
  * Button label
11
21
  */
12
22
  this.buttonLabel = 'Add to Cart';
13
- this.ticketTypes = [];
14
- this.quantities = {};
15
- this.loading = true;
16
- this.error = null;
17
- this.adding = false;
18
- this.addSuccess = false;
23
+ this.element = createElement(ticketSelectorCore, {
24
+ client: () => getSDK(),
25
+ emit: (event, detail) => this.forward(event, detail),
26
+ });
27
+ /** The core's whole view. Assigning it is what makes Stencil re-render. */
28
+ this.view = this.element.view;
29
+ }
30
+ /**
31
+ * The fee the surface has quoted for this selection. Core state, exposed here
32
+ * because it is set from outside the element and not from an attribute: there
33
+ * is no quote operation on the buyer-facing surface yet, so it stays null and
34
+ * no fee row is rendered.
35
+ */
36
+ get feeQuote() {
37
+ return this.element.state.feeQuote;
38
+ }
39
+ set feeQuote(quote) {
40
+ this.element.actions.setFeeQuote(quote);
19
41
  }
20
42
  watchPropsChange() {
21
- this.loadTicketTypes();
43
+ this.syncProps();
44
+ this.element.actions.load();
45
+ }
46
+ syncProps() {
47
+ this.element.setProps({
48
+ eventId: this.eventId,
49
+ occurrenceId: this.occurrenceId,
50
+ showButton: this.showButton,
51
+ buttonLabel: this.buttonLabel,
52
+ });
22
53
  }
23
54
  async componentWillLoad() {
55
+ this.syncProps();
56
+ this.unsubscribe = this.element.subscribe((view) => {
57
+ this.view = view;
58
+ });
59
+ this.view = this.element.view;
24
60
  await this.waitForSDKAndLoad();
25
61
  }
62
+ disconnectedCallback() {
63
+ this.unsubscribe?.();
64
+ this.element.destroy();
65
+ }
26
66
  /**
27
67
  * Wait for SDK to be ready, then load ticket types
28
68
  */
@@ -32,135 +72,40 @@ export class TlTicketSelector {
32
72
  }
33
73
  try {
34
74
  await whenSDK();
35
- await this.loadTicketTypes();
36
- }
37
- catch (err) {
38
- this.error = err instanceof Error ? err.message : 'SDK not initialized.';
39
- this.loading = false;
40
- }
41
- }
42
- async loadTicketTypes() {
43
- try {
44
- console.log('[tl-ticket-selector] Loading ticket types...', {
45
- eventId: this.eventId,
46
- occurrenceId: this.occurrenceId
47
- });
48
- this.loading = true;
49
- this.error = null;
50
- const sdk = getSDK();
51
- const eventsManager = sdk.getEventsManager();
52
- const types = await eventsManager.getTicketTypes(this.eventId, this.occurrenceId);
53
- console.log('[tl-ticket-selector] Ticket types loaded:', types.length);
54
- this.ticketTypes = types;
55
- // Initialise quantities to 0
56
- const initialQuantities = {};
57
- types.forEach((t) => {
58
- initialQuantities[t.id] = 0;
59
- });
60
- this.quantities = initialQuantities;
75
+ await this.element.actions.load();
61
76
  }
62
77
  catch (err) {
63
- console.error('[tl-ticket-selector] Failed to load ticket types:', err);
64
- this.error = err instanceof Error ? err.message : 'Failed to load tickets';
65
- this.tlError.emit({ message: this.error });
78
+ this.element.actions.connectFailed(err instanceof Error ? err.message : this.view.strings.noClient);
66
79
  }
67
- finally {
68
- this.loading = false;
69
- }
70
- }
71
- handleQuantityChange(ticketTypeId, delta) {
72
- const ticketType = this.ticketTypes.find(t => t.id === ticketTypeId);
73
- if (!ticketType)
74
- return;
75
- const currentQty = this.quantities[ticketTypeId] || 0;
76
- const newQty = Math.max(0, Math.min(ticketType.maxPerOrder, currentQty + delta));
77
- this.quantities = {
78
- ...this.quantities,
79
- [ticketTypeId]: newQty,
80
- };
81
- const total = this.calculateTotal();
82
- this.tlQuantityChange.emit({ ticketTypeId, quantity: newQty, total });
83
- }
84
- calculateTotal() {
85
- return this.ticketTypes.reduce((sum, tt) => {
86
- return sum + (this.quantities[tt.id] || 0) * tt.price;
87
- }, 0);
88
80
  }
89
- getTotalItems() {
90
- return Object.values(this.quantities).reduce((sum, qty) => sum + qty, 0);
91
- }
92
- async handleAddToCart() {
93
- const itemsToAdd = Object.entries(this.quantities)
94
- .filter(([_, qty]) => qty > 0)
95
- .map(([ticketTypeId, quantity]) => ({ ticketTypeId, quantity }));
96
- if (itemsToAdd.length === 0)
97
- return;
98
- this.adding = true;
99
- this.addSuccess = false;
100
- try {
101
- if (hasSDK()) {
102
- const sdk = getSDK();
103
- const cartManager = sdk.getCartManager?.();
104
- if (cartManager) {
105
- for (const item of itemsToAdd) {
106
- await cartManager.addItem(item.ticketTypeId, item.quantity, this.occurrenceId);
107
- }
108
- console.log('[tl-ticket-selector] Items added to cart');
109
- }
110
- }
111
- // Reset quantities after adding
112
- const resetQuantities = {};
113
- this.ticketTypes.forEach(t => {
114
- resetQuantities[t.id] = 0;
115
- });
116
- this.quantities = resetQuantities;
117
- this.addSuccess = true;
118
- // Clear success message after 3 seconds
119
- setTimeout(() => {
120
- this.addSuccess = false;
121
- }, 3000);
122
- this.tlAddToCart.emit({ items: itemsToAdd });
123
- }
124
- catch (err) {
125
- console.error('[tl-ticket-selector] Failed to add to cart:', err);
126
- this.error = err instanceof Error ? err.message : 'Failed to add to cart';
127
- this.tlError.emit({ message: this.error });
128
- }
129
- finally {
130
- this.adding = false;
81
+ forward(event, detail) {
82
+ if (event === 'tlAddToCart')
83
+ this.tlAddToCart.emit(detail);
84
+ else if (event === 'tlQuantityChange') {
85
+ this.tlQuantityChange.emit(detail);
131
86
  }
132
- }
133
- formatPrice(priceInPence, currency = 'GBP') {
134
- return new Intl.NumberFormat('en-GB', {
135
- style: 'currency',
136
- currency,
137
- }).format(priceInPence / 100);
87
+ else if (event === 'tlError')
88
+ this.tlError.emit(detail);
138
89
  }
139
90
  renderSkeleton() {
140
91
  return (h("div", { class: "skeleton-container" }, h("div", { class: "skeleton-row" }), h("div", { class: "skeleton-row" }), h("div", { class: "skeleton-row" })));
141
92
  }
142
93
  renderError() {
143
- return (h("div", { class: "error-state" }, h("p", { class: "error-message" }, this.error)));
94
+ return (h("div", { class: "error-state" }, h("p", { class: "error-message" }, this.view.state.error)));
144
95
  }
145
- renderTicketRow(tt) {
146
- const isSoldOut = tt.availabilityStatus === 'sold_out';
147
- const qty = this.quantities[tt.id] || 0;
148
- return (h("div", { class: `ticket-row ${isSoldOut ? 'sold-out' : ''}`, key: tt.id }, h("div", { class: "ticket-info" }, h("div", { class: "ticket-header" }, h("span", { class: "ticket-name" }, tt.name), tt.availabilityStatus === 'limited' && (h("span", { class: "status-badge limited" }, "Limited")), isSoldOut && (h("span", { class: "status-badge sold-out" }, "Sold Out"))), tt.description && (h("p", { class: "ticket-description" }, tt.description)), h("p", { class: "ticket-price" }, this.formatPrice(tt.price, tt.currency))), h("div", { class: "quantity-controls" }, h("button", { class: "qty-btn", onClick: () => this.handleQuantityChange(tt.id, -1), disabled: isSoldOut || qty === 0, "aria-label": "Decrease quantity" }, "\u2212"), h("span", { class: "qty-value" }, qty), h("button", { class: "qty-btn", onClick: () => this.handleQuantityChange(tt.id, 1), disabled: isSoldOut || qty >= tt.maxPerOrder, "aria-label": "Increase quantity" }, "+"))));
96
+ renderTicketRow(row) {
97
+ const strings = this.view.strings;
98
+ return (h("div", { class: `ticket-row ${row.soldOut ? 'sold-out' : ''}`, key: row.id }, h("div", { class: "ticket-info" }, h("div", { class: "ticket-header" }, h("span", { class: "ticket-name" }, row.name), row.limited && h("span", { class: "status-badge limited" }, strings.limited), row.soldOut && h("span", { class: "status-badge sold-out" }, strings.soldOut)), row.description && h("p", { class: "ticket-description" }, row.description), h("p", { class: "ticket-price" }, row.priceLabel)), h("div", { class: "quantity-controls" }, h("button", { class: "qty-btn", onClick: () => this.element.actions.changeQuantity(row.id, -1), disabled: !row.canDecrease, "aria-label": strings.decrease }, "\u2212"), h("span", { class: "qty-value" }, row.quantity), h("button", { class: "qty-btn", onClick: () => this.element.actions.changeQuantity(row.id, 1), disabled: !row.canIncrease, "aria-label": strings.increase }, "+"))));
149
99
  }
150
100
  render() {
151
- if (this.loading) {
101
+ const { status, state, strings, derived } = this.view;
102
+ if (status === 'loading') {
152
103
  return this.renderSkeleton();
153
104
  }
154
- if (this.error) {
105
+ if (status === 'error') {
155
106
  return this.renderError();
156
107
  }
157
- const totalItems = this.getTotalItems();
158
- const totalPrice = this.calculateTotal();
159
- return (h("div", { class: "ticket-selector" }, h("div", { class: "ticket-list" }, this.ticketTypes.map(tt => this.renderTicketRow(tt))), this.addSuccess && (h("div", { class: "success-message" }, h("svg", { class: "success-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M5 13l4 4L19 7" })), "Added to cart!")), this.showButton && (h("button", { class: `add-to-cart-btn ${totalItems === 0 ? 'disabled' : ''}`, onClick: () => this.handleAddToCart(), disabled: totalItems === 0 || this.adding }, this.adding
160
- ? 'Adding...'
161
- : totalItems === 0
162
- ? 'Select Tickets'
163
- : `${this.buttonLabel} - ${this.formatPrice(totalPrice)}`))));
108
+ return (h("div", { class: "ticket-selector" }, h("div", { class: "ticket-list" }, derived.rows.map((row) => this.renderTicketRow(row))), derived.showTotals && (h("div", { class: "selection-totals" }, h("div", { class: "total-row" }, h("span", null, strings.ticketsRow), h("span", null, derived.subtotalLabel)), h("div", { class: "total-row fee" }, h("span", null, derived.totals.feeLabel), h("span", null, derived.feeLabel)), h("div", { class: "total-row total" }, h("span", null, strings.totalRow), h("span", null, derived.totalLabel)))), state.addSuccess && (h("div", { class: "success-message" }, h("svg", { class: "success-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M5 13l4 4L19 7" })), strings.added)), this.showButton && (h("button", { class: `add-to-cart-btn ${derived.totalItems === 0 ? 'disabled' : ''}`, onClick: () => this.element.actions.addToCart(), disabled: derived.actionDisabled }, derived.actionLabel))));
164
109
  }
165
110
  static get is() { return "tl-ticket-selector"; }
166
111
  static get encapsulation() { return "shadow"; }
@@ -258,12 +203,7 @@ export class TlTicketSelector {
258
203
  }
259
204
  static get states() {
260
205
  return {
261
- "ticketTypes": {},
262
- "quantities": {},
263
- "loading": {},
264
- "error": {},
265
- "adding": {},
266
- "addSuccess": {}
206
+ "view": {}
267
207
  };
268
208
  }
269
209
  static get events() {
@@ -327,6 +267,12 @@ export class TlTicketSelector {
327
267
  }, {
328
268
  "propName": "occurrenceId",
329
269
  "methodName": "watchPropsChange"
270
+ }, {
271
+ "propName": "showButton",
272
+ "methodName": "syncProps"
273
+ }, {
274
+ "propName": "buttonLabel",
275
+ "methodName": "syncProps"
330
276
  }];
331
277
  }
332
278
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The money rows a cart-shaped view renders.
3
+ *
4
+ * The rule and the arithmetic moved to `@ticketlayer/elements-core` with the
5
+ * core split (TKT-68): it is behaviour, and behaviour lives in a core so every
6
+ * harness derives the same figures. This file stays as the import path the
7
+ * components and their specs already use.
8
+ */
9
+ export { cartTotals, expressesFee, minorUnits, selectionTotals, FEE_LABEL_FALLBACK, } from '@ticketlayer/elements-core';
@@ -1,3 +1,4 @@
1
+ import { expressesFee, minorUnits, FEE_LABEL_FALLBACK } from "./cart-totals";
1
2
  /** Money arrives as minor-unit integers or decimal strings ("50.00"). */
2
3
  export function formatPrice(value, currency = 'GBP') {
3
4
  if (value === null || value === undefined || value === '')
@@ -99,3 +100,38 @@ export async function resolveOccurrence(sdk, occurrenceId, maxEvents = 12) {
99
100
  }
100
101
  return null;
101
102
  }
103
+ export function orderTotals(order) {
104
+ const o = order || {};
105
+ const items = Array.isArray(o.items) ? o.items : [];
106
+ const feeLines = items.filter((i) => i.type === 'fee');
107
+ const discountLines = items.filter((i) => i.type === 'discount');
108
+ const tickets = ticketItems(o);
109
+ const feeFromLines = feeLines.length
110
+ ? feeLines.reduce((sum, i) => sum + (minorUnits(i.subtotal) ?? 0), 0)
111
+ : null;
112
+ const fees = feeFromLines ?? minorUnits(o.totalFees) ?? 0;
113
+ const declaredSubtotal = minorUnits(o.subtotal);
114
+ const subtotal = tickets.length
115
+ ? tickets.reduce((sum, i) => sum + (minorUnits(i.subtotal) ?? 0), 0)
116
+ : (declaredSubtotal ?? 0) - fees;
117
+ const discountFromLines = discountLines.length
118
+ ? discountLines.reduce((sum, i) => sum + Math.abs(minorUnits(i.subtotal) ?? 0), 0)
119
+ : null;
120
+ const discount = minorUnits(o.totalDiscounts) ?? discountFromLines ?? 0;
121
+ const tax = minorUnits(o.totalTax) ?? 0;
122
+ const named = feeLines.some((i) => typeof i.name === 'string' && !!i.name);
123
+ return {
124
+ currency: o.currency || 'GBP',
125
+ subtotal,
126
+ fees,
127
+ feeLabel: feeLines.map((i) => i.name).find((n) => !!n) || FEE_LABEL_FALLBACK,
128
+ showFee: expressesFee(feeFromLines ?? minorUnits(o.totalFees), named),
129
+ tax,
130
+ discount,
131
+ total: minorUnits(o.total) ?? subtotal + fees + tax - discount,
132
+ };
133
+ }
134
+ /** The rows add up to the total the order reports. Asserted in the specs. */
135
+ export function totalsAgree(totals) {
136
+ return totals.subtotal + totals.fees + totals.tax - totals.discount === totals.total;
137
+ }
@@ -0,0 +1 @@
1
+ const t="Booking fee";function e(t){return"number"==typeof t?Number.isInteger(t)?t:null:"string"==typeof t&&/^-?\d+$/.test(t)?Number(t):null}function n(t,e){return null===t?e:t>0||e}const o=t=>t.type||"ticket";function s(s){const u=s||{},l=Array.isArray(u.items)?u.items:[],r=l.filter((t=>"fee"===o(t))),f=l.filter((t=>"discount"===o(t))),a=e(u.itemsSubtotal)??e(u.subtotal)??l.filter((t=>!["fee","tax","discount"].includes(o(t)))).reduce(((t,n)=>t+(e(n.subtotal)??0)),0),c=r.length?r.reduce(((t,n)=>t+(e(n.subtotal)??0)),0):null,i=e(u.totalFees)??e(u.fees)??c,y=f.length?f.reduce(((t,n)=>t+Math.abs(e(n.subtotal)??0)),0):null,b=e(u.totalDiscounts)??e(u.discount)??y,p=e(u.totalTax)??0,g="string"==typeof u.feeLabel&&!!u.feeLabel||r.some((t=>"string"==typeof t.name&&!!t.name)),h="string"==typeof u.feeLabel&&u.feeLabel||r.map((t=>t.name)).find((t=>"string"==typeof t&&!!t))||t;return{currency:u.currency||"GBP",subtotal:a,fees:i??0,discount:b??0,total:e(u.total)??a+(i??0)+p-(b??0),showFee:"boolean"==typeof u.hasFees?u.hasFees:n(i,g),feeLabel:h}}function u(o,s=null){const u=(o||[]).reduce(((t,n)=>t+(e(n.price)??0)*(Math.max(0,Math.trunc(n.quantity||0))||0)),0),l=s?e(s.amount):null;return{subtotal:u,fees:l??0,total:u+(l??0),showFee:!!s&&n(l,!!s?.label),feeLabel:s?.label||t}}export{t as F,s as c,n as e,e as m,u as s}
@@ -1 +1 @@
1
- function n(n,e="GBP"){if(null==n||""===n)return"";const r=new Intl.NumberFormat("en-GB",{style:"currency",currency:e});if("number"==typeof n)return r.format(n/100);const t=Number(n);return Number.isNaN(t)?String(n):r.format(t)}function e(n){return new Date(n).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function r(n){return new Date(n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function t(n){return(n.items??[]).filter((n=>!n.type||"ticket"===n.type))}function u(n){return t(n).reduce(((n,e)=>n+(Number(e.quantity)||0)),0)||n.tickets?.length||0}function c(n){return n.eventName||t(n)[0]?.name||n.items?.[0]?.name||null}function i(n,e){const r=n?.customerEmail||n?.customer?.email;if(r)return r;const t=e;return t?.email||null}function s(n){return n?n.replace(/_/g," ").replace(/^\w/,(n=>n.toUpperCase())):""}function a(n){switch(n){case"confirmed":return"success";case"completed":case"fulfilled":return"info";case"pending":case"processing":return"warning";case"cancelled":case"expired":case"failed":return"error";default:return"muted"}}function o(n,e){return n instanceof Error&&n.message?n.message:e}function f(n){return!(!n||"object"!=typeof n||401!==n.status&&403!==n.status&&"NO_SESSION"!==n.code&&"NOT_AUTHENTICATED"!==n.code)}async function l(n,e,r=12){const t=n.getEventsManager(),u=(await t.list({limit:r})).items.slice(0,r);for(const n of u){const r=await t.get(n.id).catch((()=>null)),u=r?.occurrences?.find((n=>n.id===e));if(u)return{eventId:r?.id??n.id,eventName:r?.name??n.name??"",startsAt:u.startsAt??null}}return null}export{n as a,s as b,i as c,e as d,o as e,r as f,t as g,f as i,c as o,l as r,a as s,u as t}
1
+ import{m as n,e,F as t}from"./money.js";function r(n,e="GBP"){if(null==n||""===n)return"";const t=new Intl.NumberFormat("en-GB",{style:"currency",currency:e});if("number"==typeof n)return t.format(n/100);const r=Number(n);return Number.isNaN(r)?String(n):t.format(r)}function u(n){return new Date(n).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function c(n){return new Date(n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function s(n){return(n.items??[]).filter((n=>!n.type||"ticket"===n.type))}function a(n){return s(n).reduce(((n,e)=>n+(Number(e.quantity)||0)),0)||n.tickets?.length||0}function o(n){return n.eventName||s(n)[0]?.name||n.items?.[0]?.name||null}function i(n,e){const t=n?.customerEmail||n?.customer?.email;if(t)return t;const r=e;return r?.email||null}function f(n){return n?n.replace(/_/g," ").replace(/^\w/,(n=>n.toUpperCase())):""}function l(n){switch(n){case"confirmed":return"success";case"completed":case"fulfilled":return"info";case"pending":case"processing":return"warning";case"cancelled":case"expired":case"failed":return"error";default:return"muted"}}function m(n,e){return n instanceof Error&&n.message?n.message:e}function d(n){return!(!n||"object"!=typeof n||401!==n.status&&403!==n.status&&"NO_SESSION"!==n.code&&"NOT_AUTHENTICATED"!==n.code)}async function y(n,e,t=12){const r=n.getEventsManager(),u=(await r.list({limit:t})).items.slice(0,t);for(const n of u){const t=await r.get(n.id).catch((()=>null)),u=t?.occurrences?.find((n=>n.id===e));if(u)return{eventId:t?.id??n.id,eventName:t?.name??n.name??"",startsAt:u.startsAt??null}}return null}function h(r){const u=r||{},c=Array.isArray(u.items)?u.items:[],a=c.filter((n=>"fee"===n.type)),o=c.filter((n=>"discount"===n.type)),i=s(u),f=a.length?a.reduce(((e,t)=>e+(n(t.subtotal)??0)),0):null,l=f??n(u.totalFees)??0,m=n(u.subtotal),d=i.length?i.reduce(((e,t)=>e+(n(t.subtotal)??0)),0):(m??0)-l,y=o.length?o.reduce(((e,t)=>e+Math.abs(n(t.subtotal)??0)),0):null,h=n(u.totalDiscounts)??y??0,w=n(u.totalTax)??0,g=a.some((n=>"string"==typeof n.name&&!!n.name));return{currency:u.currency||"GBP",subtotal:d,fees:l,feeLabel:a.map((n=>n.name)).find((n=>!!n))||t,showFee:e(f??n(u.totalFees),g),tax:w,discount:h,total:n(u.total)??d+l+w-h}}export{r as a,f as b,i as c,u as d,m as e,c as f,h as g,s as h,d as i,o,y as r,l as s,a as t}
@@ -1 +1 @@
1
- import{proxyCustomElement as e,HTMLElement as t,createEvent as r,h as a,Host as i,transformTag as o}from"@stencil/core/internal/client";import{w as s,g as c}from"./sdk-connector.js";import{d}from"./tl-occurrence-selector2.js";import{d as n}from"./tl-ticket-selector2.js";const l=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.tlClose=r(this,"tlClose",7),this.tlCheckout=r(this,"tlCheckout",7),this.tlError=r(this,"tlError",7),this.step="loading",this.eventName="",this.imageUrl="",this.venueLabel="",this.dateSummary="",this.selectedOccurrenceId=null,this.occurrenceCount=0,this.occurrenceLabel="",this.error=null,this.handleOccurrenceSelect=e=>{const t=e.detail.occurrence;this.selectedOccurrenceId=t.id,this.occurrenceLabel=this.labelFor(t),this.step="tickets"},this.handleAdded=()=>{this.step="done"},this.backToDates=()=>{this.selectedOccurrenceId=null,this.step="occurrence"},this.close=()=>this.tlClose.emit(),this.goCheckout=()=>this.tlCheckout.emit()}async componentWillLoad(){if(this.eventId)try{await s();const e=await c().getEventsManager().get(this.eventId);this.eventName=e?.name??"Tickets",this.imageUrl=e?.imageUrl||e?.heroImageUrl||"",this.venueLabel=[e?.venueName,e?.venueCity].filter(Boolean).join(", ");const t=e?.occurrences??[];this.occurrenceCount=t.length,this.dateSummary=this.summariseDates(t);const r=this.occurrenceId??(1===t.length?t[0]?.id:null);r?(this.selectedOccurrenceId=r,this.occurrenceLabel=this.labelFor(t.find((e=>e.id===r))),this.step="tickets"):this.step="occurrence"}catch(e){this.fail(e instanceof Error?e.message:"Could not load this event")}else this.fail("No event specified")}fail(e){this.error=e,this.step="error",this.tlError.emit({message:e})}summariseDates(e){const t=e.map((e=>e.startsAt)).filter((e=>!!e)).sort();if(0===t.length)return"";const r=e=>new Date(e).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"});if(1===t.length)return new Date(t[0]).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short",year:"numeric"});const a=r(t[0]),i=r(t[t.length-1]);return`${a===i?a:`${a} - ${i}`} · ${t.length} dates`}labelFor(e){return e?.startsAt?new Date(e.startsAt).toLocaleString("en-GB",{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}):""}stepKicker(){switch(this.step){case"occurrence":return"Choose a date";case"tickets":return"Select tickets";case"done":return"Nice one";default:return"Tickets"}}render(){return a(i,{key:"1245e518c2b5232f4d9dba091cf808cd3867fbef"},a("div",{key:"4e770fccdd785444f1cc87df4adab5a5dc1bf58a",class:"overlay",onClick:e=>{e.target===e.currentTarget&&this.close()}},a("div",{key:"57b13dac690028aeebd6a601acfba07f00854c40",class:{panel:!0,"panel--wide":"occurrence"===this.step},role:"dialog","aria-modal":"true","aria-label":this.eventName},a("header",{key:"881e9cc70a0ca25947f272b9ebcb2e6d4b4268f2",class:"panel-header"},this.imageUrl&&a("div",{key:"753f7df1b5118dfacbbc6b89b4e5d7ba114f6cdf",class:"event-thumb",style:{backgroundImage:`url(${this.imageUrl})`}}),a("div",{key:"9aaa32d1add90fabd1b0ea0c100f198962f4e6a5",class:"titles"},a("span",{key:"538032bdf2338206ad763417386852ff97cc472f",class:"kicker"},this.stepKicker()),a("h2",{key:"71429804179e7fbbea1fa90a2937a065517092f5",class:"event-name"},this.eventName),this.venueLabel&&a("p",{key:"dd968b397deab890df3a4fbdff33226e82bd9660",class:"event-meta"},this.venueLabel),this.dateSummary&&a("p",{key:"f40e6049d09b06c9f599e7d14d6fbb43b39b22fd",class:"event-meta"},this.dateSummary)),a("button",{key:"dbe0908f8cd8544654b627921f68cc4961802b77",class:"close-btn","aria-label":"Close",onClick:this.close},a("svg",{key:"23a750830e6e16d28cbcd5025507d25848aaadf7",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},a("path",{key:"e81b8763a5c781f72c1ca8a2113482948e3ba8cc",d:"M6 6l12 12M18 6L6 18","stroke-linecap":"round"})))),a("div",{key:"da71e610f907cf53e78246d2065aaf526d5ceffd",class:"panel-body"},"loading"===this.step&&a("div",{key:"28cbb9a98c7b08fa8dcb9d8d5dfbf3bec93fe38d",class:"state-msg"},a("span",{key:"915c8de87cbdc7da1ccf0622ce6c0f02fccf2cad",class:"spinner"})," Loading…"),"error"===this.step&&a("div",{key:"5785578bfef6f1ee81d938d91ffd3ded975f8c12",class:"state-msg error"},this.error),"occurrence"===this.step&&a("tl-occurrence-selector",{key:"eeb853eab141c3c103015e82d221a140f6a3a109",eventId:this.eventId,onTlSelect:this.handleOccurrenceSelect}),"tickets"===this.step&&this.selectedOccurrenceId&&a("div",{key:"f608f592ba651eb431375433eb4ff9393863ade5",class:"tickets-step"},this.occurrenceCount>1&&a("button",{key:"84adfbdbeaceb2cf4238c6ffd09558b4499ca940",class:"back-link",onClick:this.backToDates},"← Change date"),this.occurrenceLabel&&a("p",{key:"0317e9194049608711e8c622142c3ad2c0a5dc12",class:"occ-label"},this.occurrenceLabel),a("tl-ticket-selector",{key:"27b1e05d9d92fb8d519375e2b27d4b5ea0a4890a",eventId:this.eventId,occurrenceId:this.selectedOccurrenceId,onTlAddToCart:this.handleAdded})),"done"===this.step&&a("div",{key:"0853088206988c66d489f8804df7899821d49e64",class:"done-step"},a("div",{key:"c2955b893c4dffaadcdfd27bee96ef2724a131a6",class:"done-mark"},"🎟️"),a("p",{key:"370c30dfcbc0c25b4794d984dd261a3a5779a9dc",class:"done-title"},"Added to your cart"),a("p",{key:"c462f3c9292740e2fd2c74b173484f80a5dc1a30",class:"done-sub"},"Held for you while you check out."),a("button",{key:"484991f79572e3213ad6413a1af87599880c3643",class:"primary-btn",onClick:this.goCheckout},"Go to checkout"),a("button",{key:"5b4ba5a472b794e8f5af0f131dad1c8c11b869f5",class:"ghost-btn",onClick:this.close},"Keep browsing")))),a("div",{key:"9acdd36744d363f41f0bed7938ecea33322362d1",class:"powered-by"},a("div",{key:"f45545a8fc625336618352f0c0e9e84a1babce96",class:"pb-links"},a("a",{key:"dd929b12419b8353d9a09ad242a9f351dfd699e2",href:"https://ticketlayer.com/privacy",target:"_blank",rel:"noopener noreferrer"},"Privacy Policy"),a("a",{key:"859be221bdc76602defaebdb89a997778cda6a91",href:"https://ticketlayer.com/report-abuse",target:"_blank",rel:"noopener noreferrer"},"Report Abuse")),a("a",{key:"d4e1f44b3b084160d2df8b9d15e075ddc5e05363",class:"pb-brand",href:"https://ticketlayer.com",target:"_blank",rel:"noopener noreferrer"},a("span",{key:"fe7fd86576a4e9772daa2c4c449da060f20fa143",class:"pb-pre"},"Powered by"),a("svg",{key:"19412bd9e5522f0af9f847fe8fda6aa0f0004a3a",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},a("path",{key:"c159efd1b8fce42b8c0fd5bac21792b4dc2728ce",d:"M4 7.5A1.5 1.5 0 0 1 5.5 6h13A1.5 1.5 0 0 1 20 7.5v2a2 2 0 0 0 0 5v2a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 4 16.5v-2a2 2 0 0 0 0-5v-2Z",fill:"currentColor"}),a("path",{key:"283956eead27e5919301c30882da6eaa7b093a1a",d:"M13 7v10",stroke:"var(--tl-pb-perforation, var(--tl-background, #fff))","stroke-width":"1.2","stroke-dasharray":"1.5 1.8","stroke-linecap":"round"})),a("span",{key:"bc045fda144885737b88bf81b4f9000ec8d333be",class:"pb-word"},"Ticketlayer")))))}static get style(){return":host{--_bg:var(--tl-background, #ffffff);--_fg:var(--tl-foreground, #111827);--_muted:var(--tl-muted, #f3f4f6);--_muted-fg:var(--tl-muted-foreground, #6b7280);--_border:var(--tl-border, #e5e7eb);--_primary:var(--tl-primary, #6366f1);--_primary-fg:var(--tl-primary-foreground, #ffffff);--_radius:var(--tl-radius-lg, var(--tl-radius, 0.75rem));--_font:var(--tl-font-family, system-ui, -apple-system, sans-serif);font-family:var(--_font)}.overlay{position:fixed;inset:0;z-index:2147483646;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:16px;background:rgba(8, 8, 16, 0.6);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);animation:tl-fade 0.18s ease-out}.panel{width:100%;max-width:460px;max-height:86vh;display:flex;flex-direction:column;overflow:hidden;background:var(--_bg);color:var(--_fg);border:1px solid var(--_border);border-radius:var(--_radius);box-shadow:0 24px 64px rgba(0, 0, 0, 0.45);animation:tl-rise 0.22s cubic-bezier(0.16, 1, 0.3, 1);transition:max-width 0.25s cubic-bezier(0.16, 1, 0.3, 1)}.panel--wide{max-width:720px}.powered-by{--tl-pb-perforation:rgba(8, 8, 16, 0.6);width:100%;max-width:460px;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 4px;font-size:12px;font-weight:500;color:rgba(255, 255, 255, 0.78);animation:tl-fade 0.3s ease-out}.powered-by a{color:inherit;text-decoration:none;opacity:0.85;transition:opacity 0.15s ease}.powered-by a:hover{opacity:1}.powered-by .pb-links{display:flex;gap:16px;align-items:center}.powered-by .pb-brand{display:inline-flex;align-items:center;gap:6px;opacity:0.92}.powered-by .pb-brand svg{display:block}.powered-by .pb-pre{opacity:0.7}.powered-by .pb-word{font-weight:700;letter-spacing:0.01em}.panel-header{display:flex;align-items:center;gap:14px;padding:16px 18px;border-bottom:1px solid var(--_border)}.event-thumb{flex:none;width:56px;height:56px;border-radius:12px;background-size:cover;background-position:center;background-color:var(--_muted);border:1px solid var(--_border)}.titles{display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}.event-meta{margin:0;font-size:0.8rem;color:var(--_muted-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.kicker{font-size:0.72rem;font-weight:600;letter-spacing:0.08em;text-transform:uppercase;color:var(--_primary)}.event-name{margin:0;font-size:1.18rem;font-weight:700;line-height:1.25;color:var(--_fg);overflow:hidden;text-overflow:ellipsis}.close-btn{flex:none;display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border:0;border-radius:999px;background:var(--_muted);color:var(--_muted-fg);cursor:pointer;transition:color 0.15s, background 0.15s}.close-btn:hover{color:var(--_fg)}.close-btn svg{width:16px;height:16px}.panel-body{padding:18px 22px 22px;overflow-y:auto}.state-msg{display:flex;align-items:center;justify-content:center;gap:10px;padding:40px 0;color:var(--_muted-fg)}.state-msg.error{color:#b91c1c}.spinner{width:16px;height:16px;border:2px solid var(--_border);border-top-color:var(--_primary);border-radius:999px;animation:tl-spin 0.7s linear infinite}.tickets-step{display:flex;flex-direction:column;gap:6px}.back-link{align-self:flex-start;padding:0;border:0;background:none;color:var(--_primary);font-size:0.85rem;font-weight:500;cursor:pointer}.back-link:hover{text-decoration:underline}.occ-label{margin:2px 0 8px;font-size:0.9rem;font-weight:600;color:var(--_fg)}.done-step{display:flex;flex-direction:column;align-items:center;text-align:center;gap:6px;padding:16px 0 4px}.done-mark{font-size:2.4rem;line-height:1;margin-bottom:6px}.done-title{margin:0;font-size:1.1rem;font-weight:700;color:var(--_fg)}.done-sub{margin:0 0 14px;font-size:0.9rem;color:var(--_muted-fg)}.primary-btn{width:100%;padding:13px;border:0;border-radius:var(--tl-radius-md, 0.5rem);background:var(--_primary);color:var(--_primary-fg);font-size:0.98rem;font-weight:600;cursor:pointer;transition:opacity 0.15s}.primary-btn:hover{opacity:0.9}.ghost-btn{width:100%;margin-top:8px;padding:12px;border:1px solid var(--_border);border-radius:var(--tl-radius-md, 0.5rem);background:transparent;color:var(--_fg);font-size:0.95rem;font-weight:500;cursor:pointer;transition:background 0.15s}.ghost-btn:hover{background:var(--_muted)}@keyframes tl-fade{from{opacity:0}}@keyframes tl-rise{from{opacity:0;transform:translateY(12px) scale(0.98)}}@keyframes tl-spin{to{transform:rotate(360deg)}}"}},[1,"tl-buy-modal",{eventId:[1,"event-id"],occurrenceId:[1,"occurrence-id"],step:[32],eventName:[32],imageUrl:[32],venueLabel:[32],dateSummary:[32],selectedOccurrenceId:[32],occurrenceCount:[32],occurrenceLabel:[32],error:[32]}]),f=l,b=function(){"undefined"!=typeof customElements&&["tl-buy-modal","tl-occurrence-selector","tl-ticket-selector"].forEach((e=>{switch(e){case"tl-buy-modal":customElements.get(o(e))||customElements.define(o(e),l);break;case"tl-occurrence-selector":customElements.get(o(e))||d();break;case"tl-ticket-selector":customElements.get(o(e))||n()}}))};export{f as TlBuyModal,b as defineCustomElement}
1
+ import{proxyCustomElement as e,HTMLElement as t,createEvent as r,h as a,Host as i,transformTag as c}from"@stencil/core/internal/client";import{w as o,g as s}from"./sdk-connector.js";import{d}from"./tl-occurrence-selector2.js";import{d as n}from"./tl-ticket-selector2.js";const l=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.tlClose=r(this,"tlClose",7),this.tlCheckout=r(this,"tlCheckout",7),this.tlError=r(this,"tlError",7),this.step="loading",this.eventName="",this.imageUrl="",this.venueLabel="",this.dateSummary="",this.selectedOccurrenceId=null,this.occurrenceCount=0,this.occurrenceLabel="",this.error=null,this.handleOccurrenceSelect=e=>{const t=e.detail.occurrence;this.selectedOccurrenceId=t.id,this.occurrenceLabel=this.labelFor(t),this.step="tickets"},this.handleAdded=()=>{this.step="done"},this.backToDates=()=>{this.selectedOccurrenceId=null,this.step="occurrence"},this.close=()=>this.tlClose.emit(),this.goCheckout=()=>this.tlCheckout.emit()}async componentWillLoad(){if(this.eventId)try{await o();const e=await s().getEventsManager().get(this.eventId);this.eventName=e?.name??"Tickets",this.imageUrl=e?.imageUrl||e?.heroImageUrl||"",this.venueLabel=[e?.venueName,e?.venueCity].filter(Boolean).join(", ");const t=e?.occurrences??[];this.occurrenceCount=t.length,this.dateSummary=this.summariseDates(t);const r=this.occurrenceId??(1===t.length?t[0]?.id:null);r?(this.selectedOccurrenceId=r,this.occurrenceLabel=this.labelFor(t.find((e=>e.id===r))),this.step="tickets"):this.step="occurrence"}catch(e){this.fail(e instanceof Error?e.message:"Could not load this event")}else this.fail("No event specified")}fail(e){this.error=e,this.step="error",this.tlError.emit({message:e})}summariseDates(e){const t=e.map((e=>e.startsAt)).filter((e=>!!e)).sort();if(0===t.length)return"";const r=e=>new Date(e).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"});if(1===t.length)return new Date(t[0]).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short",year:"numeric"});const a=r(t[0]),i=r(t[t.length-1]);return`${a===i?a:`${a} - ${i}`} · ${t.length} dates`}labelFor(e){return e?.startsAt?new Date(e.startsAt).toLocaleString("en-GB",{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}):""}stepKicker(){switch(this.step){case"occurrence":return"Choose a date";case"tickets":return"Select tickets";case"done":return"Nice one";default:return"Tickets"}}render(){return a(i,{key:"1245e518c2b5232f4d9dba091cf808cd3867fbef"},a("div",{key:"4e770fccdd785444f1cc87df4adab5a5dc1bf58a",class:"overlay",onClick:e=>{e.target===e.currentTarget&&this.close()}},a("div",{key:"57b13dac690028aeebd6a601acfba07f00854c40",class:{panel:!0,"panel--wide":"occurrence"===this.step},role:"dialog","aria-modal":"true","aria-label":this.eventName},a("header",{key:"881e9cc70a0ca25947f272b9ebcb2e6d4b4268f2",class:"panel-header"},this.imageUrl&&a("div",{key:"753f7df1b5118dfacbbc6b89b4e5d7ba114f6cdf",class:"event-thumb",style:{backgroundImage:`url(${this.imageUrl})`}}),a("div",{key:"9aaa32d1add90fabd1b0ea0c100f198962f4e6a5",class:"titles"},a("span",{key:"538032bdf2338206ad763417386852ff97cc472f",class:"kicker"},this.stepKicker()),a("h2",{key:"71429804179e7fbbea1fa90a2937a065517092f5",class:"event-name"},this.eventName),this.venueLabel&&a("p",{key:"dd968b397deab890df3a4fbdff33226e82bd9660",class:"event-meta"},this.venueLabel),this.dateSummary&&a("p",{key:"f40e6049d09b06c9f599e7d14d6fbb43b39b22fd",class:"event-meta"},this.dateSummary)),a("button",{key:"dbe0908f8cd8544654b627921f68cc4961802b77",class:"close-btn","aria-label":"Close",onClick:this.close},a("svg",{key:"23a750830e6e16d28cbcd5025507d25848aaadf7",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},a("path",{key:"e81b8763a5c781f72c1ca8a2113482948e3ba8cc",d:"M6 6l12 12M18 6L6 18","stroke-linecap":"round"})))),a("div",{key:"da71e610f907cf53e78246d2065aaf526d5ceffd",class:"panel-body"},"loading"===this.step&&a("div",{key:"28cbb9a98c7b08fa8dcb9d8d5dfbf3bec93fe38d",class:"state-msg"},a("span",{key:"915c8de87cbdc7da1ccf0622ce6c0f02fccf2cad",class:"spinner"})," Loading…"),"error"===this.step&&a("div",{key:"5785578bfef6f1ee81d938d91ffd3ded975f8c12",class:"state-msg error"},this.error),"occurrence"===this.step&&a("tl-occurrence-selector",{key:"eeb853eab141c3c103015e82d221a140f6a3a109",eventId:this.eventId,onTlSelect:this.handleOccurrenceSelect}),"tickets"===this.step&&this.selectedOccurrenceId&&a("div",{key:"f608f592ba651eb431375433eb4ff9393863ade5",class:"tickets-step"},this.occurrenceCount>1&&a("button",{key:"84adfbdbeaceb2cf4238c6ffd09558b4499ca940",class:"back-link",onClick:this.backToDates},"← Change date"),this.occurrenceLabel&&a("p",{key:"0317e9194049608711e8c622142c3ad2c0a5dc12",class:"occ-label"},this.occurrenceLabel),a("tl-ticket-selector",{key:"27b1e05d9d92fb8d519375e2b27d4b5ea0a4890a",eventId:this.eventId,occurrenceId:this.selectedOccurrenceId,onTlAddToCart:this.handleAdded})),"done"===this.step&&a("div",{key:"0853088206988c66d489f8804df7899821d49e64",class:"done-step"},a("div",{key:"c2955b893c4dffaadcdfd27bee96ef2724a131a6",class:"done-mark"},"🎟️"),a("p",{key:"370c30dfcbc0c25b4794d984dd261a3a5779a9dc",class:"done-title"},"Added to your cart"),a("p",{key:"c462f3c9292740e2fd2c74b173484f80a5dc1a30",class:"done-sub"},"Held for you while you check out."),a("button",{key:"484991f79572e3213ad6413a1af87599880c3643",class:"primary-btn",onClick:this.goCheckout},"Go to checkout"),a("button",{key:"5b4ba5a472b794e8f5af0f131dad1c8c11b869f5",class:"ghost-btn",onClick:this.close},"Keep browsing")))),a("div",{key:"9acdd36744d363f41f0bed7938ecea33322362d1",class:"powered-by"},a("div",{key:"f45545a8fc625336618352f0c0e9e84a1babce96",class:"pb-links"},a("a",{key:"dd929b12419b8353d9a09ad242a9f351dfd699e2",href:"https://ticketlayer.com/privacy",target:"_blank",rel:"noopener noreferrer"},"Privacy Policy"),a("a",{key:"859be221bdc76602defaebdb89a997778cda6a91",href:"https://ticketlayer.com/report-abuse",target:"_blank",rel:"noopener noreferrer"},"Report Abuse")),a("a",{key:"d4e1f44b3b084160d2df8b9d15e075ddc5e05363",class:"pb-brand",href:"https://ticketlayer.com",target:"_blank",rel:"noopener noreferrer"},a("span",{key:"fe7fd86576a4e9772daa2c4c449da060f20fa143",class:"pb-pre"},"Powered by"),a("svg",{key:"19412bd9e5522f0af9f847fe8fda6aa0f0004a3a",width:"14",height:"14",viewBox:"0 0 50 50",fill:"none","aria-hidden":"true"},a("g",{key:"8e82f14ab1e8094a210db95b1310ce6c0feef446",transform:"matrix(0.0129 0 0 -0.0129 25.4752 25.4752)"},a("path",{key:"b50b04cfc07c4e55fcf5ce92967f69b99d34dd34",fill:"currentColor",transform:"translate(-1781.5, -1759.4003)",d:"M 41 2973 c 1 -285 5 -734 9 -998 c 7 -444 9 -488 30 -580 c 81 -364 235 -634 512 -900 c 135 -130 263 -220 423 -299 c 156 -77 249 -109 409 -143 c 110 -23 142 -25 354 -24 c 230 1 310 8 427 37 c 241 60 453 162 640 309 c 82 64 252 234 317 315 c 210 264 340 604 355 926 l 6 121 l -69 6 c -86 8 -706 9 -755 1 l -36 -6 l -21 -125 c -34 -191 -98 -317 -236 -462 c -111 -115 -249 -198 -396 -238 c -98 -27 -356 -24 -463 5 c -100 27 -183 69 -273 137 c -226 173 -353 409 -354 660 c 0 44 -5 120 -10 169 c -6 49 -8 91 -6 94 c 3 3 65 -22 138 -55 c 140 -64 251 -103 358 -127 c 71 -17 295 -46 347 -46 l 33 0 l 0 434 l 0 434 l -67 7 c -147 14 -269 56 -393 133 c -222 139 -378 393 -397 648 l -6 71 l -75 7 c -41 3 -239 6 -439 6 l -363 0 l 1 -517 z"}))),a("span",{key:"2623449abd22f36f5af80d5605d3b274a4c214c4",class:"pb-word"},"ticketlayer")))))}static get style(){return":host{--_bg:var(--tl-background);--_fg:var(--tl-foreground);--_muted:var(--tl-muted);--_muted-fg:var(--tl-muted-foreground);--_border:var(--tl-border);--_primary:var(--tl-primary);--_primary-fg:var(--tl-primary-foreground);--_radius:var(--tl-radius-lg);--_font:var(--tl-font-family);font-family:var(--_font)}.overlay{position:fixed;inset:0;z-index:2147483646;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:16px;background:rgba(8, 8, 16, 0.6);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);animation:tl-fade 0.18s ease-out}.panel{width:100%;max-width:460px;max-height:86vh;display:flex;flex-direction:column;overflow:hidden;background:var(--_bg);color:var(--_fg);border:1px solid var(--_border);border-radius:var(--_radius);box-shadow:0 24px 64px rgba(0, 0, 0, 0.45);animation:tl-rise 0.22s cubic-bezier(0.16, 1, 0.3, 1);transition:max-width 0.25s cubic-bezier(0.16, 1, 0.3, 1)}.panel--wide{max-width:720px}.powered-by{width:100%;max-width:460px;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 4px;font-size:12px;font-weight:500;color:rgba(255, 255, 255, 0.78);animation:tl-fade 0.3s ease-out}.powered-by a{color:inherit;text-decoration:none;opacity:0.85;transition:opacity 0.15s ease}.powered-by a:hover{opacity:1}.powered-by .pb-links{display:flex;gap:16px;align-items:center}.powered-by .pb-brand{display:inline-flex;align-items:center;gap:6px;opacity:0.92}.powered-by .pb-brand svg{display:block}.powered-by .pb-pre{opacity:0.7}.powered-by .pb-word{font-weight:700;letter-spacing:0.01em}.panel-header{display:flex;align-items:center;gap:14px;padding:16px 18px;border-bottom:1px solid var(--_border)}.event-thumb{flex:none;width:56px;height:56px;border-radius:12px;background-size:cover;background-position:center;background-color:var(--_muted);border:1px solid var(--_border)}.titles{display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}.event-meta{margin:0;font-size:0.8rem;color:var(--_muted-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.kicker{font-size:0.72rem;font-weight:600;letter-spacing:0.08em;text-transform:uppercase;color:var(--_primary)}.event-name{margin:0;font-size:1.18rem;font-weight:700;line-height:1.25;color:var(--_fg);overflow:hidden;text-overflow:ellipsis}.close-btn{flex:none;display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border:0;border-radius:999px;background:var(--_muted);color:var(--_muted-fg);cursor:pointer;transition:color 0.15s, background 0.15s}.close-btn:hover{color:var(--_fg)}.close-btn svg{width:16px;height:16px}.panel-body{padding:18px 22px 22px;overflow-y:auto}.state-msg{display:flex;align-items:center;justify-content:center;gap:10px;padding:40px 0;color:var(--_muted-fg)}.state-msg.error{color:#b91c1c}.spinner{width:16px;height:16px;border:2px solid var(--_border);border-top-color:var(--_primary);border-radius:999px;animation:tl-spin 0.7s linear infinite}.tickets-step{display:flex;flex-direction:column;gap:6px}.back-link{align-self:flex-start;padding:0;border:0;background:none;color:var(--_primary);font-size:0.85rem;font-weight:500;cursor:pointer}.back-link:hover{text-decoration:underline}.occ-label{margin:2px 0 8px;font-size:0.9rem;font-weight:600;color:var(--_fg)}.done-step{display:flex;flex-direction:column;align-items:center;text-align:center;gap:6px;padding:16px 0 4px}.done-mark{font-size:2.4rem;line-height:1;margin-bottom:6px}.done-title{margin:0;font-size:1.1rem;font-weight:700;color:var(--_fg)}.done-sub{margin:0 0 14px;font-size:0.9rem;color:var(--_muted-fg)}.primary-btn{width:100%;padding:13px;border:0;border-radius:var(--tl-radius-md);background:var(--_primary);color:var(--_primary-fg);font-size:0.98rem;font-weight:600;cursor:pointer;transition:opacity 0.15s}.primary-btn:hover{opacity:0.9}.ghost-btn{width:100%;margin-top:8px;padding:12px;border:1px solid var(--_border);border-radius:var(--tl-radius-md);background:transparent;color:var(--_fg);font-size:0.95rem;font-weight:500;cursor:pointer;transition:background 0.15s}.ghost-btn:hover{background:var(--_muted)}@keyframes tl-fade{from{opacity:0}}@keyframes tl-rise{from{opacity:0;transform:translateY(12px) scale(0.98)}}@keyframes tl-spin{to{transform:rotate(360deg)}}"}},[1,"tl-buy-modal",{eventId:[1,"event-id"],occurrenceId:[1,"occurrence-id"],step:[32],eventName:[32],imageUrl:[32],venueLabel:[32],dateSummary:[32],selectedOccurrenceId:[32],occurrenceCount:[32],occurrenceLabel:[32],error:[32]}]),f=l,b=function(){"undefined"!=typeof customElements&&["tl-buy-modal","tl-occurrence-selector","tl-ticket-selector"].forEach((e=>{switch(e){case"tl-buy-modal":customElements.get(c(e))||customElements.define(c(e),l);break;case"tl-occurrence-selector":customElements.get(c(e))||d();break;case"tl-ticket-selector":customElements.get(c(e))||n()}}))};export{f as TlBuyModal,b as defineCustomElement}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as e,createEvent as o,h as r,Host as i,transformTag as n}from"@stencil/core/internal/client";import{h as s,g as a}from"./sdk-connector.js";const l={available:{defaultLabel:"Buy Tickets",color:"var(--tl-primary, #e64b12)",hoverColor:"var(--tl-primary, #d4440f)",foreground:"var(--tl-primary-foreground, #ffffff)"},soldOut:{defaultLabel:"Sold Out",color:"#dc2626",hoverColor:"#b91c1c",foreground:"#ffffff"},waitlist:{defaultLabel:"Join Waitlist",color:"#2563eb",hoverColor:"#1d4ed8",foreground:"#ffffff"},comingSoon:{defaultLabel:"On Sale Soon",color:"#d97706",hoverColor:"#b45309",foreground:"#ffffff"}},c=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tlClick=o(this,"tlClick",7),this.state="available",this.variant="primary",this.size="md",this.fullWidth=!1,this.currency="GBP",this.pricePrefix="From",this.disabled=!1,this.isHovered=!1,this.handleClick=()=>{if(!this.disabled&&"soldOut"!==this.state&&"comingSoon"!==this.state&&(this.tlClick.emit({eventId:this.eventId,occurrenceId:this.occurrenceId}),s()))try{a().event(this.eventId).openModal({occurrenceId:this.occurrenceId})}catch(t){console.error("[tl-buy-tickets-button] Failed to open modal:",t)}}}formatPrice(t){const e=t/100,o=e%1!=0;return new Intl.NumberFormat("en-GB",{style:"currency",currency:this.currency,minimumFractionDigits:o?2:0,maximumFractionDigits:o?2:0}).format(e)}getStateConfig(){return l[this.state]}isInteractive(){return!this.disabled&&"soldOut"!==this.state&&"comingSoon"!==this.state}render(){const t=this.getStateConfig(),e=this.label||t.defaultLabel,o=this.isInteractive();return r(i,{key:"10c8c36d12223afcfd13c9807c2ef6b0f4c34266",class:{"full-width":this.fullWidth}},r("button",{key:"c7f6a39a837c90ced0176b5d017687afabf99a5a",type:"button",class:{"buy-button":!0,["variant-"+this.variant]:!0,["size-"+this.size]:!0,disabled:!o,hovered:this.isHovered&&o},style:{"--button-color":t.color,"--button-hover-color":t.hoverColor,"--button-foreground":t.foreground},disabled:!o,onClick:this.handleClick,onMouseEnter:()=>this.isHovered=!0,onMouseLeave:()=>this.isHovered=!1},r("span",{key:"e2bc1edc9fbd2a9c81da8cc3293170b1c4275125",class:"icon"},"soldOut"===this.state&&this.renderSoldOutIcon(),"waitlist"===this.state&&this.renderWaitlistIcon(),"comingSoon"===this.state&&this.renderComingSoonIcon(),"available"===this.state&&this.renderTicketIcon()),r("span",{key:"8371c85dcc24c5ac040744edefe80618421025ef",class:"label"},e),void 0!==this.price&&r("span",{key:"c02cb5b646ade8866deafb9b3e698115abec5708",class:"price"},r("span",{key:"cb0ab272460115a5edebd674362c83711735a70d",class:"price-prefix"},this.pricePrefix),r("span",{key:"e28ba56d3928076b624513de95682351f3e0d92b",class:"price-value"},this.formatPrice(this.price)))))}renderTicketIcon(){return r("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},r("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),r("path",{d:"M13 5v2"}),r("path",{d:"M13 17v2"}),r("path",{d:"M13 11v2"}))}renderSoldOutIcon(){return r("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},r("circle",{cx:"12",cy:"12",r:"10"}),r("path",{d:"m15 9-6 6"}),r("path",{d:"m9 9 6 6"}))}renderWaitlistIcon(){return r("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},r("circle",{cx:"12",cy:"12",r:"10"}),r("polyline",{points:"12 6 12 12 16 14"}))}renderComingSoonIcon(){return r("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},r("path",{d:"M12 2v4"}),r("path",{d:"m16.2 7.8 2.9-2.9"}),r("path",{d:"M18 12h4"}),r("path",{d:"m16.2 16.2 2.9 2.9"}),r("path",{d:"M12 18v4"}),r("path",{d:"m4.9 19.1 2.9-2.9"}),r("path",{d:"M2 12h4"}),r("path",{d:"m4.9 4.9 2.9 2.9"}))}static get style(){return":host{display:inline-block;font-family:var(--tl-font-family, system-ui, -apple-system, sans-serif)}:host(.full-width){display:block;width:100%}:host(.full-width) .buy-button{width:100%}.buy-button{display:inline-flex;align-items:center;justify-content:center;gap:0.5rem;font-weight:600;border:none;cursor:pointer;text-decoration:none;outline:none;transition:all 0.2s ease;white-space:nowrap}.buy-button.variant-primary{background:var(--button-color);color:var(--button-foreground)}.buy-button.variant-secondary{background:color-mix(in srgb, var(--button-color) 15%, transparent);color:var(--button-color)}.buy-button.variant-outline{background:transparent;color:var(--button-color);border:2px solid var(--button-color)}.buy-button.size-sm{padding:0.5rem 1rem;font-size:0.875rem;border-radius:var(--tl-radius-sm, 0.375rem)}.buy-button.size-md{padding:0.75rem 1.5rem;font-size:1rem;border-radius:var(--tl-radius-md, 0.5rem)}.buy-button.size-lg{padding:1rem 2rem;font-size:1.125rem;border-radius:var(--tl-radius-lg, 0.625rem);min-height:51px}.buy-button.hovered:not(.disabled){opacity:0.9;transform:translateY(-1px)}.buy-button.hovered.variant-primary{background:var(--button-hover-color)}.buy-button.disabled{opacity:0.7;cursor:not-allowed}.icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}.icon svg{width:1em;height:1em}.label{flex-shrink:0}.price{display:inline-flex;align-items:center;gap:0.25rem;margin-left:0.5rem;white-space:nowrap;opacity:0.9}.price-prefix{opacity:0.7}.price-value{font-weight:700}"}},[1,"tl-buy-tickets-button",{eventId:[1,"event-id"],occurrenceId:[1,"occurrence-id"],state:[1],label:[1],variant:[1],size:[1],fullWidth:[4,"full-width"],price:[2],currency:[1],pricePrefix:[1,"price-prefix"],disabled:[4],isHovered:[32]}]),d=c,u=function(){"undefined"!=typeof customElements&&["tl-buy-tickets-button"].forEach((t=>{"tl-buy-tickets-button"===t&&(customElements.get(n(t))||customElements.define(n(t),c))}))};export{d as TlBuyTicketsButton,u as defineCustomElement}
1
+ import{proxyCustomElement as t,HTMLElement as e,createEvent as o,h as r,Host as i,transformTag as n}from"@stencil/core/internal/client";import{h as s,g as a}from"./sdk-connector.js";const l={available:{defaultLabel:"Buy Tickets",color:"var(--tl-primary)",hoverColor:"color-mix(in srgb, var(--tl-primary) 90%, black)",foreground:"var(--tl-primary-foreground)"},soldOut:{defaultLabel:"Sold Out",color:"#dc2626",hoverColor:"#b91c1c",foreground:"#ffffff"},waitlist:{defaultLabel:"Join Waitlist",color:"#2563eb",hoverColor:"#1d4ed8",foreground:"#ffffff"},comingSoon:{defaultLabel:"On Sale Soon",color:"#d97706",hoverColor:"#b45309",foreground:"#ffffff"}},c=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tlClick=o(this,"tlClick",7),this.state="available",this.variant="primary",this.size="md",this.fullWidth=!1,this.currency="GBP",this.pricePrefix="From",this.disabled=!1,this.isHovered=!1,this.handleClick=()=>{if(!this.disabled&&"soldOut"!==this.state&&"comingSoon"!==this.state&&(this.tlClick.emit({eventId:this.eventId,occurrenceId:this.occurrenceId}),s()))try{a().event(this.eventId).openModal({occurrenceId:this.occurrenceId})}catch(t){console.error("[tl-buy-tickets-button] Failed to open modal:",t)}}}formatPrice(t){const e=t/100,o=e%1!=0;return new Intl.NumberFormat("en-GB",{style:"currency",currency:this.currency,minimumFractionDigits:o?2:0,maximumFractionDigits:o?2:0}).format(e)}getStateConfig(){return l[this.state]}isInteractive(){return!this.disabled&&"soldOut"!==this.state&&"comingSoon"!==this.state}render(){const t=this.getStateConfig(),e=this.label||t.defaultLabel,o=this.isInteractive();return r(i,{key:"86ee9a81d82c10398dab4e22b3bbae15abb8f449",class:{"full-width":this.fullWidth}},r("button",{key:"b581e199ced7ffd14669ebe0cc727edc2f8c8914",type:"button",class:{"buy-button":!0,["variant-"+this.variant]:!0,["size-"+this.size]:!0,disabled:!o,hovered:this.isHovered&&o},style:{"--button-color":t.color,"--button-hover-color":t.hoverColor,"--button-foreground":t.foreground},disabled:!o,onClick:this.handleClick,onMouseEnter:()=>this.isHovered=!0,onMouseLeave:()=>this.isHovered=!1},r("span",{key:"f776bab4a999ed36b25400424d639b4c9261c02a",class:"icon"},"soldOut"===this.state&&this.renderSoldOutIcon(),"waitlist"===this.state&&this.renderWaitlistIcon(),"comingSoon"===this.state&&this.renderComingSoonIcon(),"available"===this.state&&this.renderTicketIcon()),r("span",{key:"e98ecbe6debc5c2c18ce1d304b60bf1074b003b3",class:"label"},e),void 0!==this.price&&r("span",{key:"e7e261d09a541b126b02b88d00992f3a6483a9b8",class:"price"},r("span",{key:"5eab43a47c2dd4c1339fe84b583902b1e38a0b2a",class:"price-prefix"},this.pricePrefix),r("span",{key:"f03b514ff2bc3c9a1b2e922d93a92accdedd0fad",class:"price-value"},this.formatPrice(this.price)))))}renderTicketIcon(){return r("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},r("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),r("path",{d:"M13 5v2"}),r("path",{d:"M13 17v2"}),r("path",{d:"M13 11v2"}))}renderSoldOutIcon(){return r("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},r("circle",{cx:"12",cy:"12",r:"10"}),r("path",{d:"m15 9-6 6"}),r("path",{d:"m9 9 6 6"}))}renderWaitlistIcon(){return r("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},r("circle",{cx:"12",cy:"12",r:"10"}),r("polyline",{points:"12 6 12 12 16 14"}))}renderComingSoonIcon(){return r("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},r("path",{d:"M12 2v4"}),r("path",{d:"m16.2 7.8 2.9-2.9"}),r("path",{d:"M18 12h4"}),r("path",{d:"m16.2 16.2 2.9 2.9"}),r("path",{d:"M12 18v4"}),r("path",{d:"m4.9 19.1 2.9-2.9"}),r("path",{d:"M2 12h4"}),r("path",{d:"m4.9 4.9 2.9 2.9"}))}static get style(){return":host{display:inline-block;font-family:var(--tl-font-family)}:host(.full-width){display:block;width:100%}:host(.full-width) .buy-button{width:100%}.buy-button{display:inline-flex;align-items:center;justify-content:center;gap:0.5rem;font-weight:600;border:none;cursor:pointer;text-decoration:none;outline:none;transition:all 0.2s ease;white-space:nowrap}.buy-button.variant-primary{background:var(--button-color);color:var(--button-foreground)}.buy-button.variant-secondary{background:color-mix(in srgb, var(--button-color) 15%, transparent);color:var(--button-color)}.buy-button.variant-outline{background:transparent;color:var(--button-color);border:2px solid var(--button-color)}.buy-button.size-sm{padding:0.5rem 1rem;font-size:0.875rem;border-radius:var(--tl-radius-sm)}.buy-button.size-md{padding:0.75rem 1.5rem;font-size:1rem;border-radius:var(--tl-radius-md)}.buy-button.size-lg{padding:1rem 2rem;font-size:1.125rem;border-radius:var(--tl-radius-lg);min-height:51px}.buy-button.hovered:not(.disabled){opacity:0.9;transform:translateY(-1px)}.buy-button.hovered.variant-primary{background:var(--button-hover-color)}.buy-button.disabled{opacity:0.7;cursor:not-allowed}.icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}.icon svg{width:1em;height:1em}.label{flex-shrink:0}.price{display:inline-flex;align-items:center;gap:0.25rem;margin-left:0.5rem;white-space:nowrap;opacity:0.9}.price-prefix{opacity:0.7}.price-value{font-weight:700}"}},[1,"tl-buy-tickets-button",{eventId:[1,"event-id"],occurrenceId:[1,"occurrence-id"],state:[1],label:[1],variant:[1],size:[1],fullWidth:[4,"full-width"],price:[2],currency:[1],pricePrefix:[1,"price-prefix"],disabled:[4],isHovered:[32]}]),d=c,u=function(){"undefined"!=typeof customElements&&["tl-buy-tickets-button"].forEach((t=>{"tl-buy-tickets-button"===t&&(customElements.get(n(t))||customElements.define(n(t),c))}))};export{d as TlBuyTicketsButton,u as defineCustomElement}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as e,createEvent as s,h as i,Host as r,transformTag as l}from"@stencil/core/internal/client";import{h as a,g as o}from"./sdk-connector.js";const c=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.tlComplete=s(this,"tl-complete",7),this.tlError=s(this,"tl-error",7),this.tlClose=s(this,"tl-close",7),this.disabled=!1,this.handleClick=()=>{if(!this.disabled)return a()?void o().event(this.eventId).openModal({occurrenceId:this.occurrenceId,onComplete:t=>{this.tlComplete.emit(t)},onError:t=>{this.tlError.emit({message:t.message})},onClose:()=>{this.tlClose.emit()}}):(console.error("[tl-buy-tickets-wrapper] SDK not initialized. Call setSDK(ticketlayer) first."),void this.tlError.emit({message:"SDK not initialized"}))},this.handleKeyDown=t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleClick())}}render(){return i(r,{key:"d6ef81ac9bc1a1194eda1603cbb2a75b355a212e",class:{"tl-buy-tickets-wrapper":!0,"tl-buy-tickets-wrapper--disabled":this.disabled},onClick:this.handleClick,onKeyDown:this.handleKeyDown,role:"button",tabindex:this.disabled?-1:0,"aria-disabled":this.disabled?"true":null},i("slot",{key:"faef5aaad20deaf5e442d688c69105e45f9ee26f"}))}get el(){return this}static get style(){return"tl-buy-tickets-wrapper,.tl-buy-tickets-wrapper{display:inline-block;cursor:pointer}tl-buy-tickets-wrapper:focus,.tl-buy-tickets-wrapper:focus{outline:2px solid var(--tl-ring, #3b82f6);outline-offset:2px;border-radius:var(--tl-radius-sm, 0.25rem)}tl-buy-tickets-wrapper[disabled],tl-buy-tickets-wrapper.tl-buy-tickets-wrapper--disabled,.tl-buy-tickets-wrapper--disabled{cursor:not-allowed;opacity:0.5}"}},[260,"tl-buy-tickets-wrapper",{eventId:[1,"event-id"],occurrenceId:[1,"occurrence-id"],disabled:[4]}]);function n(){"undefined"!=typeof customElements&&["tl-buy-tickets-wrapper"].forEach((t=>{"tl-buy-tickets-wrapper"===t&&(customElements.get(l(t))||customElements.define(l(t),c))}))}export{c as T,n as d}
1
+ import{proxyCustomElement as t,HTMLElement as e,createEvent as s,h as i,Host as r,transformTag as l}from"@stencil/core/internal/client";import{h as a,g as o}from"./sdk-connector.js";const c=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.tlComplete=s(this,"tl-complete",7),this.tlError=s(this,"tl-error",7),this.tlClose=s(this,"tl-close",7),this.disabled=!1,this.handleClick=()=>{if(!this.disabled)return a()?void o().event(this.eventId).openModal({occurrenceId:this.occurrenceId,onComplete:t=>{this.tlComplete.emit(t)},onError:t=>{this.tlError.emit({message:t.message})},onClose:()=>{this.tlClose.emit()}}):(console.error("[tl-buy-tickets-wrapper] SDK not initialized. Call setSDK(ticketlayer) first."),void this.tlError.emit({message:"SDK not initialized"}))},this.handleKeyDown=t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleClick())}}render(){return i(r,{key:"d6ef81ac9bc1a1194eda1603cbb2a75b355a212e",class:{"tl-buy-tickets-wrapper":!0,"tl-buy-tickets-wrapper--disabled":this.disabled},onClick:this.handleClick,onKeyDown:this.handleKeyDown,role:"button",tabindex:this.disabled?-1:0,"aria-disabled":this.disabled?"true":null},i("slot",{key:"faef5aaad20deaf5e442d688c69105e45f9ee26f"}))}get el(){return this}static get style(){return"tl-buy-tickets-wrapper,.tl-buy-tickets-wrapper{display:inline-block;cursor:pointer}tl-buy-tickets-wrapper:focus,.tl-buy-tickets-wrapper:focus{outline:2px solid var(--tl-ring);outline-offset:2px;border-radius:var(--tl-radius-sm)}tl-buy-tickets-wrapper[disabled],tl-buy-tickets-wrapper.tl-buy-tickets-wrapper--disabled,.tl-buy-tickets-wrapper--disabled{cursor:not-allowed;opacity:0.5}"}},[260,"tl-buy-tickets-wrapper",{eventId:[1,"event-id"],occurrenceId:[1,"occurrence-id"],disabled:[4]}]);function n(){"undefined"!=typeof customElements&&["tl-buy-tickets-wrapper"].forEach((t=>{"tl-buy-tickets-wrapper"===t&&(customElements.get(l(t))||customElements.define(l(t),c))}))}export{c as T,n as d}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as i,createEvent as e,h as s,transformTag as n}from"@stencil/core/internal/client";import{w as o}from"./sdk-connector.js";const r="tl_cart_count",a=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tlClick=e(this,"tlClick",7),this.showEmpty=!1,this.size="md",this.badgeOnly=!1,this.itemCount=0,this.handleClick=()=>{this.tlClick.emit({itemCount:this.itemCount})}}componentWillLoad(){this.itemCount=this.getPersistedCartCount()}componentDidLoad(){this.subscribeToCartUpdates()}disconnectedCallback(){this.unsubscribe&&this.unsubscribe()}getPersistedCartCount(){if("undefined"==typeof window)return 0;try{const t=localStorage.getItem(r);return t&&parseInt(t,10)||0}catch{return 0}}persistCartCount(t){if("undefined"!=typeof window)try{localStorage.setItem(r,""+t)}catch{}}async subscribeToCartUpdates(){const t=await o().catch((()=>null));if(!t)return;const i=t.getCartManager?.();i&&(this.unsubscribe=i.on?.("cart:updated",(t=>{const i=t?.itemCount||0;console.log("[tl-cart-badge] Cart updated:",i),this.itemCount=i,this.persistCartCount(i)})),i.get?.().then((t=>{const i=t?.itemCount||0;this.itemCount=i,this.persistCartCount(i)})).catch((()=>{})))}renderIcon(){return this.icon?s("span",{class:"icon-text"},this.icon):s("svg",{class:"icon-svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},s("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"}))}render(){const t=this.itemCount>0||this.showEmpty,i=this.itemCount>99?"99+":""+this.itemCount;return this.badgeOnly?0===this.itemCount?null:s("span",{class:"badge-only size-"+this.size},i):s("button",{class:"cart-badge size-"+this.size,onClick:this.handleClick,"aria-label":`Cart with ${this.itemCount} items`},this.renderIcon(),t&&this.itemCount>0&&s("span",{class:"badge-count"},i))}static get style(){return":host{display:inline-block}.cart-badge{position:relative;display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:var(--tl-spacing-2, 0.5rem);border-radius:var(--tl-radius-md, 0.5rem);color:var(--tl-color-foreground, #111827);transition:background-color 0.2s, transform 0.15s}.cart-badge:hover{background-color:var(--tl-color-muted, #f3f4f6)}.cart-badge:active{transform:scale(0.95)}.cart-badge:focus-visible{outline:2px solid var(--tl-color-primary, #6366f1);outline-offset:2px}.size-sm{padding:var(--tl-spacing-1, 0.25rem)}.size-sm .icon-svg,.size-sm .icon-text{width:18px;height:18px;font-size:18px}.size-md .icon-svg,.size-md .icon-text{width:24px;height:24px;font-size:24px}.size-lg{padding:var(--tl-spacing-3, 0.75rem)}.size-lg .icon-svg,.size-lg .icon-text{width:32px;height:32px;font-size:32px}.icon-svg{width:24px;height:24px;stroke-width:2}.icon-text{line-height:1}.badge-count{position:absolute;top:0;right:0;transform:translate(30%, -30%);min-width:18px;height:18px;padding:0 5px;border-radius:9px;background-color:var(--tl-color-primary, #6366f1);color:var(--tl-color-primary-foreground, #ffffff);font-size:11px;font-weight:600;font-family:var(--tl-font-family, system-ui, sans-serif);display:flex;align-items:center;justify-content:center;line-height:1;box-shadow:0 1px 3px rgba(0, 0, 0, 0.2)}.size-sm .badge-count{min-width:16px;height:16px;font-size:10px;padding:0 4px}.size-lg .badge-count{min-width:22px;height:22px;font-size:13px;padding:0 6px}.badge-only{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 6px;border-radius:10px;background-color:rgba(255, 255, 255, 0.3);color:inherit;font-size:12px;font-weight:600;font-family:var(--tl-font-family, system-ui, sans-serif);line-height:1}.badge-only.size-sm{min-width:18px;height:18px;font-size:11px;padding:0 5px}.badge-only.size-lg{min-width:22px;height:22px;font-size:13px;padding:0 7px}"}},[1,"tl-cart-badge",{showEmpty:[4,"show-empty"],icon:[1],size:[1],badgeOnly:[4,"badge-only"],itemCount:[32]}]),l=a,c=function(){"undefined"!=typeof customElements&&["tl-cart-badge"].forEach((t=>{"tl-cart-badge"===t&&(customElements.get(n(t))||customElements.define(n(t),a))}))};export{l as TlCartBadge,c as defineCustomElement}
1
+ import{proxyCustomElement as t,HTMLElement as i,createEvent as e,h as n,transformTag as s}from"@stencil/core/internal/client";import{w as o}from"./sdk-connector.js";const r="tl_cart_count",a=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tlClick=e(this,"tlClick",7),this.showEmpty=!1,this.size="md",this.badgeOnly=!1,this.itemCount=0,this.handleClick=()=>{this.tlClick.emit({itemCount:this.itemCount})}}componentWillLoad(){this.itemCount=this.getPersistedCartCount()}componentDidLoad(){this.subscribeToCartUpdates()}disconnectedCallback(){this.unsubscribe&&this.unsubscribe()}getPersistedCartCount(){if("undefined"==typeof window)return 0;try{const t=localStorage.getItem(r);return t&&parseInt(t,10)||0}catch{return 0}}persistCartCount(t){if("undefined"!=typeof window)try{localStorage.setItem(r,""+t)}catch{}}async subscribeToCartUpdates(){const t=await o().catch((()=>null));if(!t)return;const i=t.getCartManager?.();i&&(this.unsubscribe=i.on?.("cart:updated",(t=>{const i=t?.itemCount||0;console.log("[tl-cart-badge] Cart updated:",i),this.itemCount=i,this.persistCartCount(i)})),i.get?.().then((t=>{const i=t?.itemCount||0;this.itemCount=i,this.persistCartCount(i)})).catch((()=>{})))}renderIcon(){return this.icon?n("span",{class:"icon-text"},this.icon):n("svg",{class:"icon-svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},n("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"}))}render(){const t=this.itemCount>0||this.showEmpty,i=this.itemCount>99?"99+":""+this.itemCount;return this.badgeOnly?0===this.itemCount?null:n("span",{class:"badge-only size-"+this.size},i):n("button",{class:"cart-badge size-"+this.size,onClick:this.handleClick,"aria-label":`Cart with ${this.itemCount} items`},this.renderIcon(),t&&this.itemCount>0&&n("span",{class:"badge-count"},i))}static get style(){return":host{display:inline-block}.cart-badge{position:relative;display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:var(--tl-spacing-2);border-radius:var(--tl-radius-md);color:var(--tl-color-foreground);transition:background-color 0.2s, transform 0.15s}.cart-badge:hover{background-color:var(--tl-color-muted)}.cart-badge:active{transform:scale(0.95)}.cart-badge:focus-visible{outline:2px solid var(--tl-color-primary);outline-offset:2px}.size-sm{padding:var(--tl-spacing-1)}.size-sm .icon-svg,.size-sm .icon-text{width:18px;height:18px;font-size:18px}.size-md .icon-svg,.size-md .icon-text{width:24px;height:24px;font-size:24px}.size-lg{padding:var(--tl-spacing-3)}.size-lg .icon-svg,.size-lg .icon-text{width:32px;height:32px;font-size:32px}.icon-svg{width:24px;height:24px;stroke-width:2}.icon-text{line-height:1}.badge-count{position:absolute;top:0;right:0;transform:translate(30%, -30%);min-width:18px;height:18px;padding:0 5px;border-radius:9px;background-color:var(--tl-color-primary);color:var(--tl-color-primary-foreground);font-size:11px;font-weight:600;font-family:var(--tl-font-family);display:flex;align-items:center;justify-content:center;line-height:1;box-shadow:0 1px 3px rgba(0, 0, 0, 0.2)}.size-sm .badge-count{min-width:16px;height:16px;font-size:10px;padding:0 4px}.size-lg .badge-count{min-width:22px;height:22px;font-size:13px;padding:0 6px}.badge-only{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 6px;border-radius:10px;background-color:rgba(255, 255, 255, 0.3);color:inherit;font-size:12px;font-weight:600;font-family:var(--tl-font-family);line-height:1}.badge-only.size-sm{min-width:18px;height:18px;font-size:11px;padding:0 5px}.badge-only.size-lg{min-width:22px;height:22px;font-size:13px;padding:0 7px}"}},[1,"tl-cart-badge",{showEmpty:[4,"show-empty"],icon:[1],size:[1],badgeOnly:[4,"badge-only"],itemCount:[32]}]),l=a,c=function(){"undefined"!=typeof customElements&&["tl-cart-badge"].forEach((t=>{"tl-cart-badge"===t&&(customElements.get(s(t))||customElements.define(s(t),a))}))};export{l as TlCartBadge,c as defineCustomElement}
@@ -1 +1 @@
1
- import{proxyCustomElement as e,HTMLElement as t,createEvent as r,h as a,Host as o,transformTag as d}from"@stencil/core/internal/client";import{o as i}from"./sdk-connector.js";import{d as s}from"./tl-cart2.js";const n=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.tlOpen=r(this,"tlOpen",7),this.tlClose=r(this,"tlClose",7),this.side="right",this.heading="Your cart",this.open=!1,this.visible=!1,this.onKey=e=>{"Escape"===e.key&&this.visible&&this.setOpen(!1)},this.close=()=>this.setOpen(!1)}connectedCallback(){this.visible=this.open,this.offCart=i("ui:cart-requested",(()=>this.setOpen(!0))),this.offClose=i("ui:modal-close-requested",(()=>this.setOpen(!1))),"undefined"!=typeof document&&document.addEventListener("keydown",this.onKey)}disconnectedCallback(){this.offCart?.(),this.offClose?.(),"undefined"!=typeof document&&document.removeEventListener("keydown",this.onKey)}onOpenProp(e){this.visible=e}setOpen(e){this.visible!==e&&(this.open=e,this.visible=e,e?this.tlOpen.emit():this.tlClose.emit())}render(){return a(o,{key:"022314d9fb612e930da52ece34f2ab8ae8ce44da"},a("div",{key:"985b4001145d72ba91ef7d466adba8ab939e9cc4",class:{overlay:!0,"is-open":this.visible},onClick:e=>{e.target===e.currentTarget&&this.close()}},a("aside",{key:"3ac3588ae8feacd4f8bb96bdae8ef71e80ecb4b3",class:{panel:!0,["panel--"+this.side]:!0,"is-open":this.visible},role:"dialog","aria-modal":"true","aria-label":this.heading,"aria-hidden":this.visible?"false":"true"},a("header",{key:"e0126d634e952ebf56b73e54545f6c3981210827",class:"drawer-header"},a("h2",{key:"a72b23114aa836076ec59cd4a5d1438d228179d9",class:"drawer-title"},this.heading),a("button",{key:"92fb5b159490440352a6c23d65aa6e8c956ae3d8",class:"close-btn",onClick:this.close,"aria-label":"Close cart"},a("svg",{key:"138f4dc7669e62fb667091da0ba26dfbe94327c6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},a("path",{key:"21fedd9dc89937a92f9c1124d4fa834b55908f1e",d:"M6 6l12 12M18 6L6 18","stroke-linecap":"round"})))),a("div",{key:"ebee87cb6a3c98dbf813d0a903a9cb4da2c696f3",class:"drawer-body"},a("tl-cart",{key:"323db3a160837b68ffaa767e647ec67b06fa53b0"})),a("footer",{key:"d35543373eb13ad1acc46ae50aefcb5a04f305a1",class:"drawer-footer"},a("div",{key:"52229c74d39471bf186c965b6a53b38f79ce8d61",class:"pb-links"},a("a",{key:"d0430bf93d920c57fc42043faed7e8fd895855aa",href:"https://ticketlayer.com/privacy",target:"_blank",rel:"noopener noreferrer"},"Privacy Policy"),a("a",{key:"2a75dc8dcdc9ec3010fe83f97d903cdc32767e49",href:"https://ticketlayer.com/report-abuse",target:"_blank",rel:"noopener noreferrer"},"Report Abuse")),a("a",{key:"40642c5c4c003a454dd7ab2b66ebe5948a03df7d",class:"pb-brand",href:"https://ticketlayer.com",target:"_blank",rel:"noopener noreferrer"},a("span",{key:"a5d9b5c023381d25b6aaddf61e56dbdb21580975",class:"pb-pre"},"Powered by"),a("svg",{key:"35bc23af9a35272d7ada24fd66d5f12f1d951ae8",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},a("path",{key:"90139e79acd8920bcd494cc6579dbcb8278b0aef",d:"M4 7.5A1.5 1.5 0 0 1 5.5 6h13A1.5 1.5 0 0 1 20 7.5v2a2 2 0 0 0 0 5v2a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 4 16.5v-2a2 2 0 0 0 0-5v-2Z",fill:"currentColor"}),a("path",{key:"ba3aa34471395e33752e72f87f93a85381f7caad",d:"M13 7v10",stroke:"var(--tl-pb-perforation, var(--tl-background, #fff))","stroke-width":"1.2","stroke-dasharray":"1.5 1.8","stroke-linecap":"round"})),a("span",{key:"429154bd6c38febe4da8871a7e614bf272a18854",class:"pb-word"},"Ticketlayer"))))))}static get watchers(){return{open:[{onOpenProp:0}]}}static get style(){return":host{--_bg:var(--tl-background, #ffffff);--_fg:var(--tl-foreground, #111827);--_muted-fg:var(--tl-muted-foreground, #6b7280);--_muted:var(--tl-muted, #f3f4f6);--_border:var(--tl-border, #e5e7eb);--_font:var(--tl-font-family, system-ui, -apple-system, sans-serif);font-family:var(--_font)}.overlay{position:fixed;inset:0;z-index:2147483640;background:rgba(8, 8, 16, 0.6);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);opacity:0;pointer-events:none;transition:opacity 0.25s ease}.overlay.is-open{opacity:1;pointer-events:auto}.panel{position:fixed;top:0;bottom:0;width:min(420px, 100%);display:flex;flex-direction:column;background:var(--_bg);color:var(--_fg);box-shadow:0 0 48px rgba(0, 0, 0, 0.5);transition:transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);will-change:transform}.panel--right{right:0;border-left:1px solid var(--_border);transform:translateX(100%)}.panel--left{left:0;border-right:1px solid var(--_border);transform:translateX(-100%)}.panel.is-open{transform:translateX(0)}.drawer-header{display:flex;align-items:center;justify-content:space-between;padding:18px 20px;border-bottom:1px solid var(--_border)}.drawer-title{margin:0;font-size:1.1rem;font-weight:700}.close-btn{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border:0;border-radius:999px;background:var(--_muted);color:var(--_muted-fg);cursor:pointer;transition:color 0.15s}.close-btn:hover{color:var(--_fg)}.close-btn svg{width:16px;height:16px}.drawer-body{flex:1;overflow-y:auto;padding:18px 20px}.drawer-footer{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 20px;border-top:1px solid var(--_border);font-size:11.5px;font-weight:500;color:var(--_muted-fg)}.drawer-footer a{color:inherit;text-decoration:none;opacity:0.9;transition:opacity 0.15s ease}.drawer-footer a:hover{opacity:1}.drawer-footer .pb-links{display:flex;gap:14px}.drawer-footer .pb-brand{display:inline-flex;align-items:center;gap:5px}.drawer-footer .pb-brand svg{display:block}.drawer-footer .pb-pre{opacity:0.7}.drawer-footer .pb-word{font-weight:700}"}},[1,"tl-cart-drawer",{side:[1],heading:[1],open:[1028],visible:[32]},void 0,{open:[{onOpenProp:0}]}]),c=n,l=function(){"undefined"!=typeof customElements&&["tl-cart-drawer","tl-cart"].forEach((e=>{switch(e){case"tl-cart-drawer":customElements.get(d(e))||customElements.define(d(e),n);break;case"tl-cart":customElements.get(d(e))||s()}}))};export{c as TlCartDrawer,l as defineCustomElement}
1
+ import{proxyCustomElement as e,HTMLElement as t,createEvent as r,h as a,Host as o,transformTag as c}from"@stencil/core/internal/client";import{o as i}from"./sdk-connector.js";import{d}from"./tl-cart2.js";const s=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.tlOpen=r(this,"tlOpen",7),this.tlClose=r(this,"tlClose",7),this.side="right",this.heading="Your cart",this.open=!1,this.visible=!1,this.onKey=e=>{"Escape"===e.key&&this.visible&&this.setOpen(!1)},this.close=()=>this.setOpen(!1)}connectedCallback(){this.visible=this.open,this.offCart=i("ui:cart-requested",(()=>this.setOpen(!0))),this.offClose=i("ui:modal-close-requested",(()=>this.setOpen(!1))),"undefined"!=typeof document&&document.addEventListener("keydown",this.onKey)}disconnectedCallback(){this.offCart?.(),this.offClose?.(),"undefined"!=typeof document&&document.removeEventListener("keydown",this.onKey)}onOpenProp(e){this.visible=e}setOpen(e){this.visible!==e&&(this.open=e,this.visible=e,e?this.tlOpen.emit():this.tlClose.emit())}render(){return a(o,{key:"022314d9fb612e930da52ece34f2ab8ae8ce44da"},a("div",{key:"985b4001145d72ba91ef7d466adba8ab939e9cc4",class:{overlay:!0,"is-open":this.visible},onClick:e=>{e.target===e.currentTarget&&this.close()}},a("aside",{key:"3ac3588ae8feacd4f8bb96bdae8ef71e80ecb4b3",class:{panel:!0,["panel--"+this.side]:!0,"is-open":this.visible},role:"dialog","aria-modal":"true","aria-label":this.heading,"aria-hidden":this.visible?"false":"true"},a("header",{key:"e0126d634e952ebf56b73e54545f6c3981210827",class:"drawer-header"},a("h2",{key:"a72b23114aa836076ec59cd4a5d1438d228179d9",class:"drawer-title"},this.heading),a("button",{key:"92fb5b159490440352a6c23d65aa6e8c956ae3d8",class:"close-btn",onClick:this.close,"aria-label":"Close cart"},a("svg",{key:"138f4dc7669e62fb667091da0ba26dfbe94327c6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},a("path",{key:"21fedd9dc89937a92f9c1124d4fa834b55908f1e",d:"M6 6l12 12M18 6L6 18","stroke-linecap":"round"})))),a("div",{key:"ebee87cb6a3c98dbf813d0a903a9cb4da2c696f3",class:"drawer-body"},a("tl-cart",{key:"323db3a160837b68ffaa767e647ec67b06fa53b0"})),a("footer",{key:"d35543373eb13ad1acc46ae50aefcb5a04f305a1",class:"drawer-footer"},a("div",{key:"52229c74d39471bf186c965b6a53b38f79ce8d61",class:"pb-links"},a("a",{key:"d0430bf93d920c57fc42043faed7e8fd895855aa",href:"https://ticketlayer.com/privacy",target:"_blank",rel:"noopener noreferrer"},"Privacy Policy"),a("a",{key:"2a75dc8dcdc9ec3010fe83f97d903cdc32767e49",href:"https://ticketlayer.com/report-abuse",target:"_blank",rel:"noopener noreferrer"},"Report Abuse")),a("a",{key:"40642c5c4c003a454dd7ab2b66ebe5948a03df7d",class:"pb-brand",href:"https://ticketlayer.com",target:"_blank",rel:"noopener noreferrer"},a("span",{key:"a5d9b5c023381d25b6aaddf61e56dbdb21580975",class:"pb-pre"},"Powered by"),a("svg",{key:"35bc23af9a35272d7ada24fd66d5f12f1d951ae8",width:"13",height:"13",viewBox:"0 0 50 50",fill:"none","aria-hidden":"true"},a("g",{key:"fcca5f9bbc13d2781ea65bb907c9c07516972e28",transform:"matrix(0.0129 0 0 -0.0129 25.4752 25.4752)"},a("path",{key:"7bf2071ba8d6d14c9ac9fc7c7a5a36a8008136e8",fill:"currentColor",transform:"translate(-1781.5, -1759.4003)",d:"M 41 2973 c 1 -285 5 -734 9 -998 c 7 -444 9 -488 30 -580 c 81 -364 235 -634 512 -900 c 135 -130 263 -220 423 -299 c 156 -77 249 -109 409 -143 c 110 -23 142 -25 354 -24 c 230 1 310 8 427 37 c 241 60 453 162 640 309 c 82 64 252 234 317 315 c 210 264 340 604 355 926 l 6 121 l -69 6 c -86 8 -706 9 -755 1 l -36 -6 l -21 -125 c -34 -191 -98 -317 -236 -462 c -111 -115 -249 -198 -396 -238 c -98 -27 -356 -24 -463 5 c -100 27 -183 69 -273 137 c -226 173 -353 409 -354 660 c 0 44 -5 120 -10 169 c -6 49 -8 91 -6 94 c 3 3 65 -22 138 -55 c 140 -64 251 -103 358 -127 c 71 -17 295 -46 347 -46 l 33 0 l 0 434 l 0 434 l -67 7 c -147 14 -269 56 -393 133 c -222 139 -378 393 -397 648 l -6 71 l -75 7 c -41 3 -239 6 -439 6 l -363 0 l 1 -517 z"}))),a("span",{key:"c97081daa81688106395f6ef6c497b11df53a6a9",class:"pb-word"},"ticketlayer"))))))}static get watchers(){return{open:[{onOpenProp:0}]}}static get style(){return":host{--_bg:var(--tl-background);--_fg:var(--tl-foreground);--_muted-fg:var(--tl-muted-foreground);--_muted:var(--tl-muted);--_border:var(--tl-border);--_font:var(--tl-font-family);font-family:var(--_font)}.overlay{position:fixed;inset:0;z-index:2147483640;background:rgba(8, 8, 16, 0.6);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);opacity:0;pointer-events:none;transition:opacity 0.25s ease}.overlay.is-open{opacity:1;pointer-events:auto}.panel{position:fixed;top:0;bottom:0;width:min(420px, 100%);display:flex;flex-direction:column;background:var(--_bg);color:var(--_fg);box-shadow:0 0 48px rgba(0, 0, 0, 0.5);transition:transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);will-change:transform}.panel--right{right:0;border-left:1px solid var(--_border);transform:translateX(100%)}.panel--left{left:0;border-right:1px solid var(--_border);transform:translateX(-100%)}.panel.is-open{transform:translateX(0)}.drawer-header{display:flex;align-items:center;justify-content:space-between;padding:18px 20px;border-bottom:1px solid var(--_border)}.drawer-title{margin:0;font-size:1.1rem;font-weight:700}.close-btn{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border:0;border-radius:999px;background:var(--_muted);color:var(--_muted-fg);cursor:pointer;transition:color 0.15s}.close-btn:hover{color:var(--_fg)}.close-btn svg{width:16px;height:16px}.drawer-body{flex:1;overflow-y:auto;padding:18px 20px}.drawer-footer{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 20px;border-top:1px solid var(--_border);font-size:11.5px;font-weight:500;color:var(--_muted-fg)}.drawer-footer a{color:inherit;text-decoration:none;opacity:0.9;transition:opacity 0.15s ease}.drawer-footer a:hover{opacity:1}.drawer-footer .pb-links{display:flex;gap:14px}.drawer-footer .pb-brand{display:inline-flex;align-items:center;gap:5px}.drawer-footer .pb-brand svg{display:block}.drawer-footer .pb-pre{opacity:0.7}.drawer-footer .pb-word{font-weight:700}"}},[1,"tl-cart-drawer",{side:[1],heading:[1],open:[1028],visible:[32]},void 0,{open:[{onOpenProp:0}]}]),n=s,l=function(){"undefined"!=typeof customElements&&["tl-cart-drawer","tl-cart"].forEach((e=>{switch(e){case"tl-cart-drawer":customElements.get(c(e))||customElements.define(c(e),s);break;case"tl-cart":customElements.get(c(e))||d()}}))};export{n as TlCartDrawer,l as defineCustomElement}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as e,createEvent as r,h as o,transformTag as a}from"@stencil/core/internal/client";import{w as i,h as s,g as n}from"./sdk-connector.js";const l=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tlCheckout=r(this,"tlCheckout",7),this.tlItemRemoved=r(this,"tlItemRemoved",7),this.tlCartUpdated=r(this,"tlCartUpdated",7),this.tlError=r(this,"tlError",7),this.showCheckoutButton=!0,this.checkoutLabel="Checkout",this.showRemoveButtons=!0,this.compact=!1,this.cart=null,this.loading=!0,this.error=null,this.removingItemId=null,this.handleCheckout=()=>{this.cart&&this.cart.items.length>0&&this.tlCheckout.emit({cart:this.cart})}}componentWillLoad(){this.loadCart()}componentDidLoad(){this.subscribeToCartUpdates()}disconnectedCallback(){this.unsubscribe&&this.unsubscribe()}async loadCart(){try{console.log("[tl-cart] Loading cart..."),this.loading=!0,this.error=null;const t=await i(),e=t.getCartManager?.();if(e){const t=await e.get();console.log("[tl-cart] Cart loaded:",t),this.cart=t}}catch(t){console.error("[tl-cart] Failed to load cart:",t),this.error=t instanceof Error?t.message:"Failed to load cart",this.tlError.emit({message:this.error})}finally{this.loading=!1}}async subscribeToCartUpdates(){const t=await i().catch((()=>null));if(!t)return;const e=t.getCartManager?.();e&&(this.unsubscribe=e.on?.("cart:updated",(t=>{console.log("[tl-cart] Cart updated:",t),this.cart=t,this.tlCartUpdated.emit({cart:t})})))}async handleRemoveItem(t){if(s()){this.removingItemId=t;try{const e=n(),r=e.getCartManager?.();r&&(await r.removeItem(t),console.log("[tl-cart] Item removed:",t),this.tlItemRemoved.emit({itemId:t}))}catch(t){console.error("[tl-cart] Failed to remove item:",t),this.error=t instanceof Error?t.message:"Failed to remove item",this.tlError.emit({message:this.error})}finally{this.removingItemId=null}}}formatPrice(t,e="GBP"){return new Intl.NumberFormat("en-GB",{style:"currency",currency:e}).format(t/100)}formatDate(t){return new Date(t).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})}renderSkeleton(){return o("div",{class:"skeleton-container"},o("div",{class:"skeleton-item"}),o("div",{class:"skeleton-item"}),o("div",{class:"skeleton-totals"}))}renderEmptyCart(){return o("div",{class:"empty-cart"},o("svg",{class:"empty-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"})),o("p",{class:"empty-title"},"Your cart is empty"),o("p",{class:"empty-message"},"Add tickets to get started"))}renderCartItem(t){const e=this.removingItemId===t.id;return o("div",{class:"cart-item "+(e?"removing":""),key:t.id},o("div",{class:"item-info"},o("p",{class:"item-name"},t.ticketTypeName),!this.compact&&o("p",{class:"item-event"},t.eventName),!this.compact&&t.occurrenceDate&&o("p",{class:"item-date"},this.formatDate(t.occurrenceDate)),o("p",{class:"item-quantity"},"Qty: ",t.quantity)),o("div",{class:"item-actions"},o("p",{class:"item-price"},this.formatPrice(t.totalPrice,t.currency)),this.showRemoveButtons&&o("button",{class:"remove-btn",onClick:()=>this.handleRemoveItem(t.id),disabled:e,"aria-label":"Remove item"},e?o("span",{class:"spinner"}):o("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},o("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})))))}render(){if(this.loading)return this.renderSkeleton();if(!this.cart||0===this.cart.items.length)return this.renderEmptyCart();const{items:t,subtotal:e,fees:r,total:a,currency:i}=this.cart;return o("div",{class:"cart "+(this.compact?"compact":"")},o("div",{class:"cart-items"},t.map((t=>this.renderCartItem(t)))),o("div",{class:"cart-totals"},!this.compact&&o("div",{class:"total-row subtotal"},o("span",null,"Subtotal"),o("span",null,this.formatPrice(e,i))),r>0&&!this.compact&&o("div",{class:"total-row fees"},o("span",null,"Fees"),o("span",null,this.formatPrice(r,i))),o("div",{class:"total-row total"},o("span",null,"Total"),o("span",null,this.formatPrice(a,i)))),this.showCheckoutButton&&o("button",{class:"checkout-btn",onClick:this.handleCheckout,disabled:0===t.length},this.checkoutLabel))}static get style(){return":host{display:block;font-family:var(--tl-font-family, system-ui, sans-serif)}.skeleton-container{padding:var(--tl-spacing-4, 1rem)}.skeleton-item{height:70px;background:var(--tl-color-muted, #f3f4f6);border-radius:var(--tl-radius-md, 0.5rem);margin-bottom:var(--tl-spacing-3, 0.75rem);animation:pulse 1.5s ease-in-out infinite}.skeleton-totals{height:100px;background:var(--tl-color-muted, #f3f4f6);border-radius:var(--tl-radius-md, 0.5rem);animation:pulse 1.5s ease-in-out infinite}@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.5}}.empty-cart{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--tl-spacing-8, 2rem);text-align:center}.empty-icon{width:48px;height:48px;color:var(--tl-color-muted-foreground, #9ca3af);margin-bottom:var(--tl-spacing-4, 1rem)}.empty-title{margin:0 0 var(--tl-spacing-2, 0.5rem);font-size:16px;font-weight:600;color:var(--tl-color-foreground, #111827)}.empty-message{margin:0;font-size:14px;color:var(--tl-color-muted-foreground, #6b7280)}.cart{background:var(--tl-color-background, #ffffff)}.cart.compact .cart-items{margin-bottom:var(--tl-spacing-2, 0.5rem)}.cart-items{margin-bottom:var(--tl-spacing-4, 1rem)}.cart-item{display:flex;justify-content:space-between;align-items:flex-start;padding:var(--tl-spacing-3, 0.75rem) 0;border-bottom:1px solid var(--tl-color-border, #e5e7eb);transition:opacity 0.2s}.cart-item:last-child{border-bottom:none}.cart-item.removing{opacity:0.5}.item-info{flex:1;min-width:0}.item-name{margin:0;font-weight:600;font-size:15px;color:var(--tl-color-foreground, #111827)}.item-event{margin:var(--tl-spacing-1, 0.25rem) 0 0;font-size:14px;color:var(--tl-color-muted-foreground, #6b7280)}.item-date{margin:var(--tl-spacing-1, 0.25rem) 0 0;font-size:13px;color:var(--tl-color-muted-foreground, #9ca3af)}.item-quantity{margin:var(--tl-spacing-1, 0.25rem) 0 0;font-size:13px;color:var(--tl-color-muted-foreground, #6b7280)}.item-actions{display:flex;align-items:center;gap:var(--tl-spacing-3, 0.75rem);margin-left:var(--tl-spacing-4, 1rem)}.item-price{margin:0;font-weight:600;font-size:15px;color:var(--tl-color-foreground, #111827);white-space:nowrap}.remove-btn{width:28px;height:28px;padding:0;border:none;background:transparent;border-radius:var(--tl-radius-sm, 0.25rem);color:var(--tl-color-muted-foreground, #9ca3af);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color 0.15s, color 0.15s}.remove-btn:hover:not(:disabled){background-color:var(--tl-color-destructive-bg, #fee2e2);color:var(--tl-color-destructive, #ef4444)}.remove-btn:disabled{cursor:not-allowed;opacity:0.5}.remove-btn svg{width:16px;height:16px}.spinner{width:14px;height:14px;border:2px solid var(--tl-color-border, #e5e7eb);border-top-color:var(--tl-color-primary, #6366f1);border-radius:50%;animation:spin 0.6s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.cart-totals{padding:var(--tl-spacing-3, 0.75rem) 0;border-top:1px solid var(--tl-color-border, #e5e7eb)}.total-row{display:flex;justify-content:space-between;align-items:center;padding:var(--tl-spacing-1, 0.25rem) 0}.total-row.subtotal,.total-row.fees{font-size:14px;color:var(--tl-color-muted-foreground, #6b7280)}.total-row.total{font-size:16px;font-weight:700;color:var(--tl-color-foreground, #111827);padding-top:var(--tl-spacing-2, 0.5rem);border-top:1px solid var(--tl-color-border, #e5e7eb);margin-top:var(--tl-spacing-2, 0.5rem)}.checkout-btn{width:100%;margin-top:var(--tl-spacing-4, 1rem);padding:var(--tl-spacing-3, 0.75rem) var(--tl-spacing-4, 1rem);border-radius:var(--tl-radius-md, 0.5rem);border:none;background-color:var(--tl-color-primary, #6366f1);color:var(--tl-color-primary-foreground, #ffffff);font-weight:600;font-size:16px;cursor:pointer;transition:opacity 0.15s, transform 0.1s}.checkout-btn:hover:not(:disabled){opacity:0.9}.checkout-btn:active:not(:disabled){transform:scale(0.98)}.checkout-btn:disabled{background-color:var(--tl-color-muted, #d1d5db);color:var(--tl-color-muted-foreground, #6b7280);cursor:not-allowed}.cart.compact .item-info{flex-direction:row;align-items:center}.cart.compact .cart-totals{padding:var(--tl-spacing-2, 0.5rem) 0}.cart.compact .total-row.total{margin-top:0;border-top:none;padding-top:0}"}},[1,"tl-cart",{showCheckoutButton:[4,"show-checkout-button"],checkoutLabel:[1,"checkout-label"],showRemoveButtons:[4,"show-remove-buttons"],compact:[4],cart:[32],loading:[32],error:[32],removingItemId:[32]}]);function c(){"undefined"!=typeof customElements&&["tl-cart"].forEach((t=>{"tl-cart"===t&&(customElements.get(a(t))||customElements.define(a(t),l))}))}export{l as T,c as d}
1
+ import{proxyCustomElement as t,HTMLElement as o,createEvent as r,h as e,transformTag as a}from"@stencil/core/internal/client";import{w as i,h as s,g as n}from"./sdk-connector.js";import{c as l}from"./money.js";const c=t(class extends o{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tlCheckout=r(this,"tlCheckout",7),this.tlItemRemoved=r(this,"tlItemRemoved",7),this.tlCartUpdated=r(this,"tlCartUpdated",7),this.tlError=r(this,"tlError",7),this.showCheckoutButton=!0,this.checkoutLabel="Checkout",this.showRemoveButtons=!0,this.compact=!1,this.cart=null,this.loading=!0,this.error=null,this.removingItemId=null,this.handleCheckout=()=>{this.cart&&this.cart.items.length>0&&this.tlCheckout.emit({cart:this.cart})}}componentWillLoad(){this.loadCart()}componentDidLoad(){this.subscribeToCartUpdates()}disconnectedCallback(){this.unsubscribe&&this.unsubscribe()}async loadCart(){try{console.log("[tl-cart] Loading cart..."),this.loading=!0,this.error=null;const t=await i(),o=t.getCartManager?.();if(o){const t=await o.get();console.log("[tl-cart] Cart loaded:",t),this.cart=t}}catch(t){console.error("[tl-cart] Failed to load cart:",t),this.error=t instanceof Error?t.message:"Failed to load cart",this.tlError.emit({message:this.error})}finally{this.loading=!1}}async subscribeToCartUpdates(){const t=await i().catch((()=>null));if(!t)return;const o=t.getCartManager?.();o&&(this.unsubscribe=o.on?.("cart:updated",(t=>{console.log("[tl-cart] Cart updated:",t),this.cart=t,this.tlCartUpdated.emit({cart:t})})))}async handleRemoveItem(t){if(s()){this.removingItemId=t;try{const o=n(),r=o.getCartManager?.();r&&(await r.removeItem(t),console.log("[tl-cart] Item removed:",t),this.tlItemRemoved.emit({itemId:t}))}catch(t){console.error("[tl-cart] Failed to remove item:",t),this.error=t instanceof Error?t.message:"Failed to remove item",this.tlError.emit({message:this.error})}finally{this.removingItemId=null}}}formatPrice(t,o="GBP"){return new Intl.NumberFormat("en-GB",{style:"currency",currency:o}).format(t/100)}formatDate(t){return new Date(t).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})}renderSkeleton(){return e("div",{class:"skeleton-container"},e("div",{class:"skeleton-item"}),e("div",{class:"skeleton-item"}),e("div",{class:"skeleton-totals"}))}renderEmptyCart(){return e("div",{class:"empty-cart"},e("svg",{class:"empty-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"})),e("p",{class:"empty-title"},"Your cart is empty"),e("p",{class:"empty-message"},"Add tickets to get started"))}renderCartItem(t){const o=this.removingItemId===t.id;return e("div",{class:"cart-item "+(o?"removing":""),key:t.id},e("div",{class:"item-info"},e("p",{class:"item-name"},t.ticketTypeName),!this.compact&&e("p",{class:"item-event"},t.eventName),!this.compact&&t.occurrenceDate&&e("p",{class:"item-date"},this.formatDate(t.occurrenceDate)),e("p",{class:"item-quantity"},"Qty: ",t.quantity)),e("div",{class:"item-actions"},e("p",{class:"item-price"},this.formatPrice(t.totalPrice,t.currency)),this.showRemoveButtons&&e("button",{class:"remove-btn",onClick:()=>this.handleRemoveItem(t.id),disabled:o,"aria-label":"Remove item"},o?e("span",{class:"spinner"}):e("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})))))}render(){if(this.loading)return this.renderSkeleton();if(!this.cart||0===this.cart.items.length)return this.renderEmptyCart();const{items:t}=this.cart,o=l(this.cart),r=o.currency;return e("div",{class:"cart "+(this.compact?"compact":"")},e("div",{class:"cart-items"},t.map((t=>this.renderCartItem(t)))),e("div",{class:"cart-totals"},!this.compact&&e("div",{class:"total-row subtotal"},e("span",null,"Subtotal"),e("span",null,this.formatPrice(o.subtotal,r))),o.showFee&&!this.compact&&e("div",{class:"total-row fees"},e("span",null,o.feeLabel),e("span",null,this.formatPrice(o.fees,r))),o.discount>0&&!this.compact&&e("div",{class:"total-row discount"},e("span",null,"Discount"),e("span",null,"-",this.formatPrice(o.discount,r))),e("div",{class:"total-row total"},e("span",null,"Total"),e("span",null,this.formatPrice(o.total,r)))),this.showCheckoutButton&&e("button",{class:"checkout-btn",onClick:this.handleCheckout,disabled:0===t.length},this.checkoutLabel))}static get style(){return":host{display:block;font-family:var(--tl-font-family)}.skeleton-container{padding:var(--tl-spacing-4)}.skeleton-item{height:70px;background:var(--tl-color-muted);border-radius:var(--tl-radius-md);margin-bottom:var(--tl-spacing-3);animation:pulse 1.5s ease-in-out infinite}.skeleton-totals{height:100px;background:var(--tl-color-muted);border-radius:var(--tl-radius-md);animation:pulse 1.5s ease-in-out infinite}@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.5}}.empty-cart{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--tl-spacing-8);text-align:center}.empty-icon{width:48px;height:48px;color:var(--tl-color-muted-foreground);margin-bottom:var(--tl-spacing-4)}.empty-title{margin:0 0 var(--tl-spacing-2);font-size:16px;font-weight:600;color:var(--tl-color-foreground)}.empty-message{margin:0;font-size:14px;color:var(--tl-color-muted-foreground)}.cart{background:var(--tl-color-background)}.cart.compact .cart-items{margin-bottom:var(--tl-spacing-2)}.cart-items{margin-bottom:var(--tl-spacing-4)}.cart-item{display:flex;justify-content:space-between;align-items:flex-start;padding:var(--tl-spacing-3) 0;border-bottom:1px solid var(--tl-color-border);transition:opacity 0.2s}.cart-item:last-child{border-bottom:none}.cart-item.removing{opacity:0.5}.item-info{flex:1;min-width:0}.item-name{margin:0;font-weight:600;font-size:15px;color:var(--tl-color-foreground)}.item-event{margin:var(--tl-spacing-1) 0 0;font-size:14px;color:var(--tl-color-muted-foreground)}.item-date{margin:var(--tl-spacing-1) 0 0;font-size:13px;color:var(--tl-color-muted-foreground)}.item-quantity{margin:var(--tl-spacing-1) 0 0;font-size:13px;color:var(--tl-color-muted-foreground)}.item-actions{display:flex;align-items:center;gap:var(--tl-spacing-3);margin-left:var(--tl-spacing-4)}.item-price{margin:0;font-weight:600;font-size:15px;color:var(--tl-color-foreground);white-space:nowrap}.remove-btn{width:28px;height:28px;padding:0;border:none;background:transparent;border-radius:var(--tl-radius-sm);color:var(--tl-color-muted-foreground);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color 0.15s, color 0.15s}.remove-btn:hover:not(:disabled){background-color:var(--tl-color-destructive-bg);color:var(--tl-color-destructive)}.remove-btn:disabled{cursor:not-allowed;opacity:0.5}.remove-btn svg{width:16px;height:16px}.spinner{width:14px;height:14px;border:2px solid var(--tl-color-border);border-top-color:var(--tl-color-primary);border-radius:50%;animation:spin 0.6s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.cart-totals{padding:var(--tl-spacing-3) 0;border-top:1px solid var(--tl-color-border)}.total-row{display:flex;justify-content:space-between;align-items:center;padding:var(--tl-spacing-1) 0}.total-row.subtotal,.total-row.fees,.total-row.discount{font-size:14px;color:var(--tl-color-muted-foreground)}.total-row.total{font-size:16px;font-weight:700;color:var(--tl-color-foreground);padding-top:var(--tl-spacing-2);border-top:1px solid var(--tl-color-border);margin-top:var(--tl-spacing-2)}.checkout-btn{width:100%;margin-top:var(--tl-spacing-4);padding:var(--tl-spacing-3) var(--tl-spacing-4);border-radius:var(--tl-radius-md);border:none;background-color:var(--tl-color-primary);color:var(--tl-color-primary-foreground);font-weight:600;font-size:16px;cursor:pointer;transition:opacity 0.15s, transform 0.1s}.checkout-btn:hover:not(:disabled){opacity:0.9}.checkout-btn:active:not(:disabled){transform:scale(0.98)}.checkout-btn:disabled{background-color:var(--tl-color-muted);color:var(--tl-color-muted-foreground);cursor:not-allowed}.cart.compact .item-info{flex-direction:row;align-items:center}.cart.compact .cart-totals{padding:var(--tl-spacing-2) 0}.cart.compact .total-row.total{margin-top:0;border-top:none;padding-top:0}"}},[1,"tl-cart",{showCheckoutButton:[4,"show-checkout-button"],checkoutLabel:[1,"checkout-label"],showRemoveButtons:[4,"show-remove-buttons"],compact:[4],cart:[32],loading:[32],error:[32],removingItemId:[32]}]);function d(){"undefined"!=typeof customElements&&["tl-cart"].forEach((t=>{"tl-cart"===t&&(customElements.get(a(t))||customElements.define(a(t),c))}))}export{c as T,d}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as e,createEvent as r,h as s,Host as o,transformTag as i}from"@stencil/core/internal/client";import{h as c,g as l}from"./sdk-connector.js";const a=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.tlComplete=r(this,"tl-complete",7),this.tlError=r(this,"tl-error",7),this.tlClose=r(this,"tl-close",7),this.disabled=!1,this.handleClick=()=>{if(!this.disabled)return c()?void l().checkout.openModal({onComplete:t=>{this.tlComplete.emit(t)},onError:t=>{this.tlError.emit({message:t.message})},onClose:()=>{this.tlClose.emit()}}):(console.error("[tl-checkout-wrapper] SDK not initialized. Call setSDK(ticketlayer) first."),void this.tlError.emit({message:"SDK not initialized"}))},this.handleKeyDown=t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleClick())}}render(){return s(o,{key:"ebaae5dd6710ffc5353ece4327012df0332fdbb7",class:{"tl-checkout-wrapper":!0,"tl-checkout-wrapper--disabled":this.disabled},onClick:this.handleClick,onKeyDown:this.handleKeyDown,role:"button",tabindex:this.disabled?-1:0,"aria-disabled":this.disabled?"true":null},s("slot",{key:"0118d9921df5af1ae2376fd4135bac487aac7ebd"}))}get el(){return this}static get style(){return"tl-checkout-wrapper,.tl-checkout-wrapper{display:inline-block;cursor:pointer}tl-checkout-wrapper:focus,.tl-checkout-wrapper:focus{outline:2px solid var(--tl-ring, #3b82f6);outline-offset:2px;border-radius:var(--tl-radius-sm, 0.25rem)}tl-checkout-wrapper[disabled],tl-checkout-wrapper.tl-checkout-wrapper--disabled,.tl-checkout-wrapper--disabled{cursor:not-allowed;opacity:0.5}"}},[260,"tl-checkout-wrapper",{disabled:[4]}]);function n(){"undefined"!=typeof customElements&&["tl-checkout-wrapper"].forEach((t=>{"tl-checkout-wrapper"===t&&(customElements.get(i(t))||customElements.define(i(t),a))}))}export{a as T,n as d}
1
+ import{proxyCustomElement as t,HTMLElement as e,createEvent as r,h as s,Host as o,transformTag as i}from"@stencil/core/internal/client";import{h as c,g as l}from"./sdk-connector.js";const a=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.tlComplete=r(this,"tl-complete",7),this.tlError=r(this,"tl-error",7),this.tlClose=r(this,"tl-close",7),this.disabled=!1,this.handleClick=()=>{if(!this.disabled)return c()?void l().checkout.openModal({onComplete:t=>{this.tlComplete.emit(t)},onError:t=>{this.tlError.emit({message:t.message})},onClose:()=>{this.tlClose.emit()}}):(console.error("[tl-checkout-wrapper] SDK not initialized. Call setSDK(ticketlayer) first."),void this.tlError.emit({message:"SDK not initialized"}))},this.handleKeyDown=t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleClick())}}render(){return s(o,{key:"ebaae5dd6710ffc5353ece4327012df0332fdbb7",class:{"tl-checkout-wrapper":!0,"tl-checkout-wrapper--disabled":this.disabled},onClick:this.handleClick,onKeyDown:this.handleKeyDown,role:"button",tabindex:this.disabled?-1:0,"aria-disabled":this.disabled?"true":null},s("slot",{key:"0118d9921df5af1ae2376fd4135bac487aac7ebd"}))}get el(){return this}static get style(){return"tl-checkout-wrapper,.tl-checkout-wrapper{display:inline-block;cursor:pointer}tl-checkout-wrapper:focus,.tl-checkout-wrapper:focus{outline:2px solid var(--tl-ring);outline-offset:2px;border-radius:var(--tl-radius-sm)}tl-checkout-wrapper[disabled],tl-checkout-wrapper.tl-checkout-wrapper--disabled,.tl-checkout-wrapper--disabled{cursor:not-allowed;opacity:0.5}"}},[260,"tl-checkout-wrapper",{disabled:[4]}]);function n(){"undefined"!=typeof customElements&&["tl-checkout-wrapper"].forEach((t=>{"tl-checkout-wrapper"===t&&(customElements.get(i(t))||customElements.define(i(t),a))}))}export{a as T,n as d}