@ticketlayer/elements 0.3.3 → 1.0.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 (179) hide show
  1. package/README.md +3 -2
  2. package/dist/cjs/{index-BpfoKd9Q.js → index-DanPUX0s.js} +1 -1
  3. package/dist/cjs/index.cjs.js +2 -1
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/cjs/ticket-selector-BYVL13k_.js +3623 -0
  6. package/dist/cjs/ticketlayer-elements.cjs.js +2 -2
  7. package/dist/cjs/tl-buy-modal.cjs.entry.js +4 -4
  8. package/dist/cjs/tl-buy-tickets-button.cjs.entry.js +89 -71
  9. package/dist/cjs/tl-buy-tickets-wrapper.cjs.entry.js +62 -31
  10. package/dist/cjs/tl-cart-badge.cjs.entry.js +75 -62
  11. package/dist/cjs/tl-cart-drawer.cjs.entry.js +52 -24
  12. package/dist/cjs/tl-cart.cjs.entry.js +72 -98
  13. package/dist/cjs/tl-checkout-wrapper.cjs.entry.js +52 -30
  14. package/dist/cjs/tl-event-card.cjs.entry.js +44 -105
  15. package/dist/cjs/tl-event-list.cjs.entry.js +73 -36
  16. package/dist/cjs/tl-login.cjs.entry.js +75 -141
  17. package/dist/cjs/tl-my-orders.cjs.entry.js +53 -92
  18. package/dist/cjs/tl-occurrence-selector_2.cjs.entry.js +205 -641
  19. package/dist/cjs/tl-order-confirmation.cjs.entry.js +72 -105
  20. package/dist/cjs/tl-order-tickets_2.cjs.entry.js +50 -76
  21. package/dist/cjs/tl-promo-code.cjs.entry.js +51 -47
  22. package/dist/cjs/tl-seat-map.cjs.entry.js +4 -4
  23. package/dist/cjs/web-query-Ce73jB4k.js +16 -0
  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 +2 -2
  26. package/dist/collection/components/tl-buy-tickets-button/tl-buy-tickets-button.css +41 -4
  27. package/dist/collection/components/tl-buy-tickets-button/tl-buy-tickets-button.js +105 -76
  28. package/dist/collection/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.css +2 -2
  29. package/dist/collection/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.js +73 -30
  30. package/dist/collection/components/tl-cart/tl-cart.css +52 -51
  31. package/dist/collection/components/tl-cart/tl-cart.js +82 -101
  32. package/dist/collection/components/tl-cart-badge/tl-cart-badge.css +11 -11
  33. package/dist/collection/components/tl-cart-badge/tl-cart-badge.js +62 -62
  34. package/dist/collection/components/tl-cart-drawer/tl-cart-drawer.css +6 -6
  35. package/dist/collection/components/tl-cart-drawer/tl-cart-drawer.js +56 -24
  36. package/dist/collection/components/tl-checkout-wrapper/tl-checkout-wrapper.css +2 -2
  37. package/dist/collection/components/tl-checkout-wrapper/tl-checkout-wrapper.js +61 -29
  38. package/dist/collection/components/tl-event-card/event-card-adapter.js +11 -23
  39. package/dist/collection/components/tl-event-card/tl-event-card.css +22 -22
  40. package/dist/collection/components/tl-event-card/tl-event-card.js +51 -84
  41. package/dist/collection/components/tl-event-list/tl-event-list.css +17 -17
  42. package/dist/collection/components/tl-event-list/tl-event-list.js +82 -38
  43. package/dist/collection/components/tl-login/tl-login.css +26 -26
  44. package/dist/collection/components/tl-login/tl-login.js +83 -147
  45. package/dist/collection/components/tl-my-orders/tl-my-orders.css +40 -40
  46. package/dist/collection/components/tl-my-orders/tl-my-orders.js +58 -96
  47. package/dist/collection/components/tl-occurrence-selector/tl-occurrence-selector.css +54 -65
  48. package/dist/collection/components/tl-occurrence-selector/tl-occurrence-selector.js +137 -516
  49. package/dist/collection/components/tl-order-confirmation/tl-order-confirmation.css +38 -38
  50. package/dist/collection/components/tl-order-confirmation/tl-order-confirmation.js +81 -113
  51. package/dist/collection/components/tl-order-tickets/tl-order-tickets.css +9 -9
  52. package/dist/collection/components/tl-order-tickets/tl-order-tickets.js +57 -92
  53. package/dist/collection/components/tl-promo-code/tl-promo-code.css +25 -25
  54. package/dist/collection/components/tl-promo-code/tl-promo-code.js +55 -50
  55. package/dist/collection/components/tl-seat-map/tl-seat-map.css +10 -10
  56. package/dist/collection/components/tl-seat-map/tl-seat-map.js +2 -2
  57. package/dist/collection/components/tl-ticket/tl-ticket.css +13 -13
  58. package/dist/collection/components/tl-ticket-selector/tl-ticket-selector.css +74 -49
  59. package/dist/collection/components/tl-ticket-selector/tl-ticket-selector.js +95 -135
  60. package/dist/collection/utils/cart-totals.js +9 -0
  61. package/dist/collection/utils/order-summary.js +15 -99
  62. package/dist/collection/utils/testing/deep-text.js +29 -0
  63. package/dist/collection/utils/testing/fixtures.js +290 -0
  64. package/dist/collection/utils/testing/mock-sdk.js +13 -2
  65. package/dist/collection/utils/web-query.js +12 -0
  66. package/dist/collection/utils/web-storage.js +22 -0
  67. package/dist/components/ticket-selector.js +1 -0
  68. package/dist/components/tl-buy-modal.js +1 -1
  69. package/dist/components/tl-buy-tickets-button.js +1 -1
  70. package/dist/components/tl-buy-tickets-wrapper2.js +1 -1
  71. package/dist/components/tl-cart-badge.js +1 -1
  72. package/dist/components/tl-cart-drawer.js +1 -1
  73. package/dist/components/tl-cart2.js +1 -1
  74. package/dist/components/tl-checkout-wrapper2.js +1 -1
  75. package/dist/components/tl-event-card2.js +1 -1
  76. package/dist/components/tl-event-list.js +1 -1
  77. package/dist/components/tl-login2.js +1 -1
  78. package/dist/components/tl-my-orders.js +1 -1
  79. package/dist/components/tl-occurrence-selector2.js +1 -1
  80. package/dist/components/tl-order-confirmation.js +1 -1
  81. package/dist/components/tl-order-tickets2.js +1 -1
  82. package/dist/components/tl-promo-code.js +1 -1
  83. package/dist/components/tl-seat-map.js +1 -1
  84. package/dist/components/tl-ticket-selector2.js +1 -1
  85. package/dist/components/tl-ticket2.js +1 -1
  86. package/dist/components/web-query.js +1 -0
  87. package/dist/elements.docs.json +36 -36
  88. package/dist/esm/{index-CNX8hZa8.js → index-imfxp765.js} +1 -1
  89. package/dist/esm/index.js +2 -1
  90. package/dist/esm/loader.js +3 -3
  91. package/dist/esm/ticket-selector-BwChnHVC.js +3606 -0
  92. package/dist/esm/ticketlayer-elements.js +3 -3
  93. package/dist/esm/tl-buy-modal.entry.js +4 -4
  94. package/dist/esm/tl-buy-tickets-button.entry.js +90 -72
  95. package/dist/esm/tl-buy-tickets-wrapper.entry.js +63 -32
  96. package/dist/esm/tl-cart-badge.entry.js +76 -63
  97. package/dist/esm/tl-cart-drawer.entry.js +53 -25
  98. package/dist/esm/tl-cart.entry.js +73 -99
  99. package/dist/esm/tl-checkout-wrapper.entry.js +53 -31
  100. package/dist/esm/tl-event-card.entry.js +45 -106
  101. package/dist/esm/tl-event-list.entry.js +74 -37
  102. package/dist/esm/tl-login.entry.js +76 -142
  103. package/dist/esm/tl-my-orders.entry.js +54 -93
  104. package/dist/esm/tl-occurrence-selector_2.entry.js +206 -642
  105. package/dist/esm/tl-order-confirmation.entry.js +73 -106
  106. package/dist/esm/tl-order-tickets_2.entry.js +51 -77
  107. package/dist/esm/tl-promo-code.entry.js +52 -48
  108. package/dist/esm/tl-seat-map.entry.js +4 -4
  109. package/dist/esm/web-query-Bdbb2lk5.js +14 -0
  110. package/dist/ticketlayer-elements/index.esm.js +1 -1
  111. package/dist/ticketlayer-elements/p-45923d2c.entry.js +1 -0
  112. package/dist/ticketlayer-elements/p-492adc77.entry.js +1 -0
  113. package/dist/ticketlayer-elements/p-4cfc9e53.entry.js +1 -0
  114. package/dist/ticketlayer-elements/p-5135630e.entry.js +1 -0
  115. package/dist/ticketlayer-elements/p-5bbce3b5.entry.js +1 -0
  116. package/dist/ticketlayer-elements/p-7d547721.entry.js +1 -0
  117. package/dist/ticketlayer-elements/p-7fe7b6ba.entry.js +1 -0
  118. package/dist/ticketlayer-elements/p-8122f0c1.entry.js +1 -0
  119. package/dist/ticketlayer-elements/p-98d40869.entry.js +1 -0
  120. package/dist/ticketlayer-elements/p-Bdbb2lk5.js +1 -0
  121. package/dist/ticketlayer-elements/p-BwChnHVC.js +1 -0
  122. package/dist/ticketlayer-elements/p-abec290a.entry.js +1 -0
  123. package/dist/ticketlayer-elements/p-ac79a3f6.entry.js +1 -0
  124. package/dist/ticketlayer-elements/p-d01f4429.entry.js +1 -0
  125. package/dist/ticketlayer-elements/p-d7ffaf46.entry.js +1 -0
  126. package/dist/ticketlayer-elements/p-e7170f3c.entry.js +1 -0
  127. package/dist/ticketlayer-elements/p-e787e862.entry.js +1 -0
  128. package/dist/ticketlayer-elements/p-f1ff931f.entry.js +1 -0
  129. package/dist/ticketlayer-elements/p-imfxp765.js +3 -0
  130. package/dist/ticketlayer-elements/ticketlayer-elements.css +1 -1
  131. package/dist/ticketlayer-elements/ticketlayer-elements.esm.js +1 -1
  132. package/dist/types/components/tl-buy-tickets-button/tl-buy-tickets-button.d.ts +40 -8
  133. package/dist/types/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.d.ts +20 -1
  134. package/dist/types/components/tl-cart/tl-cart.d.ts +40 -32
  135. package/dist/types/components/tl-cart-badge/tl-cart-badge.d.ts +22 -7
  136. package/dist/types/components/tl-cart-drawer/tl-cart-drawer.d.ts +28 -5
  137. package/dist/types/components/tl-checkout-wrapper/tl-checkout-wrapper.d.ts +18 -1
  138. package/dist/types/components/tl-event-card/event-card-adapter.d.ts +9 -20
  139. package/dist/types/components/tl-event-card/tl-event-card.d.ts +25 -28
  140. package/dist/types/components/tl-event-list/tl-event-list.d.ts +46 -6
  141. package/dist/types/components/tl-login/tl-login.d.ts +68 -22
  142. package/dist/types/components/tl-my-orders/tl-my-orders.d.ts +30 -12
  143. package/dist/types/components/tl-occurrence-selector/tl-occurrence-selector.d.ts +73 -161
  144. package/dist/types/components/tl-order-confirmation/tl-order-confirmation.d.ts +48 -15
  145. package/dist/types/components/tl-order-tickets/tl-order-tickets.d.ts +29 -31
  146. package/dist/types/components/tl-promo-code/tl-promo-code.d.ts +28 -10
  147. package/dist/types/components/tl-ticket/tl-ticket.d.ts +2 -11
  148. package/dist/types/components/tl-ticket-selector/tl-ticket-selector.d.ts +61 -32
  149. package/dist/types/components.d.ts +302 -62
  150. package/dist/types/utils/cart-totals.d.ts +10 -0
  151. package/dist/types/utils/order-summary.d.ts +16 -65
  152. package/dist/types/utils/testing/deep-text.d.ts +13 -0
  153. package/dist/types/utils/testing/fixtures.d.ts +225 -0
  154. package/dist/types/utils/testing/mock-sdk.d.ts +14 -1
  155. package/dist/types/utils/web-query.d.ts +18 -0
  156. package/dist/types/utils/web-storage.d.ts +16 -0
  157. package/elements.catalogue.json +676 -55
  158. package/package.json +14 -6
  159. package/dist/cjs/order-summary-ZMkJ5bez.js +0 -116
  160. package/dist/components/order-summary.js +0 -1
  161. package/dist/esm/order-summary-BGekdjN9.js +0 -103
  162. package/dist/ticketlayer-elements/p-0b1d16f8.entry.js +0 -1
  163. package/dist/ticketlayer-elements/p-1471f6d8.entry.js +0 -1
  164. package/dist/ticketlayer-elements/p-1c51cbc1.entry.js +0 -1
  165. package/dist/ticketlayer-elements/p-5169f68b.entry.js +0 -1
  166. package/dist/ticketlayer-elements/p-895ba1f3.entry.js +0 -1
  167. package/dist/ticketlayer-elements/p-8d5722e1.entry.js +0 -1
  168. package/dist/ticketlayer-elements/p-917d8e09.entry.js +0 -1
  169. package/dist/ticketlayer-elements/p-9629029a.entry.js +0 -1
  170. package/dist/ticketlayer-elements/p-BGekdjN9.js +0 -1
  171. package/dist/ticketlayer-elements/p-CNX8hZa8.js +0 -3
  172. package/dist/ticketlayer-elements/p-a22714d0.entry.js +0 -1
  173. package/dist/ticketlayer-elements/p-bf73044b.entry.js +0 -1
  174. package/dist/ticketlayer-elements/p-e02079fa.entry.js +0 -1
  175. package/dist/ticketlayer-elements/p-e04ace15.entry.js +0 -1
  176. package/dist/ticketlayer-elements/p-e6fab1d5.entry.js +0 -1
  177. package/dist/ticketlayer-elements/p-f826b753.entry.js +0 -1
  178. package/dist/ticketlayer-elements/p-fa639d88.entry.js +0 -1
  179. package/dist/ticketlayer-elements/p-fbaca948.entry.js +0 -1
@@ -1,7 +1,8 @@
1
- import { r as registerInstance, c as createEvent, h, H as Host } from './index-CNX8hZa8.js';
2
- import { o as onSDKEvent } from './sdk-connector-CqhvfyKV.js';
1
+ import { r as registerInstance, c as createEvent, h, H as Host } from './index-imfxp765.js';
2
+ import { w as whenSDK, g as getSDK } from './sdk-connector-CqhvfyKV.js';
3
+ import { c as createElement, a as cartDrawerCore } from './ticket-selector-BwChnHVC.js';
3
4
 
4
- const tlCartDrawerCss = () => `: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}`;
5
+ const tlCartDrawerCss = () => `: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}`;
5
6
 
6
7
  const TlCartDrawer = class {
7
8
  constructor(hostRef) {
@@ -14,47 +15,74 @@ const TlCartDrawer = class {
14
15
  this.heading = 'Your cart';
15
16
  /** Controlled open state (also driven by the `ui:cart-requested` intent). */
16
17
  this.open = false;
17
- this.visible = false;
18
+ this.element = createElement(cartDrawerCore, {
19
+ client: () => getSDK(),
20
+ clientReady: () => whenSDK(),
21
+ emit: (event, detail) => this.forward(event, detail),
22
+ });
23
+ /** The core's whole view. Assigning it is what makes Stencil re-render. */
24
+ this.view = this.element.view;
25
+ /** The one thing only a browser has. What Escape means is the core's answer. */
18
26
  this.onKey = (e) => {
19
- if (e.key === 'Escape' && this.visible)
20
- this.setOpen(false);
27
+ if (e.key === 'Escape')
28
+ this.element.actions.setOpen(false);
21
29
  };
22
- this.close = () => this.setOpen(false);
30
+ this.close = () => this.element.actions.setOpen(false);
31
+ }
32
+ syncProps() {
33
+ this.element.setProps({ side: this.side, heading: this.heading, open: this.open });
34
+ }
35
+ /**
36
+ * The host moved `open`. The core follows it without announcing it, which is
37
+ * what the component's watcher did: an event here would be the host hearing
38
+ * its own write back.
39
+ */
40
+ onOpenProp(v) {
41
+ this.element.setProps({ open: v });
42
+ this.element.actions.openChanged(v);
23
43
  }
24
44
  connectedCallback() {
25
- this.visible = this.open;
26
- // Open on the cart intent; close on the shared modal-close intent.
27
- this.offCart = onSDKEvent('ui:cart-requested', () => this.setOpen(true));
28
- this.offClose = onSDKEvent('ui:modal-close-requested', () => this.setOpen(false));
45
+ this.syncProps();
46
+ this.unsubscribe ?? (this.unsubscribe = this.element.subscribe((view) => {
47
+ this.view = view;
48
+ // Reflect the core's state back onto the prop a host reads. Writing it
49
+ // re-enters onOpenProp, which is a no-op once the core already agrees.
50
+ if (this.open !== view.state.visible)
51
+ this.open = view.state.visible;
52
+ }));
53
+ this.view = this.element.view;
54
+ this.teardown = this.element.mount();
29
55
  if (typeof document !== 'undefined')
30
56
  document.addEventListener('keydown', this.onKey);
31
57
  }
32
58
  disconnectedCallback() {
33
- this.offCart?.();
34
- this.offClose?.();
59
+ this.teardown?.();
60
+ this.teardown = undefined;
61
+ this.unsubscribe?.();
62
+ this.unsubscribe = undefined;
35
63
  if (typeof document !== 'undefined')
36
64
  document.removeEventListener('keydown', this.onKey);
37
65
  }
38
- onOpenProp(v) {
39
- this.visible = v;
40
- }
41
- setOpen(v) {
42
- if (this.visible === v)
43
- return;
44
- this.open = v;
45
- this.visible = v;
46
- if (v)
66
+ forward(event, _detail) {
67
+ if (event === 'tlOpen')
47
68
  this.tlOpen.emit();
48
- else
69
+ else if (event === 'tlClose')
49
70
  this.tlClose.emit();
50
71
  }
51
72
  render() {
52
- return (h(Host, { key: '022314d9fb612e930da52ece34f2ab8ae8ce44da' }, h("div", { key: '985b4001145d72ba91ef7d466adba8ab939e9cc4', class: { overlay: true, 'is-open': this.visible }, onClick: (e) => {
73
+ const { strings, derived } = this.view;
74
+ return (h(Host, { key: 'ab41f3557cd8dd2b182bbfc3ed631bca7839d4a9' }, h("div", { key: '70bbe63d1f9a2d449cb9ff970631c0c69a2eb757', class: { overlay: true, 'is-open': derived.visible }, onClick: (e) => {
53
75
  if (e.target === e.currentTarget)
54
76
  this.close();
55
- } }, h("aside", { key: '3ac3588ae8feacd4f8bb96bdae8ef71e80ecb4b3', class: { panel: true, [`panel--${this.side}`]: true, 'is-open': this.visible }, role: "dialog", "aria-modal": "true", "aria-label": this.heading, "aria-hidden": this.visible ? 'false' : 'true' }, h("header", { key: 'e0126d634e952ebf56b73e54545f6c3981210827', class: "drawer-header" }, h("h2", { key: 'a72b23114aa836076ec59cd4a5d1438d228179d9', class: "drawer-title" }, this.heading), h("button", { key: '92fb5b159490440352a6c23d65aa6e8c956ae3d8', class: "close-btn", onClick: this.close, "aria-label": "Close cart" }, h("svg", { key: '138f4dc7669e62fb667091da0ba26dfbe94327c6', viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("path", { key: '21fedd9dc89937a92f9c1124d4fa834b55908f1e', d: "M6 6l12 12M18 6L6 18", "stroke-linecap": "round" })))), h("div", { key: 'ebee87cb6a3c98dbf813d0a903a9cb4da2c696f3', class: "drawer-body" }, h("tl-cart", { key: '323db3a160837b68ffaa767e647ec67b06fa53b0' })), h("footer", { key: 'd35543373eb13ad1acc46ae50aefcb5a04f305a1', class: "drawer-footer" }, h("div", { key: '52229c74d39471bf186c965b6a53b38f79ce8d61', class: "pb-links" }, h("a", { key: 'd0430bf93d920c57fc42043faed7e8fd895855aa', href: "https://ticketlayer.com/privacy", target: "_blank", rel: "noopener noreferrer" }, "Privacy Policy"), h("a", { key: '2a75dc8dcdc9ec3010fe83f97d903cdc32767e49', href: "https://ticketlayer.com/report-abuse", target: "_blank", rel: "noopener noreferrer" }, "Report Abuse")), h("a", { key: '40642c5c4c003a454dd7ab2b66ebe5948a03df7d', class: "pb-brand", href: "https://ticketlayer.com", target: "_blank", rel: "noopener noreferrer" }, h("span", { key: 'a5d9b5c023381d25b6aaddf61e56dbdb21580975', class: "pb-pre" }, "Powered by"), h("svg", { key: '35bc23af9a35272d7ada24fd66d5f12f1d951ae8', width: "13", height: "13", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true" }, h("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" }), h("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" })), h("span", { key: '429154bd6c38febe4da8871a7e614bf272a18854', class: "pb-word" }, "Ticketlayer")))))));
77
+ } }, h("aside", { key: 'eefe601ef6d2d8fc6bcfe62f1777d139875f875d', class: { panel: true, [derived.sideClass]: true, 'is-open': derived.visible }, role: "dialog", "aria-modal": "true", "aria-label": this.heading, "aria-hidden": derived.ariaHidden }, h("header", { key: '753d616182c3a903111dcaaf9b37f03186e17b48', class: "drawer-header" }, h("h2", { key: '3e839ddbc2a2da1f4c8eb0c1e38c421de13426cd', class: "drawer-title" }, this.heading), h("button", { key: '0d80fff5f425d6150fb391fd930161167b5f7d27', class: "close-btn", onClick: this.close, "aria-label": strings.close }, h("svg", { key: '7ffcbfb86f921d13deb5070140f21e4c7ca668f1', viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("path", { key: '53d690ef2ac8d1d73038c53fa3aa0146bde0fb51', d: "M6 6l12 12M18 6L6 18", "stroke-linecap": "round" })))), h("div", { key: 'a782b1527cde89656e5f776311f848c446d92d48', class: "drawer-body" }, h("tl-cart", { key: '3cd2c09f728cf14f0ea5b6ff4493b3e51e0dda62' })), h("footer", { key: '2df57237bbd548ae4af09098676d7e1315e11d71', class: "drawer-footer" }, h("div", { key: 'f02f5970181a2d83b70ac44188f00523a188771d', class: "pb-links" }, h("a", { key: 'd799da3a8c1c33b10a268500b02fda5523cd8bcf', href: strings.privacyHref, target: "_blank", rel: "noopener noreferrer" }, strings.privacy), h("a", { key: 'e928acb4c78cef8762d7ae8d258fa705554fd121', href: strings.reportAbuseHref, target: "_blank", rel: "noopener noreferrer" }, strings.reportAbuse)), h("a", { key: '39278516b8da6dd14fe8bf0d0379c32ccfeb1d29', class: "pb-brand", href: strings.brandHref, target: "_blank", rel: "noopener noreferrer" }, h("span", { key: '96b2cb7ac0a73cd0c60fb7977999a00b4989177e', class: "pb-pre" }, strings.poweredBy), h("svg", { key: 'b3950f83eab4a41e63a7919e6872a9ecdafab38b', width: "13", height: "13", viewBox: "0 0 50 50", fill: "none", "aria-hidden": "true" }, h("g", { key: '4c0c7ec66952f8a1956b3061f6bf2eb45c438989', transform: "matrix(0.0129 0 0 -0.0129 25.4752 25.4752)" }, h("path", { key: 'b1c9a143f0b2ad24da843323a4c1c550e9717d1b', 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" }))), h("span", { key: '053ca451a9674161799458e731862a93c954be23', class: "pb-word" }, strings.brand)))))));
56
78
  }
57
79
  static get watchers() { return {
80
+ "side": [{
81
+ "syncProps": 0
82
+ }],
83
+ "heading": [{
84
+ "syncProps": 0
85
+ }],
58
86
  "open": [{
59
87
  "onOpenProp": 0
60
88
  }]
@@ -1,7 +1,8 @@
1
- import { r as registerInstance, c as createEvent, h } from './index-CNX8hZa8.js';
2
- import { w as whenSDK, h as hasSDK, g as getSDK } from './sdk-connector-CqhvfyKV.js';
1
+ import { r as registerInstance, c as createEvent, h } from './index-imfxp765.js';
2
+ import { w as whenSDK, g as getSDK } from './sdk-connector-CqhvfyKV.js';
3
+ import { c as createElement, d as cartCore } from './ticket-selector-BwChnHVC.js';
3
4
 
4
- const tlCartCss = () => `: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}`;
5
+ const tlCartCss = () => `: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}`;
5
6
 
6
7
  const TlCart = class {
7
8
  constructor(hostRef) {
@@ -26,120 +27,93 @@ const TlCart = class {
26
27
  * Compact mode - hides some details
27
28
  */
28
29
  this.compact = false;
29
- this.cart = null;
30
- this.loading = true;
31
- this.error = null;
32
- this.removingItemId = null;
33
- this.handleCheckout = () => {
34
- if (this.cart && this.cart.items.length > 0) {
35
- this.tlCheckout.emit({ cart: this.cart });
36
- }
37
- };
38
- }
39
- componentWillLoad() {
40
- this.loadCart();
41
- }
42
- componentDidLoad() {
43
- this.subscribeToCartUpdates();
44
- }
45
- disconnectedCallback() {
46
- if (this.unsubscribe) {
47
- this.unsubscribe();
48
- }
49
- }
50
- async loadCart() {
51
- try {
52
- console.log('[tl-cart] Loading cart...');
53
- this.loading = true;
54
- this.error = null;
55
- const sdk = await whenSDK();
56
- const cartManager = sdk.getCartManager?.();
57
- if (cartManager) {
58
- const cartData = await cartManager.get();
59
- console.log('[tl-cart] Cart loaded:', cartData);
60
- this.cart = cartData;
61
- }
62
- }
63
- catch (err) {
64
- console.error('[tl-cart] Failed to load cart:', err);
65
- this.error = err instanceof Error ? err.message : 'Failed to load cart';
66
- this.tlError.emit({ message: this.error });
67
- }
68
- finally {
69
- this.loading = false;
70
- }
30
+ this.element = createElement(cartCore, {
31
+ client: () => getSDK(),
32
+ // What "the client is up" means on the web. The core waits on it in its
33
+ // own mount, subscribes there and loads there; the harness decides none
34
+ // of it (TKT-197).
35
+ clientReady: () => whenSDK(),
36
+ emit: (event, detail) => this.forward(event, detail),
37
+ });
38
+ /** The core's whole view. Assigning it is what makes Stencil re-render. */
39
+ this.view = this.element.view;
71
40
  }
72
- async subscribeToCartUpdates() {
73
- const sdk = await whenSDK().catch(() => null);
74
- if (!sdk)
75
- return;
76
- const cartManager = sdk.getCartManager?.();
77
- if (!cartManager)
78
- return;
79
- this.unsubscribe = cartManager.on?.('cart:updated', (cartData) => {
80
- console.log('[tl-cart] Cart updated:', cartData);
81
- this.cart = cartData;
82
- this.tlCartUpdated.emit({ cart: cartData });
41
+ syncProps() {
42
+ this.element.setProps({
43
+ showCheckoutButton: this.showCheckoutButton,
44
+ checkoutLabel: this.checkoutLabel,
45
+ showRemoveButtons: this.showRemoveButtons,
46
+ compact: this.compact,
83
47
  });
84
48
  }
85
- async handleRemoveItem(itemId) {
86
- if (!hasSDK())
87
- return;
88
- this.removingItemId = itemId;
89
- try {
90
- const sdk = getSDK();
91
- const cartManager = sdk.getCartManager?.();
92
- if (cartManager) {
93
- await cartManager.removeItem(itemId);
94
- console.log('[tl-cart] Item removed:', itemId);
95
- this.tlItemRemoved.emit({ itemId });
96
- }
97
- }
98
- catch (err) {
99
- console.error('[tl-cart] Failed to remove item:', err);
100
- this.error = err instanceof Error ? err.message : 'Failed to remove item';
101
- this.tlError.emit({ message: this.error });
102
- }
103
- finally {
104
- this.removingItemId = null;
105
- }
49
+ /**
50
+ * On screen: render what the core says and put the core to work. For this
51
+ * element that means waiting for the client, subscribing to `cart:updated`
52
+ * and reading the cart - all of it the core's business.
53
+ */
54
+ connectedCallback() {
55
+ this.syncProps();
56
+ this.unsubscribe ?? (this.unsubscribe = this.element.subscribe((view) => {
57
+ this.view = view;
58
+ }));
59
+ this.view = this.element.view;
60
+ this.teardown = this.element.mount();
106
61
  }
107
- formatPrice(priceInPence, currency = 'GBP') {
108
- return new Intl.NumberFormat('en-GB', {
109
- style: 'currency',
110
- currency,
111
- }).format(priceInPence / 100);
62
+ /**
63
+ * Off screen: run the mount's teardown, which is what drops the cart
64
+ * subscription. Not `destroy()`: Stencil calls this for a DOM move as well
65
+ * as a removal, and a destroyed core never mounts again.
66
+ */
67
+ disconnectedCallback() {
68
+ this.teardown?.();
69
+ this.teardown = undefined;
70
+ this.unsubscribe?.();
71
+ this.unsubscribe = undefined;
112
72
  }
113
- formatDate(dateString) {
114
- const date = new Date(dateString);
115
- return date.toLocaleDateString('en-GB', {
116
- weekday: 'short',
117
- day: 'numeric',
118
- month: 'short',
119
- hour: '2-digit',
120
- minute: '2-digit',
121
- });
73
+ forward(event, detail) {
74
+ if (event === 'tlCheckout')
75
+ this.tlCheckout.emit(detail);
76
+ else if (event === 'tlItemRemoved')
77
+ this.tlItemRemoved.emit(detail);
78
+ else if (event === 'tlCartUpdated')
79
+ this.tlCartUpdated.emit(detail);
80
+ else if (event === 'tlError')
81
+ this.tlError.emit(detail);
122
82
  }
123
83
  renderSkeleton() {
124
84
  return (h("div", { class: "skeleton-container" }, h("div", { class: "skeleton-item" }), h("div", { class: "skeleton-item" }), h("div", { class: "skeleton-totals" })));
125
85
  }
126
86
  renderEmptyCart() {
127
- return (h("div", { class: "empty-cart" }, h("svg", { class: "empty-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("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" })), h("p", { class: "empty-title" }, "Your cart is empty"), h("p", { class: "empty-message" }, "Add tickets to get started")));
87
+ const strings = this.view.strings;
88
+ return (h("div", { class: "empty-cart" }, h("svg", { class: "empty-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("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" })), h("p", { class: "empty-title" }, strings.emptyTitle), h("p", { class: "empty-message" }, strings.emptyMessage)));
128
89
  }
129
- renderCartItem(item) {
130
- const isRemoving = this.removingItemId === item.id;
131
- return (h("div", { class: `cart-item ${isRemoving ? 'removing' : ''}`, key: item.id }, h("div", { class: "item-info" }, h("p", { class: "item-name" }, item.ticketTypeName), !this.compact && (h("p", { class: "item-event" }, item.eventName)), !this.compact && item.occurrenceDate && (h("p", { class: "item-date" }, this.formatDate(item.occurrenceDate))), h("p", { class: "item-quantity" }, "Qty: ", item.quantity)), h("div", { class: "item-actions" }, h("p", { class: "item-price" }, this.formatPrice(item.totalPrice, item.currency)), this.showRemoveButtons && (h("button", { class: "remove-btn", onClick: () => this.handleRemoveItem(item.id), disabled: isRemoving, "aria-label": "Remove item" }, isRemoving ? (h("span", { class: "spinner" })) : (h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M6 18L18 6M6 6l12 12" }))))))));
90
+ renderCartItem(row) {
91
+ return (h("div", { class: `cart-item ${row.removing ? 'removing' : ''}`, key: row.id }, h("div", { class: "item-info" }, h("p", { class: "item-name" }, row.name), row.showEvent && h("p", { class: "item-event" }, row.eventName), row.showDate && h("p", { class: "item-date" }, row.dateLabel), h("p", { class: "item-quantity" }, row.quantityLabel)), h("div", { class: "item-actions" }, h("p", { class: "item-price" }, row.priceLabel), this.showRemoveButtons && (h("button", { class: "remove-btn", onClick: () => this.element.actions.removeItem(row.id), disabled: row.removing, "aria-label": this.view.strings.removeItem }, row.removing ? (h("span", { class: "spinner" })) : (h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M6 18L18 6M6 6l12 12" }))))))));
132
92
  }
133
93
  render() {
134
- if (this.loading) {
94
+ const { status, strings, derived } = this.view;
95
+ if (status === 'loading') {
135
96
  return this.renderSkeleton();
136
97
  }
137
- if (!this.cart || this.cart.items.length === 0) {
98
+ if (status === 'empty') {
138
99
  return this.renderEmptyCart();
139
100
  }
140
- const { items, subtotal, fees, total, currency } = this.cart;
141
- return (h("div", { class: `cart ${this.compact ? 'compact' : ''}` }, h("div", { class: "cart-items" }, items.map(item => this.renderCartItem(item))), h("div", { class: "cart-totals" }, !this.compact && (h("div", { class: "total-row subtotal" }, h("span", null, "Subtotal"), h("span", null, this.formatPrice(subtotal, currency)))), fees > 0 && !this.compact && (h("div", { class: "total-row fees" }, h("span", null, "Fees"), h("span", null, this.formatPrice(fees, currency)))), h("div", { class: "total-row total" }, h("span", null, "Total"), h("span", null, this.formatPrice(total, currency)))), this.showCheckoutButton && (h("button", { class: "checkout-btn", onClick: this.handleCheckout, disabled: items.length === 0 }, this.checkoutLabel))));
101
+ return (h("div", { class: `cart ${this.compact ? 'compact' : ''}` }, h("div", { class: "cart-items" }, derived.rows.map((row) => this.renderCartItem(row))), h("div", { class: "cart-totals" }, derived.showSubtotalRow && (h("div", { class: "total-row subtotal" }, h("span", null, strings.subtotalRow), h("span", null, derived.subtotalLabel))), derived.showFeeRow && (h("div", { class: "total-row fees" }, h("span", null, derived.totals.feeLabel), h("span", null, derived.feeAmountLabel))), derived.showDiscountRow && (h("div", { class: "total-row discount" }, h("span", null, strings.discountRow), h("span", null, "-", derived.discountLabel))), h("div", { class: "total-row total" }, h("span", null, strings.totalRow), h("span", null, derived.totalLabel))), this.showCheckoutButton && (h("button", { class: "checkout-btn", onClick: () => this.element.actions.checkout(), disabled: derived.checkoutDisabled }, this.checkoutLabel))));
142
102
  }
103
+ static get watchers() { return {
104
+ "showCheckoutButton": [{
105
+ "syncProps": 0
106
+ }],
107
+ "checkoutLabel": [{
108
+ "syncProps": 0
109
+ }],
110
+ "showRemoveButtons": [{
111
+ "syncProps": 0
112
+ }],
113
+ "compact": [{
114
+ "syncProps": 0
115
+ }]
116
+ }; }
143
117
  };
144
118
  TlCart.style = tlCartCss();
145
119
 
@@ -1,54 +1,76 @@
1
- import { r as registerInstance, c as createEvent, h, H as Host, a as getElement } from './index-CNX8hZa8.js';
2
- import { h as hasSDK, g as getSDK } from './sdk-connector-CqhvfyKV.js';
1
+ import { r as registerInstance, c as createEvent, h, H as Host } from './index-imfxp765.js';
2
+ import { w as whenSDK, g as getSDK } from './sdk-connector-CqhvfyKV.js';
3
+ import { c as createElement, k as checkoutWrapperCore } from './ticket-selector-BwChnHVC.js';
3
4
 
4
- const tlCheckoutWrapperCss = () => `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}`;
5
+ const tlCheckoutWrapperCss = () => `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}`;
5
6
 
6
7
  const TlCheckoutWrapper = class {
7
8
  constructor(hostRef) {
8
9
  registerInstance(this, hostRef);
9
- this.tlComplete = createEvent(this, "tl-complete");
10
- this.tlError = createEvent(this, "tl-error");
11
- this.tlClose = createEvent(this, "tl-close");
10
+ this.tlComplete = createEvent(this, "tlComplete");
11
+ this.tlError = createEvent(this, "tlError");
12
+ this.tlClose = createEvent(this, "tlClose");
12
13
  /**
13
14
  * Whether the wrapper is disabled
14
15
  */
15
16
  this.disabled = false;
17
+ this.element = createElement(checkoutWrapperCore, {
18
+ client: () => getSDK(),
19
+ clientReady: () => whenSDK(),
20
+ emit: (event, detail) => this.forward(event, detail),
21
+ });
22
+ /** The core's whole view. Assigning it is what makes Stencil re-render. */
23
+ this.view = this.element.view;
16
24
  this.handleClick = () => {
17
- if (this.disabled)
18
- return;
19
- if (!hasSDK()) {
20
- console.error('[tl-checkout-wrapper] SDK not initialized. Call setSDK(ticketlayer) first.');
21
- this.tlError.emit({ message: 'SDK not initialized' });
22
- return;
23
- }
24
- const sdk = getSDK();
25
- // Open the checkout modal via SDK
26
- sdk.checkout.openModal({
27
- onComplete: (order) => {
28
- this.tlComplete.emit(order);
29
- },
30
- onError: (err) => {
31
- this.tlError.emit({ message: err.message });
32
- },
33
- onClose: () => {
34
- this.tlClose.emit();
35
- },
36
- });
25
+ this.element.actions.activate();
37
26
  };
27
+ /** Enter and Space are a press on the web. The core knows nothing of keys. */
38
28
  this.handleKeyDown = (e) => {
39
29
  if (e.key === 'Enter' || e.key === ' ') {
40
30
  e.preventDefault();
41
- this.handleClick();
31
+ this.element.actions.activate();
42
32
  }
43
33
  };
44
34
  }
35
+ syncProps() {
36
+ this.element.setProps({ disabled: this.disabled });
37
+ }
38
+ connectedCallback() {
39
+ this.syncProps();
40
+ this.unsubscribe ?? (this.unsubscribe = this.element.subscribe((view) => {
41
+ this.view = view;
42
+ }));
43
+ this.view = this.element.view;
44
+ // Nothing to do on mount, and mounted anyway: a harness calls mount()
45
+ // unconditionally and pairs it with its teardown (TKT-197).
46
+ this.teardown = this.element.mount();
47
+ }
48
+ disconnectedCallback() {
49
+ this.teardown?.();
50
+ this.teardown = undefined;
51
+ this.unsubscribe?.();
52
+ this.unsubscribe = undefined;
53
+ }
54
+ forward(event, detail) {
55
+ if (event === 'tlComplete')
56
+ this.tlComplete.emit(detail);
57
+ else if (event === 'tlError')
58
+ this.tlError.emit(detail);
59
+ else if (event === 'tlClose')
60
+ this.tlClose.emit();
61
+ }
45
62
  render() {
46
- return (h(Host, { key: 'ebaae5dd6710ffc5353ece4327012df0332fdbb7', class: {
63
+ const { interactive } = this.view.derived;
64
+ return (h(Host, { key: 'b261046c2627825258a5905662a79f436d713683', class: {
47
65
  'tl-checkout-wrapper': true,
48
- 'tl-checkout-wrapper--disabled': this.disabled,
49
- }, onClick: this.handleClick, onKeyDown: this.handleKeyDown, role: "button", tabindex: this.disabled ? -1 : 0, "aria-disabled": this.disabled ? 'true' : null }, h("slot", { key: '0118d9921df5af1ae2376fd4135bac487aac7ebd' })));
66
+ 'tl-checkout-wrapper--disabled': !interactive,
67
+ }, onClick: this.handleClick, onKeyDown: this.handleKeyDown, role: "button", tabindex: interactive ? 0 : -1, "aria-disabled": interactive ? null : 'true' }, h("slot", { key: '5be08d5007a755e3d88a06ae89c08e082e4ba052' })));
50
68
  }
51
- get el() { return getElement(this); }
69
+ static get watchers() { return {
70
+ "disabled": [{
71
+ "syncProps": 0
72
+ }]
73
+ }; }
52
74
  };
53
75
  TlCheckoutWrapper.style = tlCheckoutWrapperCss();
54
76