stripe-pwa-elements 3.2.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -3
  2. package/dist/cjs/error-FFC4kSs5.js +0 -3
  3. package/dist/cjs/{factory-CbbbSvkg.js → factory-Cd2VI_N2.js} +216 -77
  4. package/dist/cjs/{index-Ba1pBePA.js → index-CYbA1N_k.js} +24 -6
  5. package/dist/cjs/index-Dkb0SxZc.js +4694 -0
  6. package/dist/cjs/index.cjs.js +0 -1
  7. package/dist/cjs/ion-icon.cjs.entry.js +22 -13
  8. package/dist/cjs/loader.cjs.js +2 -3
  9. package/dist/cjs/stripe-address-element.cjs.entry.js +41 -26
  10. package/dist/cjs/stripe-card-element-modal.cjs.entry.js +6 -7
  11. package/dist/cjs/stripe-card-element_2.cjs.entry.js +129 -72
  12. package/dist/cjs/stripe-currency-selector.cjs.entry.js +20 -10
  13. package/dist/cjs/stripe-elements.cjs.js +31 -5
  14. package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +32 -22
  15. package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +20 -10
  16. package/dist/cjs/stripe-payment-element.cjs.entry.js +283 -167
  17. package/dist/cjs/stripe-payment-request-button.cjs.entry.js +30 -18
  18. package/dist/collection/collection-manifest.json +6 -5
  19. package/dist/collection/components/stripe-address-element/stripe-address-element.js +36 -21
  20. package/dist/collection/components/stripe-card-element/stripe-card-element.helpers.js +57 -0
  21. package/dist/collection/components/stripe-card-element/stripe-card-element.js +62 -68
  22. package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +15 -11
  23. package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js +17 -6
  24. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +35 -20
  25. package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js +19 -7
  26. package/dist/collection/components/stripe-modal/stripe-modal.js +18 -7
  27. package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +114 -0
  28. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +162 -162
  29. package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +48 -19
  30. package/dist/collection/index.js +0 -1
  31. package/dist/collection/interfaces.js +0 -1
  32. package/dist/collection/services/address-element-manager.js +3 -4
  33. package/dist/collection/services/card-element-manager.js +3 -4
  34. package/dist/collection/services/currency-selector-element-manager.js +3 -4
  35. package/dist/collection/services/express-checkout-element-manager.js +9 -10
  36. package/dist/collection/services/factory.js +0 -1
  37. package/dist/collection/services/interfaces.js +0 -1
  38. package/dist/collection/services/link-authentication-element-manager.js +3 -4
  39. package/dist/collection/services/payment-element-manager.js +4 -5
  40. package/dist/collection/services/stripe-service.js +27 -10
  41. package/dist/collection/utils/element-finder.js +2 -3
  42. package/dist/collection/utils/error.js +0 -1
  43. package/dist/collection/utils/i18n.js +0 -1
  44. package/dist/collection/utils/platform.js +0 -1
  45. package/dist/collection/utils/test-setup.js +0 -1
  46. package/dist/collection/utils/utils.js +2 -3
  47. package/dist/components/error.js +1 -16
  48. package/dist/components/factory.js +1 -3736
  49. package/dist/components/icon.js +1 -459
  50. package/dist/components/index.d.ts +2 -0
  51. package/dist/components/index.js +1 -4
  52. package/dist/components/index2.js +1 -192
  53. package/dist/components/ion-icon.js +1 -9
  54. package/dist/components/stripe-address-element.js +1 -327
  55. package/dist/components/stripe-card-element-modal.js +1 -174
  56. package/dist/components/stripe-card-element.js +1 -9
  57. package/dist/components/stripe-card-element2.js +1 -440
  58. package/dist/components/stripe-currency-selector.js +1 -218
  59. package/dist/components/stripe-express-checkout-element.js +1 -332
  60. package/dist/components/stripe-link-authentication-element.js +1 -256
  61. package/dist/components/stripe-modal.js +1 -9
  62. package/dist/components/stripe-modal2.js +1 -112
  63. package/dist/components/stripe-payment-element.js +1 -510
  64. package/dist/components/stripe-payment-request-button.js +1 -9
  65. package/dist/components/stripe-payment-request-button2.js +1 -224
  66. package/dist/components/utils.js +1 -89
  67. package/dist/esm/app-globals-DQuL1Twl.js +0 -3
  68. package/dist/esm/error-XRfh5Wrs.js +0 -3
  69. package/dist/esm/{factory-Drde6-y7.js → factory-VTa1Gc94.js} +216 -77
  70. package/dist/esm/index-C6bbmyga.js +4677 -0
  71. package/dist/esm/{index-BHDCxQOb.js → index-CBXaOfXU.js} +24 -6
  72. package/dist/esm/index.js +0 -1
  73. package/dist/esm/ion-icon.entry.js +22 -13
  74. package/dist/esm/loader.js +3 -4
  75. package/dist/esm/stripe-address-element.entry.js +41 -26
  76. package/dist/esm/stripe-card-element-modal.entry.js +6 -7
  77. package/dist/esm/stripe-card-element_2.entry.js +129 -72
  78. package/dist/esm/stripe-currency-selector.entry.js +20 -10
  79. package/dist/esm/stripe-elements.js +32 -6
  80. package/dist/esm/stripe-express-checkout-element.entry.js +32 -22
  81. package/dist/esm/stripe-link-authentication-element.entry.js +20 -10
  82. package/dist/esm/stripe-payment-element.entry.js +283 -167
  83. package/dist/esm/stripe-payment-request-button.entry.js +27 -15
  84. package/dist/stripe-elements/index.esm.js +0 -2
  85. package/dist/stripe-elements/p-1bd46766.entry.js +1 -0
  86. package/dist/stripe-elements/p-1c6e0a45.entry.js +1 -0
  87. package/dist/stripe-elements/p-3f42ca0c.entry.js +1 -0
  88. package/dist/stripe-elements/p-5cf62945.entry.js +1 -0
  89. package/dist/stripe-elements/p-74de1556.entry.js +1 -0
  90. package/dist/stripe-elements/p-76e57d78.entry.js +1 -0
  91. package/dist/stripe-elements/p-840d499f.entry.js +1 -0
  92. package/dist/stripe-elements/p-C6bbmyga.js +2 -0
  93. package/dist/stripe-elements/p-CBXaOfXU.js +1 -0
  94. package/dist/stripe-elements/p-CrjrbGJ3.js +1 -0
  95. package/dist/stripe-elements/p-DQuL1Twl.js +1 -2
  96. package/dist/stripe-elements/p-XRfh5Wrs.js +1 -2
  97. package/dist/stripe-elements/p-ae0c336e.entry.js +1 -0
  98. package/dist/stripe-elements/p-cfd8e081.entry.js +1 -0
  99. package/dist/stripe-elements/stripe-elements.esm.js +1 -2
  100. package/dist/stripe-elements/svg/.gitignore +4 -0
  101. package/dist/types/components/stripe-address-element/stripe-address-element.d.ts +6 -0
  102. package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +11 -1
  103. package/dist/types/components/stripe-card-element/stripe-card-element.helpers.d.ts +29 -0
  104. package/dist/types/components/stripe-card-element-modal/stripe-card-element-modal.d.ts +4 -4
  105. package/dist/types/components/stripe-currency-selector/stripe-currency-selector.d.ts +6 -0
  106. package/dist/types/components/stripe-express-checkout-element/stripe-express-checkout-element.d.ts +6 -0
  107. package/dist/types/components/stripe-link-authentication-element/stripe-link-authentication-element.d.ts +6 -0
  108. package/dist/types/components/stripe-modal/stripe-modal.d.ts +1 -0
  109. package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +20 -2
  110. package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +54 -0
  111. package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +14 -1
  112. package/dist/types/components.d.ts +139 -29
  113. package/dist/types/index.d.ts +1 -0
  114. package/dist/types/services/interfaces.d.ts +4 -3
  115. package/dist/types/services/stripe-service.d.ts +8 -4
  116. package/dist/types/stencil-public-runtime.d.ts +110 -5
  117. package/package.json +50 -30
  118. package/readme.md +386 -133
  119. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
  120. package/dist/cjs/error-FFC4kSs5.js.map +0 -1
  121. package/dist/cjs/factory-CbbbSvkg.js.map +0 -1
  122. package/dist/cjs/index-BXVW_rzh.js +0 -1932
  123. package/dist/cjs/index-BXVW_rzh.js.map +0 -1
  124. package/dist/cjs/index-Ba1pBePA.js.map +0 -1
  125. package/dist/cjs/index.cjs.js.map +0 -1
  126. package/dist/cjs/ion-icon.entry.cjs.js.map +0 -1
  127. package/dist/cjs/loader.cjs.js.map +0 -1
  128. package/dist/cjs/stripe-address-element.entry.cjs.js.map +0 -1
  129. package/dist/cjs/stripe-card-element-modal.entry.cjs.js.map +0 -1
  130. package/dist/cjs/stripe-card-element.stripe-modal.entry.cjs.js.map +0 -1
  131. package/dist/cjs/stripe-currency-selector.entry.cjs.js.map +0 -1
  132. package/dist/cjs/stripe-elements.cjs.js.map +0 -1
  133. package/dist/cjs/stripe-express-checkout-element.entry.cjs.js.map +0 -1
  134. package/dist/cjs/stripe-link-authentication-element.entry.cjs.js.map +0 -1
  135. package/dist/cjs/stripe-payment-element.entry.cjs.js.map +0 -1
  136. package/dist/cjs/stripe-payment-request-button.entry.cjs.js.map +0 -1
  137. package/dist/collection/components/stripe-address-element/stripe-address-element.js.map +0 -1
  138. package/dist/collection/components/stripe-card-element/stripe-card-element.js.map +0 -1
  139. package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js.map +0 -1
  140. package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js.map +0 -1
  141. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js.map +0 -1
  142. package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js.map +0 -1
  143. package/dist/collection/components/stripe-modal/stripe-modal.js.map +0 -1
  144. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js.map +0 -1
  145. package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js.map +0 -1
  146. package/dist/collection/index.js.map +0 -1
  147. package/dist/collection/interfaces.js.map +0 -1
  148. package/dist/collection/services/address-element-manager.js.map +0 -1
  149. package/dist/collection/services/card-element-manager.js.map +0 -1
  150. package/dist/collection/services/currency-selector-element-manager.js.map +0 -1
  151. package/dist/collection/services/express-checkout-element-manager.js.map +0 -1
  152. package/dist/collection/services/factory.js.map +0 -1
  153. package/dist/collection/services/interfaces.js.map +0 -1
  154. package/dist/collection/services/link-authentication-element-manager.js.map +0 -1
  155. package/dist/collection/services/payment-element-manager.js.map +0 -1
  156. package/dist/collection/services/stripe-service.js.map +0 -1
  157. package/dist/collection/utils/element-finder.js.map +0 -1
  158. package/dist/collection/utils/error.js.map +0 -1
  159. package/dist/collection/utils/i18n.js.map +0 -1
  160. package/dist/collection/utils/platform.js.map +0 -1
  161. package/dist/collection/utils/test-setup.js.map +0 -1
  162. package/dist/collection/utils/utils.js.map +0 -1
  163. package/dist/components/error.js.map +0 -1
  164. package/dist/components/factory.js.map +0 -1
  165. package/dist/components/icon.js.map +0 -1
  166. package/dist/components/index.js.map +0 -1
  167. package/dist/components/index2.js.map +0 -1
  168. package/dist/components/ion-icon.js.map +0 -1
  169. package/dist/components/stripe-address-element.js.map +0 -1
  170. package/dist/components/stripe-card-element-modal.js.map +0 -1
  171. package/dist/components/stripe-card-element.js.map +0 -1
  172. package/dist/components/stripe-card-element2.js.map +0 -1
  173. package/dist/components/stripe-currency-selector.js.map +0 -1
  174. package/dist/components/stripe-express-checkout-element.js.map +0 -1
  175. package/dist/components/stripe-link-authentication-element.js.map +0 -1
  176. package/dist/components/stripe-modal.js.map +0 -1
  177. package/dist/components/stripe-modal2.js.map +0 -1
  178. package/dist/components/stripe-payment-element.js.map +0 -1
  179. package/dist/components/stripe-payment-request-button.js.map +0 -1
  180. package/dist/components/stripe-payment-request-button2.js.map +0 -1
  181. package/dist/components/utils.js.map +0 -1
  182. package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
  183. package/dist/esm/error-XRfh5Wrs.js.map +0 -1
  184. package/dist/esm/factory-Drde6-y7.js.map +0 -1
  185. package/dist/esm/index-BHDCxQOb.js.map +0 -1
  186. package/dist/esm/index-DJwTOfxZ.js +0 -1920
  187. package/dist/esm/index-DJwTOfxZ.js.map +0 -1
  188. package/dist/esm/index.js.map +0 -1
  189. package/dist/esm/ion-icon.entry.js.map +0 -1
  190. package/dist/esm/loader.js.map +0 -1
  191. package/dist/esm/stripe-address-element.entry.js.map +0 -1
  192. package/dist/esm/stripe-card-element-modal.entry.js.map +0 -1
  193. package/dist/esm/stripe-card-element.stripe-modal.entry.js.map +0 -1
  194. package/dist/esm/stripe-currency-selector.entry.js.map +0 -1
  195. package/dist/esm/stripe-elements.js.map +0 -1
  196. package/dist/esm/stripe-express-checkout-element.entry.js.map +0 -1
  197. package/dist/esm/stripe-link-authentication-element.entry.js.map +0 -1
  198. package/dist/esm/stripe-payment-element.entry.js.map +0 -1
  199. package/dist/esm/stripe-payment-request-button.entry.js.map +0 -1
  200. package/dist/stripe-elements/index.esm.js.map +0 -1
  201. package/dist/stripe-elements/ion-icon.entry.esm.js.map +0 -1
  202. package/dist/stripe-elements/loader.esm.js.map +0 -1
  203. package/dist/stripe-elements/p-02f6e421.entry.js +0 -2
  204. package/dist/stripe-elements/p-02f6e421.entry.js.map +0 -1
  205. package/dist/stripe-elements/p-19888fa6.entry.js +0 -2
  206. package/dist/stripe-elements/p-19888fa6.entry.js.map +0 -1
  207. package/dist/stripe-elements/p-4d505729.entry.js +0 -2
  208. package/dist/stripe-elements/p-4d505729.entry.js.map +0 -1
  209. package/dist/stripe-elements/p-7e7ad92a.entry.js +0 -2
  210. package/dist/stripe-elements/p-7e7ad92a.entry.js.map +0 -1
  211. package/dist/stripe-elements/p-8bb4212c.entry.js +0 -2
  212. package/dist/stripe-elements/p-8bb4212c.entry.js.map +0 -1
  213. package/dist/stripe-elements/p-9aee2b6b.entry.js +0 -2
  214. package/dist/stripe-elements/p-9aee2b6b.entry.js.map +0 -1
  215. package/dist/stripe-elements/p-BHDCxQOb.js +0 -2
  216. package/dist/stripe-elements/p-BHDCxQOb.js.map +0 -1
  217. package/dist/stripe-elements/p-DI2vmGaI.js +0 -2
  218. package/dist/stripe-elements/p-DI2vmGaI.js.map +0 -1
  219. package/dist/stripe-elements/p-DJwTOfxZ.js +0 -3
  220. package/dist/stripe-elements/p-DJwTOfxZ.js.map +0 -1
  221. package/dist/stripe-elements/p-DQuL1Twl.js.map +0 -1
  222. package/dist/stripe-elements/p-XRfh5Wrs.js.map +0 -1
  223. package/dist/stripe-elements/p-ba251393.entry.js +0 -2
  224. package/dist/stripe-elements/p-ba251393.entry.js.map +0 -1
  225. package/dist/stripe-elements/p-c649edfc.entry.js +0 -2
  226. package/dist/stripe-elements/p-c649edfc.entry.js.map +0 -1
  227. package/dist/stripe-elements/p-e8bb43ae.entry.js +0 -2
  228. package/dist/stripe-elements/p-e8bb43ae.entry.js.map +0 -1
  229. package/dist/stripe-elements/stripe-address-element.entry.esm.js.map +0 -1
  230. package/dist/stripe-elements/stripe-card-element-modal.entry.esm.js.map +0 -1
  231. package/dist/stripe-elements/stripe-card-element.stripe-modal.entry.esm.js.map +0 -1
  232. package/dist/stripe-elements/stripe-currency-selector.entry.esm.js.map +0 -1
  233. package/dist/stripe-elements/stripe-elements.esm.js.map +0 -1
  234. package/dist/stripe-elements/stripe-express-checkout-element.entry.esm.js.map +0 -1
  235. package/dist/stripe-elements/stripe-link-authentication-element.entry.esm.js.map +0 -1
  236. package/dist/stripe-elements/stripe-payment-element.entry.esm.js.map +0 -1
  237. package/dist/stripe-elements/stripe-payment-request-button.entry.esm.js.map +0 -1
@@ -1,218 +1 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { c as checkPlatform } from './utils.js';
3
- import { s as serviceFactory, i as i18n } from './factory.js';
4
-
5
- const stripeCurrencySelectorCss = ":root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}:host{box-sizing:border-box}:host *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:\"Roboto\", sans-serif;box-sizing:border-box}:host button{cursor:pointer}:host{display:block;width:100%}.stripe-currency-selector-wrap{width:100%;padding:0;margin:0}.stripe-currency-selector-wrap #currency-selector{width:100%;min-height:40px}.stripe-currency-selector-wrap #currency-selector-errors{margin-top:8px}";
6
-
7
- const StripeCurrencySelector$1 = /*@__PURE__*/ proxyCustomElement(class StripeCurrencySelector extends HTMLElement {
8
- updatePublishableKey(publishableKey) {
9
- this.initStripe(publishableKey, {
10
- stripeAccount: this.stripeAccount,
11
- });
12
- }
13
- updateStripeAccountId(stripeAccount) {
14
- const publishableKey = this.stripeService.state.publishableKey || this.publishableKey;
15
- if (!publishableKey) {
16
- return;
17
- }
18
- this.initStripe(publishableKey, {
19
- stripeAccount,
20
- });
21
- }
22
- /**
23
- * Get Stripe.js, and initialize elements
24
- * @param publishableKey - Your Stripe publishable API key
25
- * @param options - Optional initialization options (e.g., stripeAccount)
26
- * @example
27
- * ```
28
- * const stripeCurrencySelector = document.createElement('stripe-currency-selector');
29
- * customElements
30
- * .whenDefined('stripe-currency-selector')
31
- * .then(() => {
32
- * stripeCurrencySelector.initStripe('pk_test_XXXXXXXXX')
33
- * })
34
- * ```
35
- */
36
- async initStripe(publishableKey, options) {
37
- await this.stripeService.initialize(publishableKey, {
38
- stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
39
- applicationName: this.applicationName,
40
- });
41
- // If already successfully loaded, initialize elements immediately
42
- if (this.stripeService.state.loadStripeStatus === 'success') {
43
- await this.initElement();
44
- this.stripeLoadedEventHandler();
45
- }
46
- else {
47
- // Otherwise, wait for successful load
48
- const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
49
- if (newState !== 'success') {
50
- return;
51
- }
52
- await this.initElement();
53
- this.stripeLoadedEventHandler();
54
- unsubscribe(); // Clean up listener after first success
55
- });
56
- }
57
- }
58
- /**
59
- * Set error message
60
- * @param errorMessage - The error message to display
61
- * @returns Promise resolving to this instance for method chaining
62
- * @example
63
- * ```
64
- * const stripeCurrencySelector = document.createElement('stripe-currency-selector');
65
- * customElements
66
- * .whenDefined('stripe-currency-selector')
67
- * .then(() => {
68
- * stripeCurrencySelector.setErrorMessage('Invalid currency selected');
69
- * });
70
- * ```
71
- */
72
- async setErrorMessage(errorMessage) {
73
- this.currencySelectorElementManager.setError(errorMessage);
74
- return this;
75
- }
76
- /**
77
- * Get the selected currency
78
- * @returns Promise resolving to the selected currency code (e.g., 'USD', 'EUR')
79
- * @example
80
- * ```
81
- * const stripeCurrencySelector = document.querySelector('stripe-currency-selector');
82
- * const currency = await stripeCurrencySelector.getSelectedCurrency();
83
- * console.log('Selected currency:', currency);
84
- * ```
85
- */
86
- async getSelectedCurrency() {
87
- return this.currencySelectorElementManager.getState().selectedCurrency;
88
- }
89
- stripeLoadedEventHandler() {
90
- const event = {
91
- stripe: this.stripeService.getStripe(),
92
- };
93
- if (this.stripeDidLoaded) {
94
- this.stripeDidLoaded(event);
95
- }
96
- this.stripeLoaded.emit(event);
97
- }
98
- async currencyChangeEventHandler(currency) {
99
- const changeEvent = {
100
- currency,
101
- };
102
- this.currencyChange.emit(changeEvent);
103
- if (this.handleCurrencyChange) {
104
- await this.handleCurrencyChange(changeEvent);
105
- }
106
- }
107
- componentWillRender() {
108
- if (!this.stripeService.state.publishableKey) {
109
- return;
110
- }
111
- if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {
112
- return;
113
- }
114
- this.initStripe(this.stripeService.state.publishableKey, {
115
- stripeAccount: this.stripeService.state.stripeAccount,
116
- });
117
- }
118
- constructor(registerHost) {
119
- super();
120
- if (registerHost !== false) {
121
- this.__registerHost();
122
- }
123
- this.stripeLoaded = createEvent(this, "stripeLoaded", 7);
124
- this.currencyChange = createEvent(this, "currencyChange", 7);
125
- /**
126
- * Overwrite the application name that registered
127
- * For wrapper library (like Capacitor)
128
- */
129
- this.applicationName = 'stripe-pwa-elements';
130
- // Dependency Injection via factory
131
- this.stripeService = serviceFactory.createStripeService();
132
- this.currencySelectorElementManager = serviceFactory.createCurrencySelectorElementManager(this.stripeService);
133
- if (this.publishableKey) {
134
- this.initStripe(this.publishableKey, {
135
- stripeAccount: this.stripeAccount,
136
- });
137
- }
138
- }
139
- /**
140
- * Initialize Component using Stripe Currency Selector Element
141
- */
142
- async initElement() {
143
- // Prepare currency selector element options
144
- // Note: StripeCurrencySelectorElementOptions is not yet exported in @stripe/stripe-js v8.6.0
145
- const options = {};
146
- if (this.clientSecret) {
147
- options.clientSecret = this.clientSecret;
148
- }
149
- // Initialize currency selector element
150
- const currencySelectorElement = await this.currencySelectorElementManager.initialize(this.el, options);
151
- // Listen for currency changes
152
- // Note: The 'change' event type is not yet in @stripe/stripe-js type definitions
153
- // but is documented in Stripe's Currency Selector Element documentation
154
- currencySelectorElement.on('change', (event) => {
155
- var _a;
156
- if ((_a = event === null || event === void 0 ? void 0 : event.value) === null || _a === void 0 ? void 0 : _a.currency) {
157
- this.currencyChangeEventHandler(event.value.currency);
158
- }
159
- });
160
- }
161
- componentDidLoad() {
162
- const platform = checkPlatform();
163
- if (platform) {
164
- this.el.classList.add(platform);
165
- }
166
- }
167
- disconnectedCallback() {
168
- this.currencySelectorElementManager.unmount();
169
- }
170
- render() {
171
- const { loadStripeStatus } = this.stripeService.state;
172
- const { errorMessage } = this.currencySelectorElementManager.getState();
173
- if (loadStripeStatus === 'failure') {
174
- return h("p", null, i18n.t('Failed to load Stripe'));
175
- }
176
- return (h("div", { class: "stripe-currency-selector-wrap" }, h("div", { id: "currency-selector" }), errorMessage ? (h("div", { id: "currency-selector-errors", class: "stripe-element-errors" }, errorMessage)) : null));
177
- }
178
- get el() { return this; }
179
- static get watchers() { return {
180
- "publishableKey": ["updatePublishableKey"],
181
- "stripeAccount": ["updateStripeAccountId"]
182
- }; }
183
- static get style() { return stripeCurrencySelectorCss; }
184
- }, [256, "stripe-currency-selector", {
185
- "publishableKey": [1, "publishable-key"],
186
- "stripeAccount": [1, "stripe-account"],
187
- "applicationName": [1, "application-name"],
188
- "clientSecret": [1, "client-secret"],
189
- "handleCurrencyChange": [1040],
190
- "stripeDidLoaded": [1040],
191
- "initStripe": [64],
192
- "setErrorMessage": [64],
193
- "getSelectedCurrency": [64]
194
- }, undefined, {
195
- "publishableKey": ["updatePublishableKey"],
196
- "stripeAccount": ["updateStripeAccountId"]
197
- }]);
198
- function defineCustomElement$1() {
199
- if (typeof customElements === "undefined") {
200
- return;
201
- }
202
- const components = ["stripe-currency-selector"];
203
- components.forEach(tagName => { switch (tagName) {
204
- case "stripe-currency-selector":
205
- if (!customElements.get(tagName)) {
206
- customElements.define(tagName, StripeCurrencySelector$1);
207
- }
208
- break;
209
- } });
210
- }
211
-
212
- const StripeCurrencySelector = StripeCurrencySelector$1;
213
- const defineCustomElement = defineCustomElement$1;
214
-
215
- export { StripeCurrencySelector, defineCustomElement };
216
- //# sourceMappingURL=stripe-currency-selector.js.map
217
-
218
- //# sourceMappingURL=stripe-currency-selector.js.map
1
+ import{transformTag as t,proxyCustomElement as e,HTMLElement as s,createEvent as r,h as i}from"@stencil/core/internal/client";import{c}from"./utils.js";import{s as o,i as n}from"./factory.js";const a=e(class extends s{updatePublishableKey(t){this.initStripe(t,{stripeAccount:this.stripeAccount})}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;e&&this.initStripe(e,{stripeAccount:t})}async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async setErrorMessage(t){return this.currencySelectorElementManager.setError(t),this}async getSelectedCurrency(){return this.currencySelectorElementManager.getState().selectedCurrency}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async currencyChangeEventHandler(t){const e={currency:t};this.currencyChange.emit(e),this.handleCurrencyChange&&await this.handleCurrencyChange(e)}componentWillRender(){this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=r(this,"stripeLoaded",7),this.currencyChange=r(this,"currencyChange",7),this.applicationName="stripe-pwa-elements",this.stripeService=o.createStripeService(),this.currencySelectorElementManager=o.createCurrencySelectorElementManager(this.stripeService)}componentWillLoad(){this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}async initElement(){const t={};this.clientSecret&&(t.clientSecret=this.clientSecret),(await this.currencySelectorElementManager.initialize(this.el,t)).on("change",(t=>{var e;(null===(e=null==t?void 0:t.value)||void 0===e?void 0:e.currency)&&this.currencyChangeEventHandler(t.value.currency)}))}componentDidLoad(){const t=c();t&&this.el.classList.add(t)}disconnectedCallback(){this.currencySelectorElementManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.currencySelectorElementManager.getState();return"failure"===t?i("p",null,n.t("Failed to load Stripe")):i("div",{class:"stripe-currency-selector-wrap"},i("div",{id:"currency-selector"}),e?i("div",{id:"currency-selector-errors",class:"stripe-element-errors"},e):null)}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}:host{box-sizing:border-box}:host *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}:host button{cursor:pointer}:host{display:block;width:100%}.stripe-currency-selector-wrap{width:100%;padding:0;margin:0}.stripe-currency-selector-wrap #currency-selector{width:100%;min-height:40px}.stripe-currency-selector-wrap #currency-selector-errors{margin-top:8px}'}},[0,"stripe-currency-selector",{publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],clientSecret:[1,"client-secret"],handleCurrencyChange:[1040],stripeDidLoaded:[1040],initStripe:[64],setErrorMessage:[64],getSelectedCurrency:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function l(){"undefined"!=typeof customElements&&["stripe-currency-selector"].forEach((e=>{"stripe-currency-selector"===e&&(customElements.get(t(e))||customElements.define(t(e),a))}))}l();const h=a,u=l;export{h as StripeCurrencySelector,u as defineCustomElement}
@@ -1,332 +1 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { c as checkPlatform } from './utils.js';
3
- import { s as serviceFactory, i as i18n } from './factory.js';
4
- import { S as StripeAPIError } from './error.js';
5
-
6
- const stripeExpressCheckoutElementCss = ":root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-express-checkout-wrap{width:100%;max-width:500px;margin:0 auto;padding:1rem 0}.stripe-express-checkout-wrap #express-checkout-element{margin-bottom:1rem}.stripe-express-checkout-wrap .stripe-element-errors{color:var(--stripe-error-color, #fa755a);font-size:14px;margin-top:0.5rem;padding:0.5rem;background-color:var(--stripe-error-bg, #fff5f5);border:1px solid var(--stripe-error-border, #fdd);border-radius:6px}.stripe-express-checkout-wrap .stripe-express-checkout-loading{text-align:center;padding:1rem;color:var(--stripe-loading-color, #6772e5);font-size:14px}";
7
-
8
- const StripeExpressCheckoutElement$1 = /*@__PURE__*/ proxyCustomElement(class StripeExpressCheckoutElement extends HTMLElement {
9
- updatePublishableKey(publishableKey) {
10
- const options = {};
11
- options.stripeAccount = this.stripeService.state.stripeAccount;
12
- const hasOptionValue = Object.values(options).filter(Boolean).length > 0;
13
- this.initStripe(publishableKey, hasOptionValue ? options : undefined);
14
- }
15
- updateStripeAccountId(stripeAccount) {
16
- this.initStripe(this.stripeService.state.publishableKey, {
17
- stripeAccount: stripeAccount,
18
- });
19
- }
20
- /**
21
- * Update the progress status
22
- * @param progress
23
- * @returns
24
- * @example
25
- * ```
26
- * const element = document.createElement('stripe-express-checkout-element');
27
- * customElements
28
- * .whenDefined('stripe-express-checkout-element')
29
- * .then(() => {
30
- * element.updateProgress('success')
31
- * })
32
- * ```
33
- */
34
- async updateProgress(progress) {
35
- this.progress = progress;
36
- return this;
37
- }
38
- /**
39
- * Set error message
40
- * @param errorMessage string
41
- * @returns
42
- * @example
43
- * ```
44
- * const element = document.createElement('stripe-express-checkout-element');
45
- * customElements
46
- * .whenDefined('stripe-express-checkout-element')
47
- * .then(() => {
48
- * element.setErrorMessage('Payment failed')
49
- * })
50
- * ```
51
- */
52
- async setErrorMessage(errorMessage) {
53
- this.expressCheckoutManager.setError(errorMessage);
54
- return this;
55
- }
56
- /**
57
- * Get Stripe.js, and initialize elements
58
- * @param publishableKey
59
- * @param options
60
- * @example
61
- * ```
62
- * const element = document.createElement('stripe-express-checkout-element');
63
- * customElements
64
- * .whenDefined('stripe-express-checkout-element')
65
- * .then(() => {
66
- * element.initStripe('pk_test_XXXXXXXXX')
67
- * })
68
- * ```
69
- */
70
- async initStripe(publishableKey, options) {
71
- await this.stripeService.initialize(publishableKey, {
72
- stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
73
- applicationName: this.applicationName,
74
- });
75
- // If already successfully loaded, initialize elements immediately
76
- if (this.stripeService.state.loadStripeStatus === 'success') {
77
- await this.initElement();
78
- this.stripeLoadedEventHandler();
79
- }
80
- else {
81
- // Otherwise, wait for successful load
82
- const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
83
- if (newState !== 'success') {
84
- return;
85
- }
86
- await this.initElement();
87
- this.stripeLoadedEventHandler();
88
- unsubscribe(); // Clean up listener after first success
89
- });
90
- }
91
- }
92
- /**
93
- * Update element options dynamically
94
- * @param options - Partial options to update
95
- * @example
96
- * ```
97
- * const element = document.createElement('stripe-express-checkout-element');
98
- * customElements
99
- * .whenDefined('stripe-express-checkout-element')
100
- * .then(async () => {
101
- * await element.initStripe('pk_test_xxx')
102
- * element.updateElementOptions({ amount: 2000 })
103
- * })
104
- * ```
105
- */
106
- async updateElementOptions(options) {
107
- this.expressCheckoutManager.update(options);
108
- return this;
109
- }
110
- stripeLoadedEventHandler() {
111
- const event = {
112
- stripe: this.stripeService.getStripe(),
113
- };
114
- if (this.stripeDidLoaded) {
115
- this.stripeDidLoaded(event);
116
- }
117
- this.stripeLoaded.emit(event);
118
- }
119
- async defaultConfirmResultHandler(result) {
120
- this.defaultConfirmResult.emit(result);
121
- }
122
- constructor(registerHost) {
123
- super();
124
- if (registerHost !== false) {
125
- this.__registerHost();
126
- }
127
- this.stripeLoaded = createEvent(this, "stripeLoaded", 7);
128
- this.confirm = createEvent(this, "confirm", 7);
129
- this.expressCheckoutClick = createEvent(this, "expressCheckoutClick", 7);
130
- this.cancel = createEvent(this, "cancel", 7);
131
- this.defaultConfirmResult = createEvent(this, "defaultConfirmResult", 7);
132
- /**
133
- * Default submit handle type.
134
- * If you want to use `setupIntent`, should update this attribute.
135
- */
136
- this.intentType = 'payment';
137
- /**
138
- * Overwrite the application name that registered
139
- * For wrapper library (like Capacitor)
140
- */
141
- this.applicationName = 'stripe-pwa-elements';
142
- /**
143
- * The component will provide a function to call the confirmation API.
144
- * If you want to customize the behavior, should set false.
145
- * And listen the 'confirm' event on the element
146
- */
147
- this.shouldUseDefaultConfirmAction = true;
148
- /**
149
- * The progress status of the checkout process
150
- */
151
- this.progress = '';
152
- // Dependency Injection via factory
153
- this.stripeService = serviceFactory.createStripeService();
154
- this.expressCheckoutManager = serviceFactory.createExpressCheckoutElementManager(this.stripeService);
155
- if (this.publishableKey) {
156
- this.initStripe(this.publishableKey, {
157
- stripeAccount: this.stripeAccount,
158
- });
159
- }
160
- }
161
- componentWillUpdate() {
162
- if (!this.stripeService.state.publishableKey) {
163
- return;
164
- }
165
- if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {
166
- return;
167
- }
168
- this.initStripe(this.stripeService.state.publishableKey, {
169
- stripeAccount: this.stripeService.state.stripeAccount,
170
- });
171
- }
172
- /**
173
- * Default confirm action
174
- * Confirms the payment or setup intent based on intentType
175
- * @param event
176
- */
177
- async defaultConfirmAction(event) {
178
- try {
179
- this.progress = 'loading';
180
- const stripe = this.stripeService.getStripe();
181
- const { intentType, clientSecret } = this;
182
- if (!stripe) {
183
- throw new Error('Stripe not initialized');
184
- }
185
- if (!clientSecret) {
186
- throw new Error('Client secret is required');
187
- }
188
- const result = await (() => {
189
- if (intentType === 'payment') {
190
- return stripe.confirmPayment({
191
- elements: this.stripeService.getElements(),
192
- clientSecret,
193
- confirmParams: {
194
- return_url: `${window.location.origin}${window.location.pathname}`,
195
- },
196
- redirect: 'if_required',
197
- });
198
- }
199
- return stripe.confirmSetup({
200
- elements: this.stripeService.getElements(),
201
- clientSecret,
202
- confirmParams: {
203
- return_url: `${window.location.origin}${window.location.pathname}`,
204
- },
205
- redirect: 'if_required',
206
- });
207
- })();
208
- if (result.error) {
209
- throw new StripeAPIError(result.error);
210
- }
211
- // Complete the payment in the Express Checkout Element
212
- // Note: complete() method exists at runtime but is not in type definitions yet
213
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
214
- event.complete('success');
215
- this.progress = 'success';
216
- this.defaultConfirmResultHandler(result);
217
- }
218
- catch (e) {
219
- console.error(e);
220
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
221
- event.complete('fail');
222
- this.expressCheckoutManager.setError(e.message);
223
- this.progress = 'failure';
224
- this.defaultConfirmResultHandler(e);
225
- }
226
- }
227
- /**
228
- * Initialize Component using Express Checkout Element
229
- */
230
- async initElement() {
231
- const elementOptions = {
232
- mode: this.intentType === 'payment' ? 'payment' : 'setup',
233
- };
234
- if (this.amount !== undefined) {
235
- elementOptions.amount = this.amount;
236
- }
237
- if (this.currency) {
238
- elementOptions.currency = this.currency;
239
- }
240
- if (this.buttonHeight) {
241
- // Convert string like "48px" to number for Stripe API
242
- if (typeof this.buttonHeight === 'string') {
243
- const height = parseInt(this.buttonHeight.replace('px', ''), 10);
244
- if (!isNaN(height)) {
245
- elementOptions.buttonHeight = height;
246
- }
247
- }
248
- else {
249
- elementOptions.buttonHeight = this.buttonHeight;
250
- }
251
- }
252
- // Initialize express checkout element with event handlers
253
- await this.expressCheckoutManager.initialize(this.el, elementOptions, {
254
- onConfirm: async (event) => {
255
- this.confirm.emit(event);
256
- if (this.shouldUseDefaultConfirmAction && this.clientSecret) {
257
- await this.defaultConfirmAction(event);
258
- }
259
- },
260
- onClick: event => {
261
- this.expressCheckoutClick.emit(event);
262
- },
263
- onCancel: () => {
264
- this.cancel.emit();
265
- this.progress = '';
266
- },
267
- });
268
- }
269
- componentDidLoad() {
270
- this.el.classList.add(checkPlatform());
271
- }
272
- disconnectedCallback() {
273
- this.expressCheckoutManager.unmount();
274
- }
275
- render() {
276
- const { loadStripeStatus } = this.stripeService.state;
277
- const { errorMessage, isReady } = this.expressCheckoutManager.getState();
278
- if (loadStripeStatus === 'failure') {
279
- return h("p", null, i18n.t('Failed to load Stripe'));
280
- }
281
- if (loadStripeStatus === 'loading') {
282
- return h("p", null, i18n.t('Loading'));
283
- }
284
- return (h("div", { class: "stripe-express-checkout-wrap" }, h("div", { id: "express-checkout-element" }), errorMessage && (h("div", { id: "express-checkout-errors", class: "stripe-element-errors" }, errorMessage)), !isReady && loadStripeStatus === 'success' && h("div", { class: "stripe-express-checkout-loading" }, i18n.t('Loading'))));
285
- }
286
- get el() { return this; }
287
- static get watchers() { return {
288
- "publishableKey": ["updatePublishableKey"],
289
- "stripeAccount": ["updateStripeAccountId"]
290
- }; }
291
- static get style() { return stripeExpressCheckoutElementCss; }
292
- }, [256, "stripe-express-checkout-element", {
293
- "intentType": [1, "intent-type"],
294
- "publishableKey": [1, "publishable-key"],
295
- "stripeAccount": [1, "stripe-account"],
296
- "applicationName": [1, "application-name"],
297
- "clientSecret": [1, "client-secret"],
298
- "amount": [2],
299
- "currency": [1],
300
- "buttonHeight": [1, "button-height"],
301
- "shouldUseDefaultConfirmAction": [4, "should-use-default-confirm-action"],
302
- "stripeDidLoaded": [1040],
303
- "progress": [32],
304
- "updateProgress": [64],
305
- "setErrorMessage": [64],
306
- "initStripe": [64],
307
- "updateElementOptions": [64]
308
- }, undefined, {
309
- "publishableKey": ["updatePublishableKey"],
310
- "stripeAccount": ["updateStripeAccountId"]
311
- }]);
312
- function defineCustomElement$1() {
313
- if (typeof customElements === "undefined") {
314
- return;
315
- }
316
- const components = ["stripe-express-checkout-element"];
317
- components.forEach(tagName => { switch (tagName) {
318
- case "stripe-express-checkout-element":
319
- if (!customElements.get(tagName)) {
320
- customElements.define(tagName, StripeExpressCheckoutElement$1);
321
- }
322
- break;
323
- } });
324
- }
325
-
326
- const StripeExpressCheckoutElement = StripeExpressCheckoutElement$1;
327
- const defineCustomElement = defineCustomElement$1;
328
-
329
- export { StripeExpressCheckoutElement, defineCustomElement };
330
- //# sourceMappingURL=stripe-express-checkout-element.js.map
331
-
332
- //# sourceMappingURL=stripe-express-checkout-element.js.map
1
+ import{transformTag as t,proxyCustomElement as e,HTMLElement as s,createEvent as i,h as r}from"@stencil/core/internal/client";import{c as o}from"./utils.js";import{s as n,i as c}from"./factory.js";import{S as a}from"./error.js";const l=e(class extends s{updatePublishableKey(t){const e={};e.stripeAccount=this.stripeService.state.stripeAccount;const s=Object.values(e).filter(Boolean).length>0;this.initStripe(t,s?e:void 0)}updateStripeAccountId(t){this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:t})}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.expressCheckoutManager.setError(t),this}async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateElementOptions(t){return this.expressCheckoutManager.update(t),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async defaultConfirmResultHandler(t){this.defaultConfirmResult.emit(t)}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=i(this,"stripeLoaded",7),this.confirm=i(this,"confirm",7),this.expressCheckoutClick=i(this,"expressCheckoutClick",7),this.cancel=i(this,"cancel",7),this.defaultConfirmResult=i(this,"defaultConfirmResult",7),this.intentType="payment",this.applicationName="stripe-pwa-elements",this.shouldUseDefaultConfirmAction=!0,this.progress="",this.stripeService=n.createStripeService(),this.expressCheckoutManager=n.createExpressCheckoutElementManager(this.stripeService)}componentWillLoad(){null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}componentWillUpdate(){null!=this.stripeService.state.publishableKey&&""!==this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}async defaultConfirmAction(t){try{this.progress="loading";const e=this.stripeService.getStripe(),{intentType:s,clientSecret:i}=this;if(null==e)throw Error("Stripe not initialized");if(null==i||""===i)throw Error("Client secret is required");const r=await(()=>"payment"===s?e.confirmPayment({elements:this.stripeService.getElements(),clientSecret:i,confirmParams:{return_url:`${window.location.origin}${window.location.pathname}`},redirect:"if_required"}):e.confirmSetup({elements:this.stripeService.getElements(),clientSecret:i,confirmParams:{return_url:`${window.location.origin}${window.location.pathname}`},redirect:"if_required"}))();if(null!=r.error)throw new a(r.error);t.complete("success"),this.progress="success",this.defaultConfirmResultHandler(r)}catch(e){console.error(e),t.complete("fail"),this.expressCheckoutManager.setError(e.message),this.progress="failure",this.defaultConfirmResultHandler(e)}}async initElement(){const t={mode:"payment"===this.intentType?"payment":"setup"};if(void 0!==this.amount&&(t.amount=this.amount),null!=this.currency&&""!==this.currency&&(t.currency=this.currency),null!=this.buttonHeight&&""!==this.buttonHeight)if("string"==typeof this.buttonHeight){const e=parseInt(this.buttonHeight.replace("px",""),10);isNaN(e)||(t.buttonHeight=e)}else t.buttonHeight=this.buttonHeight;await this.expressCheckoutManager.initialize(this.el,t,{onConfirm:async t=>{this.confirm.emit(t),this.shouldUseDefaultConfirmAction&&null!=this.clientSecret&&""!==this.clientSecret&&await this.defaultConfirmAction(t)},onClick:t=>{this.expressCheckoutClick.emit(t)},onCancel:()=>{this.cancel.emit(),this.progress=""}})}componentDidLoad(){this.el.classList.add(o())}disconnectedCallback(){this.expressCheckoutManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e,isReady:s}=this.expressCheckoutManager.getState();return"failure"===t?r("p",null,c.t("Failed to load Stripe")):"loading"===t?r("p",null,c.t("Loading")):r("div",{class:"stripe-express-checkout-wrap"},r("div",{id:"express-checkout-element"}),e&&r("div",{id:"express-checkout-errors",class:"stripe-element-errors"},e),!s&&"success"===t&&r("div",{class:"stripe-express-checkout-loading"},c.t("Loading")))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return":root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-express-checkout-wrap{width:100%;max-width:500px;margin:0 auto;padding:1rem 0}.stripe-express-checkout-wrap #express-checkout-element{margin-bottom:1rem}.stripe-express-checkout-wrap .stripe-element-errors{color:var(--stripe-error-color, #fa755a);font-size:14px;margin-top:0.5rem;padding:0.5rem;background-color:var(--stripe-error-bg, #fff5f5);border:1px solid var(--stripe-error-border, #fdd);border-radius:6px}.stripe-express-checkout-wrap .stripe-express-checkout-loading{text-align:center;padding:1rem;color:var(--stripe-loading-color, #6772e5);font-size:14px}"}},[0,"stripe-express-checkout-element",{intentType:[1,"intent-type"],publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],clientSecret:[1,"client-secret"],amount:[2],currency:[1],buttonHeight:[1,"button-height"],shouldUseDefaultConfirmAction:[4,"should-use-default-confirm-action"],stripeDidLoaded:[1040],progress:[32],updateProgress:[64],setErrorMessage:[64],initStripe:[64],updateElementOptions:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function h(){"undefined"!=typeof customElements&&["stripe-express-checkout-element"].forEach((e=>{"stripe-express-checkout-element"===e&&(customElements.get(t(e))||customElements.define(t(e),l))}))}h();const p=l,u=h;export{p as StripeExpressCheckoutElement,u as defineCustomElement}