@justifi/webcomponents 6.15.0-rc.1 → 6.15.0-rc.2

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 (267) hide show
  1. package/dist/cjs/{Analytics-VQGAbMVS.js → Analytics-COhunq0p.js} +2 -2
  2. package/dist/cjs/{Api--EGkA-pT.js → Api-Do6SaltY.js} +1 -1
  3. package/dist/cjs/additional-questions-form-step_15.cjs.entry.js +4 -4
  4. package/dist/cjs/bank-account-form.cjs.entry.js +2 -2
  5. package/dist/cjs/{business.service-B51fjG_j.js → business.service-72YETCdB.js} +1 -1
  6. package/dist/cjs/card-form.cjs.entry.js +2 -2
  7. package/dist/cjs/{check-pkg-version-RMsgKzFc.js → check-pkg-version-BxGoSXGD.js} +1 -1
  8. package/dist/cjs/{checkout.service-BsOwkSNp.js → checkout.service-CPsXfx0Z.js} +1 -1
  9. package/dist/cjs/custom-popper_2.cjs.entry.js +2 -2
  10. package/dist/cjs/dispute-notification_2.cjs.entry.js +5 -5
  11. package/dist/cjs/{event-types-C_LP6UcW.js → event-types-UHzCC7Ga.js} +1 -1
  12. package/dist/cjs/form-address-fields_3.cjs.entry.js +2 -2
  13. package/dist/cjs/form-alert_3.cjs.entry.js +5 -5
  14. package/dist/cjs/form-control-date.cjs.entry.js +2 -2
  15. package/dist/cjs/form-control-file-v2_2.cjs.entry.js +3 -3
  16. package/dist/cjs/form-control-file.cjs.entry.js +2 -2
  17. package/dist/cjs/form-control-monetary.cjs.entry.js +2 -2
  18. package/dist/cjs/form-control-number_2.cjs.entry.js +2 -2
  19. package/dist/cjs/form-control-radio.cjs.entry.js +2 -2
  20. package/dist/cjs/form-control-select_2.cjs.entry.js +2 -2
  21. package/dist/cjs/{get-subaccounts-d4CUegsn.js → get-subaccounts-Bp7DOmM_.js} +1 -1
  22. package/dist/cjs/internal-button.cjs.entry.js +1 -1
  23. package/dist/cjs/justifi-apple-pay_12.cjs.entry.js +47 -16
  24. package/dist/cjs/justifi-bank-account-billing-form-simple.cjs.entry.js +4 -4
  25. package/dist/cjs/justifi-bank-account-form.cjs.entry.js +4 -4
  26. package/dist/cjs/justifi-business-details.cjs.entry.js +5 -5
  27. package/dist/cjs/justifi-business-form.cjs.entry.js +5 -5
  28. package/dist/cjs/justifi-card-form.cjs.entry.js +4 -4
  29. package/dist/cjs/justifi-checkout-qr-code.cjs.entry.js +4 -4
  30. package/dist/cjs/justifi-checkout.cjs.entry.js +4 -4
  31. package/dist/cjs/justifi-checkouts-list.cjs.entry.js +6 -6
  32. package/dist/cjs/justifi-dispute-management.cjs.entry.js +5 -5
  33. package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +4 -4
  34. package/dist/cjs/justifi-order-terminals.cjs.entry.js +7 -7
  35. package/dist/cjs/justifi-payment-details.cjs.entry.js +13 -13
  36. package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +5 -5
  37. package/dist/cjs/justifi-payment-transactions-list.cjs.entry.js +6 -6
  38. package/dist/cjs/justifi-payments-list-filters.cjs.entry.js +2 -2
  39. package/dist/cjs/justifi-payments-list.cjs.entry.js +6 -6
  40. package/dist/cjs/justifi-payout-details.cjs.entry.js +8 -8
  41. package/dist/cjs/justifi-payout-transactions-list.cjs.entry.js +6 -6
  42. package/dist/cjs/justifi-payouts-list-filters.cjs.entry.js +2 -2
  43. package/dist/cjs/justifi-payouts-list.cjs.entry.js +7 -7
  44. package/dist/cjs/justifi-qr-terminal.cjs.entry.js +5 -5
  45. package/dist/cjs/justifi-refund-payment.cjs.entry.js +5 -5
  46. package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +4 -4
  47. package/dist/cjs/justifi-skeleton.cjs.entry.js +1 -1
  48. package/dist/cjs/justifi-terminal-orders-list-filters.cjs.entry.js +3 -3
  49. package/dist/cjs/justifi-terminal-orders-list.cjs.entry.js +6 -6
  50. package/dist/cjs/justifi-terminals-list-filters.cjs.entry.js +1 -1
  51. package/dist/cjs/justifi-terminals-list.cjs.entry.js +7 -7
  52. package/dist/cjs/loader.cjs.js +1 -1
  53. package/dist/cjs/{package-DfwuePUh.js → package-G3Vs7Jx5.js} +1 -1
  54. package/dist/cjs/{payment.service-Vy_JnuSA.js → payment.service-CVwTrHEL.js} +1 -1
  55. package/dist/cjs/{payout.service-BEPglFXf.js → payout.service-CL3VR0hN.js} +1 -1
  56. package/dist/cjs/{plaid.service-DXQ7q51E.js → plaid.service-Cukg5wuY.js} +1 -1
  57. package/dist/cjs/radio-list-item.cjs.entry.js +1 -1
  58. package/dist/cjs/terminal-quantity-selector.cjs.entry.js +1 -1
  59. package/dist/cjs/{terminal.service-BP2YecQ_.js → terminal.service-C0KG7BqL.js} +1 -1
  60. package/dist/cjs/webcomponents.cjs.js +1 -1
  61. package/dist/collection/components/modular-checkout/sub-components/paypal/justifi-paypal.js +38 -13
  62. package/dist/collection/components/order-terminals/justifi-order-terminals.js +1 -1
  63. package/dist/collection/components/order-terminals/terminal-quantity-selector/terminal-quantity-selector.js +1 -1
  64. package/dist/collection/components/payment-details/justifi-payment-details.js +8 -8
  65. package/dist/collection/components/payment-transactions-list/justifi-payment-transactions-list.js +1 -1
  66. package/dist/collection/components/payments-list/justifi-payments-list-filters.js +2 -2
  67. package/dist/collection/components/payments-list/justifi-payments-list.js +1 -1
  68. package/dist/collection/components/payout-details/justifi-payout-details.js +3 -3
  69. package/dist/collection/components/payout-transactions-list/justifi-payout-transactions-list.js +1 -1
  70. package/dist/collection/components/payouts-list/justifi-payouts-list-filters.js +2 -2
  71. package/dist/collection/components/payouts-list/justifi-payouts-list.js +1 -1
  72. package/dist/collection/components/terminal-orders-list/justifi-terminal-orders-list-filters.js +3 -3
  73. package/dist/collection/components/terminal-orders-list/justifi-terminal-orders-list.js +2 -2
  74. package/dist/collection/components/terminals-list/justifi-terminals-list-filters.js +1 -1
  75. package/dist/collection/components/terminals-list/justifi-terminals-list.js +1 -1
  76. package/dist/collection/components/tokenize-payment-method/justifi-tokenize-payment-method.js +1 -1
  77. package/dist/collection/ui-components/custom-popper/custom-popper.js +2 -2
  78. package/dist/collection/ui-components/form/form-control-date.js +2 -2
  79. package/dist/collection/ui-components/form/form-control-file-v2.js +1 -1
  80. package/dist/collection/ui-components/form/form-control-file.js +2 -2
  81. package/dist/collection/ui-components/form/form-control-monetary.js +2 -2
  82. package/dist/collection/ui-components/form/form-control-number-masked.js +2 -2
  83. package/dist/collection/ui-components/form/form-control-number.js +2 -2
  84. package/dist/collection/ui-components/form/form-control-radio.js +2 -2
  85. package/dist/collection/ui-components/form/form-control-text.js +2 -2
  86. package/dist/collection/ui-components/form/form-control-textarea.js +2 -2
  87. package/dist/collection/ui-components/form/hidden-input.js +1 -1
  88. package/dist/collection/ui-components/form/iframe-input.js +3 -3
  89. package/dist/collection/ui-components/internal-button.js +1 -1
  90. package/dist/collection/ui-components/radio-list-item.js +1 -1
  91. package/dist/collection/ui-components/shadow-dom-components/justifi-button.js +1 -1
  92. package/dist/collection/ui-components/shadow-dom-components/justifi-header.js +1 -1
  93. package/dist/collection/ui-components/shadow-dom-components/justifi-skeleton.js +1 -1
  94. package/dist/docs.json +1 -1
  95. package/dist/esm/{Analytics-hKJLmoJl.js → Analytics-3WmRTICF.js} +2 -2
  96. package/dist/esm/{Api-DAJ9sMMj.js → Api-83B3f28Q.js} +1 -1
  97. package/dist/esm/additional-questions-form-step_15.entry.js +4 -4
  98. package/dist/esm/bank-account-form.entry.js +2 -2
  99. package/dist/esm/{business.service-kmkjOyTm.js → business.service-CTqiKKy5.js} +1 -1
  100. package/dist/esm/card-form.entry.js +2 -2
  101. package/dist/esm/{check-pkg-version-FEAmKlDW.js → check-pkg-version-CmFl6VLH.js} +1 -1
  102. package/dist/esm/{checkout.service-BVBmNheb.js → checkout.service-wjFjBxIB.js} +1 -1
  103. package/dist/esm/custom-popper_2.entry.js +2 -2
  104. package/dist/esm/dispute-notification_2.entry.js +5 -5
  105. package/dist/esm/{event-types-B5-lsGjZ.js → event-types-cqQHLwCy.js} +1 -1
  106. package/dist/esm/form-address-fields_3.entry.js +2 -2
  107. package/dist/esm/form-alert_3.entry.js +5 -5
  108. package/dist/esm/form-control-date.entry.js +2 -2
  109. package/dist/esm/form-control-file-v2_2.entry.js +3 -3
  110. package/dist/esm/form-control-file.entry.js +2 -2
  111. package/dist/esm/form-control-monetary.entry.js +2 -2
  112. package/dist/esm/form-control-number_2.entry.js +2 -2
  113. package/dist/esm/form-control-radio.entry.js +2 -2
  114. package/dist/esm/form-control-select_2.entry.js +2 -2
  115. package/dist/esm/{get-subaccounts-By7m_FxO.js → get-subaccounts-ClGG-LRZ.js} +1 -1
  116. package/dist/esm/internal-button.entry.js +1 -1
  117. package/dist/esm/justifi-apple-pay_12.entry.js +47 -16
  118. package/dist/esm/justifi-bank-account-billing-form-simple.entry.js +4 -4
  119. package/dist/esm/justifi-bank-account-form.entry.js +4 -4
  120. package/dist/esm/justifi-business-details.entry.js +5 -5
  121. package/dist/esm/justifi-business-form.entry.js +5 -5
  122. package/dist/esm/justifi-card-form.entry.js +4 -4
  123. package/dist/esm/justifi-checkout-qr-code.entry.js +4 -4
  124. package/dist/esm/justifi-checkout.entry.js +4 -4
  125. package/dist/esm/justifi-checkouts-list.entry.js +6 -6
  126. package/dist/esm/justifi-dispute-management.entry.js +5 -5
  127. package/dist/esm/justifi-gross-payment-chart.entry.js +4 -4
  128. package/dist/esm/justifi-order-terminals.entry.js +7 -7
  129. package/dist/esm/justifi-payment-details.entry.js +13 -13
  130. package/dist/esm/justifi-payment-provisioning.entry.js +5 -5
  131. package/dist/esm/justifi-payment-transactions-list.entry.js +6 -6
  132. package/dist/esm/justifi-payments-list-filters.entry.js +2 -2
  133. package/dist/esm/justifi-payments-list.entry.js +6 -6
  134. package/dist/esm/justifi-payout-details.entry.js +8 -8
  135. package/dist/esm/justifi-payout-transactions-list.entry.js +6 -6
  136. package/dist/esm/justifi-payouts-list-filters.entry.js +2 -2
  137. package/dist/esm/justifi-payouts-list.entry.js +7 -7
  138. package/dist/esm/justifi-qr-terminal.entry.js +5 -5
  139. package/dist/esm/justifi-refund-payment.entry.js +5 -5
  140. package/dist/esm/justifi-season-interruption-insurance.entry.js +4 -4
  141. package/dist/esm/justifi-skeleton.entry.js +1 -1
  142. package/dist/esm/justifi-terminal-orders-list-filters.entry.js +3 -3
  143. package/dist/esm/justifi-terminal-orders-list.entry.js +6 -6
  144. package/dist/esm/justifi-terminals-list-filters.entry.js +1 -1
  145. package/dist/esm/justifi-terminals-list.entry.js +7 -7
  146. package/dist/esm/loader.js +1 -1
  147. package/dist/esm/{package-Dn9_7aQh.js → package-CAVi_ne1.js} +1 -1
  148. package/dist/esm/{payment.service-CMUlMV1Y.js → payment.service-D7uv5vym.js} +1 -1
  149. package/dist/esm/{payout.service-C0yd0JZS.js → payout.service-BoSyqft1.js} +1 -1
  150. package/dist/esm/{plaid.service-CqihCTBS.js → plaid.service-DufQkxDk.js} +1 -1
  151. package/dist/esm/radio-list-item.entry.js +1 -1
  152. package/dist/esm/terminal-quantity-selector.entry.js +1 -1
  153. package/dist/esm/{terminal.service-DuF3uTuA.js → terminal.service-BM2aebB6.js} +1 -1
  154. package/dist/esm/webcomponents.js +1 -1
  155. package/dist/module/custom-popper2.js +2 -2
  156. package/dist/module/form-control-date2.js +2 -2
  157. package/dist/module/form-control-file-v22.js +1 -1
  158. package/dist/module/form-control-file2.js +2 -2
  159. package/dist/module/form-control-monetary2.js +2 -2
  160. package/dist/module/form-control-number-masked2.js +2 -2
  161. package/dist/module/form-control-number2.js +2 -2
  162. package/dist/module/form-control-radio2.js +2 -2
  163. package/dist/module/form-control-text2.js +2 -2
  164. package/dist/module/form-control-textarea2.js +2 -2
  165. package/dist/module/hidden-input2.js +1 -1
  166. package/dist/module/iframe-input2.js +3 -3
  167. package/dist/module/internal-button2.js +1 -1
  168. package/dist/module/justifi-button2.js +1 -1
  169. package/dist/module/justifi-header2.js +1 -1
  170. package/dist/module/justifi-order-terminals.js +1 -1
  171. package/dist/module/justifi-payment-details.js +8 -8
  172. package/dist/module/justifi-payment-transactions-list.js +1 -1
  173. package/dist/module/justifi-payments-list-filters.js +2 -2
  174. package/dist/module/justifi-payments-list.js +1 -1
  175. package/dist/module/justifi-payout-details.js +3 -3
  176. package/dist/module/justifi-payout-transactions-list.js +1 -1
  177. package/dist/module/justifi-payouts-list-filters.js +2 -2
  178. package/dist/module/justifi-payouts-list.js +1 -1
  179. package/dist/module/justifi-paypal2.js +39 -11
  180. package/dist/module/justifi-skeleton.js +1 -1
  181. package/dist/module/justifi-terminal-orders-list-filters.js +3 -3
  182. package/dist/module/justifi-terminal-orders-list.js +2 -2
  183. package/dist/module/justifi-terminals-list-filters.js +1 -1
  184. package/dist/module/justifi-terminals-list.js +1 -1
  185. package/dist/module/justifi-tokenize-payment-method2.js +1 -1
  186. package/dist/module/package.js +1 -1
  187. package/dist/module/radio-list-item2.js +1 -1
  188. package/dist/module/terminal-quantity-selector2.js +1 -1
  189. package/dist/types/components/modular-checkout/sub-components/paypal/justifi-paypal.d.ts +9 -2
  190. package/dist/webcomponents/{p-d4de565d.entry.js → p-0aa96018.entry.js} +1 -1
  191. package/dist/webcomponents/p-0fbc806f.entry.js +1 -0
  192. package/dist/webcomponents/{p-36f05f5f.entry.js → p-10787684.entry.js} +1 -1
  193. package/dist/webcomponents/{p-86f9d5f6.entry.js → p-1365a46b.entry.js} +1 -1
  194. package/dist/webcomponents/p-1fa62eba.entry.js +1 -0
  195. package/dist/webcomponents/p-25f70d5f.entry.js +1 -0
  196. package/dist/webcomponents/{p-DsvK2pes.js → p-27igUlku.js} +1 -1
  197. package/dist/webcomponents/{p-31204dd5.entry.js → p-2b5533a1.entry.js} +1 -1
  198. package/dist/webcomponents/p-388082cd.entry.js +1 -0
  199. package/dist/webcomponents/p-3f2fb856.entry.js +1 -0
  200. package/dist/webcomponents/{p-e0bce67a.entry.js → p-4cad48c1.entry.js} +1 -1
  201. package/dist/webcomponents/{p-10b91a6c.entry.js → p-50c2b8f0.entry.js} +1 -1
  202. package/dist/webcomponents/{p-5a11c49f.entry.js → p-5842d4e8.entry.js} +1 -1
  203. package/dist/webcomponents/{p-0d8a256c.entry.js → p-5c89dcdf.entry.js} +1 -1
  204. package/dist/webcomponents/{p-b6ce91f0.entry.js → p-5d7b3d71.entry.js} +1 -1
  205. package/dist/webcomponents/p-5dcb1713.entry.js +1 -0
  206. package/dist/webcomponents/{p-33281304.entry.js → p-5f8c30b6.entry.js} +1 -1
  207. package/dist/webcomponents/p-68e88747.entry.js +1 -0
  208. package/dist/webcomponents/{p-c6f85bef.entry.js → p-6931a1f2.entry.js} +1 -1
  209. package/dist/webcomponents/{p-f8764c8e.entry.js → p-6c94218c.entry.js} +1 -1
  210. package/dist/webcomponents/{p-1a55efda.entry.js → p-6eb65d23.entry.js} +1 -1
  211. package/dist/webcomponents/{p-0f7cc07b.entry.js → p-7002286e.entry.js} +1 -1
  212. package/dist/webcomponents/p-72bb4aff.entry.js +1 -0
  213. package/dist/webcomponents/{p-1034e83d.entry.js → p-74575a99.entry.js} +1 -1
  214. package/dist/webcomponents/{p-18306b40.entry.js → p-7c405573.entry.js} +1 -1
  215. package/dist/webcomponents/{p-2458de56.entry.js → p-825a7ee6.entry.js} +1 -1
  216. package/dist/webcomponents/{p-408a4f5f.entry.js → p-909a9828.entry.js} +3 -3
  217. package/dist/webcomponents/p-955c06d3.entry.js +1 -0
  218. package/dist/webcomponents/{p-5bdae8c7.entry.js → p-97c6593d.entry.js} +1 -1
  219. package/dist/webcomponents/p-9e3e2e32.entry.js +1 -0
  220. package/dist/webcomponents/{p-2549c891.entry.js → p-9e9a2546.entry.js} +1 -1
  221. package/dist/webcomponents/{p-BFi5l0xt.js → p-BAKuMxC9.js} +1 -1
  222. package/dist/webcomponents/{p-ByQMBEDC.js → p-BEL8sLz6.js} +1 -1
  223. package/dist/webcomponents/{p-FWuMPTxn.js → p-BSxXlu9H.js} +1 -1
  224. package/dist/webcomponents/p-CAVi_ne1.js +1 -0
  225. package/dist/webcomponents/{p-Ba0_MQtJ.js → p-CIpBEUtx.js} +1 -1
  226. package/dist/webcomponents/{p-DnLqZpI1.js → p-CJEetAx7.js} +1 -1
  227. package/dist/webcomponents/{p-CKgQN8v0.js → p-DN7VhlTn.js} +1 -1
  228. package/dist/webcomponents/{p-rznJBkm3.js → p-D_84NsmN.js} +1 -1
  229. package/dist/webcomponents/p-PdwJswAy.js +1 -0
  230. package/dist/webcomponents/p-acb0b66c.entry.js +1 -0
  231. package/dist/webcomponents/p-b23dfa13.entry.js +1 -0
  232. package/dist/webcomponents/{p-5348209c.entry.js → p-c3818a5a.entry.js} +1 -1
  233. package/dist/webcomponents/{p-ddba9ab3.entry.js → p-c5424fda.entry.js} +1 -1
  234. package/dist/webcomponents/p-ca13117d.entry.js +1 -0
  235. package/dist/webcomponents/{p-af728bc6.entry.js → p-cb1cc88e.entry.js} +1 -1
  236. package/dist/webcomponents/{p-d446ab68.entry.js → p-ced6f6f1.entry.js} +1 -1
  237. package/dist/webcomponents/{p-fa2e7534.entry.js → p-d59676ea.entry.js} +1 -1
  238. package/dist/webcomponents/p-d98bc829.entry.js +1 -0
  239. package/dist/webcomponents/{p-636c9571.entry.js → p-eb31024f.entry.js} +1 -1
  240. package/dist/webcomponents/{p-80a9f84c.entry.js → p-ee7fe3a8.entry.js} +1 -1
  241. package/dist/webcomponents/p-f0434a13.entry.js +1 -0
  242. package/dist/webcomponents/{p-b9664e84.entry.js → p-f3682c72.entry.js} +1 -1
  243. package/dist/webcomponents/{p-aebd2149.entry.js → p-f5358a80.entry.js} +1 -1
  244. package/dist/webcomponents/{p-d555220f.entry.js → p-f9f0cb1f.entry.js} +1 -1
  245. package/dist/webcomponents/p-fdd087d4.entry.js +1 -0
  246. package/dist/webcomponents/{p-BHaO3c8W.js → p-nbKvRcwU.js} +1 -1
  247. package/dist/webcomponents/{p-Bl00tHyn.js → p-vIQBTQmc.js} +1 -1
  248. package/dist/webcomponents/webcomponents.esm.js +1 -1
  249. package/package.json +1 -1
  250. package/dist/webcomponents/p-22a57828.entry.js +0 -1
  251. package/dist/webcomponents/p-27b07530.entry.js +0 -1
  252. package/dist/webcomponents/p-2e82a488.entry.js +0 -1
  253. package/dist/webcomponents/p-3c33b3c1.entry.js +0 -1
  254. package/dist/webcomponents/p-76e96874.entry.js +0 -1
  255. package/dist/webcomponents/p-772ab8a3.entry.js +0 -1
  256. package/dist/webcomponents/p-7e64a668.entry.js +0 -1
  257. package/dist/webcomponents/p-8a5ce8ff.entry.js +0 -1
  258. package/dist/webcomponents/p-9c45729d.entry.js +0 -1
  259. package/dist/webcomponents/p-9ed85832.entry.js +0 -1
  260. package/dist/webcomponents/p-C-buCQRx.js +0 -1
  261. package/dist/webcomponents/p-Dn9_7aQh.js +0 -1
  262. package/dist/webcomponents/p-a891caf8.entry.js +0 -1
  263. package/dist/webcomponents/p-d05257f9.entry.js +0 -1
  264. package/dist/webcomponents/p-d2e890a3.entry.js +0 -1
  265. package/dist/webcomponents/p-d397b38f.entry.js +0 -1
  266. package/dist/webcomponents/p-dd4eea27.entry.js +0 -1
  267. package/dist/webcomponents/p-e1e5bddf.entry.js +0 -1
@@ -1 +1 @@
1
- import{h as t,r as e,c as a}from"./p-CV0Pyo1O.js";import"./p-B4vLfYnZ.js";import"./p-HXpYMWUU.js";import{j as s,C as i,b as r}from"./p-D6uhYbLo.js";import{p as n}from"./p-CLHwhyvu.js";import"./p-DaDqgDrb.js";import{J as o}from"./p-BHaO3c8W.js";import{c}from"./p-ByQMBEDC.js";import{g as p,a as h}from"./p-CLq3Og7o.js";import{P as d}from"./p-BFi5l0xt.js";import{T as f,a as l,b as u,c as m,d as y,e as b,f as _,g,h as j,i as T,j as w,k,l as v}from"./p-DZr0wLGh.js";import{S as D}from"./p-05AWudQe.js";import{T as C}from"./p-CZfYo5-1.js";import{a as F}from"./p-Ds_P-dB8.js";import{a6 as P,a7 as R}from"./p-Bu7gdOaV.js";import"./p-DgTOxu8x.js";import"./p-Dn9_7aQh.js";import"./p-Bl00tHyn.js";import"./p-MPer3Rw7.js";const x={created_at:()=>t("th",{part:P,scope:"col",title:"The date and time each transaction was made"},"Processed On"),type:()=>t("th",{part:P,scope:"col",title:"The type of each transaction"},"Type"),id:()=>t("th",{part:P,scope:"col",title:"The unique identifier of each transaction"},"ID"),amount:()=>t("th",{part:P,scope:"col",title:"The dollar amount of each transaction",class:"text-end"},"Amount"),balance:()=>t("th",{part:P,scope:"col",title:"The running total amount of this payment that belongs to you",class:"text-end"},"Balance"),currency:()=>t("th",{part:P,scope:"col",title:"The currency of each transaction"},"Currency"),financial_transaction_id:()=>t("th",{part:P,scope:"col",title:"The unique identifier of the financial transaction associated with the payment balance transaction"},"Financial Transaction ID"),payment_id:()=>t("th",{part:P,scope:"col",title:"The unique identifier of the payment associated with the payment balance transaction"},"Payment ID"),payment_balance_txn_type:()=>t("th",{part:P,scope:"col",title:"The type of the payment balance transaction"},"Transaction Type"),source_id:()=>t("th",{part:P,scope:"col",title:"The unique identifier of the source object associated with the payment balance transaction"},"Source ID"),source_type:()=>t("th",{part:P,scope:"col",title:"The type of the source object associated with the payment balance transaction"},"Source Type")},S={ach_return:"ACH Return",ach_return_fee:"ACH Return Fee",dispute:"Dispute",dispute_fee:"Dispute Fee",dispute_fee_refund:"Dispute Fee Refund",dispute_refund:"Dispute Refund",payment:"Payment",payment_fee:"Fee",platform_fee:"Platform Fee",platform_fee_return:"Platform Fee Return",processing_fee:"Processing Fee",processing_fee_return:"Processing Fee Return",refund:"Refund",fee_refund:"Fee Refund",application_fee_returned:"Application Fee Returned",refund_failure:"Refund Failure",void:"Void"},B={created_at:(e,a)=>t("td",{part:R(a)},t("div",{class:"fw-bold"},F(e.created_at,{showDisplayDate:!0})),t("div",{class:"fw-bold"},F(e.created_at,{showTime:!0}))),type:(e,a)=>t("td",{part:R(a)},S[e.payment_balance_txn_type]),id:(e,a)=>t("td",{part:R(a)},e.id),amount:(e,a)=>t("td",{part:R(a),class:"text-end"},e.formattedPaymentAmount(e.amount)),balance:(e,a)=>t("td",{part:R(a),class:"text-end"},e.formattedPaymentAmount(e.balance)),currency:(e,a)=>t("td",{part:R(a)},e.currency),financial_transaction_id:(e,a)=>t("td",{part:R(a)},e.financial_transaction_id),payment_id:(e,a)=>t("td",{part:R(a)},e.payment_id),payment_balance_txn_type:(e,a)=>t("td",{part:R(a)},e.payment_balance_txn_type),source_id:(e,a)=>t("td",{part:R(a)},e.source_id),source_type:(e,a)=>t("td",{part:R(a)},e.source_type)},O=class{constructor(t){e(this,t),this.clickEvent=a(this,"click-event",7),this.errorEvent=a(this,"error-event",7),this.balanceTransactions=[],this.isLoading=!0,this.errorMessage=null,this.paging=n,this.pagingParams={},this.columns="created_at,type,id,amount,balance",this.handleClickPrevious=t=>{this.pagingParams={before_cursor:t},this.clickEvent.emit({name:C.previous})},this.handleClickNext=t=>{this.pagingParams={after_cursor:t},this.clickEvent.emit({name:C.next})},this.rowClickHandler=t=>{const e=t.target.closest("tr").dataset.rowEntityId;if(!e)return;const a=this.balanceTransactions.find((t=>t.id===e));this.clickEvent.emit({name:C.row,data:a})}}componentWillLoad(){this.transactionsTable=new f(this.balanceTransactions,this.columns,x,B),c(),this.analytics=new o(this),this.initializeApi()}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}propChanged(){this.initializeApi()}handleError(t,e,a){this.isLoading=!1,this.errorEvent.emit({errorCode:t,message:e,severity:a})}initializeApi(){this.paymentId&&this.authToken?(({id:t,authToken:e,service:a})=>async({params:r,onSuccess:n,onError:o,final:c})=>{var d;try{const c=await a.fetchPaymentTransactions(t,e,r);c.error?o({error:h(c.error),code:p(null===(d=c.error)||void 0===d?void 0:d.code),severity:i.ERROR}):n({balanceTransactions:c.data.map((t=>new s(t))),pagingInfo:Object.assign({},c.page_info)})}catch(t){const e=p(null==t?void 0:t.code);o({error:h(t),code:e,severity:i.ERROR})}finally{c()}})({id:this.paymentId,authToken:this.authToken,service:new d})({params:this.pagingParams,onSuccess:({balanceTransactions:t,pagingInfo:e})=>{this.balanceTransactions=t,this.paging=e,this.transactionsTable.collectionData=this.balanceTransactions},onError:({error:t,code:e,severity:a})=>{this.errorMessage=t.message,this.handleError(t,e,a)},final:()=>{this.isLoading=!1}}):(this.errorMessage="payment-id and auth-token props are required",this.handleError(r.MISSING_PROPS,this.errorMessage,i.ERROR))}get entityId(){return this.balanceTransactions.map((t=>t.id))}get showEmptyState(){return!this.isLoading&&!this.errorMessage&&this.transactionsTable.rowData.length<1}get showErrorState(){return!this.isLoading&&!!this.errorMessage}get showRowData(){return!this.showEmptyState&&!this.showErrorState&&!this.isLoading}render(){return t(D,{key:"0f3e26b2c3f60508208665182d225851b661ce52"},t(l,{key:"cec0e06941349943965f48f1724891b08eb2a9f0"},t(u,{key:"0cc4ed8dba379a5007129098d9fafc666771bd68"},t(m,{key:"2cf86dc1d70add019c7a60a19776926987c6669d"},t(y,{key:"26ee0bade994b3f103fbf143974095e24df3100f"},this.transactionsTable.columnData.map((t=>t)))),t(b,{key:"68e61b6f6ce309c66444868cc76fa5d5975cbf51"},t(_,{key:"d71b0929a60dd74f1cd14e4bbafe2030f50fdd1f",columnSpan:this.transactionsTable.columnKeys.length,isLoading:this.isLoading}),t(g,{key:"cb9ff5c2f19c506cb04dd0ff89e1ac3b2d9477cc",isEmpty:this.showEmptyState,columnSpan:this.transactionsTable.columnKeys.length}),t(j,{key:"cc194ed6bd9985ecc11052159636abf93d72baa1",columnSpan:this.transactionsTable.columnKeys.length,errorMessage:this.errorMessage}),this.showRowData&&this.transactionsTable.rowData.map(((e,a)=>t(T,{"data-test-id":"table-row","data-row-entity-id":this.entityId[a],onClick:this.rowClickHandler},e)))),this.paging&&t(w,{key:"466be6cad4dc5aa82d492758845a36ab7ded07cb"},t(k,{key:"635a3e29fd03027eae0430afe0777905342bda35"},t(v,{key:"87cacd49245ab6e07ae7c2adef2cb26561fae1c6",colSpan:this.transactionsTable.columnData.length},t("pagination-menu",{key:"3b54af40f5aa9ac5e1198fc52218ec887cbd4e59",paging:Object.assign(Object.assign({},this.paging),{handleClickPrevious:this.handleClickPrevious,handleClickNext:this.handleClickNext})})))))))}static get watchers(){return{pagingParams:["propChanged"],paymentId:["propChanged"],authToken:["propChanged"]}}};export{O as justifi_payment_transactions_list}
1
+ import{h as t,r as e,c as a}from"./p-CV0Pyo1O.js";import"./p-B4vLfYnZ.js";import"./p-HXpYMWUU.js";import{j as s,C as i,b as r}from"./p-D6uhYbLo.js";import{p as n}from"./p-CLHwhyvu.js";import"./p-DaDqgDrb.js";import{J as o}from"./p-nbKvRcwU.js";import{c}from"./p-BEL8sLz6.js";import{g as p,a as h}from"./p-CLq3Og7o.js";import{P as d}from"./p-BAKuMxC9.js";import{T as f,a as l,b as u,c as m,d as b,e as y,f as _,g,h as j,i as T,j as w,k,l as v}from"./p-DZr0wLGh.js";import{S as C}from"./p-05AWudQe.js";import{T as D}from"./p-CZfYo5-1.js";import{a as P}from"./p-Ds_P-dB8.js";import{a6 as R,a7 as F}from"./p-Bu7gdOaV.js";import"./p-DgTOxu8x.js";import"./p-CAVi_ne1.js";import"./p-vIQBTQmc.js";import"./p-MPer3Rw7.js";const x={created_at:()=>t("th",{part:R,scope:"col",title:"The date and time each transaction was made"},"Processed On"),type:()=>t("th",{part:R,scope:"col",title:"The type of each transaction"},"Type"),id:()=>t("th",{part:R,scope:"col",title:"The unique identifier of each transaction"},"ID"),amount:()=>t("th",{part:R,scope:"col",title:"The dollar amount of each transaction",class:"text-end"},"Amount"),balance:()=>t("th",{part:R,scope:"col",title:"The running total amount of this payment that belongs to you",class:"text-end"},"Balance"),currency:()=>t("th",{part:R,scope:"col",title:"The currency of each transaction"},"Currency"),financial_transaction_id:()=>t("th",{part:R,scope:"col",title:"The unique identifier of the financial transaction associated with the payment balance transaction"},"Financial Transaction ID"),payment_id:()=>t("th",{part:R,scope:"col",title:"The unique identifier of the payment associated with the payment balance transaction"},"Payment ID"),payment_balance_txn_type:()=>t("th",{part:R,scope:"col",title:"The type of the payment balance transaction"},"Transaction Type"),source_id:()=>t("th",{part:R,scope:"col",title:"The unique identifier of the source object associated with the payment balance transaction"},"Source ID"),source_type:()=>t("th",{part:R,scope:"col",title:"The type of the source object associated with the payment balance transaction"},"Source Type")},S={ach_return:"ACH Return",ach_return_fee:"ACH Return Fee",dispute:"Dispute",dispute_fee:"Dispute Fee",dispute_fee_refund:"Dispute Fee Refund",dispute_refund:"Dispute Refund",payment:"Payment",payment_fee:"Fee",platform_fee:"Platform Fee",platform_fee_return:"Platform Fee Return",processing_fee:"Processing Fee",processing_fee_return:"Processing Fee Return",refund:"Refund",fee_refund:"Fee Refund",application_fee_returned:"Application Fee Returned",refund_failure:"Refund Failure",void:"Void"},I={created_at:(e,a)=>t("td",{part:F(a)},t("div",{class:"fw-bold"},P(e.created_at,{showDisplayDate:!0})),t("div",{class:"fw-bold"},P(e.created_at,{showTime:!0}))),type:(e,a)=>t("td",{part:F(a)},S[e.payment_balance_txn_type]),id:(e,a)=>t("td",{part:F(a)},e.id),amount:(e,a)=>t("td",{part:F(a),class:"text-end"},e.formattedPaymentAmount(e.amount)),balance:(e,a)=>t("td",{part:F(a),class:"text-end"},e.formattedPaymentAmount(e.balance)),currency:(e,a)=>t("td",{part:F(a)},e.currency),financial_transaction_id:(e,a)=>t("td",{part:F(a)},e.financial_transaction_id),payment_id:(e,a)=>t("td",{part:F(a)},e.payment_id),payment_balance_txn_type:(e,a)=>t("td",{part:F(a)},e.payment_balance_txn_type),source_id:(e,a)=>t("td",{part:F(a)},e.source_id),source_type:(e,a)=>t("td",{part:F(a)},e.source_type)},L=class{constructor(t){e(this,t),this.clickEvent=a(this,"click-event",7),this.errorEvent=a(this,"error-event",7),this.balanceTransactions=[],this.isLoading=!0,this.errorMessage=null,this.paging=n,this.pagingParams={},this.columns="created_at,type,id,amount,balance",this.handleClickPrevious=t=>{this.pagingParams={before_cursor:t},this.clickEvent.emit({name:D.previous})},this.handleClickNext=t=>{this.pagingParams={after_cursor:t},this.clickEvent.emit({name:D.next})},this.rowClickHandler=t=>{const e=t.target.closest("tr").dataset.rowEntityId;if(!e)return;const a=this.balanceTransactions.find((t=>t.id===e));this.clickEvent.emit({name:D.row,data:a})}}componentWillLoad(){this.transactionsTable=new f(this.balanceTransactions,this.columns,x,I),c(),this.analytics=new o(this),this.initializeApi()}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}propChanged(){this.initializeApi()}handleError(t,e,a){this.isLoading=!1,this.errorEvent.emit({errorCode:t,message:e,severity:a})}initializeApi(){this.paymentId&&this.authToken?(({id:t,authToken:e,service:a})=>async({params:r,onSuccess:n,onError:o,final:c})=>{var d;try{const c=await a.fetchPaymentTransactions(t,e,r);c.error?o({error:h(c.error),code:p(null===(d=c.error)||void 0===d?void 0:d.code),severity:i.ERROR}):n({balanceTransactions:c.data.map((t=>new s(t))),pagingInfo:Object.assign({},c.page_info)})}catch(t){const e=p(null==t?void 0:t.code);o({error:h(t),code:e,severity:i.ERROR})}finally{c()}})({id:this.paymentId,authToken:this.authToken,service:new d})({params:this.pagingParams,onSuccess:({balanceTransactions:t,pagingInfo:e})=>{this.balanceTransactions=t,this.paging=e,this.transactionsTable.collectionData=this.balanceTransactions},onError:({error:t,code:e,severity:a})=>{this.errorMessage=t.message,this.handleError(t,e,a)},final:()=>{this.isLoading=!1}}):(this.errorMessage="payment-id and auth-token props are required",this.handleError(r.MISSING_PROPS,this.errorMessage,i.ERROR))}get entityId(){return this.balanceTransactions.map((t=>t.id))}get showEmptyState(){return!this.isLoading&&!this.errorMessage&&this.transactionsTable.rowData.length<1}get showErrorState(){return!this.isLoading&&!!this.errorMessage}get showRowData(){return!this.showEmptyState&&!this.showErrorState&&!this.isLoading}render(){return t(C,{key:"f8b0f3a58ef7f88c0ac42fc58955b28ad97922e4"},t(l,{key:"2dc653b63611cbdfa388b386cec9b3adf751bd12"},t(u,{key:"a0bd64c01870ccd4bb921d5d90c7453650131f16"},t(m,{key:"b92ce24dab41cbaf1d8ecb1df43739d2548fe73f"},t(b,{key:"5f983b93b2b9b6661cae2cf74802519175aae8cc"},this.transactionsTable.columnData.map((t=>t)))),t(y,{key:"d9a51ecfc54c16a4859f9d66fb783f3876fc3428"},t(_,{key:"232f1b59ddeb9f949901678a67c652cc3aedfdf7",columnSpan:this.transactionsTable.columnKeys.length,isLoading:this.isLoading}),t(g,{key:"bd9a853887da939c651c234cd4f0e3ab35d610d1",isEmpty:this.showEmptyState,columnSpan:this.transactionsTable.columnKeys.length}),t(j,{key:"da157eb9d18d89353f6aebb085bb4becb15ac89f",columnSpan:this.transactionsTable.columnKeys.length,errorMessage:this.errorMessage}),this.showRowData&&this.transactionsTable.rowData.map(((e,a)=>t(T,{"data-test-id":"table-row","data-row-entity-id":this.entityId[a],onClick:this.rowClickHandler},e)))),this.paging&&t(w,{key:"41ffc1c9d3591dad7973f862b78b488e089af863"},t(k,{key:"17780690e1b44eb6ba13128d3ecfee73c6be06a7"},t(v,{key:"312b9a0b9649ffd9033ec1333b2d9d8eb666d185",colSpan:this.transactionsTable.columnData.length},t("pagination-menu",{key:"4ef805672cf530850ecdf13e26eefc8015f80fa3",paging:Object.assign(Object.assign({},this.paging),{handleClickPrevious:this.handleClickPrevious,handleClickNext:this.handleClickNext})})))))))}static get watchers(){return{pagingParams:["propChanged"],paymentId:["propChanged"],authToken:["propChanged"]}}};export{L as justifi_payment_transactions_list}
@@ -1 +1 @@
1
- import{r as t,c as e,h as i,H as s,g as a}from"./p-CV0Pyo1O.js";import{A as n}from"./p-Bl00tHyn.js";import{A as o,r,s as l,t as h,u as c,v as d,w as u,C as p,b as y,c as m,I as v,x as f,y as g,z as b}from"./p-D6uhYbLo.js";import{S as M}from"./p-05AWudQe.js";import"./p-CZfYo5-1.js";import{S as w}from"./p-eBK-iWrz.js";import{c as k,o as P,a as j,g as C,b as T}from"./p-Fpaf7CLD.js";import{t as A,r as E}from"./p-Bu7gdOaV.js";import{f as I}from"./p-Ds_P-dB8.js";import{w as N,c as D}from"./p-B4vLfYnZ.js";import{H as S}from"./p-CZk3i5Tu.js";import{H as O,b as L,h as x,i as z}from"./p-x2oNTAWh.js";import{H as _}from"./p-BAB1lPu0.js";import{J as R}from"./p-BHaO3c8W.js";import{c as U}from"./p-ByQMBEDC.js";import"./p-HXpYMWUU.js";import"./p-CLHwhyvu.js";import"./p-DaDqgDrb.js";import{m as B,a as Y}from"./p-CXsRwohv.js";import{C as F}from"./p-DsvK2pes.js";import{P as Q}from"./p-CKgQN8v0.js";import{P as V,a as H,b as W}from"./p-DEx8fQeW.js";import{C as Z}from"./p-ZpPDShvP.js";import"./p-Dn9_7aQh.js";import"./p-DgTOxu8x.js";import"./p-CLq3Og7o.js";const G=class{constructor(i){t(this,i),this.radioClick=e(this,"radio-click",7),this.checked=!1,this.hidden=!1}render(){return i(M,{key:"02955940079320bd9c6bf94e239545385ac36458"},i("radio-list-item",{key:"fc6b98e456e4326b843b2b3248b7327436767cf4",name:this.name,value:this.value,label:this.label,checked:this.checked,hidden:this.hidden,class:this.class,"onRadio-click":t=>this.radioClick.emit(t.detail)}))}};var q;!function(t){t.UNAVAILABLE="UNAVAILABLE",t.SESSION_ERROR="SESSION_ERROR",t.MERCHANT_VALIDATION_ERROR="MERCHANT_VALIDATION_ERROR",t.PAYMENT_PROCESSING_ERROR="PAYMENT_PROCESSING_ERROR",t.USER_CANCELLED="USER_CANCELLED"}(q||(q={}));class J{constructor(){this.api=n()}initialize(t){if(this.applePayConfig=new o(t),!this.applePayConfig.isValid)throw new Error("Invalid Apple Pay configuration provided")}async validateMerchant(t,e){try{return await this.api.post({endpoint:"apple_pay/merchant_session",authToken:t,headers:{"Sub-Account":e},body:{domain:window.location.hostname,display_name:this.applePayConfig.displayName}})}catch(t){throw console.error("Backend validation failed:",t),new Error("Merchant validation failed")}}async processPayment(t,e,i){const s=await this.api.post({endpoint:"apple_pay/process_token",authToken:t,body:i,headers:{"Sub-Account":e}});return{success:s.id&&!!s.data.token,data:s}}isAvailable(){return r.isApplePaySupported()&&r.canMakePayments()}async canMakePaymentsWithActiveCard(){if(!this.applePayConfig)throw new Error("Apple Pay not initialized. Call initialize() first.");return await r.canMakePaymentsWithActiveCard(this.applePayConfig.merchantIdentifier)}async startPaymentSession(t,e,i){if(!this.applePayConfig)throw console.error("[ApplePayService] Missing applePayConfig. Did you call initialize()?"),new Error("Apple Pay not initialized. Call initialize() first.");const s=new l(t);if(!s.isValid){const t=[];throw s.countryCode||t.push("countryCode"),s.currencyCode||t.push("currencyCode"),s.merchantCapabilities&&0!==s.merchantCapabilities.length||t.push("merchantCapabilities"),s.supportedNetworks&&0!==s.supportedNetworks.length||t.push("supportedNetworks"),s.total&&s.total.label&&s.total.amount||t.push("total"),console.error("[ApplePayService] Payment request is invalid. Missing/invalid:",t),new Error("Invalid payment request provided")}return this.currentPaymentRequest=s,new Promise(((t,a)=>{try{if("undefined"==typeof window||!("ApplePaySession"in window))return console.error("[ApplePayService] ApplePaySession not available on window"),a({success:!1,error:{code:q.UNAVAILABLE,message:"ApplePaySession API is not available in this environment"}});this.currentSession=new window.ApplePaySession(3,s),this.setupSessionEventHandlers(t,a,e,i),this.currentSession.begin()}catch(t){console.error("[ApplePayService] Exception while starting session:",t),a({success:!1,error:{code:q.SESSION_ERROR,message:t instanceof Error?t.message:"Failed to start Apple Pay session"}})}}))}abortPaymentSession(){this.currentSession&&(this.currentSession.abort(),this.currentSession=void 0,this.currentPaymentRequest=void 0)}setupSessionEventHandlers(t,e,i,s){this.currentSession&&this.applePayConfig&&this.currentPaymentRequest?(this.currentSession.onvalidatemerchant=async()=>{try{if(!i)throw console.error("[ApplePayService] Missing authToken for merchant validation"),new Error("Authentication token not provided.");const t=await this.validateMerchant(i,s);try{this.currentSession.completeMerchantValidation(t)}catch(t){throw console.error("Error calling completeMerchantValidation:",t),t}}catch(t){console.error("=== MERCHANT VALIDATION ERROR ==="),console.error("Error during merchant validation:",t),t&&t.stack&&console.error("Error stack:",t.stack),this.currentSession.abort(),e({success:!1,error:{code:q.MERCHANT_VALIDATION_ERROR,message:t instanceof Error?t.message:"Merchant validation failed"}})}},this.currentSession.onpaymentauthorized=async a=>{try{const n=a.payment,o=Object.assign(Object.assign({},n.token),{product_details:{name:this.currentPaymentRequest.total.label,price:r.parseAmount(this.currentPaymentRequest.total.amount),description:this.currentPaymentRequest.total.label}}),l=await this.processPayment(i,s,o);l.success?(this.currentSession.completePayment({status:h.STATUS_SUCCESS}),t({success:!0,token:n.token,paymentMethodId:l.data.id})):(console.error("PSP reported payment failure:",l.data),this.currentSession.completePayment({status:h.STATUS_FAILURE}),e({success:!1,error:{code:q.PAYMENT_PROCESSING_ERROR,message:"Payment processing failed"}}))}catch(t){console.error("=== PAYMENT PROCESSING ERROR ==="),console.error("Error processing payment:",t),t&&t.stack&&console.error("Error stack:",t.stack),this.currentSession.completePayment({status:h.STATUS_FAILURE}),e({success:!1,error:{code:q.PAYMENT_PROCESSING_ERROR,message:t instanceof Error?t.message:"Payment processing failed"}})}finally{this.currentSession=void 0,this.currentPaymentRequest=void 0}},this.currentSession.onpaymentmethodselected=()=>{const t={newTotal:this.currentPaymentRequest.total,newLineItems:this.currentPaymentRequest.lineItems||[]};try{this.currentSession.completePaymentMethodSelection(t)}catch(t){console.error("Error completing payment method selection:",t),this.currentSession.abort()}},this.currentSession.onshippingmethodselected=()=>{this.currentSession.completeShippingMethodSelection({status:h.STATUS_SUCCESS,newTotal:this.currentPaymentRequest.total,newLineItems:this.currentPaymentRequest.lineItems||[]})},this.currentSession.oncancel=t=>{if(t.sessionError)switch(console.error(t.sessionError),t.sessionError.code){case"unknown":console.error("Unknown error - likely merchant validation issue"),console.error("This usually means:"),console.error("1. Merchant certificate is invalid or expired"),console.error("2. Merchant identifier mismatch"),console.error("3. Backend validation endpoint issues");break;case"invalidMerchantSession":console.error("Invalid merchant session provided"),console.error("Check that the merchant session from backend is valid");break;case"userCancel":console.error("User cancelled the payment");break;default:console.error("Other error code:",t.sessionError.code)}this.currentSession=void 0,this.currentPaymentRequest=void 0,e({success:!1,error:{code:q.USER_CANCELLED,message:"User cancelled the Apple Pay session"}})},"onerror"in this.currentSession&&(this.currentSession.onerror=t=>{console.error("=== APPLE PAY SESSION ERROR ==="),console.error("Session error:",t),this.currentSession=void 0,this.currentPaymentRequest=void 0,e({success:!1,error:{code:q.SESSION_ERROR,message:"Apple Pay session error occurred"}})})):console.error("[ApplePayService] setupSessionEventHandlers called without required state",{hasSession:Boolean(this.currentSession),hasConfig:Boolean(this.applePayConfig),hasPaymentRequest:Boolean(this.currentPaymentRequest)})}static createPaymentRequest(t,e,i="US",s="USD"){return{countryCode:i,currencyCode:s,merchantCapabilities:r.getDefaultMerchantCapabilities(),supportedNetworks:r.getDefaultSupportedNetworks(),total:r.createLineItem(e,t)}}getApplePayConfig(){return this.applePayConfig}}const K=t=>{const{isLoading:e}=t;return e?i("div",{class:"container-fluid p-0"},i("div",{class:"row mb-3"},i("div",{class:"col-12 align-content-center"},i(w,{height:"44px",width:"100%",styles:{borderRadius:"8px"}})))):null},$=t=>i("div",{class:"apple-pay-button-container"},i("button",Object.assign({class:(()=>{let e="apple-pay-button";switch(t.buttonStyle){case c.WHITE:e+=" apple-pay-button-white";break;case c.WHITE_OUTLINE:e+=" apple-pay-button-white-outline";break;default:e+=" apple-pay-button-black"}switch(t.buttonType){case d.BUY:e+=" apple-pay-button-type-buy";break;case d.DONATE:e+=" apple-pay-button-type-donate";break;default:e+=" apple-pay-button-type-plain"}return(t.disabled||t.isProcessing||!t.isAvailable)&&(e+=" disabled"),e})(),style:{width:t.width,height:t.height},onClick:()=>{!t.disabled&&!t.isProcessing&&t.isAvailable&&t.clickHandler&&t.clickHandler()},disabled:t.disabled||t.isProcessing||!t.isAvailable,"aria-label":"Pay with Apple Pay",type:"button"},t),t.isProcessing&&i("div",{class:"processing-overlay"},i("div",{class:"spinner"}),i("span",null,"Processing..."))),i("style",null,"\n .apple-pay-button-container {\n display: block;\n position: relative;\n width: 100%;\n }\n\n /* Apple Pay CSS classes - these are the official Apple Pay button styles */\n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: plain; /* default */\n -apple-pay-button-style: black; /* default */\n border-radius: 8px;\n cursor: pointer;\n border: none;\n outline: none;\n transition: opacity 0.2s ease;\n position: relative;\n }\n\n /* Button styles */\n .apple-pay-button.apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n\n .apple-pay-button.apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n\n .apple-pay-button.apple-pay-button-white-outline {\n -apple-pay-button-style: white-outline;\n }\n\n /* Button types */\n .apple-pay-button.apple-pay-button-type-plain {\n -apple-pay-button-type: plain;\n }\n\n .apple-pay-button.apple-pay-button-type-buy {\n -apple-pay-button-type: buy;\n }\n\n .apple-pay-button.apple-pay-button-type-donate {\n -apple-pay-button-type: donate;\n }\n\n /* Hover and disabled states */\n .apple-pay-button:hover:not(.disabled) {\n opacity: 0.9;\n }\n\n .apple-pay-button.disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n /* Processing overlay */\n .processing-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n background: rgba(0, 0, 0, 0.8);\n color: white;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n }\n\n .spinner {\n width: 16px;\n height: 16px;\n border: 2px solid rgba(255, 255, 255, 0.3);\n border-top: 2px solid #fff;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n\n /* Responsive design */\n @media (max-width: 480px) {\n .apple-pay-button {\n width: 100% !important;\n min-width: 200px;\n }\n }\n ")),X=class{constructor(i){t(this,i),this.applePayStarted=e(this,"applePayStarted",7),this.applePayCompleted=e(this,"applePayCompleted",7),this.applePayCancelled=e(this,"applePayCancelled",7),this.applePayError=e(this,"applePayError",7),this.sdkLoaded=!1,this.countryCode="US",this.merchantIdentifier="merchant.com.staging-justifi.checkout-dev",this.merchantDisplayName="JustiFi Checkout",this.initiativeContext="dev-checkout.justifi-staging.com",this.buttonType=d.PLAIN,this.buttonStyle=c.BLACK,this.disabled=!1,this.width="100%",this.height="48px",this.isLoading=!0,this.isProcessing=!1,this.isAvailable=!1,this.canMakePayments=!1,this.isConfigValid=!0,this.error=null,this.handleApplePayClick=async()=>{var t,e,i;if(!this.isProcessing&&!this.disabled&&this.isAvailable)try{this.isProcessing=!0,this.error=null,this.applePayStarted.emit();const i={countryCode:this.countryCode,currencyCode:k.paymentCurrency,merchantCapabilities:[u.SUPPORTS_3DS,u.SUPPORTS_CREDIT,u.SUPPORTS_DEBIT],supportedNetworks:r.getDefaultSupportedNetworks(),total:r.createLineItem(k.paymentDescription,k.paymentAmount)},s=await this.applePayService.startPaymentSession(i,k.authToken,k.accountId);s.success?this.applePayCompleted.emit({success:!0,token:s.token,paymentMethodId:s.paymentMethodId}):(this.applePayCompleted.emit({success:!1,error:s.error}),this.applePayError.emit({error:(null===(t=s.error)||void 0===t?void 0:t.message)||"Payment failed",code:(null===(e=s.error)||void 0===e?void 0:e.code)||X.ErrorCode.PAYMENT_FAILED}))}catch(t){if((null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.code)===q.USER_CANCELLED)this.applePayCancelled.emit();else{const e=t instanceof Error?t.message:"Payment failed";this.error=e,this.applePayError.emit({error:e,code:X.ErrorCode.PAYMENT_FAILED}),this.applePayCompleted.emit({success:!1,error:e})}}finally{this.isProcessing=!1}}}componentWillLoad(){this.isAvailable=r.isApplePaySupported(),this.isAvailable?k.checkoutLoaded?this.loadApplePaySDK():P("checkoutLoaded",(t=>{t&&this.loadApplePaySDK()})):this.isLoading=!1}loadApplePaySDK(){if(this.sdkLoaded)return;this.sdkLoaded=!0;const t=document.createElement("script");t.src="https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",t.async=!0,t.onload=()=>this.initializeApplePay(),document.head.appendChild(t)}async initializeApplePay(){try{if(this.isLoading=!0,this.error=null,this.isConfigValid=!0,!(Boolean(k.paymentAmount)&&Boolean(k.paymentCurrency)&&Boolean(k.authToken)))return this.error="Missing required Apple Pay configuration",this.isConfigValid=!1,this.applePayError.emit({error:this.error,code:X.ErrorCode.CONFIG_ERROR}),void(this.isLoading=!1);if(this.isAvailable=r.isApplePaySupported(),this.canMakePayments=r.canMakePayments(),!this.isAvailable)return this.error="Apple Pay is not supported on this device",this.applePayError.emit({error:this.error,code:X.ErrorCode.NOT_SUPPORTED}),void(this.isLoading=!1);if(!this.canMakePayments)return this.error="Apple Pay is not available",this.applePayError.emit({error:this.error,code:X.ErrorCode.NOT_AVAILABLE}),void(this.isLoading=!1);const t={merchantIdentifier:this.merchantIdentifier,displayName:this.merchantDisplayName,initiative:"web",initiativeContext:this.initiativeContext,buttonType:this.buttonType,buttonStyle:this.buttonStyle};this.applePayService=new J,this.applePayService.initialize(t),await this.applePayService.canMakePaymentsWithActiveCard()||console.warn("No Apple Pay cards available, but continuing...")}catch(t){this.error=t instanceof Error?t.message:"Failed to initialize Apple Pay",this.applePayError.emit({error:this.error,code:X.ErrorCode.INITIALIZATION_ERROR})}finally{this.isLoading=!1}}async isSupported(){return this.isAvailable&&this.canMakePayments}async getPaymentMethods(){return this.isAvailable?r.getDefaultSupportedNetworks():[]}async abort(){var t;null===(t=this.applePayService)||void 0===t||t.abortPaymentSession(),this.isProcessing=!1,this.applePayCancelled.emit()}render(){if(!k.applePayEnabled)return null;if(!this.isAvailable)return null;const t=!this.isLoading&&this.isAvailable&&this.canMakePayments&&this.isConfigValid;return i(M,null,i("div",{class:"apple-pay-container"},i(K,{isLoading:this.isLoading}),t&&i($,{buttonType:this.buttonType,buttonStyle:this.buttonStyle,disabled:this.disabled,isProcessing:this.isProcessing,isAvailable:this.isAvailable,clickHandler:this.handleApplePayClick,width:this.width,height:this.height})),i("style",null,"\n .apple-pay-container {\n width: 100%;\n }\n "))}};X.ErrorCode={CONFIG_ERROR:"CONFIG_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",NOT_AVAILABLE:"NOT_AVAILABLE",INITIALIZATION_ERROR:"INITIALIZATION_ERROR",PAYMENT_FAILED:"PAYMENT_FAILED"};const tt=class{constructor(e){t(this,e),this.variant="primary",this.type="button"}render(){return i(M,{key:"fafd798e951f401204004138571fce414f3bb428"},i("internal-button",{key:"eda77ddbd02a38370f79e58d52d2824631517666",text:this.text,variant:this.variant,isLoading:this.isLoading,clickHandler:this.clickHandler,type:this.type,disabled:this.disabled,class:this.class,customStyle:this.customStyle,hidden:this.hidden}))}},et=class{constructor(e){t(this,e)}render(){return i(M,{key:"7d3447ff4daa9bf4f603ca381027b3f43cfcc6a1"},i("section",{key:"1c8189ccde6dc986ad2d4c74da2dd10cacfc1c36"},i("div",{key:"45e6d5f47d8a92e0bd4a7bfa427630a96f049b4a"},i("div",{key:"9900b5fd770cd59b00803c3614216c16a803da41",part:A},null==k?void 0:k.paymentDescription),i("div",{key:"16cec140ef6912533a80b1f6341fcc9cb341b478"},i("span",{key:"f8883538c99a524017bb102bfd8cfaea7062e650",part:A},"Total")," ",i("span",{key:"11baa64630a60c56cedfa53548c107ec3fe3c0f5",part:A},I(+(null==k?void 0:k.totalAmount)))))))}},it=t=>{const{isLoading:e}=t;return e?i("div",{class:"container-fluid p-0"},i("div",{class:"row mb-3"},i("div",{class:"col-12 align-content-center"},i(w,{height:"44px",width:"100%",styles:{borderRadius:"8px"}})))):null};var st;!function(t){t.initialize="justifi.googlePay.initialize",t.ready="justifi.googlePay.ready",t.sdkLoaded="justifi.googlePay.sdkLoaded",t.initializeResult="justifi.googlePay.initializeResult",t.error="justifi.googlePay.error",t.buttonClicked="justifi.googlePay.buttonClicked",t.startPayment="justifi.googlePay.startPayment",t.paymentSuccess="justifi.googlePay.paymentSuccess",t.paymentCanceled="justifi.googlePay.paymentCanceled",t.paymentError="justifi.googlePay.paymentError"}(st||(st={}));const at=class{constructor(i){t(this,i),this.googlePayStarted=e(this,"googlePayStarted",7),this.googlePayCompleted=e(this,"googlePayCompleted",7),this.googlePayCancelled=e(this,"googlePayCancelled",7),this.merchantDisplayName="JustiFi Checkout",this.useNativePaymentRequest=!1,this.iframeReady=!1,this.sdkLoaded=!1,this.isReadyToPay=!1,this.handleMessage=t=>{if(t.origin!==this.iframeOrigin)return;const{eventType:e,data:i}=t.data||{};switch(e){case st.ready:this.iframeReady=!0;break;case st.sdkLoaded:this.sdkLoaded=!0,this.sendInitialize();break;case st.initializeResult:this.isReadyToPay=i.isReadyToPay,i.error&&console.error("Init error:",i.error);break;case st.error:console.error("Google Pay error:",i);break;case st.buttonClicked:this.googlePayStarted.emit(),this.sendStartPayment();break;case st.paymentSuccess:this.googlePayCompleted.emit({success:!0,paymentMethodId:i.paymentMethodId,cardNetwork:i.cardNetwork,cardDetails:i.cardDetails});break;case st.paymentCanceled:this.googlePayCancelled.emit();break;case st.paymentError:this.googlePayCompleted.emit({success:!1,error:{code:i.code,message:i.message}})}}}async componentWillLoad(){await N(),this.iframeOrigin=D.iframeOrigin}componentDidLoad(){window.addEventListener("message",this.handleMessage)}disconnectedCallback(){window.removeEventListener("message",this.handleMessage)}googlePayEnvironment(){return void 0!==this.environment?this.environment:"test"===k.checkoutMode?"TEST":"PRODUCTION"}sendInitialize(){var t;if(!(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow))return;const e={environment:this.googlePayEnvironment(),gatewayMerchantId:k.accountId,merchantName:this.merchantDisplayName,authToken:k.authToken,accountId:k.accountId,useNativePaymentRequest:this.useNativePaymentRequest};this.iframeElement.contentWindow.postMessage({eventType:st.initialize,data:e},this.iframeOrigin)}sendStartPayment(){var t;if(!(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow))return;const e={totalPrice:String(k.paymentAmount/100),totalPriceStatus:"FINAL",currencyCode:k.paymentCurrency||"USD"};this.iframeElement.contentWindow.postMessage({eventType:st.startPayment,data:e},this.iframeOrigin)}render(){return k.checkoutLoaded?k.googlePayEnabled?i(s,null,i(it,{isLoading:!this.isReadyToPay}),i("iframe",{ref:t=>this.iframeElement=t,src:`${this.iframeOrigin}/v2/googlePay`,allow:"payment",style:{border:"none",width:"100%",height:"48px",display:this.isReadyToPay?"block":"none"}})):(console.warn("Google Pay is not enabled for this checkout"),null):null}},nt=class{constructor(e){t(this,e),this.levels={h1:S,h2:O,h3:_},this.level="h1"}render(){return i(M,{key:"b51ffe7c6ff6de409396fd941d39321eb837665d"},i(this.levels[this.level],{key:"dfba7ab895567a38b6b08fc1b734bdb9e98afff5",text:this.text,class:this.class}))}},ot=class{constructor(i){t(this,i),this.errorEvent=e(this,"error-event",7),this.submitEvent=e(this,"submit-event",7),this.checkoutChangedEvent=e(this,"checkout-changed",7),this.plaidService=new Q,this.handlePaypalStarted=()=>{k.isWalletProcessing=!0},this.handlePaypalCompleted=t=>{const{success:e,paymentMethodId:i,fundingSource:s}=t.detail||{};k.isWalletProcessing=!1,e&&i?(k.paymentToken=i,k.selectedPaymentMethod={type:"venmo"===s?V.VENMO:V.PAYPAL},this.submitCheckout()):this.errorEvent.emit({message:"Paypal payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})},this.handlePaypalCancelled=()=>{k.isWalletProcessing=!1,k.paymentToken=void 0,k.selectedPaymentMethod=void 0},this.handlePaypalError=t=>{k.isWalletProcessing=!1;const{error:e,code:i}=t.detail||{};this.errorEvent.emit({message:e||"Paypal error occurred",errorCode:`PAYPAL_${i}`,severity:p.ERROR})},this.handleApplePayStarted=()=>{k.isWalletProcessing=!0},this.handleGooglePayStarted=()=>{k.isWalletProcessing=!0},this.handleGooglePayCompleted=t=>{const{success:e,paymentMethodId:i,error:s}=t.detail||{};e&&i?(k.isWalletProcessing=!1,k.paymentToken=i,k.selectedPaymentMethod={type:V.GOOGLE_PAY},this.submitCheckout()):(k.isWalletProcessing=!1,this.errorEvent.emit({message:s&&s.message||"Google Pay payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR}))},this.handleGooglePayCancelled=()=>{k.isWalletProcessing=!1,k.paymentToken=void 0,k.selectedPaymentMethod=void 0},this.handleApplePayCompleted=t=>{const{success:e,token:i,paymentMethodId:s,error:a}=t.detail;e&&i?(k.isWalletProcessing=!1,k.paymentToken=s,k.selectedPaymentMethod={type:V.APPLE_PAY},this.submitCheckout()):(k.isWalletProcessing=!1,console.error("Apple Pay completed but failed:",a),this.errorEvent.emit({message:(null==a?void 0:a.message)||"Apple Pay payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR}))},this.handleApplePayError=t=>{k.isWalletProcessing=!1;const{error:e,code:i}=t.detail;console.error("Apple Pay error:",e),this.errorEvent.emit({message:e||"Apple Pay error occurred",errorCode:`APPLE_PAY_${i}`,severity:p.ERROR})},this.handleApplePayCancelled=()=>{k.isWalletProcessing=!1,k.paymentToken=void 0,k.selectedPaymentMethod=void 0}}connectedCallback(){var t;this.observer=new MutationObserver((()=>{this.queryFormRefs(),this.setupApplePayListeners(),this.setupGooglePayListeners(),this.setupPaypalListeners()})),this.observer.observe(this.hostEl,{childList:!0,subtree:!0}),k.checkoutId=this.checkoutId;const e={authToken:this.authToken,checkoutId:this.checkoutId,service:new F};this.getCheckout=B(e),this.completeCheckout=Y(e),null===(t=this.unsubscribeCheckoutChanges)||void 0===t||t.call(this),this.unsubscribeCheckoutChanges=j((()=>{this.emitCheckoutChanged()}))}componentWillLoad(){this.analytics=new R(this),U(),k.authToken=this.authToken,this.fetchCheckout(),L("set",(t=>{const e=z[t];void 0!==e&&x(t,e)&&this.fetchCheckout()}))}componentDidLoad(){this.queryFormRefs(),this.setupApplePayListeners(),this.setupGooglePayListeners(),this.setupPaypalListeners()}disconnectedCallback(){var t,e;null===(t=this.unsubscribeCheckoutChanges)||void 0===t||t.call(this),this.unsubscribeCheckoutChanges=void 0,null===(e=this.observer)||void 0===e||e.disconnect(),this.removeApplePayListeners(),this.removeGooglePayListeners(),this.removePaypalListeners()}fetchCheckout(){this.authToken&&this.checkoutId?this.getCheckout&&this.getCheckout({onSuccess:({checkout:t})=>{this.updateStore(t),t.status!==v.completed?t.status!==v.expired||this.errorEvent.emit({message:m.CHECKOUT_EXPIRED,errorCode:y.CHECKOUT_EXPIRED,severity:p.ERROR}):this.errorEvent.emit({message:m.CHECKOUT_ALREADY_COMPLETED,errorCode:y.CHECKOUT_ALREADY_COMPLETED,severity:p.ERROR})},onError:t=>{this.errorEvent.emit({message:t.message,errorCode:t.code,severity:t.severity})}}):this.errorEvent.emit({message:m.NOT_AUTHENTICATED,errorCode:y.NOT_AUTHENTICATED,severity:p.ERROR})}updateStore(t){var e,i,s,a,n,o,r,l,h,c,d,u,p,y,m;k.accountId=t.account_id;const v=null!=t.mode?String(t.mode).toLowerCase():"";k.checkoutMode="test"===v?"test":"live"===v?"live":null;const f=t.payment_methods.map((t=>new H(t))),g=Boolean(null===(e=t.payment_settings)||void 0===e?void 0:e.ach_payments);k.paymentMethods=f.filter((t=>t.type!==V.SAVED_BANK_ACCOUNT||g)),k.paymentMethodGroupId=t.payment_method_group_id,k.paymentDescription=t.payment_description,k.totalAmount=t.total_amount,k.paymentAmount=t.payment_amount,k.bnplEnabled=t.payment_settings.bnpl_payments,k.insuranceEnabled=null!==(i=t.payment_settings.insurance_payments)&&void 0!==i&&i,k.bankAccountVerification=null===(s=t.payment_settings)||void 0===s?void 0:s.bank_account_verification,k.applePayEnabled=null!==(n=null===(a=t.payment_settings)||void 0===a?void 0:a.apple_payments)&&void 0!==n&&n,k.googlePayEnabled=null!==(r=null===(o=t.payment_settings)||void 0===o?void 0:o.google_payments)&&void 0!==r&&r,k.paypalEnabled=null!==(h=null===(l=t.payment_settings)||void 0===l?void 0:l.paypal_payments)&&void 0!==h&&h,k.paypalProviderClientId=null!==(d=null===(c=t.paypal)||void 0===c?void 0:c.provider_client_id)&&void 0!==d?d:"",k.achPaymentsEnabled=g,k.bnplProviderClientId=null===(u=null==t?void 0:t.bnpl)||void 0===u?void 0:u.provider_client_id,k.bnplProviderMode=null===(p=null==t?void 0:t.bnpl)||void 0===p?void 0:p.provider_mode,k.bnplProviderApiVersion=null===(y=null==t?void 0:t.bnpl)||void 0===y?void 0:y.provider_api_version,k.bnplProviderCheckoutUrl=null===(m=null==t?void 0:t.bnpl)||void 0===m?void 0:m.provider_checkout_url,k.paymentCurrency=(t.payment_currency||k.paymentCurrency).toUpperCase(),k.checkoutLoaded=!0}emitCheckoutChanged(){const t={availablePaymentMethodTypes:C(),selectedPaymentMethod:k.selectedPaymentMethod,savedPaymentMethods:k.paymentMethods};this.checkoutChangedEvent.emit(t)}queryFormRefs(){if(this.billingFormRef=this.hostEl.querySelector("justifi-billing-form, justifi-bank-account-billing-form-simple, justifi-card-billing-form-simple, justifi-billing-form-full, justifi-tokenize-payment-method"),this.applePayRef=this.hostEl.querySelector("justifi-apple-pay"),this.googlePayRef=this.hostEl.querySelector("justifi-google-pay"),this.paypalRef=this.hostEl.querySelector("justifi-paypal"),this.paymentMethodFormRef=this.hostEl.querySelector("justifi-card-form, justifi-bank-account-form, justifi-tokenize-payment-method"),!k.selectedPaymentMethod&&this.paymentMethodFormRef){const t=this.paymentMethodFormRef.tagName.toLowerCase();"justifi-card-form"===t?k.selectedPaymentMethod={type:V.NEW_CARD}:"justifi-bank-account-form"!==t||k.checkoutLoaded&&!k.achPaymentsEnabled||(k.selectedPaymentMethod={type:V.NEW_BANK_ACCOUNT})}this.insuranceFormRef=this.hostEl.querySelector("justifi-season-interruption-insurance")}setupApplePayListeners(){this.applePayRef&&(this.applePayRef.addEventListener("applePayStarted",this.handleApplePayStarted),this.applePayRef.addEventListener("applePayCompleted",this.handleApplePayCompleted),this.applePayRef.addEventListener("applePayError",this.handleApplePayError),this.applePayRef.addEventListener("applePayCancelled",this.handleApplePayCancelled))}removeApplePayListeners(){this.applePayRef&&(this.applePayRef.removeEventListener("applePayStarted",this.handleApplePayStarted),this.applePayRef.removeEventListener("applePayCompleted",this.handleApplePayCompleted),this.applePayRef.removeEventListener("applePayError",this.handleApplePayError),this.applePayRef.removeEventListener("applePayCancelled",this.handleApplePayCancelled))}setupGooglePayListeners(){this.googlePayRef&&(this.googlePayRef.addEventListener("googlePayStarted",this.handleGooglePayStarted),this.googlePayRef.addEventListener("googlePayCompleted",this.handleGooglePayCompleted),this.googlePayRef.addEventListener("googlePayCancelled",this.handleGooglePayCancelled))}removeGooglePayListeners(){this.googlePayRef&&(this.googlePayRef.removeEventListener("googlePayStarted",this.handleGooglePayStarted),this.googlePayRef.removeEventListener("googlePayCompleted",this.handleGooglePayCompleted),this.googlePayRef.removeEventListener("googlePayCancelled",this.handleGooglePayCancelled))}setupPaypalListeners(){this.paypalRef&&(this.paypalRef.addEventListener("paypalStarted",this.handlePaypalStarted),this.paypalRef.addEventListener("paypalCompleted",this.handlePaypalCompleted),this.paypalRef.addEventListener("paypalCancelled",this.handlePaypalCancelled),this.paypalRef.addEventListener("paypalError",this.handlePaypalError))}removePaypalListeners(){this.paypalRef&&(this.paypalRef.removeEventListener("paypalStarted",this.handlePaypalStarted),this.paypalRef.removeEventListener("paypalCompleted",this.handlePaypalCompleted),this.paypalRef.removeEventListener("paypalCancelled",this.handlePaypalCancelled),this.paypalRef.removeEventListener("paypalError",this.handlePaypalError))}async tokenizePaymentMethod(t){var e,i,s;const a=null!==(i=await(null===(e=this.billingFormRef)||void 0===e?void 0:e.getValues()))&&void 0!==i?i:{},n=Object.assign(Object.assign({},t),a),o=Object.assign({accountId:k.accountId,payment_method_group_id:void 0},n);k.savePaymentMethod&&(o.payment_method_group_id=k.paymentMethodGroupId);const r=await(null===(s=this.paymentMethodFormRef)||void 0===s?void 0:s.tokenize({clientId:this.authToken,paymentMethodMetadata:o,account:k.accountId}));return r.error?r:(k.paymentToken=r.id,r.id)}async fillBillingForm(t){k.billingFormFields=t}async setSelectedPaymentMethod(t){k.selectedPaymentMethod=t,k.paymentToken=t.id||void 0}async validate(){var t,e;const i=[];k.insuranceEnabled&&this.insuranceFormRef&&i.push(this.insuranceFormRef.validate());const s=(null===(t=k.selectedPaymentMethod)||void 0===t?void 0:t.type)===V.NEW_CARD,a=(null===(e=k.selectedPaymentMethod)||void 0===e?void 0:e.type)===V.NEW_BANK_ACCOUNT;if((s||a)&&(this.paymentMethodFormRef&&i.push(this.paymentMethodFormRef.validate()),this.billingFormRef&&i.push(this.billingFormRef.validate())),0===i.length)return!0;try{return!!(await Promise.all(i)).every((t=>"boolean"==typeof t?t:!1!==(null==t?void 0:t.isValid)))||(this.errorEvent.emit({message:"Validation error",errorCode:y.VALIDATION_ERROR,severity:p.ERROR}),!1)}catch(t){return!1}}async submitCheckout(t){var e,i,s,a,n,o,r,l;if(k.isSubmitting)return;k.isSubmitting=!0;const h=await this.validate();if(!k.selectedPaymentMethod)return k.isSubmitting=!1,void this.errorEvent.emit({message:"No payment method selected.",errorCode:y.VALIDATION_ERROR,severity:p.ERROR});const c=(null===(e=k.selectedPaymentMethod)||void 0===e?void 0:e.type)===V.NEW_CARD,d=(null===(i=k.selectedPaymentMethod)||void 0===i?void 0:i.type)===V.NEW_BANK_ACCOUNT,u=(null===(s=k.selectedPaymentMethod)||void 0===s?void 0:s.type)===V.PLAID;if(c||d){const e=await this.tokenizePaymentMethod(t);if(null==e?void 0:e.error)return k.isSubmitting=!1,void this.errorEvent.emit({message:e.error.message,errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}if(u&&!k.paymentToken){const t=k.plaidPublicToken,e=k.plaidLinkTokenId;if(!t)return k.isSubmitting=!1,void this.errorEvent.emit({message:"Missing Plaid public token. Please connect your bank.",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR});try{const i=await this.plaidService.tokenizeBankAccount(k.authToken,k.accountId,t,e||void 0,k.savePaymentMethod?k.paymentMethodGroupId:void 0);if(null==i?void 0:i.error)return k.isSubmitting=!1,void this.errorEvent.emit({message:"string"==typeof i.error?i.error:i.error.message||"Failed to tokenize bank account",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR});const s=null==i?void 0:i.data,n=(null===(a=null==s?void 0:s.bank_account)||void 0===a?void 0:a.token)||(null==s?void 0:s.token)||(null==s?void 0:s.id);k.paymentToken=n}catch(t){return k.isSubmitting=!1,void this.errorEvent.emit({message:(null==t?void 0:t.message)||"Plaid exchange error",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}}if(!h)return k.isSubmitting=!1,void this.errorEvent.emit({message:"Please fill in all required fields.",errorCode:y.VALIDATION_ERROR,severity:p.ERROR});const m=(null===(n=k.selectedPaymentMethod)||void 0===n?void 0:n.type)===V.SEZZLE;if(m){const t=this.hostEl.querySelector("justifi-sezzle-payment-method"),e=await(null==t?void 0:t.resolvePaymentMethod({isValid:h}));if("success"!==(null===(o=null==e?void 0:e.bnpl)||void 0===o?void 0:o.status))return k.isSubmitting=!1,void this.errorEvent.emit({message:(null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.message)||"Sezzle checkout was not completed.",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}if(!m&&!k.paymentToken)return k.isSubmitting=!1,void this.errorEvent.emit({message:"Payment token not found.",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR});const v={payment_mode:(t=>{switch(t){case V.NEW_CARD:case V.SAVED_CARD:case V.NEW_BANK_ACCOUNT:case V.SAVED_BANK_ACCOUNT:case V.PLAID:return W.ECOM;case V.SEZZLE:return W.BNPL;case V.APPLE_PAY:return W.APPLE_PAY;case V.GOOGLE_PAY:return W.GOOGLE_PAY;case V.PAYPAL:return W.PAYPAL;case V.VENMO:return W.VENMO;default:return}})(null===(l=k.selectedPaymentMethod)||void 0===l?void 0:l.type),payment_token:m?void 0:k.paymentToken};if(this.preCompleteHook){const t=T();try{await new Promise(((e,i)=>{this.preCompleteHook(t,(()=>e()),(()=>i()))}))}catch(t){return k.isSubmitting=!1,void console.log("Checkout cancelled by preCompleteHook",t)}}this.completeCheckout({payment:v,onSuccess:({checkout:t})=>{k.isSubmitting=!1,this.submitEvent.emit({checkout:t,message:"Checkout completed successfully"})},onError:t=>{k.isSubmitting=!1,this.errorEvent.emit({message:t.message,errorCode:y.COMPLETE_CHECKOUT_ERROR,severity:p.ERROR})}})}render(){return i(s,{key:"127bf2aea6758c7d91e33f252a3db4bc27b066ff"})}get hostEl(){return a(this)}},rt=n();class lt{async createPaypalOrder(t,e,i,s){return rt.post({endpoint:`checkouts/${e}/paypal/orders`,body:{funding_source:i},authToken:t,signal:s})}}const ht="paypal-script",ct=["paypal-payments","venmo-payments"],dt="PAYMENT_FAILED",ut=class{constructor(i){t(this,i),this.paypalStarted=e(this,"paypalStarted",7),this.paypalCompleted=e(this,"paypalCompleted",7),this.paypalCancelled=e(this,"paypalCancelled",7),this.paypalError=e(this,"paypalError",7),this.paypalService=new lt,this.paypalEligible=!1,this.venmoEligible=!1,this.startSession=async(t,e)=>{if(!t)return;this.pendingOrderId=void 0,this.paypalStarted.emit({fundingSource:e});let i=!1;const s=this.createOrder(e).then((t=>({orderId:t.provider_order_id}))).catch((t=>{throw i=!0,this.emitError((null==t?void 0:t.message)||"Could not create the Paypal order","ORDER_ERROR"),t}));s.catch((()=>{}));try{await t.start({presentationMode:"auto"},s)}catch(t){if(i)return;this.emitError((null==t?void 0:t.message)||"Paypal payment failed",dt)}}}componentDidLoad(){k.checkoutLoaded?this.initializePaypal():P("checkoutLoaded",(t=>{t&&this.initializePaypal()}))}get currencyCode(){return(k.paymentCurrency||"USD").toUpperCase()}emitError(t,e){this.paypalError.emit({error:t,code:e})}loadPaypalScript(){const t=window.paypal;return t?Promise.resolve(t):new Promise(((t,e)=>{let i=document.head.querySelector(`script[data-test-id="${ht}"]`);i||(i=document.createElement("script"),i.src="test"===k.checkoutMode?"https://www.sandbox.paypal.com/web-sdk/v6/core":"https://www.paypal.com/web-sdk/v6/core",i.async=!0,i.setAttribute("data-test-id",ht),document.head.appendChild(i)),i.addEventListener("load",(()=>{const i=window.paypal;i?t(i):e(new Error("Paypal script loaded but window.paypal is undefined"))})),i.addEventListener("error",(()=>e(new Error("Error loading Paypal script"))))}))}metadataId(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}async initializePaypal(){const t=k.paypalProviderClientId;if(!t)return this.paypalEligible=!1,this.venmoEligible=!1,void this.emitError("Missing Paypal client id","CONFIG_ERROR");try{const e=await this.loadPaypalScript();this.sdkInstance=await e.createInstance({clientId:t,components:ct,pageType:"checkout",metadataId:this.metadataId()});const i=await this.sdkInstance.findEligibleMethods({currencyCode:this.currencyCode});this.paypalEligible=i.isEligible("paypal"),this.venmoEligible=i.isEligible("venmo"),this.paypalEligible&&(this.paypalSession=this.sdkInstance.createPayPalOneTimePaymentSession(this.sessionOptions("paypal"))),this.venmoEligible&&(this.venmoSession=this.sdkInstance.createVenmoOneTimePaymentSession(this.sessionOptions("venmo")))}catch(t){this.paypalEligible=!1,this.venmoEligible=!1,this.emitError((null==t?void 0:t.message)||"Error initializing Paypal","INITIALIZATION_ERROR")}}sessionOptions(t){return{onApprove:()=>this.paypalCompleted.emit({success:!0,paymentMethodId:this.pendingOrderId,fundingSource:t}),onCancel:()=>this.paypalCancelled.emit({fundingSource:t}),onError:t=>this.emitError((null==t?void 0:t.message)||"Paypal payment failed",dt)}}async createOrder(t){const e=await this.paypalService.createPaypalOrder(k.authToken,k.checkoutId,t);if(null==e?void 0:e.error)throw new Error(("string"==typeof e.error?e.error:e.error.message)||"Could not create the Paypal order");const i=null==e?void 0:e.data;if(!(null==i?void 0:i.provider_order_id))throw new Error("Paypal order is missing a provider order id");return this.pendingOrderId=i.id,i}render(){if(!k.paypalEnabled)return null;const t=this.venmoEligible&&"USD"===this.currencyCode;return this.paypalEligible||t?i(M,null,i("div",{class:"paypal-buttons"},this.paypalEligible&&i("paypal-button",{type:"pay",onClick:()=>this.startSession(this.paypalSession,"paypal")}),t&&i("venmo-button",{type:"pay",onClick:()=>this.startSession(this.venmoSession,"venmo")})),i("style",null,"\n .paypal-buttons {\n display: flex;\n gap: 8px;\n width: 100%;\n }\n .paypal-buttons > * {\n flex: 1 1 0;\n min-width: 0;\n }\n ")):null}},pt=class{constructor(i){t(this,i),this.paymentMethodOptionSelected=e(this,"paymentMethodOptionSelected",7),this.plaidError=e(this,"plaidError",7),this.plaidErrorRecovered=e(this,"plaidErrorRecovered",7),this.isAuthenticating=!1,this.publicToken=null,this.linkToken=null,this.linkTokenId=null,this.error=null,this.plaidLink=null,this.isSelected=!1,this.retryCount=0,this.isRetrying=!1,this.sdkLoaded=!1,this.plaidService=new Q,this.maxRetries=3,this.retryDelay=2e3,this.timeoutId=null,this.abortController=null,this.hasLoggedDisabledWarning=!1,this.hasLoggedAchPaymentsDisabledWarning=!1,this.waitForStoreAndInitialize=()=>{k.authToken&&k.accountId&&k.checkoutId?this.initializePlaidLink():setTimeout((()=>{this.waitForStoreAndInitialize()}),100)},this.initializePlaidLink=async()=>{try{if(void 0===window.Plaid)return void this.handleError({code:b.PLAID_SDK_LOAD_FAILED,message:g[b.PLAID_SDK_LOAD_FAILED],severity:f[b.PLAID_SDK_LOAD_FAILED],retryable:!0,userAction:"Refresh the page and try again"});if(await this.getLinkToken(),!this.linkToken)return void this.handleError({code:b.PLAID_LINK_TOKEN_FAILED,message:g[b.PLAID_LINK_TOKEN_FAILED],severity:f[b.PLAID_LINK_TOKEN_FAILED],retryable:!0,userAction:"Click to try again"});const t=window.Plaid;this.plaidLink=t.create({token:this.linkToken,onSuccess:this.handlePlaidSuccess,onExit:this.handlePlaidExit,onEvent:this.handlePlaidEvent,onLoad:this.handlePlaidLoad})}catch(t){this.handleError({code:b.PLAID_LINK_INIT_FAILED,message:g[b.PLAID_LINK_INIT_FAILED],severity:f[b.PLAID_LINK_INIT_FAILED],originalError:t,retryable:!0,userAction:"Click to try again"})}},this.getLinkToken=async()=>{var t,e,i,s,a;try{if(!k.authToken||!k.accountId)return void this.handleError({code:b.PLAID_LINK_TOKEN_FAILED,message:"Missing authentication. Please refresh the page and try again.",severity:p.ERROR,retryable:!1,userAction:"Refresh the page"});this.abortController=new AbortController,this.timeoutId=setTimeout((()=>{var t;null===(t=this.abortController)||void 0===t||t.abort()}),3e4);const e=await this.plaidService.getLinkToken(k.authToken,k.accountId,k.checkoutId,this.abortController.signal);if(this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),e.error)throw new Error("string"==typeof e.error?e.error:e.error.message||"Failed to get link token");this.linkToken=e.data.link_token,this.linkTokenId=(null==e?void 0:e.id)||(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.id)||null,this.linkTokenId&&(k.plaidLinkTokenId=this.linkTokenId)}catch(t){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null);let n=b.PLAID_LINK_TOKEN_FAILED,o=g[n],r=!0;"AbortError"===t.name?(n=b.PLAID_TIMEOUT,o=g[n],r=!0):(null===(e=t.message)||void 0===e?void 0:e.includes("network"))||(null===(i=t.message)||void 0===i?void 0:i.includes("fetch"))?(n=b.PLAID_NETWORK_ERROR,o=g[n],r=!0):((null===(s=t.message)||void 0===s?void 0:s.includes("401"))||(null===(a=t.message)||void 0===a?void 0:a.includes("unauthorized")))&&(n=b.PLAID_INVALID_CREDENTIALS,o="Authentication failed. Please refresh the page and try again.",r=!1),this.handleError({code:n,message:o,severity:f[n],originalError:t,retryable:r,userAction:r?"Click to try again":"Refresh the page"})}},this.mapApiErrorToPlaidError=t=>{if("string"==typeof t){if(t.includes("rate_limit"))return b.PLAID_RATE_LIMITED;if(t.includes("maintenance"))return b.PLAID_MAINTENANCE;if(t.includes("not_authenticated"))return b.PLAID_INVALID_CREDENTIALS}if(null==t?void 0:t.code)switch(t.code){case"rate_limited":return b.PLAID_RATE_LIMITED;case"maintenance":return b.PLAID_MAINTENANCE;case"not_authenticated":return b.PLAID_INVALID_CREDENTIALS;default:return b.PLAID_LINK_TOKEN_FAILED}return b.PLAID_LINK_TOKEN_FAILED},this.openPlaidLink=()=>{this.plaidLink&&this.linkToken&&(this.isAuthenticating=!0,this.clearError(),this.plaidLink.open())},this.handlePlaidSuccess=t=>{this.publicToken=t,this.isAuthenticating=!1,this.clearError(),this.retryCount=0,this.isSelected||(this.isSelected=!0,k.selectedPaymentMethod={type:V.PLAID}),this.plaidErrorRecovered.emit({code:"plaid-success",message:"Bank account connected successfully",severity:p.INFO}),k.plaidPublicToken=t},this.handlePlaidExit=t=>{this.isAuthenticating=!1,t&&this.handlePlaidError(t)},this.handlePlaidEvent=(t,e)=>{switch(t){case"OPEN":this.isAuthenticating=!0;break;case"CLOSE":this.isAuthenticating=!1;break;case"ERROR":this.handlePlaidError(e)}},this.handlePlaidLoad=()=>{},this.handlePlaidError=t=>{let e=b.PLAID_AUTHENTICATION_FAILED,i=g[e],s=!0,a="Click to try again";if(t.error_code)switch(t.error_code){case"INVALID_CREDENTIALS":e=b.PLAID_INVALID_CREDENTIALS,i=g[e],s=!0;break;case"ITEM_LOGIN_REQUIRED":e=b.PLAID_INVALID_CREDENTIALS,i="Your bank requires re-authentication. Please try again.",s=!0;break;case"ITEM_LOCKED":e=b.PLAID_ACCOUNT_LOCKED,i=g[e],s=!1,a="Contact your bank";break;case"INSTITUTION_NOT_RESPONDING":e=b.PLAID_MAINTENANCE,i=g[e],s=!0;break;case"RATE_LIMIT_EXCEEDED":e=b.PLAID_RATE_LIMITED,i=g[e],s=!0;break;case"INVALID_REQUEST":e=b.PLAID_AUTHENTICATION_FAILED,i="Invalid request. Please try again.",s=!0;break;case"PLAID_ERROR":e=b.PLAID_AUTHENTICATION_FAILED,i=t.error_message||"Bank authentication failed. Please try again.",s=!0;break;default:t.error_message&&(i=t.error_message)}if(t.error_message){const n=t.error_message.toLowerCase();n.includes("not supported")||n.includes("unsupported")?(e=b.PLAID_BANK_NOT_SUPPORTED,i=g[e],s=!1,a="Try a different payment method"):(n.includes("expired")||n.includes("timeout"))&&(e=b.PLAID_TOKEN_EXPIRED,i=g[e],s=!0)}this.handleError({code:e,message:i,severity:f[e],originalError:t,retryable:s,userAction:a}),this.isAuthenticating=!1},this.handleError=t=>{this.error=t,this.plaidError.emit({code:t.code,message:t.message,severity:t.severity,data:{originalError:t.originalError,retryable:t.retryable,userAction:t.userAction,retryCount:this.retryCount}}),console.error("Plaid error:",t),t.retryable&&this.retryCount<this.maxRetries&&this.scheduleRetry()},this.scheduleRetry=()=>{this.isRetrying||(this.isRetrying=!0,this.retryCount++,setTimeout((()=>{this.isRetrying=!1,this.clearError(),this.waitForStoreAndInitialize()}),this.retryDelay*this.retryCount))},this.clearError=()=>{this.error&&(this.error=null,this.retryCount=0)},this.syncWithStore=()=>{var t;const e=(null===(t=k.selectedPaymentMethod)||void 0===t?void 0:t.type)===V.PLAID;this.isSelected!==e&&(this.isSelected=e)}}onSelectionChange(t){var e;t&&(null===(e=k.selectedPaymentMethod)||void 0===e?void 0:e.type)!==V.PLAID&&(k.selectedPaymentMethod={type:V.PLAID}),!t||!this.plaidLink||this.publicToken||this.isAuthenticating||this.error||this.openPlaidLink()}componentWillLoad(){var t;this.isSelected=(null===(t=k.selectedPaymentMethod)||void 0===t?void 0:t.type)===V.PLAID,!0===k.bankAccountVerification&&(k.checkoutLoaded?k.achPaymentsEnabled&&this.loadPlaidSDK():P("checkoutLoaded",(t=>{t&&!0===k.bankAccountVerification&&k.achPaymentsEnabled&&this.loadPlaidSDK()})))}loadPlaidSDK(){if(this.sdkLoaded)return;this.sdkLoaded=!0;const t=document.createElement("script");t.src="https://cdn.plaid.com/link/v2/stable/link-initialize.js",t.async=!0,t.onload=()=>this.initializePlaidLink(),t.onerror=()=>{this.handleError({code:b.PLAID_SDK_LOAD_FAILED,message:g[b.PLAID_SDK_LOAD_FAILED],severity:f[b.PLAID_SDK_LOAD_FAILED],retryable:!0,userAction:"Refresh the page and try again"})},document.head.appendChild(t)}async resolvePaymentMethod(){return this.publicToken?{token:this.publicToken,data:{type:"bank_account",plaid_public_token:this.publicToken}}:{validationError:!0}}async getPaymentToken(){return k.paymentToken}async handleSelectionClick(){if(this.isSelected=!0,k.selectedPaymentMethod={type:V.PLAID},this.error)return this.clearError(),void this.waitForStoreAndInitialize();!this.plaidLink||this.publicToken||this.isAuthenticating||this.openPlaidLink()}async setSelected(t){this.isSelected=t,t&&(k.selectedPaymentMethod={type:V.PLAID})}async isCurrentlySelected(){return this.isSelected}async deselect(){this.isSelected=!1}async reset(){this.publicToken=null,this.clearError(),this.isAuthenticating=!1,this.linkToken=null,this.plaidLink=null,this.retryCount=0,this.isRetrying=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.abortController&&(this.abortController.abort(),this.abortController=null)}async isReadyForAuthentication(){return!(!this.plaidLink||!this.linkToken||this.isAuthenticating)}async retry(){this.error&&this.error.retryable&&(this.clearError(),this.waitForStoreAndInitialize())}async getErrorInfo(){return this.error}componentDidLoad(){const t=P("selectedPaymentMethod",this.syncWithStore);this.unsubscribeFromStore=t}disconnectedCallback(){this.unsubscribeFromStore&&this.unsubscribeFromStore(),this.timeoutId&&clearTimeout(this.timeoutId),this.abortController&&this.abortController.abort()}render(){if(k.checkoutLoaded&&!k.achPaymentsEnabled)return this.hasLoggedAchPaymentsDisabledWarning||(console.warn("[JustifiPlaidPaymentMethod] ACH payments are disabled for this checkout. Component will not render."),this.hasLoggedAchPaymentsDisabledWarning=!0),null;if(!0!==k.bankAccountVerification)return this.hasLoggedDisabledWarning||(console.warn("[JustifiPlaidPaymentMethod] bank_account_verification is disabled. Component will not render."),this.hasLoggedDisabledWarning=!0),null;const t=i("img",{class:"plaid-logo-img",src:"data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ4IiB2aWV3Qm94PSIwIDAgMjggMjkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgY2xhc3M9ImNzcy0xcmRhajhtIj48ZyBmaWxsPSIjMTExIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yNS43NjI5IDI2LjI2MjhMMjggMTcuNTMwOUwyNC45NjkxIDE0LjUwMDFMMjcuOTk5OSAxMS40NjkxTDI1Ljc2MjggMi43MzcwNkwxNy4wMzA5IDAuNUwxNC4wMDAxIDMuNTMxTDEwLjk2OSAwLjUwMDE0TDIuMjM3MDYgMi43MzczNEwwIDExLjQ2OTFMMy4wMzEyOCAxNC40OTk5TDAuMDAwMTQgMTcuNTMxTDIuMjM3MiAyNi4yNjI5TDEwLjk2OTEgMjguNUwxNC4wMDAxIDI1LjQ2OUwxNy4wMzEgMjguNDk5OUwyNS43NjI5IDI2LjI2MjhaTTE1LjczMjEgMjMuNzM3MUwxOC42MTg2IDIwLjg1MDVMMjIuMjkxMiAyNC41MjMzTDE3LjY5NTYgMjUuNzAwN0wxNS43MzIxIDIzLjczNzFaTTExLjExMzYgOS44ODE1NEwxNC4wMDAzIDYuOTk1MDJMMTYuODg2OCA5Ljg4MTRMMTQuMDAwMSAxMi43Njc5TDExLjExMzYgOS44ODE1NFpNMTIuMjY4MiAxNC41TDkuMzgxNTQgMTcuMzg2NUw2LjQ5NTAyIDE0LjVMOS4zODE1NCAxMS42MTM1TDEyLjI2ODIgMTQuNVpNMTguNjE4NyAxMS42MTMzTDIxLjUwNTMgMTQuNUwxOC42MTg2IDE3LjM4NjVMMTUuNzMyMSAxNC41TDE4LjYxODcgMTEuNjEzM1pNMTYuODg2NyAxOS4xMTg2TDE0LjAwMDEgMjIuMDA1MUwxMS4xMTM1IDE5LjExODVMMTQuMDAwMSAxNi4yMzE5TDE2Ljg4NjcgMTkuMTE4NlpNMTAuMzA0NCAyNS43MDA3TDUuNzA4NjQgMjQuNTIzM0w5LjM4MTU0IDIwLjg1MDRMMTIuMjY4MiAyMy43MzcxTDEwLjMwNDQgMjUuNzAwN1pNNC43NjMwOCAxNi4yMzE5TDcuNjQ5NiAxOS4xMTg1TDMuOTc2NyAyMi43OTE0TDIuNzk5MyAxOC4xOTU3TDQuNzYzMDggMTYuMjMxOVpNMy45NzY3IDYuMjA4MzZMNy42NDk3NCA5Ljg4MTRMNC43NjMwOCAxMi43NjgxTDIuNzk5MyAxMC44MDQxTDMuOTc2NyA2LjIwODM2Wk0xMi4yNjgzIDUuMjYyOTRMOS4zODE2OCA4LjE0OTZMNS43MDg5MiA0LjQ3NjdMMTAuMzA0NyAzLjI5OTNMMTIuMjY4MyA1LjI2Mjk0Wk0xNy42OTU5IDMuMjk5M0wyMi4yOTE1IDQuNDc2N0wxOC42MTg2IDguMTQ5NDZMMTUuNzMyMSA1LjI2Mjk0TDE3LjY5NTkgMy4yOTkzWk0yMy4yMzcyIDEyLjc2ODFMMjAuMzUwNSA5Ljg4MTRMMjQuMDIzMyA2LjIwODc4TDI1LjIwMDcgMTAuODA0NkwyMy4yMzcyIDEyLjc2ODFaTTI0LjAyMzMgMjIuNzkxNEwyMC4zNTA1IDE5LjExODZMMjMuMjM3MiAxNi4yMzIxTDI1LjIwMDcgMTguMTk1N0wyNC4wMjMzIDIyLjc5MTRaIj48L3BhdGg+PC9nPjwvc3ZnPgo=",alt:"Plaid",title:"Plaid",style:{display:"inline",width:"20px",height:"20px",marginLeft:"5px",marginTop:"-2px"}});return i(M,{class:"payment-method"},i("div",{title:"Pay with Plaid"},i("div",{onClick:t=>{t.preventDefault(),this.handleSelectionClick()}},"Pay with Bank Account ",t," "),(()=>this.error?i("div",{class:(this.error.severity===p.ERROR?"text-danger":this.error.severity===p.WARNING?"text-warning":"text-info")+" mt-2"},i("small",null,this.error.message),i("br",null),i("small",{class:"text-muted"},this.error.userAction,this.error.retryable&&this.retryCount<this.maxRetries&&i("span",null," • Auto-retry in progress..."))):null)(),(()=>this.error?null:this.isAuthenticating?i("div",{class:"text-info mt-2"},i("small",null,"Connecting to your bank...")):this.publicToken?i("div",{class:"text-success mt-2"},i("small",null,"✓ Bank account connected successfully")):!this.isSelected||this.publicToken||this.error||this.isAuthenticating?null:i("div",{class:"text-muted mt-2"},i("small",null,"Click to connect your bank account")))()))}static get watchers(){return{isSelected:["onSelectionChange"]}}},yt=class{constructor(e){t(this,e),this.onPaymentMethodOptionClick=t=>e=>{e.preventDefault(),k.selectedPaymentMethod={id:t.id,type:t.type},k.paymentToken=t.id},this.isAllowedPaymentMethod=t=>!(t===V.SAVED_CARD&&k.disableCreditCard||t===V.SAVED_BANK_ACCOUNT&&k.disableBankAccount)}componentWillLoad(){k.checkoutLoaded&&(k.paymentMethods.length||console.warn("No saved payment methods available."),k.disablePaymentMethodGroup&&console.warn("Payment method group is disabled."))}render(){return k.disablePaymentMethodGroup?null:i(M,null,i("div",{class:"saved-payment-methods"},k.paymentMethods.length?k.paymentMethods.filter((t=>this.isAllowedPaymentMethod(t.type))).map((t=>i("div",{class:"radio-list-item p-3",part:E,onClick:this.onPaymentMethodOptionClick(t)},i("form-control-radio",{name:"paymentMethodType",value:null==t?void 0:t.id,checked:k.paymentToken===(null==t?void 0:t.id),label:`${Z[null==t?void 0:t.brand]||""} *${null==t?void 0:t.acct_last_four}`})))):null))}},mt=class{constructor(i){t(this,i),this.paymentMethodOptionSelected=e(this,"paymentMethodOptionSelected",7),this.paymentMethodOptionId=V.SEZZLE,this.initializeSezzleCheckout=()=>{const t=Number(k.paymentAmount),e=new(0,window.Checkout)({mode:"popup",publicKey:k.bnplProviderClientId,apiMode:k.bnplProviderMode,apiVersion:k.bnplProviderApiVersion});e.sezzleButtonElement=this.sezzleButtonRef,e.init({onClick:function(t){t.preventDefault(),e.startCheckout({checkout_url:k.bnplProviderCheckoutUrl})},onComplete:t=>{var e;return null===(e=this.resolveSezzlePromise)||void 0===e?void 0:e.call(this,{bnpl:t.data})},onCancel:t=>{var e;return null===(e=this.resolveSezzlePromise)||void 0===e?void 0:e.call(this,{bnpl:t.data})},onFailure:t=>{var e;return null===(e=this.resolveSezzlePromise)||void 0===e?void 0:e.call(this,{bnpl:t.data})}}),this.sezzleCheckout=e,this.installmentPlan=this.sezzleCheckout.getInstallmentPlan(t)}}componentDidRender(){this.scriptRef&&(this.scriptRef.onload=()=>{this.sezzleButtonRef=document.createElement("button"),this.initializeSezzleCheckout()})}async resolvePaymentMethod(t){if(!t.isValid)return{validationError:!0};if(!this.sezzleButtonRef)return{error:{code:"sezzle_not_ready",message:"Sezzle is not ready yet. Please try again.",decline_code:""}};const e=new Promise((t=>{this.resolveSezzlePromise=t}));return this.sezzleButtonRef.click(),e}async handleSelectionClick(){k.selectedPaymentMethod={type:V.SEZZLE},this.paymentMethodOptionSelected.emit(this.paymentMethodOptionId)}render(){var t,e;return k.bnplEnabled?i(M,{class:"payment-method"},i("script",{src:"https://checkout-sdk.sezzle.com/checkout.min.js",async:!0,ref:t=>this.scriptRef=t}),i("div",null,i("div",null,"Buy now, pay later with ",i("img",{class:"sezzle-smart-button-logo-img",src:"https://media.sezzle.com/branding/2.0/Sezzle_Logo_FullColor.svg",alt:"Sezzle",style:{display:"inline",width:"80px",marginLeft:"5px",marginTop:"-5px"}})),this.installmentPlan&&i("small",null,i("span",null,null===(t=this.installmentPlan)||void 0===t?void 0:t.installments.length)," ",i("span",null,this.installmentPlan.schedule," payments of")," ",i("span",{class:"fw-bold"},I(null===(e=this.installmentPlan)||void 0===e?void 0:e.installments[0].amountInCents))))):(console.warn("justifi-sezzle-payment-method: BNPL is not enabled for this account."),null)}},vt={[V.NEW_BANK_ACCOUNT]:"New bank account",[V.NEW_CARD]:"New credit or debit card"},ft="Payment form not ready",gt="Validation error",bt=class{constructor(i){t(this,i),this.errorEvent=e(this,"error-event",7),this.submitEvent=e(this,"submit-event",7),this.computedHideSubmitButton=!1,this.isLoading=!1,this.submitButtonText="Submit"}paymentMethodsChanged(){this.setDefaultSelectedPaymentMethod()}connectedCallback(){this.setDefaultSelectedPaymentMethod(),this.setComputedHideSubmitButton()}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup(),this.unsubscribeFromStore&&this.unsubscribeFromStore()}componentWillLoad(){U(),this.analytics=new R(this)}handleRadioClick(t){this.selectedPaymentMethod=t.detail,k.selectedPaymentMethod={type:t.detail}}async tokenizePaymentMethod(t){null==t||t.preventDefault(),this.validateRequiredProps(),this.isLoading=!0;try{if(!(await this.validate()).isValid)return this.errorEvent.emit({errorCode:y.TOKENIZE_ERROR,message:gt}),void(this.isLoading=!1);const t=await this.resolvePaymentMethod({isValid:!0});return t.error&&this.emitError({errorCode:t.error.code,message:t.error.message}),this.submitEvent.emit({response:t}),t}catch(t){const e=this.createErrorResponse(y.TOKENIZE_ERROR,t.message);return this.emitError({errorCode:y.TOKENIZE_ERROR,message:t.message}),this.submitEvent.emit({response:e}),e}finally{this.isLoading=!1}}async fillBillingForm(t){k.billingFormFields=t}async validate(){if(!this.areFormsReady())return{isValid:!1,errors:{general:ft}};const[t,e]=await Promise.all([this.billingFormRef.validate(),this.paymentMethodFormRef.validate()]);return{isValid:t.isValid&&e.isValid,errors:Object.assign(Object.assign({},t.errors),e.errors)}}async getValues(){return this.billingFormRef.getValues()}async tokenize(){try{const t=await this.billingFormRef.getValues(),e={clientId:this.authToken||k.authToken,account:this.accountId||k.accountId,paymentMethodMetadata:this.buildPaymentMethodMetadata(t)};return await this.paymentMethodFormRef.tokenize(e)}catch(t){return t}}validateRequiredProps(){this.authToken||k.authToken||this.emitError({errorCode:y.TOKENIZE_ERROR,message:"Auth token is required when using the tokenize-payment-method component not slotted in justifi-modular-checkout"}),this.accountId||k.accountId||this.emitError({errorCode:y.TOKENIZE_ERROR,message:"Account ID is required when using the tokenize-payment-method component not slotted in justifi-modular-checkout"})}setDefaultSelectedPaymentMethod(){this.selectedPaymentMethod||(this.disableCreditCard?this.disableBankAccount||k.checkoutLoaded&&!k.achPaymentsEnabled||(this.selectedPaymentMethod=V.NEW_BANK_ACCOUNT,k.selectedPaymentMethod={type:V.NEW_BANK_ACCOUNT}):(this.selectedPaymentMethod=V.NEW_CARD,k.selectedPaymentMethod={type:V.NEW_CARD}))}setComputedHideSubmitButton(){if(void 0!==this.hideSubmitButton)return void(this.computedHideSubmitButton=this.hideSubmitButton);const t=this.isSlottedWithinModularCheckout();this.computedHideSubmitButton=t}isSlottedWithinModularCheckout(){var t;let e=null===(t=this.host)||void 0===t?void 0:t.parentElement;for(;e;){if("JUSTIFI-MODULAR-CHECKOUT"===e.tagName)return!0;e=e.parentElement}return!1}get availablePaymentMethods(){const t=[],e=!k.checkoutLoaded||k.achPaymentsEnabled;return this.disableCreditCard||t.push(V.NEW_CARD),!this.disableBankAccount&&e&&t.push(V.NEW_BANK_ACCOUNT),t}areFormsReady(){return!(!this.billingFormRef||!this.paymentMethodFormRef)}emitError(t){this.errorEvent.emit(Object.assign(Object.assign({},t),{severity:p.ERROR}))}createErrorResponse(t,e){return{error:{code:t,message:e,decline_code:void 0}}}async resolvePaymentMethod(t){if(!this.areFormsReady())return this.createErrorResponse("form_not_ready",ft);try{const e=await this.validate();if(!e.isValid||!t.isValid){const t=Object.values(e.errors)[0]||gt;return{validationError:!0,error:{code:"validation_error",message:String(t),decline_code:void 0}}}return await this.performTokenization()}catch(t){return{error:t}}}async performTokenization(){var t,e;const i=await this.tokenize();if(i.error)return{error:i.error};const s=i.data;return{token:(null===(t=s.card)||void 0===t?void 0:t.token)||(null===(e=s.bank_account)||void 0===e?void 0:e.token),data:s}}buildPaymentMethodMetadata(t){return this.shouldSavePaymentMethod?Object.assign(Object.assign({},t),{payment_method_group_id:this.paymentMethodGroupID}):Object.assign({},t)}get paymentMethodGroupID(){return this.paymentMethodGroupId||k.paymentMethodGroupId}get shouldSavePaymentMethod(){return!(!this.paymentMethodGroupId&&!k.savePaymentMethod)}get shouldHideRadioInput(){return this.disableCreditCard||this.disableBankAccount}renderPaymentMethodOption(t){const e=this.selectedPaymentMethod===t&&void 0===k.selectedPaymentMethod.id;return i("div",{class:"payment-method"},i("radio-list-item",{name:"paymentMethodType",value:t,checked:e,label:vt[t],hidden:this.shouldHideRadioInput}),e&&this.renderSelectedPaymentMethodForm(t))}renderSelectedPaymentMethodForm(t){return i("div",{class:"mt-4 pb-4"},this.renderPaymentMethodForm(t),i("div",{class:"mt-4"},i("billing-form",{ref:t=>{t&&(this.billingFormRef=t)},hideCardBillingForm:this.hideCardBillingForm,hideBankAccountBillingForm:this.hideBankAccountBillingForm,paymentMethodType:t})),i("div",{class:"mt-4"},i("save-new-payment-method",{hidden:!this.paymentMethodGroupID,label:this.savePaymentMethodLabel})))}renderPaymentMethodForm(t){return i(t===V.NEW_CARD?"card-form":"bank-account-form",{ref:t=>{t&&(this.paymentMethodFormRef=t)}})}render(){return i(M,{key:"73aeacd6caa05ef5e126a6577c22464eacfc6d96"},i("form",{key:"7c1ddd145c53590fb1b9522ea8dbd52339817754"},i("fieldset",{key:"38bb226348b721f01f900930710f6b705d5a96ed"},i("div",{key:"b4f27d1e36c4d5e37190fa99b79c36cf00a8d9a3",class:"row gy-3"},i("div",{key:"85ae7c532c3c6056d5122cfd30fd4e2b75cf82f9",class:"col-12"},this.availablePaymentMethods.map((t=>this.renderPaymentMethodOption(t)))),i("div",{key:"7727760fa2ccbaff134fa95e338406224bc8d787",class:"col-12"},i("internal-button",{key:"9f268e40c2d37a0d8ba423ad6dffe88c4cab3bc3",text:this.submitButtonText,variant:"primary",type:"submit",clickHandler:t=>this.tokenizePaymentMethod(t),isLoading:this.isLoading,"data-testid":"submit-button",hidden:this.computedHideSubmitButton}))))))}get host(){return a(this)}static get watchers(){return{disableCreditCard:["paymentMethodsChanged"],disableBankAccount:["paymentMethodsChanged"]}}};export{X as justifi_apple_pay,tt as justifi_button,et as justifi_checkout_summary,at as justifi_google_pay,nt as justifi_header,ot as justifi_modular_checkout,ut as justifi_paypal,pt as justifi_plaid_payment_method,G as justifi_radio_list_item,yt as justifi_saved_payment_methods,mt as justifi_sezzle_payment_method,bt as justifi_tokenize_payment_method}
1
+ import{r as t,c as e,h as i,H as s,g as a}from"./p-CV0Pyo1O.js";import{A as n}from"./p-vIQBTQmc.js";import{A as o,r,s as l,t as h,u as c,v as d,w as u,C as p,b as y,c as m,I as v,x as f,y as g,z as b}from"./p-D6uhYbLo.js";import{S as M}from"./p-05AWudQe.js";import"./p-CZfYo5-1.js";import{S as w}from"./p-eBK-iWrz.js";import{c as k,o as P,a as j,g as C,b as T}from"./p-Fpaf7CLD.js";import{t as A,r as E}from"./p-Bu7gdOaV.js";import{f as I}from"./p-Ds_P-dB8.js";import{w as N,c as D}from"./p-B4vLfYnZ.js";import{H as S}from"./p-CZk3i5Tu.js";import{H as O,b as L,h as x,i as z}from"./p-x2oNTAWh.js";import{H as _}from"./p-BAB1lPu0.js";import{J as R}from"./p-nbKvRcwU.js";import{c as U}from"./p-BEL8sLz6.js";import"./p-HXpYMWUU.js";import"./p-CLHwhyvu.js";import"./p-DaDqgDrb.js";import{m as B,a as Y}from"./p-CXsRwohv.js";import{C as F}from"./p-27igUlku.js";import{P as V}from"./p-DN7VhlTn.js";import{P as Q,a as H,b as W}from"./p-DEx8fQeW.js";import{C as Z}from"./p-ZpPDShvP.js";import"./p-CAVi_ne1.js";import"./p-DgTOxu8x.js";import"./p-CLq3Og7o.js";const G=class{constructor(i){t(this,i),this.radioClick=e(this,"radio-click",7),this.checked=!1,this.hidden=!1}render(){return i(M,{key:"02955940079320bd9c6bf94e239545385ac36458"},i("radio-list-item",{key:"fc6b98e456e4326b843b2b3248b7327436767cf4",name:this.name,value:this.value,label:this.label,checked:this.checked,hidden:this.hidden,class:this.class,"onRadio-click":t=>this.radioClick.emit(t.detail)}))}};var q;!function(t){t.UNAVAILABLE="UNAVAILABLE",t.SESSION_ERROR="SESSION_ERROR",t.MERCHANT_VALIDATION_ERROR="MERCHANT_VALIDATION_ERROR",t.PAYMENT_PROCESSING_ERROR="PAYMENT_PROCESSING_ERROR",t.USER_CANCELLED="USER_CANCELLED"}(q||(q={}));class J{constructor(){this.api=n()}initialize(t){if(this.applePayConfig=new o(t),!this.applePayConfig.isValid)throw new Error("Invalid Apple Pay configuration provided")}async validateMerchant(t,e){try{return await this.api.post({endpoint:"apple_pay/merchant_session",authToken:t,headers:{"Sub-Account":e},body:{domain:window.location.hostname,display_name:this.applePayConfig.displayName}})}catch(t){throw console.error("Backend validation failed:",t),new Error("Merchant validation failed")}}async processPayment(t,e,i){const s=await this.api.post({endpoint:"apple_pay/process_token",authToken:t,body:i,headers:{"Sub-Account":e}});return{success:s.id&&!!s.data.token,data:s}}isAvailable(){return r.isApplePaySupported()&&r.canMakePayments()}async canMakePaymentsWithActiveCard(){if(!this.applePayConfig)throw new Error("Apple Pay not initialized. Call initialize() first.");return await r.canMakePaymentsWithActiveCard(this.applePayConfig.merchantIdentifier)}async startPaymentSession(t,e,i){if(!this.applePayConfig)throw console.error("[ApplePayService] Missing applePayConfig. Did you call initialize()?"),new Error("Apple Pay not initialized. Call initialize() first.");const s=new l(t);if(!s.isValid){const t=[];throw s.countryCode||t.push("countryCode"),s.currencyCode||t.push("currencyCode"),s.merchantCapabilities&&0!==s.merchantCapabilities.length||t.push("merchantCapabilities"),s.supportedNetworks&&0!==s.supportedNetworks.length||t.push("supportedNetworks"),s.total&&s.total.label&&s.total.amount||t.push("total"),console.error("[ApplePayService] Payment request is invalid. Missing/invalid:",t),new Error("Invalid payment request provided")}return this.currentPaymentRequest=s,new Promise(((t,a)=>{try{if("undefined"==typeof window||!("ApplePaySession"in window))return console.error("[ApplePayService] ApplePaySession not available on window"),a({success:!1,error:{code:q.UNAVAILABLE,message:"ApplePaySession API is not available in this environment"}});this.currentSession=new window.ApplePaySession(3,s),this.setupSessionEventHandlers(t,a,e,i),this.currentSession.begin()}catch(t){console.error("[ApplePayService] Exception while starting session:",t),a({success:!1,error:{code:q.SESSION_ERROR,message:t instanceof Error?t.message:"Failed to start Apple Pay session"}})}}))}abortPaymentSession(){this.currentSession&&(this.currentSession.abort(),this.currentSession=void 0,this.currentPaymentRequest=void 0)}setupSessionEventHandlers(t,e,i,s){this.currentSession&&this.applePayConfig&&this.currentPaymentRequest?(this.currentSession.onvalidatemerchant=async()=>{try{if(!i)throw console.error("[ApplePayService] Missing authToken for merchant validation"),new Error("Authentication token not provided.");const t=await this.validateMerchant(i,s);try{this.currentSession.completeMerchantValidation(t)}catch(t){throw console.error("Error calling completeMerchantValidation:",t),t}}catch(t){console.error("=== MERCHANT VALIDATION ERROR ==="),console.error("Error during merchant validation:",t),t&&t.stack&&console.error("Error stack:",t.stack),this.currentSession.abort(),e({success:!1,error:{code:q.MERCHANT_VALIDATION_ERROR,message:t instanceof Error?t.message:"Merchant validation failed"}})}},this.currentSession.onpaymentauthorized=async a=>{try{const n=a.payment,o=Object.assign(Object.assign({},n.token),{product_details:{name:this.currentPaymentRequest.total.label,price:r.parseAmount(this.currentPaymentRequest.total.amount),description:this.currentPaymentRequest.total.label}}),l=await this.processPayment(i,s,o);l.success?(this.currentSession.completePayment({status:h.STATUS_SUCCESS}),t({success:!0,token:n.token,paymentMethodId:l.data.id})):(console.error("PSP reported payment failure:",l.data),this.currentSession.completePayment({status:h.STATUS_FAILURE}),e({success:!1,error:{code:q.PAYMENT_PROCESSING_ERROR,message:"Payment processing failed"}}))}catch(t){console.error("=== PAYMENT PROCESSING ERROR ==="),console.error("Error processing payment:",t),t&&t.stack&&console.error("Error stack:",t.stack),this.currentSession.completePayment({status:h.STATUS_FAILURE}),e({success:!1,error:{code:q.PAYMENT_PROCESSING_ERROR,message:t instanceof Error?t.message:"Payment processing failed"}})}finally{this.currentSession=void 0,this.currentPaymentRequest=void 0}},this.currentSession.onpaymentmethodselected=()=>{const t={newTotal:this.currentPaymentRequest.total,newLineItems:this.currentPaymentRequest.lineItems||[]};try{this.currentSession.completePaymentMethodSelection(t)}catch(t){console.error("Error completing payment method selection:",t),this.currentSession.abort()}},this.currentSession.onshippingmethodselected=()=>{this.currentSession.completeShippingMethodSelection({status:h.STATUS_SUCCESS,newTotal:this.currentPaymentRequest.total,newLineItems:this.currentPaymentRequest.lineItems||[]})},this.currentSession.oncancel=t=>{if(t.sessionError)switch(console.error(t.sessionError),t.sessionError.code){case"unknown":console.error("Unknown error - likely merchant validation issue"),console.error("This usually means:"),console.error("1. Merchant certificate is invalid or expired"),console.error("2. Merchant identifier mismatch"),console.error("3. Backend validation endpoint issues");break;case"invalidMerchantSession":console.error("Invalid merchant session provided"),console.error("Check that the merchant session from backend is valid");break;case"userCancel":console.error("User cancelled the payment");break;default:console.error("Other error code:",t.sessionError.code)}this.currentSession=void 0,this.currentPaymentRequest=void 0,e({success:!1,error:{code:q.USER_CANCELLED,message:"User cancelled the Apple Pay session"}})},"onerror"in this.currentSession&&(this.currentSession.onerror=t=>{console.error("=== APPLE PAY SESSION ERROR ==="),console.error("Session error:",t),this.currentSession=void 0,this.currentPaymentRequest=void 0,e({success:!1,error:{code:q.SESSION_ERROR,message:"Apple Pay session error occurred"}})})):console.error("[ApplePayService] setupSessionEventHandlers called without required state",{hasSession:Boolean(this.currentSession),hasConfig:Boolean(this.applePayConfig),hasPaymentRequest:Boolean(this.currentPaymentRequest)})}static createPaymentRequest(t,e,i="US",s="USD"){return{countryCode:i,currencyCode:s,merchantCapabilities:r.getDefaultMerchantCapabilities(),supportedNetworks:r.getDefaultSupportedNetworks(),total:r.createLineItem(e,t)}}getApplePayConfig(){return this.applePayConfig}}const K=t=>{const{isLoading:e}=t;return e?i("div",{class:"container-fluid p-0"},i("div",{class:"row mb-3"},i("div",{class:"col-12 align-content-center"},i(w,{height:"44px",width:"100%",styles:{borderRadius:"8px"}})))):null},$=t=>i("div",{class:"apple-pay-button-container"},i("button",Object.assign({class:(()=>{let e="apple-pay-button";switch(t.buttonStyle){case c.WHITE:e+=" apple-pay-button-white";break;case c.WHITE_OUTLINE:e+=" apple-pay-button-white-outline";break;default:e+=" apple-pay-button-black"}switch(t.buttonType){case d.BUY:e+=" apple-pay-button-type-buy";break;case d.DONATE:e+=" apple-pay-button-type-donate";break;default:e+=" apple-pay-button-type-plain"}return(t.disabled||t.isProcessing||!t.isAvailable)&&(e+=" disabled"),e})(),style:{width:t.width,height:t.height},onClick:()=>{!t.disabled&&!t.isProcessing&&t.isAvailable&&t.clickHandler&&t.clickHandler()},disabled:t.disabled||t.isProcessing||!t.isAvailable,"aria-label":"Pay with Apple Pay",type:"button"},t),t.isProcessing&&i("div",{class:"processing-overlay"},i("div",{class:"spinner"}),i("span",null,"Processing..."))),i("style",null,"\n .apple-pay-button-container {\n display: block;\n position: relative;\n width: 100%;\n }\n\n /* Apple Pay CSS classes - these are the official Apple Pay button styles */\n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: plain; /* default */\n -apple-pay-button-style: black; /* default */\n border-radius: 8px;\n cursor: pointer;\n border: none;\n outline: none;\n transition: opacity 0.2s ease;\n position: relative;\n }\n\n /* Button styles */\n .apple-pay-button.apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n\n .apple-pay-button.apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n\n .apple-pay-button.apple-pay-button-white-outline {\n -apple-pay-button-style: white-outline;\n }\n\n /* Button types */\n .apple-pay-button.apple-pay-button-type-plain {\n -apple-pay-button-type: plain;\n }\n\n .apple-pay-button.apple-pay-button-type-buy {\n -apple-pay-button-type: buy;\n }\n\n .apple-pay-button.apple-pay-button-type-donate {\n -apple-pay-button-type: donate;\n }\n\n /* Hover and disabled states */\n .apple-pay-button:hover:not(.disabled) {\n opacity: 0.9;\n }\n\n .apple-pay-button.disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n /* Processing overlay */\n .processing-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n background: rgba(0, 0, 0, 0.8);\n color: white;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n }\n\n .spinner {\n width: 16px;\n height: 16px;\n border: 2px solid rgba(255, 255, 255, 0.3);\n border-top: 2px solid #fff;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n\n /* Responsive design */\n @media (max-width: 480px) {\n .apple-pay-button {\n width: 100% !important;\n min-width: 200px;\n }\n }\n ")),X=class{constructor(i){t(this,i),this.applePayStarted=e(this,"applePayStarted",7),this.applePayCompleted=e(this,"applePayCompleted",7),this.applePayCancelled=e(this,"applePayCancelled",7),this.applePayError=e(this,"applePayError",7),this.sdkLoaded=!1,this.countryCode="US",this.merchantIdentifier="merchant.com.staging-justifi.checkout-dev",this.merchantDisplayName="JustiFi Checkout",this.initiativeContext="dev-checkout.justifi-staging.com",this.buttonType=d.PLAIN,this.buttonStyle=c.BLACK,this.disabled=!1,this.width="100%",this.height="48px",this.isLoading=!0,this.isProcessing=!1,this.isAvailable=!1,this.canMakePayments=!1,this.isConfigValid=!0,this.error=null,this.handleApplePayClick=async()=>{var t,e,i;if(!this.isProcessing&&!this.disabled&&this.isAvailable)try{this.isProcessing=!0,this.error=null,this.applePayStarted.emit();const i={countryCode:this.countryCode,currencyCode:k.paymentCurrency,merchantCapabilities:[u.SUPPORTS_3DS,u.SUPPORTS_CREDIT,u.SUPPORTS_DEBIT],supportedNetworks:r.getDefaultSupportedNetworks(),total:r.createLineItem(k.paymentDescription,k.paymentAmount)},s=await this.applePayService.startPaymentSession(i,k.authToken,k.accountId);s.success?this.applePayCompleted.emit({success:!0,token:s.token,paymentMethodId:s.paymentMethodId}):(this.applePayCompleted.emit({success:!1,error:s.error}),this.applePayError.emit({error:(null===(t=s.error)||void 0===t?void 0:t.message)||"Payment failed",code:(null===(e=s.error)||void 0===e?void 0:e.code)||X.ErrorCode.PAYMENT_FAILED}))}catch(t){if((null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.code)===q.USER_CANCELLED)this.applePayCancelled.emit();else{const e=t instanceof Error?t.message:"Payment failed";this.error=e,this.applePayError.emit({error:e,code:X.ErrorCode.PAYMENT_FAILED}),this.applePayCompleted.emit({success:!1,error:e})}}finally{this.isProcessing=!1}}}componentWillLoad(){this.isAvailable=r.isApplePaySupported(),this.isAvailable?k.checkoutLoaded?this.loadApplePaySDK():P("checkoutLoaded",(t=>{t&&this.loadApplePaySDK()})):this.isLoading=!1}loadApplePaySDK(){if(this.sdkLoaded)return;this.sdkLoaded=!0;const t=document.createElement("script");t.src="https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",t.async=!0,t.onload=()=>this.initializeApplePay(),document.head.appendChild(t)}async initializeApplePay(){try{if(this.isLoading=!0,this.error=null,this.isConfigValid=!0,!(Boolean(k.paymentAmount)&&Boolean(k.paymentCurrency)&&Boolean(k.authToken)))return this.error="Missing required Apple Pay configuration",this.isConfigValid=!1,this.applePayError.emit({error:this.error,code:X.ErrorCode.CONFIG_ERROR}),void(this.isLoading=!1);if(this.isAvailable=r.isApplePaySupported(),this.canMakePayments=r.canMakePayments(),!this.isAvailable)return this.error="Apple Pay is not supported on this device",this.applePayError.emit({error:this.error,code:X.ErrorCode.NOT_SUPPORTED}),void(this.isLoading=!1);if(!this.canMakePayments)return this.error="Apple Pay is not available",this.applePayError.emit({error:this.error,code:X.ErrorCode.NOT_AVAILABLE}),void(this.isLoading=!1);const t={merchantIdentifier:this.merchantIdentifier,displayName:this.merchantDisplayName,initiative:"web",initiativeContext:this.initiativeContext,buttonType:this.buttonType,buttonStyle:this.buttonStyle};this.applePayService=new J,this.applePayService.initialize(t),await this.applePayService.canMakePaymentsWithActiveCard()||console.warn("No Apple Pay cards available, but continuing...")}catch(t){this.error=t instanceof Error?t.message:"Failed to initialize Apple Pay",this.applePayError.emit({error:this.error,code:X.ErrorCode.INITIALIZATION_ERROR})}finally{this.isLoading=!1}}async isSupported(){return this.isAvailable&&this.canMakePayments}async getPaymentMethods(){return this.isAvailable?r.getDefaultSupportedNetworks():[]}async abort(){var t;null===(t=this.applePayService)||void 0===t||t.abortPaymentSession(),this.isProcessing=!1,this.applePayCancelled.emit()}render(){if(!k.applePayEnabled)return null;if(!this.isAvailable)return null;const t=!this.isLoading&&this.isAvailable&&this.canMakePayments&&this.isConfigValid;return i(M,null,i("div",{class:"apple-pay-container"},i(K,{isLoading:this.isLoading}),t&&i($,{buttonType:this.buttonType,buttonStyle:this.buttonStyle,disabled:this.disabled,isProcessing:this.isProcessing,isAvailable:this.isAvailable,clickHandler:this.handleApplePayClick,width:this.width,height:this.height})),i("style",null,"\n .apple-pay-container {\n width: 100%;\n }\n "))}};X.ErrorCode={CONFIG_ERROR:"CONFIG_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",NOT_AVAILABLE:"NOT_AVAILABLE",INITIALIZATION_ERROR:"INITIALIZATION_ERROR",PAYMENT_FAILED:"PAYMENT_FAILED"};const tt=class{constructor(e){t(this,e),this.variant="primary",this.type="button"}render(){return i(M,{key:"1e09a302d064e2e4a860dc4efd9eb9693d4d0055"},i("internal-button",{key:"9ce7819853789c44860de43f26632c62415ebdb5",text:this.text,variant:this.variant,isLoading:this.isLoading,clickHandler:this.clickHandler,type:this.type,disabled:this.disabled,class:this.class,customStyle:this.customStyle,hidden:this.hidden}))}},et=class{constructor(e){t(this,e)}render(){return i(M,{key:"7d3447ff4daa9bf4f603ca381027b3f43cfcc6a1"},i("section",{key:"1c8189ccde6dc986ad2d4c74da2dd10cacfc1c36"},i("div",{key:"45e6d5f47d8a92e0bd4a7bfa427630a96f049b4a"},i("div",{key:"9900b5fd770cd59b00803c3614216c16a803da41",part:A},null==k?void 0:k.paymentDescription),i("div",{key:"16cec140ef6912533a80b1f6341fcc9cb341b478"},i("span",{key:"f8883538c99a524017bb102bfd8cfaea7062e650",part:A},"Total")," ",i("span",{key:"11baa64630a60c56cedfa53548c107ec3fe3c0f5",part:A},I(+(null==k?void 0:k.totalAmount)))))))}},it=t=>{const{isLoading:e}=t;return e?i("div",{class:"container-fluid p-0"},i("div",{class:"row mb-3"},i("div",{class:"col-12 align-content-center"},i(w,{height:"44px",width:"100%",styles:{borderRadius:"8px"}})))):null};var st;!function(t){t.initialize="justifi.googlePay.initialize",t.ready="justifi.googlePay.ready",t.sdkLoaded="justifi.googlePay.sdkLoaded",t.initializeResult="justifi.googlePay.initializeResult",t.error="justifi.googlePay.error",t.buttonClicked="justifi.googlePay.buttonClicked",t.startPayment="justifi.googlePay.startPayment",t.paymentSuccess="justifi.googlePay.paymentSuccess",t.paymentCanceled="justifi.googlePay.paymentCanceled",t.paymentError="justifi.googlePay.paymentError"}(st||(st={}));const at=class{constructor(i){t(this,i),this.googlePayStarted=e(this,"googlePayStarted",7),this.googlePayCompleted=e(this,"googlePayCompleted",7),this.googlePayCancelled=e(this,"googlePayCancelled",7),this.merchantDisplayName="JustiFi Checkout",this.useNativePaymentRequest=!1,this.iframeReady=!1,this.sdkLoaded=!1,this.isReadyToPay=!1,this.handleMessage=t=>{if(t.origin!==this.iframeOrigin)return;const{eventType:e,data:i}=t.data||{};switch(e){case st.ready:this.iframeReady=!0;break;case st.sdkLoaded:this.sdkLoaded=!0,this.sendInitialize();break;case st.initializeResult:this.isReadyToPay=i.isReadyToPay,i.error&&console.error("Init error:",i.error);break;case st.error:console.error("Google Pay error:",i);break;case st.buttonClicked:this.googlePayStarted.emit(),this.sendStartPayment();break;case st.paymentSuccess:this.googlePayCompleted.emit({success:!0,paymentMethodId:i.paymentMethodId,cardNetwork:i.cardNetwork,cardDetails:i.cardDetails});break;case st.paymentCanceled:this.googlePayCancelled.emit();break;case st.paymentError:this.googlePayCompleted.emit({success:!1,error:{code:i.code,message:i.message}})}}}async componentWillLoad(){await N(),this.iframeOrigin=D.iframeOrigin}componentDidLoad(){window.addEventListener("message",this.handleMessage)}disconnectedCallback(){window.removeEventListener("message",this.handleMessage)}googlePayEnvironment(){return void 0!==this.environment?this.environment:"test"===k.checkoutMode?"TEST":"PRODUCTION"}sendInitialize(){var t;if(!(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow))return;const e={environment:this.googlePayEnvironment(),gatewayMerchantId:k.accountId,merchantName:this.merchantDisplayName,authToken:k.authToken,accountId:k.accountId,useNativePaymentRequest:this.useNativePaymentRequest};this.iframeElement.contentWindow.postMessage({eventType:st.initialize,data:e},this.iframeOrigin)}sendStartPayment(){var t;if(!(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow))return;const e={totalPrice:String(k.paymentAmount/100),totalPriceStatus:"FINAL",currencyCode:k.paymentCurrency||"USD"};this.iframeElement.contentWindow.postMessage({eventType:st.startPayment,data:e},this.iframeOrigin)}render(){return k.checkoutLoaded?k.googlePayEnabled?i(s,null,i(it,{isLoading:!this.isReadyToPay}),i("iframe",{ref:t=>this.iframeElement=t,src:`${this.iframeOrigin}/v2/googlePay`,allow:"payment",style:{border:"none",width:"100%",height:"48px",display:this.isReadyToPay?"block":"none"}})):(console.warn("Google Pay is not enabled for this checkout"),null):null}},nt=class{constructor(e){t(this,e),this.levels={h1:S,h2:O,h3:_},this.level="h1"}render(){return i(M,{key:"1843adabddf7d439036f8ce6f55627b7ca3e4a9f"},i(this.levels[this.level],{key:"b16e5624ce7e092cc8c144a7cdfd9cb6afdf7a83",text:this.text,class:this.class}))}},ot=class{constructor(i){t(this,i),this.errorEvent=e(this,"error-event",7),this.submitEvent=e(this,"submit-event",7),this.checkoutChangedEvent=e(this,"checkout-changed",7),this.plaidService=new V,this.handlePaypalStarted=()=>{k.isWalletProcessing=!0},this.handlePaypalCompleted=t=>{const{success:e,paymentMethodId:i,fundingSource:s}=t.detail||{};k.isWalletProcessing=!1,e&&i?(k.paymentToken=i,k.selectedPaymentMethod={type:"venmo"===s?Q.VENMO:Q.PAYPAL},this.submitCheckout()):this.errorEvent.emit({message:"Paypal payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})},this.handlePaypalCancelled=()=>{k.isWalletProcessing=!1,k.paymentToken=void 0,k.selectedPaymentMethod=void 0},this.handlePaypalError=t=>{k.isWalletProcessing=!1;const{error:e,code:i}=t.detail||{};this.errorEvent.emit({message:e||"Paypal error occurred",errorCode:`PAYPAL_${i}`,severity:p.ERROR})},this.handleApplePayStarted=()=>{k.isWalletProcessing=!0},this.handleGooglePayStarted=()=>{k.isWalletProcessing=!0},this.handleGooglePayCompleted=t=>{const{success:e,paymentMethodId:i,error:s}=t.detail||{};e&&i?(k.isWalletProcessing=!1,k.paymentToken=i,k.selectedPaymentMethod={type:Q.GOOGLE_PAY},this.submitCheckout()):(k.isWalletProcessing=!1,this.errorEvent.emit({message:s&&s.message||"Google Pay payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR}))},this.handleGooglePayCancelled=()=>{k.isWalletProcessing=!1,k.paymentToken=void 0,k.selectedPaymentMethod=void 0},this.handleApplePayCompleted=t=>{const{success:e,token:i,paymentMethodId:s,error:a}=t.detail;e&&i?(k.isWalletProcessing=!1,k.paymentToken=s,k.selectedPaymentMethod={type:Q.APPLE_PAY},this.submitCheckout()):(k.isWalletProcessing=!1,console.error("Apple Pay completed but failed:",a),this.errorEvent.emit({message:(null==a?void 0:a.message)||"Apple Pay payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR}))},this.handleApplePayError=t=>{k.isWalletProcessing=!1;const{error:e,code:i}=t.detail;console.error("Apple Pay error:",e),this.errorEvent.emit({message:e||"Apple Pay error occurred",errorCode:`APPLE_PAY_${i}`,severity:p.ERROR})},this.handleApplePayCancelled=()=>{k.isWalletProcessing=!1,k.paymentToken=void 0,k.selectedPaymentMethod=void 0}}connectedCallback(){var t;this.observer=new MutationObserver((()=>{this.queryFormRefs(),this.setupApplePayListeners(),this.setupGooglePayListeners(),this.setupPaypalListeners()})),this.observer.observe(this.hostEl,{childList:!0,subtree:!0}),k.checkoutId=this.checkoutId;const e={authToken:this.authToken,checkoutId:this.checkoutId,service:new F};this.getCheckout=B(e),this.completeCheckout=Y(e),null===(t=this.unsubscribeCheckoutChanges)||void 0===t||t.call(this),this.unsubscribeCheckoutChanges=j((()=>{this.emitCheckoutChanged()}))}componentWillLoad(){this.analytics=new R(this),U(),k.authToken=this.authToken,this.fetchCheckout(),L("set",(t=>{const e=z[t];void 0!==e&&x(t,e)&&this.fetchCheckout()}))}componentDidLoad(){this.queryFormRefs(),this.setupApplePayListeners(),this.setupGooglePayListeners(),this.setupPaypalListeners()}disconnectedCallback(){var t,e;null===(t=this.unsubscribeCheckoutChanges)||void 0===t||t.call(this),this.unsubscribeCheckoutChanges=void 0,null===(e=this.observer)||void 0===e||e.disconnect(),this.removeApplePayListeners(),this.removeGooglePayListeners(),this.removePaypalListeners()}fetchCheckout(){this.authToken&&this.checkoutId?this.getCheckout&&this.getCheckout({onSuccess:({checkout:t})=>{this.updateStore(t),t.status!==v.completed?t.status!==v.expired||this.errorEvent.emit({message:m.CHECKOUT_EXPIRED,errorCode:y.CHECKOUT_EXPIRED,severity:p.ERROR}):this.errorEvent.emit({message:m.CHECKOUT_ALREADY_COMPLETED,errorCode:y.CHECKOUT_ALREADY_COMPLETED,severity:p.ERROR})},onError:t=>{this.errorEvent.emit({message:t.message,errorCode:t.code,severity:t.severity})}}):this.errorEvent.emit({message:m.NOT_AUTHENTICATED,errorCode:y.NOT_AUTHENTICATED,severity:p.ERROR})}updateStore(t){var e,i,s,a,n,o,r,l,h,c,d,u,p,y,m;k.accountId=t.account_id;const v=null!=t.mode?String(t.mode).toLowerCase():"";k.checkoutMode="test"===v?"test":"live"===v?"live":null;const f=t.payment_methods.map((t=>new H(t))),g=Boolean(null===(e=t.payment_settings)||void 0===e?void 0:e.ach_payments);k.paymentMethods=f.filter((t=>t.type!==Q.SAVED_BANK_ACCOUNT||g)),k.paymentMethodGroupId=t.payment_method_group_id,k.paymentDescription=t.payment_description,k.totalAmount=t.total_amount,k.paymentAmount=t.payment_amount,k.bnplEnabled=t.payment_settings.bnpl_payments,k.insuranceEnabled=null!==(i=t.payment_settings.insurance_payments)&&void 0!==i&&i,k.bankAccountVerification=null===(s=t.payment_settings)||void 0===s?void 0:s.bank_account_verification,k.applePayEnabled=null!==(n=null===(a=t.payment_settings)||void 0===a?void 0:a.apple_payments)&&void 0!==n&&n,k.googlePayEnabled=null!==(r=null===(o=t.payment_settings)||void 0===o?void 0:o.google_payments)&&void 0!==r&&r,k.paypalEnabled=null!==(h=null===(l=t.payment_settings)||void 0===l?void 0:l.paypal_payments)&&void 0!==h&&h,k.paypalProviderClientId=null!==(d=null===(c=t.paypal)||void 0===c?void 0:c.provider_client_id)&&void 0!==d?d:"",k.achPaymentsEnabled=g,k.bnplProviderClientId=null===(u=null==t?void 0:t.bnpl)||void 0===u?void 0:u.provider_client_id,k.bnplProviderMode=null===(p=null==t?void 0:t.bnpl)||void 0===p?void 0:p.provider_mode,k.bnplProviderApiVersion=null===(y=null==t?void 0:t.bnpl)||void 0===y?void 0:y.provider_api_version,k.bnplProviderCheckoutUrl=null===(m=null==t?void 0:t.bnpl)||void 0===m?void 0:m.provider_checkout_url,k.paymentCurrency=(t.payment_currency||k.paymentCurrency).toUpperCase(),k.checkoutLoaded=!0}emitCheckoutChanged(){const t={availablePaymentMethodTypes:C(),selectedPaymentMethod:k.selectedPaymentMethod,savedPaymentMethods:k.paymentMethods};this.checkoutChangedEvent.emit(t)}queryFormRefs(){if(this.billingFormRef=this.hostEl.querySelector("justifi-billing-form, justifi-bank-account-billing-form-simple, justifi-card-billing-form-simple, justifi-billing-form-full, justifi-tokenize-payment-method"),this.applePayRef=this.hostEl.querySelector("justifi-apple-pay"),this.googlePayRef=this.hostEl.querySelector("justifi-google-pay"),this.paypalRef=this.hostEl.querySelector("justifi-paypal"),this.paymentMethodFormRef=this.hostEl.querySelector("justifi-card-form, justifi-bank-account-form, justifi-tokenize-payment-method"),!k.selectedPaymentMethod&&this.paymentMethodFormRef){const t=this.paymentMethodFormRef.tagName.toLowerCase();"justifi-card-form"===t?k.selectedPaymentMethod={type:Q.NEW_CARD}:"justifi-bank-account-form"!==t||k.checkoutLoaded&&!k.achPaymentsEnabled||(k.selectedPaymentMethod={type:Q.NEW_BANK_ACCOUNT})}this.insuranceFormRef=this.hostEl.querySelector("justifi-season-interruption-insurance")}setupApplePayListeners(){this.applePayRef&&(this.applePayRef.addEventListener("applePayStarted",this.handleApplePayStarted),this.applePayRef.addEventListener("applePayCompleted",this.handleApplePayCompleted),this.applePayRef.addEventListener("applePayError",this.handleApplePayError),this.applePayRef.addEventListener("applePayCancelled",this.handleApplePayCancelled))}removeApplePayListeners(){this.applePayRef&&(this.applePayRef.removeEventListener("applePayStarted",this.handleApplePayStarted),this.applePayRef.removeEventListener("applePayCompleted",this.handleApplePayCompleted),this.applePayRef.removeEventListener("applePayError",this.handleApplePayError),this.applePayRef.removeEventListener("applePayCancelled",this.handleApplePayCancelled))}setupGooglePayListeners(){this.googlePayRef&&(this.googlePayRef.addEventListener("googlePayStarted",this.handleGooglePayStarted),this.googlePayRef.addEventListener("googlePayCompleted",this.handleGooglePayCompleted),this.googlePayRef.addEventListener("googlePayCancelled",this.handleGooglePayCancelled))}removeGooglePayListeners(){this.googlePayRef&&(this.googlePayRef.removeEventListener("googlePayStarted",this.handleGooglePayStarted),this.googlePayRef.removeEventListener("googlePayCompleted",this.handleGooglePayCompleted),this.googlePayRef.removeEventListener("googlePayCancelled",this.handleGooglePayCancelled))}setupPaypalListeners(){this.paypalRef&&(this.paypalRef.addEventListener("paypalStarted",this.handlePaypalStarted),this.paypalRef.addEventListener("paypalCompleted",this.handlePaypalCompleted),this.paypalRef.addEventListener("paypalCancelled",this.handlePaypalCancelled),this.paypalRef.addEventListener("paypalError",this.handlePaypalError))}removePaypalListeners(){this.paypalRef&&(this.paypalRef.removeEventListener("paypalStarted",this.handlePaypalStarted),this.paypalRef.removeEventListener("paypalCompleted",this.handlePaypalCompleted),this.paypalRef.removeEventListener("paypalCancelled",this.handlePaypalCancelled),this.paypalRef.removeEventListener("paypalError",this.handlePaypalError))}async tokenizePaymentMethod(t){var e,i,s;const a=null!==(i=await(null===(e=this.billingFormRef)||void 0===e?void 0:e.getValues()))&&void 0!==i?i:{},n=Object.assign(Object.assign({},t),a),o=Object.assign({accountId:k.accountId,payment_method_group_id:void 0},n);k.savePaymentMethod&&(o.payment_method_group_id=k.paymentMethodGroupId);const r=await(null===(s=this.paymentMethodFormRef)||void 0===s?void 0:s.tokenize({clientId:this.authToken,paymentMethodMetadata:o,account:k.accountId}));return r.error?r:(k.paymentToken=r.id,r.id)}async fillBillingForm(t){k.billingFormFields=t}async setSelectedPaymentMethod(t){k.selectedPaymentMethod=t,k.paymentToken=t.id||void 0}async validate(){var t,e;const i=[];k.insuranceEnabled&&this.insuranceFormRef&&i.push(this.insuranceFormRef.validate());const s=(null===(t=k.selectedPaymentMethod)||void 0===t?void 0:t.type)===Q.NEW_CARD,a=(null===(e=k.selectedPaymentMethod)||void 0===e?void 0:e.type)===Q.NEW_BANK_ACCOUNT;if((s||a)&&(this.paymentMethodFormRef&&i.push(this.paymentMethodFormRef.validate()),this.billingFormRef&&i.push(this.billingFormRef.validate())),0===i.length)return!0;try{return!!(await Promise.all(i)).every((t=>"boolean"==typeof t?t:!1!==(null==t?void 0:t.isValid)))||(this.errorEvent.emit({message:"Validation error",errorCode:y.VALIDATION_ERROR,severity:p.ERROR}),!1)}catch(t){return!1}}async submitCheckout(t){var e,i,s,a,n,o,r,l;if(k.isSubmitting)return;k.isSubmitting=!0;const h=await this.validate();if(!k.selectedPaymentMethod)return k.isSubmitting=!1,void this.errorEvent.emit({message:"No payment method selected.",errorCode:y.VALIDATION_ERROR,severity:p.ERROR});const c=(null===(e=k.selectedPaymentMethod)||void 0===e?void 0:e.type)===Q.NEW_CARD,d=(null===(i=k.selectedPaymentMethod)||void 0===i?void 0:i.type)===Q.NEW_BANK_ACCOUNT,u=(null===(s=k.selectedPaymentMethod)||void 0===s?void 0:s.type)===Q.PLAID;if(c||d){const e=await this.tokenizePaymentMethod(t);if(null==e?void 0:e.error)return k.isSubmitting=!1,void this.errorEvent.emit({message:e.error.message,errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}if(u&&!k.paymentToken){const t=k.plaidPublicToken,e=k.plaidLinkTokenId;if(!t)return k.isSubmitting=!1,void this.errorEvent.emit({message:"Missing Plaid public token. Please connect your bank.",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR});try{const i=await this.plaidService.tokenizeBankAccount(k.authToken,k.accountId,t,e||void 0,k.savePaymentMethod?k.paymentMethodGroupId:void 0);if(null==i?void 0:i.error)return k.isSubmitting=!1,void this.errorEvent.emit({message:"string"==typeof i.error?i.error:i.error.message||"Failed to tokenize bank account",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR});const s=null==i?void 0:i.data,n=(null===(a=null==s?void 0:s.bank_account)||void 0===a?void 0:a.token)||(null==s?void 0:s.token)||(null==s?void 0:s.id);k.paymentToken=n}catch(t){return k.isSubmitting=!1,void this.errorEvent.emit({message:(null==t?void 0:t.message)||"Plaid exchange error",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}}if(!h)return k.isSubmitting=!1,void this.errorEvent.emit({message:"Please fill in all required fields.",errorCode:y.VALIDATION_ERROR,severity:p.ERROR});const m=(null===(n=k.selectedPaymentMethod)||void 0===n?void 0:n.type)===Q.SEZZLE;if(m){const t=this.hostEl.querySelector("justifi-sezzle-payment-method"),e=await(null==t?void 0:t.resolvePaymentMethod({isValid:h}));if("success"!==(null===(o=null==e?void 0:e.bnpl)||void 0===o?void 0:o.status))return k.isSubmitting=!1,void this.errorEvent.emit({message:(null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.message)||"Sezzle checkout was not completed.",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}if(!m&&!k.paymentToken)return k.isSubmitting=!1,void this.errorEvent.emit({message:"Payment token not found.",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR});const v={payment_mode:(t=>{switch(t){case Q.NEW_CARD:case Q.SAVED_CARD:case Q.NEW_BANK_ACCOUNT:case Q.SAVED_BANK_ACCOUNT:case Q.PLAID:return W.ECOM;case Q.SEZZLE:return W.BNPL;case Q.APPLE_PAY:return W.APPLE_PAY;case Q.GOOGLE_PAY:return W.GOOGLE_PAY;case Q.PAYPAL:return W.PAYPAL;case Q.VENMO:return W.VENMO;default:return}})(null===(l=k.selectedPaymentMethod)||void 0===l?void 0:l.type),payment_token:m?void 0:k.paymentToken};if(this.preCompleteHook){const t=T();try{await new Promise(((e,i)=>{this.preCompleteHook(t,(()=>e()),(()=>i()))}))}catch(t){return k.isSubmitting=!1,void console.log("Checkout cancelled by preCompleteHook",t)}}this.completeCheckout({payment:v,onSuccess:({checkout:t})=>{k.isSubmitting=!1,this.submitEvent.emit({checkout:t,message:"Checkout completed successfully"})},onError:t=>{k.isSubmitting=!1,this.errorEvent.emit({message:t.message,errorCode:y.COMPLETE_CHECKOUT_ERROR,severity:p.ERROR})}})}render(){return i(s,{key:"127bf2aea6758c7d91e33f252a3db4bc27b066ff"})}get hostEl(){return a(this)}},rt=n();class lt{async createPaypalOrder(t,e,i,s){return rt.post({endpoint:`checkouts/${e}/paypal/orders`,body:{funding_source:i},authToken:t,signal:s})}}const ht="paypal-script",ct=["paypal-payments","venmo-payments"],dt="PAYMENT_FAILED",ut="shown",pt=(t,e)=>{t&&(e?t.classList.add(ut):t.classList.remove(ut))},yt=class{constructor(i){t(this,i),this.paypalStarted=e(this,"paypalStarted",7),this.paypalCompleted=e(this,"paypalCompleted",7),this.paypalCancelled=e(this,"paypalCancelled",7),this.paypalError=e(this,"paypalError",7),this.paypalService=new lt,this.paypalEligible=!1,this.venmoEligible=!1,this.startSession=async(t,e)=>{if(!t)return;this.pendingOrderId=void 0,this.paypalStarted.emit({fundingSource:e});let i=!1;const s=this.createOrder(e).then((t=>({orderId:t.provider_order_id}))).catch((t=>{throw i=!0,this.emitError((null==t?void 0:t.message)||"Could not create the Paypal order","ORDER_ERROR"),t}));s.catch((()=>{}));try{await t.start({presentationMode:"auto"},s)}catch(t){if(i)return;this.emitError((null==t?void 0:t.message)||"Paypal payment failed",dt)}}}componentDidLoad(){k.checkoutLoaded?this.initializePaypal():P("checkoutLoaded",(t=>{t&&this.initializePaypal()}))}componentDidRender(){this.applyVisibility()}get currencyCode(){return(k.paymentCurrency||"USD").toUpperCase()}get showPaypal(){return!!k.paypalEnabled&&this.paypalEligible}get showVenmo(){return!!k.paypalEnabled&&this.venmoEligible&&"USD"===this.currencyCode}applyVisibility(){const{showPaypal:t,showVenmo:e}=this;pt(this.buttonsEl,t||e),pt(this.paypalButtonEl,t),pt(this.venmoButtonEl,e)}emitError(t,e){this.paypalError.emit({error:t,code:e})}loadPaypalScript(){const t=window.paypal;return t?Promise.resolve(t):new Promise(((t,e)=>{let i=document.head.querySelector(`script[data-test-id="${ht}"]`);i||(i=document.createElement("script"),i.src="test"===k.checkoutMode?"https://www.sandbox.paypal.com/web-sdk/v6/core":"https://www.paypal.com/web-sdk/v6/core",i.async=!0,i.setAttribute("data-test-id",ht),document.head.appendChild(i)),i.addEventListener("load",(()=>{const i=window.paypal;i?t(i):e(new Error("Paypal script loaded but window.paypal is undefined"))})),i.addEventListener("error",(()=>e(new Error("Error loading Paypal script"))))}))}metadataId(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}async initializePaypal(){const t=k.paypalProviderClientId;if(!t)return this.paypalEligible=!1,this.venmoEligible=!1,this.applyVisibility(),void this.emitError("Missing Paypal client id","CONFIG_ERROR");try{const e=await this.loadPaypalScript();this.sdkInstance=await e.createInstance({clientId:t,components:ct,pageType:"checkout",metadataId:this.metadataId()});const i=await this.sdkInstance.findEligibleMethods({currencyCode:this.currencyCode});this.paypalEligible=i.isEligible("paypal"),this.venmoEligible=i.isEligible("venmo"),this.paypalEligible&&(this.paypalSession=this.sdkInstance.createPayPalOneTimePaymentSession(this.sessionOptions("paypal"))),this.venmoEligible&&(this.venmoSession=this.sdkInstance.createVenmoOneTimePaymentSession(this.sessionOptions("venmo"))),this.applyVisibility()}catch(t){this.paypalEligible=!1,this.venmoEligible=!1,this.applyVisibility(),this.emitError((null==t?void 0:t.message)||"Error initializing Paypal","INITIALIZATION_ERROR")}}sessionOptions(t){return{onApprove:()=>this.paypalCompleted.emit({success:!0,paymentMethodId:this.pendingOrderId,fundingSource:t}),onCancel:()=>this.paypalCancelled.emit({fundingSource:t}),onError:t=>this.emitError((null==t?void 0:t.message)||"Paypal payment failed",dt)}}async createOrder(t){const e=await this.paypalService.createPaypalOrder(k.authToken,k.checkoutId,t);if(null==e?void 0:e.error)throw new Error(("string"==typeof e.error?e.error:e.error.message)||"Could not create the Paypal order");const i=null==e?void 0:e.data;if(!(null==i?void 0:i.provider_order_id))throw new Error("Paypal order is missing a provider order id");return this.pendingOrderId=i.id,i}render(){return i(M,{key:"05c771ae41d3b21da7046e70c7d0e03efc296a0c"},i("div",{key:"8e7a14372ce29b4da284efadb43c27d0c059607e",class:"paypal-buttons",ref:t=>this.buttonsEl=t},i("paypal-button",{key:"aa7fa82c96ca4d41872f445a01e72a18f6f5920a",type:"pay",ref:t=>this.paypalButtonEl=t,onClick:()=>this.startSession(this.paypalSession,"paypal")}),i("venmo-button",{key:"2cb068aa82460068548f133607cebec096028a41",type:"pay",ref:t=>this.venmoButtonEl=t,onClick:()=>this.startSession(this.venmoSession,"venmo")})),i("style",{key:"159cc68f682ed79a9a83be7d1b4c88127f8a2623"},"\n .paypal-buttons {\n display: none;\n gap: 8px;\n width: 100%;\n }\n .paypal-buttons.shown {\n display: flex;\n }\n .paypal-buttons > * {\n display: none;\n flex: 1 1 0;\n min-width: 0;\n }\n .paypal-buttons > .shown {\n display: block;\n }\n "))}},mt=class{constructor(i){t(this,i),this.paymentMethodOptionSelected=e(this,"paymentMethodOptionSelected",7),this.plaidError=e(this,"plaidError",7),this.plaidErrorRecovered=e(this,"plaidErrorRecovered",7),this.isAuthenticating=!1,this.publicToken=null,this.linkToken=null,this.linkTokenId=null,this.error=null,this.plaidLink=null,this.isSelected=!1,this.retryCount=0,this.isRetrying=!1,this.sdkLoaded=!1,this.plaidService=new V,this.maxRetries=3,this.retryDelay=2e3,this.timeoutId=null,this.abortController=null,this.hasLoggedDisabledWarning=!1,this.hasLoggedAchPaymentsDisabledWarning=!1,this.waitForStoreAndInitialize=()=>{k.authToken&&k.accountId&&k.checkoutId?this.initializePlaidLink():setTimeout((()=>{this.waitForStoreAndInitialize()}),100)},this.initializePlaidLink=async()=>{try{if(void 0===window.Plaid)return void this.handleError({code:b.PLAID_SDK_LOAD_FAILED,message:g[b.PLAID_SDK_LOAD_FAILED],severity:f[b.PLAID_SDK_LOAD_FAILED],retryable:!0,userAction:"Refresh the page and try again"});if(await this.getLinkToken(),!this.linkToken)return void this.handleError({code:b.PLAID_LINK_TOKEN_FAILED,message:g[b.PLAID_LINK_TOKEN_FAILED],severity:f[b.PLAID_LINK_TOKEN_FAILED],retryable:!0,userAction:"Click to try again"});const t=window.Plaid;this.plaidLink=t.create({token:this.linkToken,onSuccess:this.handlePlaidSuccess,onExit:this.handlePlaidExit,onEvent:this.handlePlaidEvent,onLoad:this.handlePlaidLoad})}catch(t){this.handleError({code:b.PLAID_LINK_INIT_FAILED,message:g[b.PLAID_LINK_INIT_FAILED],severity:f[b.PLAID_LINK_INIT_FAILED],originalError:t,retryable:!0,userAction:"Click to try again"})}},this.getLinkToken=async()=>{var t,e,i,s,a;try{if(!k.authToken||!k.accountId)return void this.handleError({code:b.PLAID_LINK_TOKEN_FAILED,message:"Missing authentication. Please refresh the page and try again.",severity:p.ERROR,retryable:!1,userAction:"Refresh the page"});this.abortController=new AbortController,this.timeoutId=setTimeout((()=>{var t;null===(t=this.abortController)||void 0===t||t.abort()}),3e4);const e=await this.plaidService.getLinkToken(k.authToken,k.accountId,k.checkoutId,this.abortController.signal);if(this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),e.error)throw new Error("string"==typeof e.error?e.error:e.error.message||"Failed to get link token");this.linkToken=e.data.link_token,this.linkTokenId=(null==e?void 0:e.id)||(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.id)||null,this.linkTokenId&&(k.plaidLinkTokenId=this.linkTokenId)}catch(t){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null);let n=b.PLAID_LINK_TOKEN_FAILED,o=g[n],r=!0;"AbortError"===t.name?(n=b.PLAID_TIMEOUT,o=g[n],r=!0):(null===(e=t.message)||void 0===e?void 0:e.includes("network"))||(null===(i=t.message)||void 0===i?void 0:i.includes("fetch"))?(n=b.PLAID_NETWORK_ERROR,o=g[n],r=!0):((null===(s=t.message)||void 0===s?void 0:s.includes("401"))||(null===(a=t.message)||void 0===a?void 0:a.includes("unauthorized")))&&(n=b.PLAID_INVALID_CREDENTIALS,o="Authentication failed. Please refresh the page and try again.",r=!1),this.handleError({code:n,message:o,severity:f[n],originalError:t,retryable:r,userAction:r?"Click to try again":"Refresh the page"})}},this.mapApiErrorToPlaidError=t=>{if("string"==typeof t){if(t.includes("rate_limit"))return b.PLAID_RATE_LIMITED;if(t.includes("maintenance"))return b.PLAID_MAINTENANCE;if(t.includes("not_authenticated"))return b.PLAID_INVALID_CREDENTIALS}if(null==t?void 0:t.code)switch(t.code){case"rate_limited":return b.PLAID_RATE_LIMITED;case"maintenance":return b.PLAID_MAINTENANCE;case"not_authenticated":return b.PLAID_INVALID_CREDENTIALS;default:return b.PLAID_LINK_TOKEN_FAILED}return b.PLAID_LINK_TOKEN_FAILED},this.openPlaidLink=()=>{this.plaidLink&&this.linkToken&&(this.isAuthenticating=!0,this.clearError(),this.plaidLink.open())},this.handlePlaidSuccess=t=>{this.publicToken=t,this.isAuthenticating=!1,this.clearError(),this.retryCount=0,this.isSelected||(this.isSelected=!0,k.selectedPaymentMethod={type:Q.PLAID}),this.plaidErrorRecovered.emit({code:"plaid-success",message:"Bank account connected successfully",severity:p.INFO}),k.plaidPublicToken=t},this.handlePlaidExit=t=>{this.isAuthenticating=!1,t&&this.handlePlaidError(t)},this.handlePlaidEvent=(t,e)=>{switch(t){case"OPEN":this.isAuthenticating=!0;break;case"CLOSE":this.isAuthenticating=!1;break;case"ERROR":this.handlePlaidError(e)}},this.handlePlaidLoad=()=>{},this.handlePlaidError=t=>{let e=b.PLAID_AUTHENTICATION_FAILED,i=g[e],s=!0,a="Click to try again";if(t.error_code)switch(t.error_code){case"INVALID_CREDENTIALS":e=b.PLAID_INVALID_CREDENTIALS,i=g[e],s=!0;break;case"ITEM_LOGIN_REQUIRED":e=b.PLAID_INVALID_CREDENTIALS,i="Your bank requires re-authentication. Please try again.",s=!0;break;case"ITEM_LOCKED":e=b.PLAID_ACCOUNT_LOCKED,i=g[e],s=!1,a="Contact your bank";break;case"INSTITUTION_NOT_RESPONDING":e=b.PLAID_MAINTENANCE,i=g[e],s=!0;break;case"RATE_LIMIT_EXCEEDED":e=b.PLAID_RATE_LIMITED,i=g[e],s=!0;break;case"INVALID_REQUEST":e=b.PLAID_AUTHENTICATION_FAILED,i="Invalid request. Please try again.",s=!0;break;case"PLAID_ERROR":e=b.PLAID_AUTHENTICATION_FAILED,i=t.error_message||"Bank authentication failed. Please try again.",s=!0;break;default:t.error_message&&(i=t.error_message)}if(t.error_message){const n=t.error_message.toLowerCase();n.includes("not supported")||n.includes("unsupported")?(e=b.PLAID_BANK_NOT_SUPPORTED,i=g[e],s=!1,a="Try a different payment method"):(n.includes("expired")||n.includes("timeout"))&&(e=b.PLAID_TOKEN_EXPIRED,i=g[e],s=!0)}this.handleError({code:e,message:i,severity:f[e],originalError:t,retryable:s,userAction:a}),this.isAuthenticating=!1},this.handleError=t=>{this.error=t,this.plaidError.emit({code:t.code,message:t.message,severity:t.severity,data:{originalError:t.originalError,retryable:t.retryable,userAction:t.userAction,retryCount:this.retryCount}}),console.error("Plaid error:",t),t.retryable&&this.retryCount<this.maxRetries&&this.scheduleRetry()},this.scheduleRetry=()=>{this.isRetrying||(this.isRetrying=!0,this.retryCount++,setTimeout((()=>{this.isRetrying=!1,this.clearError(),this.waitForStoreAndInitialize()}),this.retryDelay*this.retryCount))},this.clearError=()=>{this.error&&(this.error=null,this.retryCount=0)},this.syncWithStore=()=>{var t;const e=(null===(t=k.selectedPaymentMethod)||void 0===t?void 0:t.type)===Q.PLAID;this.isSelected!==e&&(this.isSelected=e)}}onSelectionChange(t){var e;t&&(null===(e=k.selectedPaymentMethod)||void 0===e?void 0:e.type)!==Q.PLAID&&(k.selectedPaymentMethod={type:Q.PLAID}),!t||!this.plaidLink||this.publicToken||this.isAuthenticating||this.error||this.openPlaidLink()}componentWillLoad(){var t;this.isSelected=(null===(t=k.selectedPaymentMethod)||void 0===t?void 0:t.type)===Q.PLAID,!0===k.bankAccountVerification&&(k.checkoutLoaded?k.achPaymentsEnabled&&this.loadPlaidSDK():P("checkoutLoaded",(t=>{t&&!0===k.bankAccountVerification&&k.achPaymentsEnabled&&this.loadPlaidSDK()})))}loadPlaidSDK(){if(this.sdkLoaded)return;this.sdkLoaded=!0;const t=document.createElement("script");t.src="https://cdn.plaid.com/link/v2/stable/link-initialize.js",t.async=!0,t.onload=()=>this.initializePlaidLink(),t.onerror=()=>{this.handleError({code:b.PLAID_SDK_LOAD_FAILED,message:g[b.PLAID_SDK_LOAD_FAILED],severity:f[b.PLAID_SDK_LOAD_FAILED],retryable:!0,userAction:"Refresh the page and try again"})},document.head.appendChild(t)}async resolvePaymentMethod(){return this.publicToken?{token:this.publicToken,data:{type:"bank_account",plaid_public_token:this.publicToken}}:{validationError:!0}}async getPaymentToken(){return k.paymentToken}async handleSelectionClick(){if(this.isSelected=!0,k.selectedPaymentMethod={type:Q.PLAID},this.error)return this.clearError(),void this.waitForStoreAndInitialize();!this.plaidLink||this.publicToken||this.isAuthenticating||this.openPlaidLink()}async setSelected(t){this.isSelected=t,t&&(k.selectedPaymentMethod={type:Q.PLAID})}async isCurrentlySelected(){return this.isSelected}async deselect(){this.isSelected=!1}async reset(){this.publicToken=null,this.clearError(),this.isAuthenticating=!1,this.linkToken=null,this.plaidLink=null,this.retryCount=0,this.isRetrying=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.abortController&&(this.abortController.abort(),this.abortController=null)}async isReadyForAuthentication(){return!(!this.plaidLink||!this.linkToken||this.isAuthenticating)}async retry(){this.error&&this.error.retryable&&(this.clearError(),this.waitForStoreAndInitialize())}async getErrorInfo(){return this.error}componentDidLoad(){const t=P("selectedPaymentMethod",this.syncWithStore);this.unsubscribeFromStore=t}disconnectedCallback(){this.unsubscribeFromStore&&this.unsubscribeFromStore(),this.timeoutId&&clearTimeout(this.timeoutId),this.abortController&&this.abortController.abort()}render(){if(k.checkoutLoaded&&!k.achPaymentsEnabled)return this.hasLoggedAchPaymentsDisabledWarning||(console.warn("[JustifiPlaidPaymentMethod] ACH payments are disabled for this checkout. Component will not render."),this.hasLoggedAchPaymentsDisabledWarning=!0),null;if(!0!==k.bankAccountVerification)return this.hasLoggedDisabledWarning||(console.warn("[JustifiPlaidPaymentMethod] bank_account_verification is disabled. Component will not render."),this.hasLoggedDisabledWarning=!0),null;const t=i("img",{class:"plaid-logo-img",src:"data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ4IiB2aWV3Qm94PSIwIDAgMjggMjkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgY2xhc3M9ImNzcy0xcmRhajhtIj48ZyBmaWxsPSIjMTExIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yNS43NjI5IDI2LjI2MjhMMjggMTcuNTMwOUwyNC45NjkxIDE0LjUwMDFMMjcuOTk5OSAxMS40NjkxTDI1Ljc2MjggMi43MzcwNkwxNy4wMzA5IDAuNUwxNC4wMDAxIDMuNTMxTDEwLjk2OSAwLjUwMDE0TDIuMjM3MDYgMi43MzczNEwwIDExLjQ2OTFMMy4wMzEyOCAxNC40OTk5TDAuMDAwMTQgMTcuNTMxTDIuMjM3MiAyNi4yNjI5TDEwLjk2OTEgMjguNUwxNC4wMDAxIDI1LjQ2OUwxNy4wMzEgMjguNDk5OUwyNS43NjI5IDI2LjI2MjhaTTE1LjczMjEgMjMuNzM3MUwxOC42MTg2IDIwLjg1MDVMMjIuMjkxMiAyNC41MjMzTDE3LjY5NTYgMjUuNzAwN0wxNS43MzIxIDIzLjczNzFaTTExLjExMzYgOS44ODE1NEwxNC4wMDAzIDYuOTk1MDJMMTYuODg2OCA5Ljg4MTRMMTQuMDAwMSAxMi43Njc5TDExLjExMzYgOS44ODE1NFpNMTIuMjY4MiAxNC41TDkuMzgxNTQgMTcuMzg2NUw2LjQ5NTAyIDE0LjVMOS4zODE1NCAxMS42MTM1TDEyLjI2ODIgMTQuNVpNMTguNjE4NyAxMS42MTMzTDIxLjUwNTMgMTQuNUwxOC42MTg2IDE3LjM4NjVMMTUuNzMyMSAxNC41TDE4LjYxODcgMTEuNjEzM1pNMTYuODg2NyAxOS4xMTg2TDE0LjAwMDEgMjIuMDA1MUwxMS4xMTM1IDE5LjExODVMMTQuMDAwMSAxNi4yMzE5TDE2Ljg4NjcgMTkuMTE4NlpNMTAuMzA0NCAyNS43MDA3TDUuNzA4NjQgMjQuNTIzM0w5LjM4MTU0IDIwLjg1MDRMMTIuMjY4MiAyMy43MzcxTDEwLjMwNDQgMjUuNzAwN1pNNC43NjMwOCAxNi4yMzE5TDcuNjQ5NiAxOS4xMTg1TDMuOTc2NyAyMi43OTE0TDIuNzk5MyAxOC4xOTU3TDQuNzYzMDggMTYuMjMxOVpNMy45NzY3IDYuMjA4MzZMNy42NDk3NCA5Ljg4MTRMNC43NjMwOCAxMi43NjgxTDIuNzk5MyAxMC44MDQxTDMuOTc2NyA2LjIwODM2Wk0xMi4yNjgzIDUuMjYyOTRMOS4zODE2OCA4LjE0OTZMNS43MDg5MiA0LjQ3NjdMMTAuMzA0NyAzLjI5OTNMMTIuMjY4MyA1LjI2Mjk0Wk0xNy42OTU5IDMuMjk5M0wyMi4yOTE1IDQuNDc2N0wxOC42MTg2IDguMTQ5NDZMMTUuNzMyMSA1LjI2Mjk0TDE3LjY5NTkgMy4yOTkzWk0yMy4yMzcyIDEyLjc2ODFMMjAuMzUwNSA5Ljg4MTRMMjQuMDIzMyA2LjIwODc4TDI1LjIwMDcgMTAuODA0NkwyMy4yMzcyIDEyLjc2ODFaTTI0LjAyMzMgMjIuNzkxNEwyMC4zNTA1IDE5LjExODZMMjMuMjM3MiAxNi4yMzIxTDI1LjIwMDcgMTguMTk1N0wyNC4wMjMzIDIyLjc5MTRaIj48L3BhdGg+PC9nPjwvc3ZnPgo=",alt:"Plaid",title:"Plaid",style:{display:"inline",width:"20px",height:"20px",marginLeft:"5px",marginTop:"-2px"}});return i(M,{class:"payment-method"},i("div",{title:"Pay with Plaid"},i("div",{onClick:t=>{t.preventDefault(),this.handleSelectionClick()}},"Pay with Bank Account ",t," "),(()=>this.error?i("div",{class:(this.error.severity===p.ERROR?"text-danger":this.error.severity===p.WARNING?"text-warning":"text-info")+" mt-2"},i("small",null,this.error.message),i("br",null),i("small",{class:"text-muted"},this.error.userAction,this.error.retryable&&this.retryCount<this.maxRetries&&i("span",null," • Auto-retry in progress..."))):null)(),(()=>this.error?null:this.isAuthenticating?i("div",{class:"text-info mt-2"},i("small",null,"Connecting to your bank...")):this.publicToken?i("div",{class:"text-success mt-2"},i("small",null,"✓ Bank account connected successfully")):!this.isSelected||this.publicToken||this.error||this.isAuthenticating?null:i("div",{class:"text-muted mt-2"},i("small",null,"Click to connect your bank account")))()))}static get watchers(){return{isSelected:["onSelectionChange"]}}},vt=class{constructor(e){t(this,e),this.onPaymentMethodOptionClick=t=>e=>{e.preventDefault(),k.selectedPaymentMethod={id:t.id,type:t.type},k.paymentToken=t.id},this.isAllowedPaymentMethod=t=>!(t===Q.SAVED_CARD&&k.disableCreditCard||t===Q.SAVED_BANK_ACCOUNT&&k.disableBankAccount)}componentWillLoad(){k.checkoutLoaded&&(k.paymentMethods.length||console.warn("No saved payment methods available."),k.disablePaymentMethodGroup&&console.warn("Payment method group is disabled."))}render(){return k.disablePaymentMethodGroup?null:i(M,null,i("div",{class:"saved-payment-methods"},k.paymentMethods.length?k.paymentMethods.filter((t=>this.isAllowedPaymentMethod(t.type))).map((t=>i("div",{class:"radio-list-item p-3",part:E,onClick:this.onPaymentMethodOptionClick(t)},i("form-control-radio",{name:"paymentMethodType",value:null==t?void 0:t.id,checked:k.paymentToken===(null==t?void 0:t.id),label:`${Z[null==t?void 0:t.brand]||""} *${null==t?void 0:t.acct_last_four}`})))):null))}},ft=class{constructor(i){t(this,i),this.paymentMethodOptionSelected=e(this,"paymentMethodOptionSelected",7),this.paymentMethodOptionId=Q.SEZZLE,this.initializeSezzleCheckout=()=>{const t=Number(k.paymentAmount),e=new(0,window.Checkout)({mode:"popup",publicKey:k.bnplProviderClientId,apiMode:k.bnplProviderMode,apiVersion:k.bnplProviderApiVersion});e.sezzleButtonElement=this.sezzleButtonRef,e.init({onClick:function(t){t.preventDefault(),e.startCheckout({checkout_url:k.bnplProviderCheckoutUrl})},onComplete:t=>{var e;return null===(e=this.resolveSezzlePromise)||void 0===e?void 0:e.call(this,{bnpl:t.data})},onCancel:t=>{var e;return null===(e=this.resolveSezzlePromise)||void 0===e?void 0:e.call(this,{bnpl:t.data})},onFailure:t=>{var e;return null===(e=this.resolveSezzlePromise)||void 0===e?void 0:e.call(this,{bnpl:t.data})}}),this.sezzleCheckout=e,this.installmentPlan=this.sezzleCheckout.getInstallmentPlan(t)}}componentDidRender(){this.scriptRef&&(this.scriptRef.onload=()=>{this.sezzleButtonRef=document.createElement("button"),this.initializeSezzleCheckout()})}async resolvePaymentMethod(t){if(!t.isValid)return{validationError:!0};if(!this.sezzleButtonRef)return{error:{code:"sezzle_not_ready",message:"Sezzle is not ready yet. Please try again.",decline_code:""}};const e=new Promise((t=>{this.resolveSezzlePromise=t}));return this.sezzleButtonRef.click(),e}async handleSelectionClick(){k.selectedPaymentMethod={type:Q.SEZZLE},this.paymentMethodOptionSelected.emit(this.paymentMethodOptionId)}render(){var t,e;return k.bnplEnabled?i(M,{class:"payment-method"},i("script",{src:"https://checkout-sdk.sezzle.com/checkout.min.js",async:!0,ref:t=>this.scriptRef=t}),i("div",null,i("div",null,"Buy now, pay later with ",i("img",{class:"sezzle-smart-button-logo-img",src:"https://media.sezzle.com/branding/2.0/Sezzle_Logo_FullColor.svg",alt:"Sezzle",style:{display:"inline",width:"80px",marginLeft:"5px",marginTop:"-5px"}})),this.installmentPlan&&i("small",null,i("span",null,null===(t=this.installmentPlan)||void 0===t?void 0:t.installments.length)," ",i("span",null,this.installmentPlan.schedule," payments of")," ",i("span",{class:"fw-bold"},I(null===(e=this.installmentPlan)||void 0===e?void 0:e.installments[0].amountInCents))))):(console.warn("justifi-sezzle-payment-method: BNPL is not enabled for this account."),null)}},gt={[Q.NEW_BANK_ACCOUNT]:"New bank account",[Q.NEW_CARD]:"New credit or debit card"},bt="Payment form not ready",Mt="Validation error",wt=class{constructor(i){t(this,i),this.errorEvent=e(this,"error-event",7),this.submitEvent=e(this,"submit-event",7),this.computedHideSubmitButton=!1,this.isLoading=!1,this.submitButtonText="Submit"}paymentMethodsChanged(){this.setDefaultSelectedPaymentMethod()}connectedCallback(){this.setDefaultSelectedPaymentMethod(),this.setComputedHideSubmitButton()}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup(),this.unsubscribeFromStore&&this.unsubscribeFromStore()}componentWillLoad(){U(),this.analytics=new R(this)}handleRadioClick(t){this.selectedPaymentMethod=t.detail,k.selectedPaymentMethod={type:t.detail}}async tokenizePaymentMethod(t){null==t||t.preventDefault(),this.validateRequiredProps(),this.isLoading=!0;try{if(!(await this.validate()).isValid)return this.errorEvent.emit({errorCode:y.TOKENIZE_ERROR,message:Mt}),void(this.isLoading=!1);const t=await this.resolvePaymentMethod({isValid:!0});return t.error&&this.emitError({errorCode:t.error.code,message:t.error.message}),this.submitEvent.emit({response:t}),t}catch(t){const e=this.createErrorResponse(y.TOKENIZE_ERROR,t.message);return this.emitError({errorCode:y.TOKENIZE_ERROR,message:t.message}),this.submitEvent.emit({response:e}),e}finally{this.isLoading=!1}}async fillBillingForm(t){k.billingFormFields=t}async validate(){if(!this.areFormsReady())return{isValid:!1,errors:{general:bt}};const[t,e]=await Promise.all([this.billingFormRef.validate(),this.paymentMethodFormRef.validate()]);return{isValid:t.isValid&&e.isValid,errors:Object.assign(Object.assign({},t.errors),e.errors)}}async getValues(){return this.billingFormRef.getValues()}async tokenize(){try{const t=await this.billingFormRef.getValues(),e={clientId:this.authToken||k.authToken,account:this.accountId||k.accountId,paymentMethodMetadata:this.buildPaymentMethodMetadata(t)};return await this.paymentMethodFormRef.tokenize(e)}catch(t){return t}}validateRequiredProps(){this.authToken||k.authToken||this.emitError({errorCode:y.TOKENIZE_ERROR,message:"Auth token is required when using the tokenize-payment-method component not slotted in justifi-modular-checkout"}),this.accountId||k.accountId||this.emitError({errorCode:y.TOKENIZE_ERROR,message:"Account ID is required when using the tokenize-payment-method component not slotted in justifi-modular-checkout"})}setDefaultSelectedPaymentMethod(){this.selectedPaymentMethod||(this.disableCreditCard?this.disableBankAccount||k.checkoutLoaded&&!k.achPaymentsEnabled||(this.selectedPaymentMethod=Q.NEW_BANK_ACCOUNT,k.selectedPaymentMethod={type:Q.NEW_BANK_ACCOUNT}):(this.selectedPaymentMethod=Q.NEW_CARD,k.selectedPaymentMethod={type:Q.NEW_CARD}))}setComputedHideSubmitButton(){if(void 0!==this.hideSubmitButton)return void(this.computedHideSubmitButton=this.hideSubmitButton);const t=this.isSlottedWithinModularCheckout();this.computedHideSubmitButton=t}isSlottedWithinModularCheckout(){var t;let e=null===(t=this.host)||void 0===t?void 0:t.parentElement;for(;e;){if("JUSTIFI-MODULAR-CHECKOUT"===e.tagName)return!0;e=e.parentElement}return!1}get availablePaymentMethods(){const t=[],e=!k.checkoutLoaded||k.achPaymentsEnabled;return this.disableCreditCard||t.push(Q.NEW_CARD),!this.disableBankAccount&&e&&t.push(Q.NEW_BANK_ACCOUNT),t}areFormsReady(){return!(!this.billingFormRef||!this.paymentMethodFormRef)}emitError(t){this.errorEvent.emit(Object.assign(Object.assign({},t),{severity:p.ERROR}))}createErrorResponse(t,e){return{error:{code:t,message:e,decline_code:void 0}}}async resolvePaymentMethod(t){if(!this.areFormsReady())return this.createErrorResponse("form_not_ready",bt);try{const e=await this.validate();if(!e.isValid||!t.isValid){const t=Object.values(e.errors)[0]||Mt;return{validationError:!0,error:{code:"validation_error",message:String(t),decline_code:void 0}}}return await this.performTokenization()}catch(t){return{error:t}}}async performTokenization(){var t,e;const i=await this.tokenize();if(i.error)return{error:i.error};const s=i.data;return{token:(null===(t=s.card)||void 0===t?void 0:t.token)||(null===(e=s.bank_account)||void 0===e?void 0:e.token),data:s}}buildPaymentMethodMetadata(t){return this.shouldSavePaymentMethod?Object.assign(Object.assign({},t),{payment_method_group_id:this.paymentMethodGroupID}):Object.assign({},t)}get paymentMethodGroupID(){return this.paymentMethodGroupId||k.paymentMethodGroupId}get shouldSavePaymentMethod(){return!(!this.paymentMethodGroupId&&!k.savePaymentMethod)}get shouldHideRadioInput(){return this.disableCreditCard||this.disableBankAccount}renderPaymentMethodOption(t){const e=this.selectedPaymentMethod===t&&void 0===k.selectedPaymentMethod.id;return i("div",{class:"payment-method"},i("radio-list-item",{name:"paymentMethodType",value:t,checked:e,label:gt[t],hidden:this.shouldHideRadioInput}),e&&this.renderSelectedPaymentMethodForm(t))}renderSelectedPaymentMethodForm(t){return i("div",{class:"mt-4 pb-4"},this.renderPaymentMethodForm(t),i("div",{class:"mt-4"},i("billing-form",{ref:t=>{t&&(this.billingFormRef=t)},hideCardBillingForm:this.hideCardBillingForm,hideBankAccountBillingForm:this.hideBankAccountBillingForm,paymentMethodType:t})),i("div",{class:"mt-4"},i("save-new-payment-method",{hidden:!this.paymentMethodGroupID,label:this.savePaymentMethodLabel})))}renderPaymentMethodForm(t){return i(t===Q.NEW_CARD?"card-form":"bank-account-form",{ref:t=>{t&&(this.paymentMethodFormRef=t)}})}render(){return i(M,{key:"16a5a47febb09295c95f141ddc96a849e530c477"},i("form",{key:"e1ac3ac80435b32cb0a742198d814778bffd635c"},i("fieldset",{key:"68d0f984d3e66a6abc794e8b2086e27f26ecc809"},i("div",{key:"b1759ec1b9c94a976da992947b06da6d8f48f553",class:"row gy-3"},i("div",{key:"bc1ef82406d3da36c5d4d97b1a10259de87fdd09",class:"col-12"},this.availablePaymentMethods.map((t=>this.renderPaymentMethodOption(t)))),i("div",{key:"ed26f2908aa90daba5ab320a668369566b9dacfa",class:"col-12"},i("internal-button",{key:"094cdacb592825374ad33dd80a05091747bfec4b",text:this.submitButtonText,variant:"primary",type:"submit",clickHandler:t=>this.tokenizePaymentMethod(t),isLoading:this.isLoading,"data-testid":"submit-button",hidden:this.computedHideSubmitButton}))))))}get host(){return a(this)}static get watchers(){return{disableCreditCard:["paymentMethodsChanged"],disableBankAccount:["paymentMethodsChanged"]}}};export{X as justifi_apple_pay,tt as justifi_button,et as justifi_checkout_summary,at as justifi_google_pay,nt as justifi_header,ot as justifi_modular_checkout,yt as justifi_paypal,mt as justifi_plaid_payment_method,G as justifi_radio_list_item,vt as justifi_saved_payment_methods,ft as justifi_sezzle_payment_method,wt as justifi_tokenize_payment_method}
@@ -1 +1 @@
1
- import{r as t,h as o}from"./p-CV0Pyo1O.js";import{J as r}from"./p-BHaO3c8W.js";import{c as a}from"./p-ByQMBEDC.js";import{w as s}from"./p-B4vLfYnZ.js";import{S as p}from"./p-05AWudQe.js";import"./p-CZfYo5-1.js";import"./p-Dn9_7aQh.js";import"./p-Bl00tHyn.js";import"./p-Ds_P-dB8.js";import"./p-HXpYMWUU.js";import"./p-D6uhYbLo.js";import"./p-CLHwhyvu.js";import"./p-DaDqgDrb.js";import"./p-DgTOxu8x.js";const i=class{constructor(o){t(this,o)}async componentWillLoad(){await s(),a(),this.analytics=new r(this)}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}async validate(){return this.cardFormElement.validate()}async tokenize({clientId:t,paymentMethodMetadata:o,account:r}){return this.cardFormElement.tokenize({clientId:t,paymentMethodMetadata:o,account:r})}render(){return o(p,{key:"4fa9ff677d40a6733c33d34135fe85e52392f8b0"},o("card-form",{key:"3fe97adcb966b78dc28d5902409671e88525ca41",ref:t=>this.cardFormElement=t}))}};export{i as justifi_card_form}
1
+ import{r as t,h as o}from"./p-CV0Pyo1O.js";import{J as r}from"./p-nbKvRcwU.js";import{c as s}from"./p-BEL8sLz6.js";import{w as a}from"./p-B4vLfYnZ.js";import{S as p}from"./p-05AWudQe.js";import"./p-CZfYo5-1.js";import"./p-CAVi_ne1.js";import"./p-vIQBTQmc.js";import"./p-Ds_P-dB8.js";import"./p-HXpYMWUU.js";import"./p-D6uhYbLo.js";import"./p-CLHwhyvu.js";import"./p-DaDqgDrb.js";import"./p-DgTOxu8x.js";const i=class{constructor(o){t(this,o)}async componentWillLoad(){await a(),s(),this.analytics=new r(this)}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}async validate(){return this.cardFormElement.validate()}async tokenize({clientId:t,paymentMethodMetadata:o,account:r}){return this.cardFormElement.tokenize({clientId:t,paymentMethodMetadata:o,account:r})}render(){return o(p,{key:"4fa9ff677d40a6733c33d34135fe85e52392f8b0"},o("card-form",{key:"3fe97adcb966b78dc28d5902409671e88525ca41",ref:t=>this.cardFormElement=t}))}};export{i as justifi_card_form}