@justifi/webcomponents 6.12.4 → 6.12.5

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 (151) hide show
  1. package/dist/cjs/{Analytics-BERGweGK.js → Analytics-CITnMj7H.js} +3 -3
  2. package/dist/cjs/additional-questions-details_5.cjs.entry.js +1 -1
  3. package/dist/cjs/additional-questions-form-step_14.cjs.entry.js +4 -3
  4. package/dist/cjs/additional-questions_5.cjs.entry.js +1 -1
  5. package/dist/cjs/bank-account-billing-form-simple_4.cjs.entry.js +5 -5
  6. package/dist/cjs/bank-account-form.cjs.entry.js +2 -2
  7. package/dist/cjs/{business-identity-schema-DI9XFbaD.js → business-identity-schema-DuFGX6_i.js} +2 -2
  8. package/dist/cjs/card-form.cjs.entry.js +2 -2
  9. package/dist/cjs/{check-pkg-version-ByKpJklZ.js → check-pkg-version-CZMgXZID.js} +1 -1
  10. package/dist/cjs/{country-config-D7fss2oF.js → country-config-aJp8ScEs.js} +1 -0
  11. package/dist/cjs/dispute-notification_2.cjs.entry.js +3 -3
  12. package/dist/cjs/form-address-fields_3.cjs.entry.js +1 -1
  13. package/dist/cjs/form-control-number_2.cjs.entry.js +1 -1
  14. package/dist/cjs/hidden-input_2.cjs.entry.js +1 -1
  15. package/dist/cjs/justifi-apple-pay_11.cjs.entry.js +3 -3
  16. package/dist/cjs/justifi-bank-account-billing-form-simple.cjs.entry.js +3 -3
  17. package/dist/cjs/justifi-bank-account-form.cjs.entry.js +3 -3
  18. package/dist/cjs/justifi-business-details.cjs.entry.js +3 -3
  19. package/dist/cjs/justifi-business-form.cjs.entry.js +6 -6
  20. package/dist/cjs/justifi-card-form.cjs.entry.js +3 -3
  21. package/dist/cjs/justifi-checkout.cjs.entry.js +3 -3
  22. package/dist/cjs/justifi-checkouts-list.cjs.entry.js +3 -3
  23. package/dist/cjs/justifi-dispute-management.cjs.entry.js +3 -3
  24. package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +3 -3
  25. package/dist/cjs/justifi-order-terminals.cjs.entry.js +3 -3
  26. package/dist/cjs/justifi-payment-details.cjs.entry.js +3 -3
  27. package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +3 -3
  28. package/dist/cjs/justifi-payment-transactions-list.cjs.entry.js +3 -3
  29. package/dist/cjs/justifi-payments-list.cjs.entry.js +3 -3
  30. package/dist/cjs/justifi-payout-details.cjs.entry.js +3 -3
  31. package/dist/cjs/justifi-payout-transactions-list.cjs.entry.js +3 -3
  32. package/dist/cjs/justifi-payouts-list.cjs.entry.js +3 -3
  33. package/dist/cjs/justifi-refund-payment.cjs.entry.js +3 -3
  34. package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +3 -3
  35. package/dist/cjs/justifi-terminal-orders-list.cjs.entry.js +3 -3
  36. package/dist/cjs/justifi-terminals-list.cjs.entry.js +3 -3
  37. package/dist/cjs/{package-B6L3zyfG.js → package-DOiqjXmm.js} +1 -1
  38. package/dist/cjs/{schema-validations-_yWWnnaG.js → schema-validations-DNPcvDh5.js} +13 -2
  39. package/dist/collection/api/Analytics.js +2 -2
  40. package/dist/collection/components/business-details/owner-details/owner-details.js +1 -1
  41. package/dist/collection/components/business-forms/payment-provisioning/business-owners/business-owners-form-step.js +1 -0
  42. package/dist/collection/components/business-forms/schemas/schema-validations.js +2 -2
  43. package/dist/collection/components/checkout/billing-form/billing-form-full.js +2 -2
  44. package/dist/collection/components/checkout/billing-form/billing-form-schema.js +1 -1
  45. package/dist/collection/utils/checkout-billing-state-options.js +12 -0
  46. package/dist/docs.json +1 -1
  47. package/dist/esm/{Analytics-B1bQP71R.js → Analytics-Cg17Xhj_.js} +3 -3
  48. package/dist/esm/additional-questions-details_5.entry.js +1 -1
  49. package/dist/esm/additional-questions-form-step_14.entry.js +5 -4
  50. package/dist/esm/additional-questions_5.entry.js +1 -1
  51. package/dist/esm/additional-statement_8.entry.js +1 -1
  52. package/dist/esm/bank-account-billing-form-simple_4.entry.js +6 -6
  53. package/dist/esm/bank-account-form.entry.js +2 -2
  54. package/dist/esm/{business-identity-schema-D-Nk9aGV.js → business-identity-schema-0Q3kck3C.js} +3 -3
  55. package/dist/esm/card-form.entry.js +2 -2
  56. package/dist/esm/{check-pkg-version-CNwUC4SV.js → check-pkg-version-D-rHqtUI.js} +1 -1
  57. package/dist/esm/{country-config-B_fuF6JU.js → country-config-CdvhLcnT.js} +1 -1
  58. package/dist/esm/dispute-notification_2.entry.js +3 -3
  59. package/dist/esm/form-address-fields_3.entry.js +1 -1
  60. package/dist/esm/form-control-number_2.entry.js +1 -1
  61. package/dist/esm/hidden-input_2.entry.js +1 -1
  62. package/dist/esm/{index.esm-CgNcFueq.js → index.esm-BHdVU4hV.js} +1 -1
  63. package/dist/esm/justifi-apple-pay_11.entry.js +3 -3
  64. package/dist/esm/justifi-bank-account-billing-form-simple.entry.js +3 -3
  65. package/dist/esm/justifi-bank-account-form.entry.js +3 -3
  66. package/dist/esm/justifi-business-details.entry.js +3 -3
  67. package/dist/esm/justifi-business-form.entry.js +7 -7
  68. package/dist/esm/justifi-card-form.entry.js +3 -3
  69. package/dist/esm/justifi-checkout.entry.js +3 -3
  70. package/dist/esm/justifi-checkouts-list.entry.js +3 -3
  71. package/dist/esm/justifi-dispute-management.entry.js +3 -3
  72. package/dist/esm/justifi-gross-payment-chart.entry.js +3 -3
  73. package/dist/esm/justifi-order-terminals.entry.js +3 -3
  74. package/dist/esm/justifi-payment-details.entry.js +3 -3
  75. package/dist/esm/justifi-payment-provisioning.entry.js +3 -3
  76. package/dist/esm/justifi-payment-transactions-list.entry.js +3 -3
  77. package/dist/esm/justifi-payments-list.entry.js +3 -3
  78. package/dist/esm/justifi-payout-details.entry.js +3 -3
  79. package/dist/esm/justifi-payout-transactions-list.entry.js +3 -3
  80. package/dist/esm/justifi-payouts-list.entry.js +3 -3
  81. package/dist/esm/justifi-refund-payment.entry.js +4 -4
  82. package/dist/esm/justifi-season-interruption-insurance.entry.js +3 -3
  83. package/dist/esm/justifi-terminal-orders-list.entry.js +3 -3
  84. package/dist/esm/justifi-terminals-list.entry.js +3 -3
  85. package/dist/esm/{package-OGt0dCJl.js → package-B6YPrwyC.js} +1 -1
  86. package/dist/esm/{schema-validations-u9_XnlUL.js → schema-validations-A1o1biOB.js} +14 -4
  87. package/dist/module/Analytics.js +2 -2
  88. package/dist/module/billing-form-full2.js +2 -2
  89. package/dist/module/billing-form-schema.js +1 -1
  90. package/dist/module/business-address-schema.js +1 -1
  91. package/dist/module/business-bank-account-form-step2.js +1 -1
  92. package/dist/module/business-core-info-schema.js +1 -1
  93. package/dist/module/business-identity-schema.js +1 -1
  94. package/dist/module/business-owners-form-step2.js +1 -0
  95. package/dist/module/country-config.js +1 -1
  96. package/dist/module/owner-details2.js +1 -1
  97. package/dist/module/package.js +1 -1
  98. package/dist/module/schema-validations.js +13 -3
  99. package/dist/types/utils/checkout-billing-state-options.d.ts +9 -0
  100. package/dist/webcomponents/{p-8aa53ef2.entry.js → p-0ce6c1b1.entry.js} +1 -1
  101. package/dist/webcomponents/{p-215c6b6b.entry.js → p-137a36a4.entry.js} +1 -1
  102. package/dist/webcomponents/{p-07236291.entry.js → p-1d294e34.entry.js} +1 -1
  103. package/dist/webcomponents/{p-383b8317.entry.js → p-1f34b2f7.entry.js} +1 -1
  104. package/dist/webcomponents/{p-35dd1fc0.entry.js → p-1f7f2436.entry.js} +1 -1
  105. package/dist/webcomponents/{p-b341efd6.entry.js → p-2aac2ab6.entry.js} +1 -1
  106. package/dist/webcomponents/{p-a1dcdc8b.entry.js → p-397b28ba.entry.js} +4 -4
  107. package/dist/webcomponents/{p-a80f69a9.entry.js → p-3cefb032.entry.js} +1 -1
  108. package/dist/webcomponents/{p-45c0fb53.entry.js → p-45668f01.entry.js} +1 -1
  109. package/dist/webcomponents/{p-3d6b9434.entry.js → p-5ec9634c.entry.js} +1 -1
  110. package/dist/webcomponents/{p-ae91fc9b.entry.js → p-60c65da4.entry.js} +1 -1
  111. package/dist/webcomponents/{p-b272a29d.entry.js → p-63e88b48.entry.js} +1 -1
  112. package/dist/webcomponents/{p-91aef5bf.entry.js → p-65281b33.entry.js} +1 -1
  113. package/dist/webcomponents/{p-f3ff7e00.entry.js → p-7ff9ce05.entry.js} +1 -1
  114. package/dist/webcomponents/{p-c8f3656f.entry.js → p-89844a98.entry.js} +1 -1
  115. package/dist/webcomponents/{p-69fdd137.entry.js → p-8d6856e7.entry.js} +1 -1
  116. package/dist/webcomponents/{p-7119fddd.entry.js → p-8e821593.entry.js} +1 -1
  117. package/dist/webcomponents/{p-9d021e10.entry.js → p-90f2f71d.entry.js} +1 -1
  118. package/dist/webcomponents/p-91940d05.entry.js +1 -0
  119. package/dist/webcomponents/{p-8d173a7c.entry.js → p-95317547.entry.js} +1 -1
  120. package/dist/webcomponents/p-B6YPrwyC.js +1 -0
  121. package/dist/webcomponents/{p-DwoT0UoX.js → p-CKiAlBsU.js} +1 -1
  122. package/dist/webcomponents/p-D8ytux5N.js +1 -0
  123. package/dist/webcomponents/p-DO9lqnbB.js +1 -0
  124. package/dist/webcomponents/{p-mF5zKtkx.js → p-DjjAx7PF.js} +1 -1
  125. package/dist/webcomponents/p-DrMJliVY.js +1 -0
  126. package/dist/webcomponents/p-XIWgia4J.js +1 -0
  127. package/dist/webcomponents/{p-ea0d7a98.entry.js → p-afe714cb.entry.js} +1 -1
  128. package/dist/webcomponents/p-b192f251.entry.js +1 -0
  129. package/dist/webcomponents/{p-daaa2a99.entry.js → p-b436a7d2.entry.js} +1 -1
  130. package/dist/webcomponents/{p-c9fe4f33.entry.js → p-bde7fe69.entry.js} +1 -1
  131. package/dist/webcomponents/{p-6220a384.entry.js → p-c108cd71.entry.js} +1 -1
  132. package/dist/webcomponents/{p-d24240a5.entry.js → p-c4415366.entry.js} +1 -1
  133. package/dist/webcomponents/{p-f30069ea.entry.js → p-c8bc235f.entry.js} +1 -1
  134. package/dist/webcomponents/{p-4ec433f4.entry.js → p-d1eabad2.entry.js} +1 -1
  135. package/dist/webcomponents/{p-49a4123c.entry.js → p-d5e7291a.entry.js} +1 -1
  136. package/dist/webcomponents/p-e17b92ec.entry.js +1 -0
  137. package/dist/webcomponents/{p-cde76bf8.entry.js → p-e322dcba.entry.js} +1 -1
  138. package/dist/webcomponents/p-e6ec9e6d.entry.js +1 -0
  139. package/dist/webcomponents/{p-9fc7714d.entry.js → p-ff8cf16c.entry.js} +1 -1
  140. package/dist/webcomponents/webcomponents.esm.js +1 -1
  141. package/package.json +2 -2
  142. package/readme.md +7 -14
  143. package/dist/webcomponents/p-31452258.entry.js +0 -1
  144. package/dist/webcomponents/p-3f5e9afb.entry.js +0 -1
  145. package/dist/webcomponents/p-6RTf1SXX.js +0 -1
  146. package/dist/webcomponents/p-Cz_7BuGW.js +0 -1
  147. package/dist/webcomponents/p-DyucNSA4.js +0 -1
  148. package/dist/webcomponents/p-KXLYEe1D.js +0 -1
  149. package/dist/webcomponents/p-OGt0dCJl.js +0 -1
  150. package/dist/webcomponents/p-e4cb7c21.entry.js +0 -1
  151. package/dist/webcomponents/p-ef85717f.entry.js +0 -1
@@ -0,0 +1 @@
1
+ import{S as e}from"./p-BcNb9bVO.js";const a=[{label:"Choose province",value:""},{label:"Alberta",value:"AB"},{label:"British Columbia",value:"BC"},{label:"Manitoba",value:"MB"},{label:"New Brunswick",value:"NB"},{label:"Newfoundland and Labrador",value:"NL"},{label:"Northwest Territories",value:"NT"},{label:"Nova Scotia",value:"NS"},{label:"Nunavut",value:"NU"},{label:"Ontario",value:"ON"},{label:"Prince Edward Island",value:"PE"},{label:"Quebec",value:"QC"},{label:"Saskatchewan",value:"SK"},{label:"Yukon",value:"YT"}],l={USA:{stateLabel:"State",postalLabel:"Zip Code",idNumberLabel:"SSN",idNumberLabelOptional:"SSN (optional)",identityHelpText:"Enter your full Social Security Number. It is required for Federal OFAC check.",taxIdLabel:"Tax ID (EIN or SSN)",taxIdHelpText:"Employer Identification Numbers (EINs) are nine digits. The federal tax identification number/EIN issued to you by the IRS. It can be found on your tax returns. Enter value without dashes."},CAN:{stateLabel:"Province",postalLabel:"Postal Code",idNumberLabel:"SIN",idNumberLabelOptional:"SIN (optional)",identityHelpText:"Enter your full Social Insurance Number.",taxIdLabel:"Business Number (BN)",taxIdHelpText:"Business Numbers (BN) are nine digits. Enter value without spaces or dashes."}},t={USA:{stateOptions:e},CAN:{stateOptions:a}},i={USA:{postalRegex:/^[0-9]{5}(-[0-9]{4})?$/,identityDigits:9,taxIdDigits:9},CAN:{postalRegex:/^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$/,identityDigits:9,taxIdDigits:9}};export{a as P,i as a,t as b,l as c}
@@ -0,0 +1 @@
1
+ import{p as t}from"./p-B6YPrwyC.js";import{A as s}from"./p-CYQvLgSs.js";import"./p-NZS8uCtH.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";const i=s();class e{async record(t){return i.post({endpoint:"analytics",body:t})}}class n{constructor(t){this.eventListeners=new Map,this.handleCustomEvent=async t=>{await this.service.record(t)},window.location.origin.includes("localhost")||window.location.origin.includes("docs.justifi.tech")||(this.service=new e,this.componentInstance=t,this.setUpBasicData(),this.setupLifecycleTracking(),this.trackCustomEvents())}get resourceId(){return this.componentInstance.accountId||this.componentInstance.businessId||this.componentInstance.paymentId||this.componentInstance.payoutId||this.componentInstance.checkoutId}setUpBasicData(){this.basicData={component_name:this.componentInstance.tagName,component_version:t.version,client_user_agent:navigator.userAgent,client_platform:navigator.userAgent,client_origin:window.location.origin,resource_id:this.resourceId}}trackCustomEvents(){this.eventEmitters=["submit-event","error-event"],this.eventEmitters.forEach((t=>{if("function"==typeof this.componentInstance.addEventListener){const s=s=>this.handleCustomEvent({event_type:t,data:Object.assign(Object.assign({},this.basicData),"error-event"===t&&{error:s.detail})});this.eventListeners.set(t,s),this.componentInstance.addEventListener(t,s)}}))}setupLifecycleTracking(){const t=this.componentInstance.componentDidLoad;this.componentInstance.componentDidLoad=()=>{if(this.service.record({event_type:"init",data:this.basicData}),t)return t.apply(this.componentInstance)}}cleanup(){this.eventListeners.forEach(((t,s)=>{this.componentInstance.removeEventListener(s,t)})),this.eventListeners.clear()}}export{n as J}
@@ -1 +1 @@
1
- import{p as e}from"./p-OGt0dCJl.js";const s="__JUSTIFI_WC_VERSION__",o=async()=>{var o,t;if((()=>{if("undefined"==typeof globalThis)return;const o=e.version,t=globalThis[s];t&&t!==o?console.error(`@justifi/webcomponents: Multiple versions detected. Version ${t} was loaded first and registered all components. Version ${o} is also present but its components will NOT be used. To fix this, add to your package.json:\n"pnpm": { "overrides": { "@justifi/webcomponents": "${o}" } }`):globalThis[s]=o})(),"undefined"!=typeof process&&("test"===(null===(o=process.env)||void 0===o?void 0:o.NODE_ENV)||(null===(t=process.env)||void 0===t?void 0:t.JEST_WORKER_ID)))return;const i=e.version,n=e.name,a=await(async e=>{const s=await fetch("https://registry.npmjs.org/"+e+"/latest");return(await s.json()).version})(n),r=a.replace(/-rc.*/,""),l=i.split("."),p=a.split(".");l[0]!==p[0]&&console.warn(`The package ${n} is out of date. The latest version is ${r}. Please update.`)};export{o as c}
1
+ import{p as e}from"./p-B6YPrwyC.js";const s="__JUSTIFI_WC_VERSION__",o=async()=>{var o,t;if((()=>{if("undefined"==typeof globalThis)return;const o=e.version,t=globalThis[s];t&&t!==o?console.error(`@justifi/webcomponents: Multiple versions detected. Version ${t} was loaded first and registered all components. Version ${o} is also present but its components will NOT be used. To fix this, add to your package.json:\n"pnpm": { "overrides": { "@justifi/webcomponents": "${o}" } }`):globalThis[s]=o})(),"undefined"!=typeof process&&("test"===(null===(o=process.env)||void 0===o?void 0:o.NODE_ENV)||(null===(t=process.env)||void 0===t?void 0:t.JEST_WORKER_ID)))return;const i=e.version,n=e.name,a=await(async e=>{const s=await fetch("https://registry.npmjs.org/"+e+"/latest");return(await s.json()).version})(n),r=a.replace(/-rc.*/,""),l=i.split("."),p=a.split(".");l[0]!==p[0]&&console.warn(`The package ${n} is out of date. The latest version is ${r}. Please update.`)};export{o as c}
@@ -0,0 +1 @@
1
+ import{c as e,a as s}from"./p-CKiAlBsU.js";import{m as t,d as a,i as n,b as i,a as r,p as o,e as l,w as _,c,t as d,o as u,f as m,r as p,g as b,h,l as E,j as f,k as v,n as g,s as w,q as y,u as $,v as x,x as S}from"./p-XIWgia4J.js";import{C as j}from"./p-BcNb9bVO.js";import{c as B}from"./p-D8ytux5N.js";const C=s=>{const t=e({legal_name:c.required("Enter legal name"),website_url:_.required("Enter business website url"),email:l.required("Enter business email"),phone:o.required("Enter phone number"),doing_business_as:r.nullable(),classification:i.required("Select business classification"),industry:n.required("Enter a business industry"),date_of_incorporation:a.required("Enter date of registration")}),u=e({legal_name:c.required("Enter legal name"),website_url:_.nullable(),email:l.nullable(),phone:o.nullable(),doing_business_as:r.nullable(),classification:i.nullable(),industry:n.nullable(),tax_id:d.nullable(),date_of_incorporation:a.nullable()});return s?u:t},N=a=>C(a).concat(e({classification:s().required("Select business classification"),tax_id:t(j.USA).when("tax_id_last4",{is:e=>!e,then:e=>e.required(`Enter valid ${B.USA.taxIdLabel} without dashes`),otherwise:e=>e.nullable()})})),k=a=>C(a).concat(e({classification:s().required("Select business classification"),tax_id:t(j.CAN).when("tax_id_last4",{is:e=>!e,then:e=>e.required(`Enter valid ${B.CAN.taxIdLabel} without dashes`),otherwise:e=>e.nullable()})})),q=s=>{const t=e({business_revenue:p.required("Enter business revenue"),business_payment_volume:b.required("Enter business payment volume"),business_average_transaction_amount:p.required("Enter average transaction amount"),business_when_service_received:m.required("Select when service is received"),business_other_payment_details:u.nullable()}),a=e({business_revenue:p.nullable(),business_payment_volume:b.nullable(),business_average_transaction_amount:p.nullable(),business_when_service_received:m.nullable(),business_other_payment_details:u.nullable()});return s?a:t},A=t=>e(t?{line1:f.nullable(),line2:E.nullable(),city:h.nullable(),state:s().nullable(),postal_code:s().nullable()}:{line1:f.required("Enter street address"),line2:E.nullable(),city:h.required("Enter city"),state:s().required("Select state"),postal_code:v(j.USA).required("Enter postal code")}),D=t=>e(t?{line1:f.nullable(),line2:E.nullable(),city:h.nullable(),state:s().nullable(),postal_code:s().nullable()}:{line1:f.required("Enter street address"),line2:E.nullable(),city:h.required("Enter city"),state:s().required("Select province"),postal_code:v(j.CAN).required("Enter postal code")}),I={[j.USA]:A,[j.CAN]:D},J=(t,a)=>a?(t=>e({name:x.required(`Enter ${t} name`),title:$.nullable(),email:l.nullable(),phone:o.nullable(),dob_full:y(t).nullable(),ssn_last4:s().nullable(),identification_number:w.nullable(),ownership_percentage:g.nullable(),address:A(!0)}))(t):(t=>e({name:x.required(`Enter ${t} name`),title:$.required(`Enter ${t} title`),email:l.required(`Enter ${t} email`),phone:o.required("Enter phone number"),dob_full:y(t).required("Enter date of birth"),ssn_last4:s().nullable(),identification_number:w,ownership_percentage:g.nullable(),address:A(!1)}))(t),K=(t,a)=>a?(t=>e({name:x.required(`Enter ${t} name`),title:$.nullable(),email:l.nullable(),phone:o.nullable(),dob_full:y(t).nullable(),ssn_last4:s().nullable(),identification_number:S(j.CAN).nullable(),ownership_percentage:g.nullable(),address:D(!0)}))(t):(t=>e({name:x.required(`Enter ${t} name`),title:$.required(`Enter ${t} title`),email:l.required(`Enter ${t} email`),phone:o.required("Enter phone number"),dob_full:y(t).required("Enter date of birth"),ssn_last4:s().nullable(),identification_number:S(j.CAN),ownership_percentage:g.nullable(),address:D(!1)}))(t),O={[j.USA]:J,[j.CAN]:K};export{q as a,N as b,A as c,k as d,K as e,D as f,O as g,I as h,J as i}
@@ -0,0 +1 @@
1
+ import{a as e}from"./p-CKiAlBsU.js";import{P as a,a as t}from"./p-D8ytux5N.js";import{S as s,C as r}from"./p-BcNb9bVO.js";import{b as n,a as i}from"./p-Bt4GjEWL.js";const l=[{label:"Choose state / province",value:""},...s.filter((e=>""!==e.value)),...a.filter((e=>""!==e.value))],d=e=>""===e?null:e,o=/^\d+$/,u=/P\.?\s?O\.?\s?Box|Postal\sBox/i,c=e().email("Enter valid email").transform(d),m=e().matches(/^\d{10}$/,"Enter valid phone number").transform(d),b=e().min(2,"Name must be at least 2 characters").max(100,"Name must be less than 100 characters").transform(d),h=e().min(2,"Name must be at least 2 characters").max(100,"Name must be less than 100 characters").transform(d),v=e().matches(/^(?:http(s)?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/,"Enter valid website url").transform(d),N=e().transform(d),E=e().min(2,"Industry must be at least 2 characters").max(50,"Industry must be less than 50 characters").transform(d),p=e().matches(o,"Enter valid tax id, SSN, or EIN").test("not-repeat","Enter valid tax id, SSN, or EIN",(e=>!/^(\d)\1+$/.test(e))).test("not-seq","Enter valid tax id, SSN, or EIN",(e=>"123456789"!==e)).transform(d),S=a=>e().matches(t[a].postalRegex,"Enter valid postal code").transform(d),B=a=>a===r.CAN?e().matches(o,"Enter valid SIN").length(t[a].identityDigits,"Enter valid SIN").when("ssn_last4",{is:e=>!e||0===e.length,then:e=>e.required("Enter SIN"),otherwise:e=>e.nullable()}).test("not-repeat","Enter valid SIN",(e=>!/^(\d)\1+$/.test(e))).test("not-seq","Enter valid SIN",(e=>"123456789"!==e)).transform(d):$,A=a=>a===r.CAN?e().matches(o,"Enter valid Business Number (BN)").length(t[a].taxIdDigits,"Enter valid Business Number (BN)").test("not-repeat","Enter valid Business Number (BN)",(e=>!/^(\d)\1+$/.test(e))).test("not-seq","Enter valid Business Number (BN)",(e=>"123456789"!==e)).transform(d):p,w=e().test("not-future","Date of incorporation cannot be in the future",(e=>new Date(e)<=new Date)).transform(d),g=e().min(2,"Name must be at least 2 characters").max(100,"Name must be less than 100 characters").transform(d),x=e().min(2,"Title must be at least 2 characters").max(50,"Title must be less than 50 characters").transform(d),y=a=>e().test("min","Enter a valid date",(e=>new Date(e)>=new Date("1902-01-01"))).test("age",`${a} must be at least 18 years old`,(e=>{const a=new Date(e),t=new Date;return t.setFullYear(t.getFullYear()-18),a<=t})).transform(d),$=e().matches(/^(?!000|666|9\d{2})\d{3}(?!00)\d{2}(?!0000)\d{4}$/,"Enter valid SSN").when("ssn_last4",{is:e=>!e||0===e.length,then:e=>e.required("Enter SSN"),otherwise:e=>e.nullable()}).test("not-repeat","Enter valid SSN",(e=>!/^(\d)\1+$/.test(e))).test("not-seq","Enter valid SSN",(e=>"123456789"!==e)).transform(d),I=e().matches(o,"Enter valid percentage").test("min","Percentage must be at least 0",(e=>!e||parseFloat(e)>=0)).test("max","Percentage must be at most 100",(e=>!e||parseFloat(e)<=100)).transform(d),f=e().min(5,"Address must be at least 5 characters").max(100,"Address must be less than 100 characters").test("not-po-box","A PO Box is not a valid address entry",(e=>!u.test(e))).transform(d),D=e().max(100,"Address must be less than 100 characters").test("not-po-box","A PO Box is not a valid address entry",(e=>!u.test(e))).transform(d),P=e().min(2,"City must be at least 2 characters").max(50,"City must be less than 50 characters").transform(d),j=e().oneOf(l.map((e=>e.value)),"Select a valid state or province").transform(d),C=e().matches(/^((\d{5}-\d{4})|(\d{5})|([A-Z]\d[A-Z]\s\d[A-Z]\d))$/,"Enter valid postal code").transform(d),q=e().matches(o,"Enter valid revenue").transform(d),Z=e().matches(o,"Enter valid payment volume").transform(d),z=e().oneOf(n.map((e=>e.value)),"Select when service is received").transform(d),O=e().transform(d),_=e().min(2,"Name must be at least 2 characters").max(50,"Name must be less than 50 characters").transform(d),F=e().min(2,"Name must be at least 2 characters").max(50,"Name must be less than 50 characters").transform(d),G=e().oneOf(i.map((e=>e.value)),"Select account type").transform(d),T=e().min(4,"Account number must be at least 4 digits").max(17,"Account number must be less than 17 digits").matches(o,"Enter valid account number").test("not-repeat","Enter valid account number",(e=>!/^(\d)\1+$/.test(e))).transform(d),k=e().length(9,"Routing number must be 9 digits").matches(o,"Enter valid routing number").test("not-repeat","Enter valid routing number",(e=>!/^(\d)\1+$/.test(e))).test("valid","Enter valid routing number",(e=>(e=>{if(!e)return!1;const a=Array.from(String(e),Number);return 9===a.length&&0==(3*(a[0]+a[3]+a[6])+7*(a[1]+a[4]+a[7])+(a[2]+a[5]+a[8]))%10})(e))).transform(d);export{l as A,T as B,G as C,F as D,_ as E,o as F,k as G,h as a,N as b,b as c,w as d,c as e,z as f,Z as g,P as h,E as i,f as j,S as k,D as l,A as m,I as n,O as o,m as p,y as q,q as r,$ as s,p as t,x as u,g as v,v as w,B as x,C as y,j as z}
@@ -1 +1 @@
1
- import{r as e,c as t,h as a}from"./p-CV0Pyo1O.js";import{J as i}from"./p-Cz_7BuGW.js";import{c as s}from"./p-mF5zKtkx.js";import{c as d}from"./p-BArmtmkq.js";import{c}from"./p-CPKMvyV_.js";import{S as o}from"./p-BqNNwq6C.js";import"./p-CZfYo5-1.js";import{P as f}from"./p-DkoufM1t.js";import"./p-OGt0dCJl.js";import"./p-CYQvLgSs.js";import"./p-DVJaoI_m.js";import"./p-D8GTwl9v.js";import"./p-BRnBHsdq.js";import"./p-HXpYMWUU.js";import"./p-NZS8uCtH.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";const h=class{constructor(a){e(this,a),this.errorEvent=t(this,"error-event",7),this.loadedEvent=t(this,"loaded",7),this.submitEvent=t(this,"submit-event",7),this.availablePaymentMethods=[],this.errorMessage="",this.insuranceToggled=!1,this.disableBankAccount=!1,this.disableBnpl=!1,this.disableCreditCard=!1,this.disablePaymentMethodGroup=!1,this.hideBankAccountBillingForm=!1,this.hideCardBillingForm=!1}propChanged(){this.updateStore()}connectedCallback(){this.authToken&&this.checkoutId&&this.updateStore()}componentWillLoad(){s(),this.analytics=new i(this)}disconnectedCallback(){var e;null===(e=this.analytics)||void 0===e||e.cleanup()}checkoutComplete(e){d.isSubmitting=!1}checkoutError(e){d.isSubmitting=!1}checkoutChanged(e){this.availablePaymentMethods=this.disableBnpl?e.detail.availablePaymentMethodTypes.filter((e=>e!==f.SEZZLE)):e.detail.availablePaymentMethodTypes}async fillBillingForm(e){d.billingFormFields=e}async validate(){var e;return{isValid:await(null===(e=this.modularCheckoutRef)||void 0===e?void 0:e.validate())}}updateStore(){d.checkoutId=this.checkoutId,d.authToken=this.authToken,d.disableCreditCard=this.disableCreditCard,d.disableBankAccount=this.disableBankAccount,d.disablePaymentMethodGroup=this.disablePaymentMethodGroup}async submit(e){var t;null===(t=this.modularCheckoutRef)||void 0===t||t.submitCheckout(d.billingFormFields)}get showPaymentTypeHeader(){return!this.disableCreditCard&&!this.disableBankAccount}render(){var e,t;return a(o,{key:"ffd2abaacc7edae588a9abe3a4ff96807b34fcff"},a("justifi-modular-checkout",{key:"9196c278e24353aeb1ac02c85253d629f683522b",ref:e=>{this.modularCheckoutRef=e},authToken:this.authToken,checkoutId:this.checkoutId,preCompleteHook:this.preCompleteHook},a("div",{key:"895298286bc0aa6acbda896a4f148dd4f8d7e7d2",class:"row gy-3 jfi-checkout-core"},a("div",{key:"dd186ed2f0fd479cd60024423b6d55625b962e55",class:"col-12",part:c},a("justifi-header",{key:"920d4eca26846aa1cbc16693fa45a9d8054d95a7",text:"Summary",level:"h2",class:"fs-5 fw-bold pb-3"}),a("section",{key:"560f8c3757a7cf53fd0aa898fd243b16a2f8e8d5"},a("justifi-checkout-summary",{key:"31faa6ca984aa22985927a1f80273c86a67c7025"}))),a("div",{key:"3128ae40a739573da32598213a289d8751503fb0",class:"col-12 mt-4"},a("slot",{key:"4a310881bbc4017734082d5c4f6b41d3d5f2a424",name:"insurance"})),a("div",{key:"8047c4da62e2fd67bd0b3f8654c6a19c0cacc255",class:"col-12 mt-4"},a("justifi-header",{key:"631ff14201f6246906e3e1572515de21a7977773",text:"Payment",level:"h2",class:"fs-5 fw-bold pb-3"}),this.showPaymentTypeHeader&&a("justifi-header",{key:"7fdc560ef42a5c2e8571f332e3c4ce8ff460d235",text:"Select payment type",level:"h3",class:"fs-6 fw-bold lh-lg"}),a("div",{key:"81dcb52c051044adb4dbd92ac73ee3096edc592b",class:"d-flex flex-column"},a("section",{key:"4359903b195009a2e8fb997a1f77880cba40dea4"},a("div",{key:"21728867e6288c3fb7d5e5a6ee3d15974568b866"},this.availablePaymentMethods.includes(f.APPLE_PAY)&&a("div",{key:"bdaa6b6c6d09cba294b2e46b85270241c86d2251",class:"mb-3"},a("justifi-apple-pay",{key:"150d707bff7b79a1d19141f21a9c47e00e54418a"})),this.availablePaymentMethods.includes(f.GOOGLE_PAY)&&a("div",{key:"ce2be06b20a1e7d0159fde68a1c5c349c2d11998",class:"mb-3"},a("justifi-google-pay",{key:"0fc867ce77467eb1f1fd198a62e88bd2795f4914",ref:e=>this.googlePayRef=e})),a("justifi-saved-payment-methods",{key:"0bb1999c093b3837bfdb879134dc54f66c90e164"}),this.availablePaymentMethods.includes(f.SEZZLE)&&a("justifi-radio-list-item",{key:"1599be9bcea7569d822a204c805f08f18a4e00a4",name:"paymentMethodType",value:f.SEZZLE,checked:(null===(e=null==d?void 0:d.selectedPaymentMethod)||void 0===e?void 0:e.type)===f.SEZZLE,label:a("justifi-sezzle-payment-method",{ref:e=>this.sezzlePaymentMethodRef=e}),"onRadio-click":()=>{var e;null===(e=this.sezzlePaymentMethodRef)||void 0===e||e.handleSelectionClick()}}),this.availablePaymentMethods.includes(f.PLAID)&&!this.disableBnpl&&a("justifi-radio-list-item",{key:"c1de230257d290efa05f7a7166c2f069451c71a3",name:"paymentMethodType",value:f.PLAID,checked:(null===(t=null==d?void 0:d.selectedPaymentMethod)||void 0===t?void 0:t.type)===f.PLAID,label:a("justifi-plaid-payment-method",{ref:e=>this.plaidPaymentMethodRef=e}),"onRadio-click":()=>{var e;null===(e=this.plaidPaymentMethodRef)||void 0===e||e.handleSelectionClick()}}),a("justifi-tokenize-payment-method",{key:"44bca4ee57857afd4eee213cef98db2d4bd42490",ref:e=>this.tokenizePaymentMethodRef=e,authToken:this.authToken,accountId:d.accountId,disableCreditCard:this.disableCreditCard,disableBankAccount:this.disableBankAccount,hideCardBillingForm:this.hideCardBillingForm,hideBankAccountBillingForm:this.hideBankAccountBillingForm,hideSubmitButton:!0,paymentMethodGroupId:d.paymentMethodGroupId}))))),a("div",{key:"e5b6b4ac6b0fcec20380082f1b4cc5ba73bb88aa",class:"mt-4"},a("justifi-button",{key:"188a8f46fd37b5f4f2d9b3ba7ff179d44d4a6656",text:"Pay",type:"submit",variant:"primary",clickHandler:e=>this.submit(e),disabled:d.isSubmitting||d.isWalletProcessing,isLoading:d.isSubmitting||d.isWalletProcessing,customStyle:{width:"100%",textAlign:"center"}})))))}static get watchers(){return{authToken:["propChanged"],checkoutId:["propChanged"],disableCreditCard:["propChanged"],disableBankAccount:["propChanged"],disablePaymentMethodGroup:["propChanged"]}}};export{h as justifi_checkout}
1
+ import{r as e,c as t,h as a}from"./p-CV0Pyo1O.js";import{J as i}from"./p-DO9lqnbB.js";import{c as s}from"./p-DjjAx7PF.js";import{c as d}from"./p-BArmtmkq.js";import{c}from"./p-CPKMvyV_.js";import{S as o}from"./p-BqNNwq6C.js";import"./p-CZfYo5-1.js";import{P as f}from"./p-DkoufM1t.js";import"./p-B6YPrwyC.js";import"./p-CYQvLgSs.js";import"./p-DVJaoI_m.js";import"./p-D8GTwl9v.js";import"./p-BRnBHsdq.js";import"./p-HXpYMWUU.js";import"./p-NZS8uCtH.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";const h=class{constructor(a){e(this,a),this.errorEvent=t(this,"error-event",7),this.loadedEvent=t(this,"loaded",7),this.submitEvent=t(this,"submit-event",7),this.availablePaymentMethods=[],this.errorMessage="",this.insuranceToggled=!1,this.disableBankAccount=!1,this.disableBnpl=!1,this.disableCreditCard=!1,this.disablePaymentMethodGroup=!1,this.hideBankAccountBillingForm=!1,this.hideCardBillingForm=!1}propChanged(){this.updateStore()}connectedCallback(){this.authToken&&this.checkoutId&&this.updateStore()}componentWillLoad(){s(),this.analytics=new i(this)}disconnectedCallback(){var e;null===(e=this.analytics)||void 0===e||e.cleanup()}checkoutComplete(e){d.isSubmitting=!1}checkoutError(e){d.isSubmitting=!1}checkoutChanged(e){this.availablePaymentMethods=this.disableBnpl?e.detail.availablePaymentMethodTypes.filter((e=>e!==f.SEZZLE)):e.detail.availablePaymentMethodTypes}async fillBillingForm(e){d.billingFormFields=e}async validate(){var e;return{isValid:await(null===(e=this.modularCheckoutRef)||void 0===e?void 0:e.validate())}}updateStore(){d.checkoutId=this.checkoutId,d.authToken=this.authToken,d.disableCreditCard=this.disableCreditCard,d.disableBankAccount=this.disableBankAccount,d.disablePaymentMethodGroup=this.disablePaymentMethodGroup}async submit(e){var t;null===(t=this.modularCheckoutRef)||void 0===t||t.submitCheckout(d.billingFormFields)}get showPaymentTypeHeader(){return!this.disableCreditCard&&!this.disableBankAccount}render(){var e,t;return a(o,{key:"ffd2abaacc7edae588a9abe3a4ff96807b34fcff"},a("justifi-modular-checkout",{key:"9196c278e24353aeb1ac02c85253d629f683522b",ref:e=>{this.modularCheckoutRef=e},authToken:this.authToken,checkoutId:this.checkoutId,preCompleteHook:this.preCompleteHook},a("div",{key:"895298286bc0aa6acbda896a4f148dd4f8d7e7d2",class:"row gy-3 jfi-checkout-core"},a("div",{key:"dd186ed2f0fd479cd60024423b6d55625b962e55",class:"col-12",part:c},a("justifi-header",{key:"920d4eca26846aa1cbc16693fa45a9d8054d95a7",text:"Summary",level:"h2",class:"fs-5 fw-bold pb-3"}),a("section",{key:"560f8c3757a7cf53fd0aa898fd243b16a2f8e8d5"},a("justifi-checkout-summary",{key:"31faa6ca984aa22985927a1f80273c86a67c7025"}))),a("div",{key:"3128ae40a739573da32598213a289d8751503fb0",class:"col-12 mt-4"},a("slot",{key:"4a310881bbc4017734082d5c4f6b41d3d5f2a424",name:"insurance"})),a("div",{key:"8047c4da62e2fd67bd0b3f8654c6a19c0cacc255",class:"col-12 mt-4"},a("justifi-header",{key:"631ff14201f6246906e3e1572515de21a7977773",text:"Payment",level:"h2",class:"fs-5 fw-bold pb-3"}),this.showPaymentTypeHeader&&a("justifi-header",{key:"7fdc560ef42a5c2e8571f332e3c4ce8ff460d235",text:"Select payment type",level:"h3",class:"fs-6 fw-bold lh-lg"}),a("div",{key:"81dcb52c051044adb4dbd92ac73ee3096edc592b",class:"d-flex flex-column"},a("section",{key:"4359903b195009a2e8fb997a1f77880cba40dea4"},a("div",{key:"21728867e6288c3fb7d5e5a6ee3d15974568b866"},this.availablePaymentMethods.includes(f.APPLE_PAY)&&a("div",{key:"bdaa6b6c6d09cba294b2e46b85270241c86d2251",class:"mb-3"},a("justifi-apple-pay",{key:"150d707bff7b79a1d19141f21a9c47e00e54418a"})),this.availablePaymentMethods.includes(f.GOOGLE_PAY)&&a("div",{key:"ce2be06b20a1e7d0159fde68a1c5c349c2d11998",class:"mb-3"},a("justifi-google-pay",{key:"0fc867ce77467eb1f1fd198a62e88bd2795f4914",ref:e=>this.googlePayRef=e})),a("justifi-saved-payment-methods",{key:"0bb1999c093b3837bfdb879134dc54f66c90e164"}),this.availablePaymentMethods.includes(f.SEZZLE)&&a("justifi-radio-list-item",{key:"1599be9bcea7569d822a204c805f08f18a4e00a4",name:"paymentMethodType",value:f.SEZZLE,checked:(null===(e=null==d?void 0:d.selectedPaymentMethod)||void 0===e?void 0:e.type)===f.SEZZLE,label:a("justifi-sezzle-payment-method",{ref:e=>this.sezzlePaymentMethodRef=e}),"onRadio-click":()=>{var e;null===(e=this.sezzlePaymentMethodRef)||void 0===e||e.handleSelectionClick()}}),this.availablePaymentMethods.includes(f.PLAID)&&!this.disableBnpl&&a("justifi-radio-list-item",{key:"c1de230257d290efa05f7a7166c2f069451c71a3",name:"paymentMethodType",value:f.PLAID,checked:(null===(t=null==d?void 0:d.selectedPaymentMethod)||void 0===t?void 0:t.type)===f.PLAID,label:a("justifi-plaid-payment-method",{ref:e=>this.plaidPaymentMethodRef=e}),"onRadio-click":()=>{var e;null===(e=this.plaidPaymentMethodRef)||void 0===e||e.handleSelectionClick()}}),a("justifi-tokenize-payment-method",{key:"44bca4ee57857afd4eee213cef98db2d4bd42490",ref:e=>this.tokenizePaymentMethodRef=e,authToken:this.authToken,accountId:d.accountId,disableCreditCard:this.disableCreditCard,disableBankAccount:this.disableBankAccount,hideCardBillingForm:this.hideCardBillingForm,hideBankAccountBillingForm:this.hideBankAccountBillingForm,hideSubmitButton:!0,paymentMethodGroupId:d.paymentMethodGroupId}))))),a("div",{key:"e5b6b4ac6b0fcec20380082f1b4cc5ba73bb88aa",class:"mt-4"},a("justifi-button",{key:"188a8f46fd37b5f4f2d9b3ba7ff179d44d4a6656",text:"Pay",type:"submit",variant:"primary",clickHandler:e=>this.submit(e),disabled:d.isSubmitting||d.isWalletProcessing,isLoading:d.isSubmitting||d.isWalletProcessing,customStyle:{width:"100%",textAlign:"center"}})))))}static get watchers(){return{authToken:["propChanged"],checkoutId:["propChanged"],disableCreditCard:["propChanged"],disableBankAccount:["propChanged"],disablePaymentMethodGroup:["propChanged"]}}};export{h as justifi_checkout}
@@ -0,0 +1 @@
1
+ import{h as t,r as e,c as a}from"./p-CV0Pyo1O.js";import"./p-DVJaoI_m.js";import"./p-HXpYMWUU.js";import{h as s,C as i,e as r}from"./p-NZS8uCtH.js";import{p as n}from"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import{J as o}from"./p-DO9lqnbB.js";import{c}from"./p-DjjAx7PF.js";import{g as p,a as h}from"./p-Cm9f5fyh.js";import{P as d}from"./p-nb_LhbJq.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 w,j as T,k as C,l as k}from"./p-BICxxa69.js";import{S as v}from"./p-BqNNwq6C.js";import{T as D}from"./p-CZfYo5-1.js";import{a as P}from"./p-BRnBHsdq.js";import{a6 as F,a7 as S}from"./p-CPKMvyV_.js";import"./p-D8GTwl9v.js";import"./p-B6YPrwyC.js";import"./p-CYQvLgSs.js";import"./p-CqiVXthx.js";const x={created_at:()=>t("th",{part:F,scope:"col",title:"The date and time each transaction was made"},"Processed On"),type:()=>t("th",{part:F,scope:"col",title:"The type of each transaction"},"Type"),id:()=>t("th",{part:F,scope:"col",title:"The unique identifier of each transaction"},"ID"),amount:()=>t("th",{part:F,scope:"col",title:"The dollar amount of each transaction",class:"text-end"},"Amount"),balance:()=>t("th",{part:F,scope:"col",title:"The running total amount of this payment that belongs to you",class:"text-end"},"Balance"),currency:()=>t("th",{part:F,scope:"col",title:"The currency of each transaction"},"Currency"),financial_transaction_id:()=>t("th",{part:F,scope:"col",title:"The unique identifier of the financial transaction associated with the payment balance transaction"},"Financial Transaction ID"),payment_id:()=>t("th",{part:F,scope:"col",title:"The unique identifier of the payment associated with the payment balance transaction"},"Payment ID"),payment_balance_txn_type:()=>t("th",{part:F,scope:"col",title:"The type of the payment balance transaction"},"Transaction Type"),source_id:()=>t("th",{part:F,scope:"col",title:"The unique identifier of the source object associated with the payment balance transaction"},"Source ID"),source_type:()=>t("th",{part:F,scope:"col",title:"The type of the source object associated with the payment balance transaction"},"Source Type")},R={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"},q={created_at:(e,a)=>t("td",{part:S(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:S(a)},R[e.payment_balance_txn_type]),id:(e,a)=>t("td",{part:S(a)},e.id),amount:(e,a)=>t("td",{part:S(a),class:"text-end"},e.formattedPaymentAmount(e.amount)),balance:(e,a)=>t("td",{part:S(a),class:"text-end"},e.formattedPaymentAmount(e.balance)),currency:(e,a)=>t("td",{part:S(a)},e.currency),financial_transaction_id:(e,a)=>t("td",{part:S(a)},e.financial_transaction_id),payment_id:(e,a)=>t("td",{part:S(a)},e.payment_id),payment_balance_txn_type:(e,a)=>t("td",{part:S(a)},e.payment_balance_txn_type),source_id:(e,a)=>t("td",{part:S(a)},e.source_id),source_type:(e,a)=>t("td",{part:S(a)},e.source_type)},I=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,q),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(v,{key:"a458269a6f875672be4d480411fc209c870fcc05"},t(l,{key:"6d072c9f1f3def61bfe10173220188da0b2c381f"},t(u,{key:"41b8cabf14b498e4035db4d36ef9d4dcd4d10867"},t(m,{key:"e77f2d5cd1347c2771584dadf619a1f21f7bdd5c"},t(y,{key:"053904f66c5d4ebcb33cb5b1d2ca3cdf5fd1c290"},this.transactionsTable.columnData.map((t=>t)))),t(b,{key:"5db67b01c7defdf97d2d2b305422254f9440564c"},t(_,{key:"24a110c7377f2f9e9b98302237221d168756593d",columnSpan:this.transactionsTable.columnKeys.length,isLoading:this.isLoading}),t(g,{key:"195b3cdf57087d986ee1db13b0bb5b65a417f380",isEmpty:this.showEmptyState,columnSpan:this.transactionsTable.columnKeys.length}),t(j,{key:"4e747cbbac4ffe88a9fe8bca59738feb8a0876bc",columnSpan:this.transactionsTable.columnKeys.length,errorMessage:this.errorMessage}),this.showRowData&&this.transactionsTable.rowData.map(((e,a)=>t(w,{"data-test-id":"table-row","data-row-entity-id":this.entityId[a],onClick:this.rowClickHandler},e)))),this.paging&&t(T,{key:"052862a5252fef6f4a466c667d4444778d4b84b0"},t(C,{key:"61d2a980ba3dd3c05955829741023ba814581f6c"},t(k,{key:"1e40eb28e0bb75ae6e044c4730c76fbd5054c654",colSpan:this.transactionsTable.columnData.length},t("pagination-menu",{key:"e066808fae97d39fd1f81924d5de32767f1a5c97",paging:Object.assign(Object.assign({},this.paging),{handleClickPrevious:this.handleClickPrevious,handleClickNext:this.handleClickNext})})))))))}static get watchers(){return{pagingParams:["propChanged"],paymentId:["propChanged"],authToken:["propChanged"]}}};export{I as justifi_payment_transactions_list}
@@ -1 +1 @@
1
- import{h as e,r as t,c as a}from"./p-CV0Pyo1O.js";import{P as s}from"./p-nb_LhbJq.js";import{m as i}from"./p-5G1OMxZz.js";import{C as d,e as c,g as f,f as l}from"./p-NZS8uCtH.js";import{J as r}from"./p-Cz_7BuGW.js";import{c as h}from"./p-mF5zKtkx.js";import"./p-DVJaoI_m.js";import{b as o,d as b,s as p}from"./p-BRnBHsdq.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import{P as n,M as m}from"./p-D1_eip6x.js";import{a as y,b as u,D as v,c as k,C,E as j}from"./p-Cu7hgXL1.js";import{S as g}from"./p-BqNNwq6C.js";import"./p-CZfYo5-1.js";import{S as w}from"./p-uZ5KAseb.js";import{a as x,B as D}from"./p-CHw7tICr.js";import"./p-CYQvLgSs.js";import"./p-HXpYMWUU.js";import"./p-Cm9f5fyh.js";import"./p-OGt0dCJl.js";import"./p-D8GTwl9v.js";import"./p-CPKMvyV_.js";const P=()=>e("div",{class:"row gap-3"},e("div",{class:"col-12"},e(w,{width:"35%",height:"30px"})),e("div",{class:"col-12"},e(w,{width:"70%"})),e("div",{class:"col-12"},e(w,{width:"40%"})),e("div",{class:"col-12"},e(w,{width:"40%"})),e("div",{class:"col-12"},e(w,{width:"100%"})),e("div",{class:"col-12"},e(w,{width:"80%"}))),N=class{constructor(e){t(this,e),this.errorEvent=a(this,"error-event",7),this.recordClickEvent=a(this,"record-click-event",7),this.loading=!0}componentWillLoad(){h(),this.analytics=new r(this),this.initializeGetPaymentDetails()}disconnectedCallback(){var e;null===(e=this.analytics)||void 0===e||e.cleanup()}propChanged(){this.initializeGetPaymentDetails()}initializeGetPaymentDetails(){this.paymentId&&this.authToken?(this.getPaymentDetails=i({id:this.paymentId,authToken:this.authToken,service:new s}),this.fetchData()):(this.errorMessage="Payment ID and Auth Token are required",this.errorEvent.emit({message:this.errorMessage,errorCode:c.MISSING_PROPS,severity:d.ERROR}))}updateOnPropChange(){this.getPaymentDetails&&this.fetchData()}fetchData(){this.loading=!0,this.getPaymentDetails({onSuccess:({payment:e})=>{this.payment=e,this.errorMessage=null},onError:({error:e,code:t,severity:a})=>{this.errorMessage=e,this.errorEvent.emit({errorCode:t,message:e,severity:a})},final:()=>{this.loading=!1}})}get PaymentStatus(){return this.payment.status===f.disputed&&this.payment.disputes.some((e=>e.status===l.lost))?n.DISPUTE_LOST:this.payment.status}render(){return e(g,{key:"f4952600aea69aae085ac57364e96397d1a20e51"},this.loading&&e(P,{key:"2f819c97a1a6ddb9df2a11e0cd6a5bc013ed19ae"}),!this.loading&&this.errorMessage&&j(this.errorMessage),!this.loading&&!this.errorMessage&&this.payment&&e("justifi-details",{key:"35a58e3917bdc3133f02374c0e031374be7c728c",errorMessage:this.errorMessage},e(y,{key:"dad5f79ea18ef718b92bf2c2abbbba34542d6caa",slot:"head-info",badge:e("div",{class:"d-flex gap-1"},m(this.PaymentStatus),this.payment.expedited?e(x,{variant:D.WARNING,title:"Expedited",text:"Expedited"}):null),title:this.payment.formattedPaymentAmount(this.payment.amount)},e(u,{key:"12e7cfb4f4f56a1af8403b935cb51db3751f1395",classes:"border-1 border-end",title:"Updated At",value:`${o(this.payment.updated_at)} ${b(this.payment.updated_at)}`}),e(u,{key:"023945353c0cbab340f4f510951164f110045ea5",classes:"border-1 border-end",title:"Created At",value:`${o(this.payment.created_at)} ${b(this.payment.created_at)}`}),e(u,{key:"dcb261f7c4faf53eb686cfd5c8e0ade39a72bdea",title:"ID",value:this.payment.id})),e("div",{key:"a7774df4ece900dc67494377cf648bf64f558490",slot:"detail-sections"},e(v,{key:"ef4a9197d4eb47d81c11c7f974f1e4058d5e3166",sectionTitle:"Details"}),e("div",{key:"17ef105d1b37ad34cce4bdd17cbf2e4023c0e2e5",class:"d-flex flex-column gap-2 w-100"},e(k,{key:"dbb764a1a6cbe949d2e281334e2f420f957b98fe",title:"Amount",value:this.payment.formattedPaymentAmount(this.payment.amount)}),e(k,{key:"7a3547ade7107456956618c72a95056a0771d219",title:"Fees",value:this.payment.formattedPaymentAmount(this.payment.fee_amount)}),e(k,{key:"94df0647f7286a4a7c9001f9e82b4277fe0f8457",title:"Refunded",value:this.payment.formattedPaymentAmount(this.payment.amount_refunded)}),e(k,{key:"59c13e257938124af50adfaa73571f152c402bd4",title:"Net",value:this.payment.formattedPaymentAmount(this.payment.balance)}),e(k,{key:"6abf719a072a3a1ea5878d999e517dafb7ba19d5",title:"Status",value:m(this.PaymentStatus)}),e(k,{key:"c494d2b4be8c9e13747f0299a618ea6c9ff723d7",title:"Payment ID",value:this.payment.id}),e(k,{key:"1024b282558896dcb2c4ab7718045d98a6f6853e",title:"Processing Fees",value:this.payment.formattedPaymentAmount(this.payment.fee_amount)}),e(k,{key:"6bf6fb7f648609fdeaa4e5a0b6f3d4c7bcd4af97",title:"Statement Descriptor",value:this.payment.statement_descriptor}),e(k,{key:"43da8b6ab1aa87b6b938f1d0fd95708399cb9cc0",title:"Description",value:this.payment.description}),e(k,{key:"e6180466f4341e2c438f09cc42feb518f59aded4",title:"Expedited",value:this.payment.expedited?"Yes":"No"})),this.payment.payment_method.card&&[e(v,{key:"289f80acfa3cd41f82637e8f9d9e63dac4c11b5b",sectionTitle:"Payment Method"}),e("div",{key:"616a2e7ae000581dd481725c57a644fc3e0a9b7c",class:"d-flex flex-column gap-2 w-100"},e(k,{key:"2c13ea8a771e2f155a9e3d5dbae78c7800f31adb",title:"ID",value:this.payment.payment_method.card.id}),e(k,{key:"62700836b3bd9656d07dc58d0d07d164c091cd74",title:"Payment Type",value:"Card"}),e(k,{key:"528ad4dddccaa7f5bc274b3b297557f659d46789",title:"Last 4 Numbers",value:this.payment.payment_method.lastFourDigits}),e(k,{key:"fdf2ad89e4e7ad253e16bff9038dc79da5a71b19",title:"Brand",value:p(this.payment.payment_method.card.brand)}),e(k,{key:"0b2c505e1fae49414414d5e839b1bdc849290c41",title:"Cardholder",value:this.payment.payment_method.payersName}))],this.payment.payment_method.bank_account&&[e(v,{key:"2a04be5ee508a547661e1ff947c2c9b40da2a192",sectionTitle:"Payment Method"}),e("div",{key:"1316f9c749960ca0ab4967ff03697583e690007d",class:"d-flex flex-column gap-2 w-100"},e(k,{key:"46fe5297825ef0b9e3f34fdee6f47f3dd3b9272d",title:"ID",value:this.payment.payment_method.bank_account.id}),e(k,{key:"44f1f47522b94ce5e403d766ee71645b4285d675",title:"Last 4 Numbers",value:this.payment.last_four_digits}),e(k,{key:"f03369474996dc0ae52c7d909ac1bba51e291668",title:"Bank Name",value:this.payment.payment_method.bank_account.brand}),e(k,{key:"d697a0e2a954f0e4efb4cec27dcae9c57fa0ce54",title:"Account Owner",value:this.payment.payment_method.payersName}))],this.payment.metadata&&[e(v,{key:"7cdd88cc59c7852574b05e1709f85afe3bf7367e",sectionTitle:"Metadata"}),e("div",{key:"bde3519c811862185b0757fd7c8a2a0a05117466",class:"d-table gap-2 w-100"},e(C,{key:"7675f134c9580381d495a1d7534e73b77583cb8b",metadata:this.payment.metadata}))])))}static get watchers(){return{paymentId:["propChanged"],authToken:["propChanged"],getPaymentDetails:["updateOnPropChange"]}}};export{N as justifi_payment_details}
1
+ import{h as e,r as t,c as a}from"./p-CV0Pyo1O.js";import{P as s}from"./p-nb_LhbJq.js";import{m as i}from"./p-5G1OMxZz.js";import{C as d,e as c,g as f,f as l}from"./p-NZS8uCtH.js";import{J as r}from"./p-DO9lqnbB.js";import{c as h}from"./p-DjjAx7PF.js";import"./p-DVJaoI_m.js";import{b,d as o,s as p}from"./p-BRnBHsdq.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import{P as n,M as m}from"./p-D1_eip6x.js";import{a as y,b as u,D as v,c as k,C as j,E as C}from"./p-Cu7hgXL1.js";import{S as g}from"./p-BqNNwq6C.js";import"./p-CZfYo5-1.js";import{S as w}from"./p-uZ5KAseb.js";import{a as D,B as P}from"./p-CHw7tICr.js";import"./p-CYQvLgSs.js";import"./p-HXpYMWUU.js";import"./p-Cm9f5fyh.js";import"./p-B6YPrwyC.js";import"./p-D8GTwl9v.js";import"./p-CPKMvyV_.js";const x=()=>e("div",{class:"row gap-3"},e("div",{class:"col-12"},e(w,{width:"35%",height:"30px"})),e("div",{class:"col-12"},e(w,{width:"70%"})),e("div",{class:"col-12"},e(w,{width:"40%"})),e("div",{class:"col-12"},e(w,{width:"40%"})),e("div",{class:"col-12"},e(w,{width:"100%"})),e("div",{class:"col-12"},e(w,{width:"80%"}))),B=class{constructor(e){t(this,e),this.errorEvent=a(this,"error-event",7),this.recordClickEvent=a(this,"record-click-event",7),this.loading=!0}componentWillLoad(){h(),this.analytics=new r(this),this.initializeGetPaymentDetails()}disconnectedCallback(){var e;null===(e=this.analytics)||void 0===e||e.cleanup()}propChanged(){this.initializeGetPaymentDetails()}initializeGetPaymentDetails(){this.paymentId&&this.authToken?(this.getPaymentDetails=i({id:this.paymentId,authToken:this.authToken,service:new s}),this.fetchData()):(this.errorMessage="Payment ID and Auth Token are required",this.errorEvent.emit({message:this.errorMessage,errorCode:c.MISSING_PROPS,severity:d.ERROR}))}updateOnPropChange(){this.getPaymentDetails&&this.fetchData()}fetchData(){this.loading=!0,this.getPaymentDetails({onSuccess:({payment:e})=>{this.payment=e,this.errorMessage=null},onError:({error:e,code:t,severity:a})=>{this.errorMessage=e,this.errorEvent.emit({errorCode:t,message:e,severity:a})},final:()=>{this.loading=!1}})}get PaymentStatus(){return this.payment.status===f.disputed&&this.payment.disputes.some((e=>e.status===l.lost))?n.DISPUTE_LOST:this.payment.status}render(){return e(g,{key:"f4952600aea69aae085ac57364e96397d1a20e51"},this.loading&&e(x,{key:"2f819c97a1a6ddb9df2a11e0cd6a5bc013ed19ae"}),!this.loading&&this.errorMessage&&C(this.errorMessage),!this.loading&&!this.errorMessage&&this.payment&&e("justifi-details",{key:"35a58e3917bdc3133f02374c0e031374be7c728c",errorMessage:this.errorMessage},e(y,{key:"dad5f79ea18ef718b92bf2c2abbbba34542d6caa",slot:"head-info",badge:e("div",{class:"d-flex gap-1"},m(this.PaymentStatus),this.payment.expedited?e(D,{variant:P.WARNING,title:"Expedited",text:"Expedited"}):null),title:this.payment.formattedPaymentAmount(this.payment.amount)},e(u,{key:"12e7cfb4f4f56a1af8403b935cb51db3751f1395",classes:"border-1 border-end",title:"Updated At",value:`${b(this.payment.updated_at)} ${o(this.payment.updated_at)}`}),e(u,{key:"023945353c0cbab340f4f510951164f110045ea5",classes:"border-1 border-end",title:"Created At",value:`${b(this.payment.created_at)} ${o(this.payment.created_at)}`}),e(u,{key:"dcb261f7c4faf53eb686cfd5c8e0ade39a72bdea",title:"ID",value:this.payment.id})),e("div",{key:"a7774df4ece900dc67494377cf648bf64f558490",slot:"detail-sections"},e(v,{key:"ef4a9197d4eb47d81c11c7f974f1e4058d5e3166",sectionTitle:"Details"}),e("div",{key:"17ef105d1b37ad34cce4bdd17cbf2e4023c0e2e5",class:"d-flex flex-column gap-2 w-100"},e(k,{key:"dbb764a1a6cbe949d2e281334e2f420f957b98fe",title:"Amount",value:this.payment.formattedPaymentAmount(this.payment.amount)}),e(k,{key:"7a3547ade7107456956618c72a95056a0771d219",title:"Fees",value:this.payment.formattedPaymentAmount(this.payment.fee_amount)}),e(k,{key:"94df0647f7286a4a7c9001f9e82b4277fe0f8457",title:"Refunded",value:this.payment.formattedPaymentAmount(this.payment.amount_refunded)}),e(k,{key:"59c13e257938124af50adfaa73571f152c402bd4",title:"Net",value:this.payment.formattedPaymentAmount(this.payment.balance)}),e(k,{key:"6abf719a072a3a1ea5878d999e517dafb7ba19d5",title:"Status",value:m(this.PaymentStatus)}),e(k,{key:"c494d2b4be8c9e13747f0299a618ea6c9ff723d7",title:"Payment ID",value:this.payment.id}),e(k,{key:"1024b282558896dcb2c4ab7718045d98a6f6853e",title:"Processing Fees",value:this.payment.formattedPaymentAmount(this.payment.fee_amount)}),e(k,{key:"6bf6fb7f648609fdeaa4e5a0b6f3d4c7bcd4af97",title:"Statement Descriptor",value:this.payment.statement_descriptor}),e(k,{key:"43da8b6ab1aa87b6b938f1d0fd95708399cb9cc0",title:"Description",value:this.payment.description}),e(k,{key:"e6180466f4341e2c438f09cc42feb518f59aded4",title:"Expedited",value:this.payment.expedited?"Yes":"No"})),this.payment.payment_method.card&&[e(v,{key:"289f80acfa3cd41f82637e8f9d9e63dac4c11b5b",sectionTitle:"Payment Method"}),e("div",{key:"616a2e7ae000581dd481725c57a644fc3e0a9b7c",class:"d-flex flex-column gap-2 w-100"},e(k,{key:"2c13ea8a771e2f155a9e3d5dbae78c7800f31adb",title:"ID",value:this.payment.payment_method.card.id}),e(k,{key:"62700836b3bd9656d07dc58d0d07d164c091cd74",title:"Payment Type",value:"Card"}),e(k,{key:"528ad4dddccaa7f5bc274b3b297557f659d46789",title:"Last 4 Numbers",value:this.payment.payment_method.lastFourDigits}),e(k,{key:"fdf2ad89e4e7ad253e16bff9038dc79da5a71b19",title:"Brand",value:p(this.payment.payment_method.card.brand)}),e(k,{key:"0b2c505e1fae49414414d5e839b1bdc849290c41",title:"Cardholder",value:this.payment.payment_method.payersName}))],this.payment.payment_method.bank_account&&[e(v,{key:"2a04be5ee508a547661e1ff947c2c9b40da2a192",sectionTitle:"Payment Method"}),e("div",{key:"1316f9c749960ca0ab4967ff03697583e690007d",class:"d-flex flex-column gap-2 w-100"},e(k,{key:"46fe5297825ef0b9e3f34fdee6f47f3dd3b9272d",title:"ID",value:this.payment.payment_method.bank_account.id}),e(k,{key:"44f1f47522b94ce5e403d766ee71645b4285d675",title:"Last 4 Numbers",value:this.payment.last_four_digits}),e(k,{key:"f03369474996dc0ae52c7d909ac1bba51e291668",title:"Bank Name",value:this.payment.payment_method.bank_account.brand}),e(k,{key:"d697a0e2a954f0e4efb4cec27dcae9c57fa0ce54",title:"Account Owner",value:this.payment.payment_method.payersName}))],this.payment.metadata&&[e(v,{key:"7cdd88cc59c7852574b05e1709f85afe3bf7367e",sectionTitle:"Metadata"}),e("div",{key:"bde3519c811862185b0757fd7c8a2a0a05117466",class:"d-table gap-2 w-100"},e(j,{key:"7675f134c9580381d495a1d7534e73b77583cb8b",metadata:this.payment.metadata}))])))}static get watchers(){return{paymentId:["propChanged"],authToken:["propChanged"],getPaymentDetails:["updateOnPropChange"]}}};export{B as justifi_payment_details}
@@ -1 +1 @@
1
- import{h as t,r as e,c as s}from"./p-CV0Pyo1O.js";import{a as r,c as i,F as n}from"./p-DwoT0UoX.js";import{f as o}from"./p-BRnBHsdq.js";import"./p-DVJaoI_m.js";import{R as a,C as u,e as h,o as l}from"./p-NZS8uCtH.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import{B as c}from"./p-CHo7TfsM.js";import{S as m}from"./p-BqNNwq6C.js";import"./p-CZfYo5-1.js";import{P as d}from"./p-nb_LhbJq.js";import{m as p}from"./p-5G1OMxZz.js";import{J as f}from"./p-Cz_7BuGW.js";import{c as v}from"./p-mF5zKtkx.js";import{g as y,a as j}from"./p-Cm9f5fyh.js";import{A as b}from"./p-CYQvLgSs.js";import{S as w}from"./p-uZ5KAseb.js";import"./p-BFTU3MAI.js";import"./p-HXpYMWUU.js";import"./p-D8GTwl9v.js";import"./p-CPKMvyV_.js";import"./p-OGt0dCJl.js";const C=t=>{const e=+t;return i().required("Amount is required").test("max-amount",`Refund amount cannot be more than payment amount: ${o(e)}`,(function(t){return+t<=+e})).test("min-amount","Refund amount must be greater than 0",(function(t){return+t>0}))},T=t=>{if(t)return r({amount:C(t),description:i().optional(),reason:i().optional().oneOf([a.customerRequest,a.duplicate,a.fraudulent],"Select a reason")})},g=[{label:"Select a reason",value:""},{label:"Customer requested a refund",value:"customer_request"},{label:"Customer was double-charged",value:"duplicate"},{label:"Payment was reported as fraud",value:"fraudulent"}],S=b();class x{async postRefund(t,e,s,r){return S.post({endpoint:`payments/${t}/refunds`,headers:{"Sub-Account":e},body:r,authToken:s})}}const I=b();class k{async postVoid(t,e,s){return I.post({endpoint:`payments/${t}/void`,headers:{"Sub-Account":e},authToken:s})}}const A=()=>t("div",{class:"row gap-3"},t("div",{class:"col-12"},t(w,{width:"100%",height:"40px"}))),P=()=>t(m,null,t("div",{class:"row gap-5"},t(A,null),t(A,null),t(A,null))),R=class{constructor(t){e(this,t),this.errorEvent=s(this,"error-event",7),this.submitEvent=s(this,"submit-event",7),this.refundPayload={},this.displayAmount="",this.errors={},this.paymentLoading=!0,this.refundLoading=!1,this.hideSubmitButton=!1,this.inputHandler=(t,e)=>{this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[t]:e}))}}componentWillLoad(){v(),this.analytics=new f(this),this.initializeApi(),this.formController=new n(T())}handleError(t,e,s){this.errorEvent.emit({errorCode:t,message:e,severity:s})}checkAmount(t){return t>0}handleInvalidAmount(){this.submitDisabled=!0,this.handleError(h.INVALID_REFUND_AMOUNT,"Refund amount must be greater than 0",u.ERROR)}isPaymentCreatedWithin25Minutes(){var t;if(!this.payment||!(null===(t=this.payment)||void 0===t?void 0:t.created_at))return!1;const e=new Date(this.payment.created_at);return((new Date).getTime()-e.getTime())/6e4<=25}initializeFormController(){const t=this.refundPayload.amount,e=t?t.toString():"0";this.formController=new n(T(e)),this.formController.setInitialValues({amount:e}),this.formController.values.subscribe((t=>{this.refundPayload=Object.assign({},t)})),this.formController.errors.subscribe((t=>{this.errors=Object.assign({},t)}))}initializeApi(){this.paymentId&&this.authToken?p({id:this.paymentId,authToken:this.authToken,service:new d})({onSuccess:({payment:t})=>{this.payment=t,this.refundPayload=new l({amount:t.amount_refundable})},onError:({error:t,code:e,severity:s})=>{this.handleError(e,t,s)},final:()=>{this.checkAmount(this.refundPayload.amount)?this.initializeFormController():this.handleInvalidAmount(),this.paymentLoading=!1}}):this.handleError(h.MISSING_PROPS,"Payment ID and Auth Token are required",u.ERROR)}async refundPayment(t){if(t&&t.preventDefault(),!await this.formController.validate())return;const e=this.formController.values.getValue();return this.refundLoading=!0,this.isPaymentCreatedWithin25Minutes()?this.tryVoidPayment():this.processRefund(e)}async tryVoidPayment(){const t=(({authToken:t,accountId:e,paymentId:s,service:r})=>async({onSuccess:i,onError:n,final:o})=>{var a;try{const o=await r.postVoid(s,e,t);if(o.error)return n({error:j(o.error),code:y(null===(a=o.error)||void 0===a?void 0:a.code),severity:u.ERROR});i(o)}catch(t){const e=y(null==t?void 0:t.code);return n({error:t.message||t,code:e,severity:u.ERROR})}finally{return o()}})({authToken:this.authToken,accountId:this.accountId,paymentId:this.paymentId,service:new k});return new Promise((e=>{let s,r=!1;const i=this.formController.values.getValue();t({onSuccess:t=>{s=t,r=!0},onError:({error:t,code:s,severity:n})=>{r=!0,this.handleError(t,s,n),this.processRefund(i).then(e)},final:()=>{s&&!s.error&&r&&(this.submitEvent.emit({response:s}),this.submitDisabled=!0,this.refundLoading=!1,e(s.data))}})}))}async processRefund(t){const e=(({authToken:t,accountId:e,paymentId:s,service:r})=>async({refundBody:i,onSuccess:n,onError:o,final:a})=>{var h;try{const a=await r.postRefund(s,e,t,i);if(a.error)return o({error:j(a.error),code:y(null===(h=a.error)||void 0===h?void 0:h.code),severity:u.ERROR});n(a)}catch(t){const e=y(null==t?void 0:t.code);return o({error:t.message||t,code:e,severity:u.ERROR})}finally{return a()}})({authToken:this.authToken,accountId:this.accountId,paymentId:this.paymentId,service:new x});return new Promise((s=>{let r;e({refundBody:t,onSuccess:t=>{r=t},onError:({error:t,code:e,severity:s})=>{r=t,this.handleError(t,e,s)},final:()=>{this.submitEvent.emit({response:r}),this.submitDisabled=!0,this.refundLoading=!1,s(r.data)}})}))}render(){if(this.paymentLoading)return t(P,null);const e=this.formController.getInitialValues(),s=this.refundPayload.amount;return t(m,null,t("form",null,t("fieldset",null,t("div",{class:"row gy-3"},t("div",{class:"col-12"},t("form-control-monetary",{name:"amount",label:"Refund Amount",defaultValue:e.amount,inputHandler:this.inputHandler,errorText:this.errors.amount})),t("div",{class:"col-12"},t("form-control-select",{name:"reason",label:"Reason for refund (optional)",defaultValue:e.reason,inputHandler:this.inputHandler,options:g,errorText:this.errors.reason})),t("div",{class:"col-12"},t("form-control-textarea",{name:"description",label:"Note (optional)",defaultValue:e.description,inputHandler:this.inputHandler,maxLength:250,errorText:this.errors.description})),t("div",{class:"form-group d-flex flex-row-reverse"},t(c,{variant:"primary",type:"submit",onClick:this.refundPayment.bind(this),isLoading:this.paymentLoading||this.refundLoading,hidden:this.hideSubmitButton,disabled:this.submitDisabled},`Refund ${o(+s)}`))))))}};export{R as justifi_refund_payment}
1
+ import{h as t,r as e,c as s}from"./p-CV0Pyo1O.js";import{c as r,a as i,F as n}from"./p-CKiAlBsU.js";import{f as o}from"./p-BRnBHsdq.js";import"./p-DVJaoI_m.js";import{R as a,C as u,e as h,o as l}from"./p-NZS8uCtH.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import{B as c}from"./p-CHo7TfsM.js";import{S as m}from"./p-BqNNwq6C.js";import"./p-CZfYo5-1.js";import{P as d}from"./p-nb_LhbJq.js";import{m as p}from"./p-5G1OMxZz.js";import{J as f}from"./p-DO9lqnbB.js";import{c as v}from"./p-DjjAx7PF.js";import{g as y,a as j}from"./p-Cm9f5fyh.js";import{A as b}from"./p-CYQvLgSs.js";import{S as w}from"./p-uZ5KAseb.js";import"./p-BFTU3MAI.js";import"./p-HXpYMWUU.js";import"./p-D8GTwl9v.js";import"./p-CPKMvyV_.js";import"./p-B6YPrwyC.js";const C=t=>{const e=+t;return i().required("Amount is required").test("max-amount",`Refund amount cannot be more than payment amount: ${o(e)}`,(function(t){return+t<=+e})).test("min-amount","Refund amount must be greater than 0",(function(t){return+t>0}))},T=t=>{if(t)return r({amount:C(t),description:i().optional(),reason:i().optional().oneOf([a.customerRequest,a.duplicate,a.fraudulent],"Select a reason")})},g=[{label:"Select a reason",value:""},{label:"Customer requested a refund",value:"customer_request"},{label:"Customer was double-charged",value:"duplicate"},{label:"Payment was reported as fraud",value:"fraudulent"}],A=b();class S{async postRefund(t,e,s,r){return A.post({endpoint:`payments/${t}/refunds`,headers:{"Sub-Account":e},body:r,authToken:s})}}const x=b();class I{async postVoid(t,e,s){return x.post({endpoint:`payments/${t}/void`,headers:{"Sub-Account":e},authToken:s})}}const P=()=>t("div",{class:"row gap-3"},t("div",{class:"col-12"},t(w,{width:"100%",height:"40px"}))),B=()=>t(m,null,t("div",{class:"row gap-5"},t(P,null),t(P,null),t(P,null))),k=class{constructor(t){e(this,t),this.errorEvent=s(this,"error-event",7),this.submitEvent=s(this,"submit-event",7),this.refundPayload={},this.displayAmount="",this.errors={},this.paymentLoading=!0,this.refundLoading=!1,this.hideSubmitButton=!1,this.inputHandler=(t,e)=>{this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[t]:e}))}}componentWillLoad(){v(),this.analytics=new f(this),this.initializeApi(),this.formController=new n(T())}handleError(t,e,s){this.errorEvent.emit({errorCode:t,message:e,severity:s})}checkAmount(t){return t>0}handleInvalidAmount(){this.submitDisabled=!0,this.handleError(h.INVALID_REFUND_AMOUNT,"Refund amount must be greater than 0",u.ERROR)}isPaymentCreatedWithin25Minutes(){var t;if(!this.payment||!(null===(t=this.payment)||void 0===t?void 0:t.created_at))return!1;const e=new Date(this.payment.created_at);return((new Date).getTime()-e.getTime())/6e4<=25}initializeFormController(){const t=this.refundPayload.amount,e=t?t.toString():"0";this.formController=new n(T(e)),this.formController.setInitialValues({amount:e}),this.formController.values.subscribe((t=>{this.refundPayload=Object.assign({},t)})),this.formController.errors.subscribe((t=>{this.errors=Object.assign({},t)}))}initializeApi(){this.paymentId&&this.authToken?p({id:this.paymentId,authToken:this.authToken,service:new d})({onSuccess:({payment:t})=>{this.payment=t,this.refundPayload=new l({amount:t.amount_refundable})},onError:({error:t,code:e,severity:s})=>{this.handleError(e,t,s)},final:()=>{this.checkAmount(this.refundPayload.amount)?this.initializeFormController():this.handleInvalidAmount(),this.paymentLoading=!1}}):this.handleError(h.MISSING_PROPS,"Payment ID and Auth Token are required",u.ERROR)}async refundPayment(t){if(t&&t.preventDefault(),!await this.formController.validate())return;const e=this.formController.values.getValue();return this.refundLoading=!0,this.isPaymentCreatedWithin25Minutes()?this.tryVoidPayment():this.processRefund(e)}async tryVoidPayment(){const t=(({authToken:t,accountId:e,paymentId:s,service:r})=>async({onSuccess:i,onError:n,final:o})=>{var a;try{const o=await r.postVoid(s,e,t);if(o.error)return n({error:j(o.error),code:y(null===(a=o.error)||void 0===a?void 0:a.code),severity:u.ERROR});i(o)}catch(t){const e=y(null==t?void 0:t.code);return n({error:t.message||t,code:e,severity:u.ERROR})}finally{return o()}})({authToken:this.authToken,accountId:this.accountId,paymentId:this.paymentId,service:new I});return new Promise((e=>{let s,r=!1;const i=this.formController.values.getValue();t({onSuccess:t=>{s=t,r=!0},onError:({error:t,code:s,severity:n})=>{r=!0,this.handleError(t,s,n),this.processRefund(i).then(e)},final:()=>{s&&!s.error&&r&&(this.submitEvent.emit({response:s}),this.submitDisabled=!0,this.refundLoading=!1,e(s.data))}})}))}async processRefund(t){const e=(({authToken:t,accountId:e,paymentId:s,service:r})=>async({refundBody:i,onSuccess:n,onError:o,final:a})=>{var h;try{const a=await r.postRefund(s,e,t,i);if(a.error)return o({error:j(a.error),code:y(null===(h=a.error)||void 0===h?void 0:h.code),severity:u.ERROR});n(a)}catch(t){const e=y(null==t?void 0:t.code);return o({error:t.message||t,code:e,severity:u.ERROR})}finally{return a()}})({authToken:this.authToken,accountId:this.accountId,paymentId:this.paymentId,service:new S});return new Promise((s=>{let r;e({refundBody:t,onSuccess:t=>{r=t},onError:({error:t,code:e,severity:s})=>{r=t,this.handleError(t,e,s)},final:()=>{this.submitEvent.emit({response:r}),this.submitDisabled=!0,this.refundLoading=!1,s(r.data)}})}))}render(){if(this.paymentLoading)return t(B,null);const e=this.formController.getInitialValues(),s=this.refundPayload.amount;return t(m,null,t("form",null,t("fieldset",null,t("div",{class:"row gy-3"},t("div",{class:"col-12"},t("form-control-monetary",{name:"amount",label:"Refund Amount",defaultValue:e.amount,inputHandler:this.inputHandler,errorText:this.errors.amount})),t("div",{class:"col-12"},t("form-control-select",{name:"reason",label:"Reason for refund (optional)",defaultValue:e.reason,inputHandler:this.inputHandler,options:g,errorText:this.errors.reason})),t("div",{class:"col-12"},t("form-control-textarea",{name:"description",label:"Note (optional)",defaultValue:e.description,inputHandler:this.inputHandler,maxLength:250,errorText:this.errors.description})),t("div",{class:"form-group d-flex flex-row-reverse"},t(c,{variant:"primary",type:"submit",onClick:this.refundPayment.bind(this),isLoading:this.paymentLoading||this.refundLoading,hidden:this.hideSubmitButton,disabled:this.submitDisabled},`Refund ${o(+s)}`))))))}};export{k as justifi_refund_payment}
@@ -1 +1 @@
1
- import{r as t,c as e,h as i,H as s,g as n}from"./p-CV0Pyo1O.js";import{A as a}from"./p-CYQvLgSs.js";import{A as o,p as r,q as h,r as l,s as c,t as d,u,C as p,e as y,v as m,I as v,w as f,x as g,y as M}from"./p-NZS8uCtH.js";import{S as b}from"./p-BqNNwq6C.js";import"./p-CZfYo5-1.js";import{S as k}from"./p-uZ5KAseb.js";import{c as w,o as j,a as P,g as T,b as A}from"./p-BArmtmkq.js";import{t as N,r as C}from"./p-CPKMvyV_.js";import{f as I}from"./p-BRnBHsdq.js";import{w as E,c as D}from"./p-DVJaoI_m.js";import{H as S}from"./p-jIDKmNHy.js";import{H as O,b as L,h as x,i as z}from"./p-D-zwk1J3.js";import{H as _}from"./p-DYHjzFnJ.js";import{J as R}from"./p-Cz_7BuGW.js";import{c as U}from"./p-mF5zKtkx.js";import"./p-HXpYMWUU.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import{g as B,a as Y}from"./p-Cm9f5fyh.js";import{C as F}from"./p-fE5A37L5.js";import{P as Q}from"./p-av6jyzyC.js";import{P as V,a as H,b as G}from"./p-DkoufM1t.js";import{C as q}from"./p-ZpPDShvP.js";import"./p-D8GTwl9v.js";import"./p-OGt0dCJl.js";const W=class{constructor(i){t(this,i),this.radioClick=e(this,"radio-click",7),this.checked=!1,this.hidden=!1}render(){return i(b,{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 Z;!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"}(Z||(Z={}));class J{constructor(){this.api=a()}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 h(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,n)=>{try{if("undefined"==typeof window||!("ApplePaySession"in window))return console.error("[ApplePayService] ApplePaySession not available on window"),n({success:!1,error:{code:Z.UNAVAILABLE,message:"ApplePaySession API is not available in this environment"}});this.currentSession=new window.ApplePaySession(3,s),this.setupSessionEventHandlers(t,n,e,i),this.currentSession.begin()}catch(t){console.error("[ApplePayService] Exception while starting session:",t),n({success:!1,error:{code:Z.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:Z.MERCHANT_VALIDATION_ERROR,message:t instanceof Error?t.message:"Merchant validation failed"}})}},this.currentSession.onpaymentauthorized=async n=>{try{const a=n.payment,o=Object.assign(Object.assign({},a.token),{product_details:{name:this.currentPaymentRequest.total.label,price:r.parseAmount(this.currentPaymentRequest.total.amount),description:this.currentPaymentRequest.total.label}}),h=await this.processPayment(i,s,o);h.success?(this.currentSession.completePayment({status:l.STATUS_SUCCESS}),t({success:!0,token:a.token,paymentMethodId:h.data.id})):(console.error("PSP reported payment failure:",h.data),this.currentSession.completePayment({status:l.STATUS_FAILURE}),e({success:!1,error:{code:Z.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:l.STATUS_FAILURE}),e({success:!1,error:{code:Z.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:l.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:Z.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:Z.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(k,{height:"44px",width:"100%",styles:{borderRadius:"8px"}})))):null},X=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 ")),$=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.showSkeleton=!0,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:w.paymentCurrency,merchantCapabilities:[u.SUPPORTS_3DS,u.SUPPORTS_CREDIT,u.SUPPORTS_DEBIT],supportedNetworks:r.getDefaultSupportedNetworks(),total:r.createLineItem(w.paymentDescription,w.paymentAmount)},s=await this.applePayService.startPaymentSession(i,w.authToken,w.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)||$.ErrorCode.PAYMENT_FAILED}))}catch(t){if((null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.code)===Z.USER_CANCELLED)this.applePayCancelled.emit();else{const e=t instanceof Error?t.message:"Payment failed";this.error=e,this.applePayError.emit({error:e,code:$.ErrorCode.PAYMENT_FAILED}),this.applePayCompleted.emit({success:!1,error:e})}}finally{this.isProcessing=!1}}}componentWillLoad(){this.isAvailable=r.isApplePaySupported(),this.isAvailable?w.checkoutLoaded?this.loadApplePaySDK():j("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(w.paymentAmount)&&Boolean(w.paymentCurrency)&&Boolean(w.authToken)))return this.error="Missing required Apple Pay configuration",this.isConfigValid=!1,this.applePayError.emit({error:this.error,code:$.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:$.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:$.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:$.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(!w.applePayEnabled)return null;if(!this.isAvailable)return null;const t=!this.isLoading&&this.isAvailable&&this.canMakePayments&&this.isConfigValid;return i(b,null,i("div",{class:"apple-pay-container"},i(K,{isLoading:this.isLoading}),t&&i(X,{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 "))}};$.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(b,{key:"f1ac17863df571d72e7db9b748b1980218145322"},i("internal-button",{key:"0b7052d216fb79ed5d9f90aacff97d39dce87473",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(b,{key:"4dda3e1e4f81cfda61011706c2f4e3104815d97c"},i("section",{key:"f8bbdeb389afbfc906e6cc956a68f9a3485ed43c"},i("div",{key:"2f8019ae43d5d4a5835ec6d5674304bd321d34b7"},i("div",{key:"67626fe735d0c0372fe638960198592027fb24f5",part:N},null==w?void 0:w.paymentDescription),i("div",{key:"48d8b4b930d2f3b199bc0a59c93ef4f1339f7649"},i("span",{key:"ca6413ce719ae81eaa4654911cdfc09d63f9a9db",part:N},"Total")," ",i("span",{key:"9ed165b192efa2ecf2f77a129d33161e36b1594f",part:N},I(+(null==w?void 0:w.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(k,{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 nt=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.environment="TEST",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 E(),this.iframeOrigin=D.iframeOrigin}componentDidLoad(){window.addEventListener("message",this.handleMessage)}disconnectedCallback(){window.removeEventListener("message",this.handleMessage)}sendInitialize(){var t;(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow)&&this.iframeElement.contentWindow.postMessage({eventType:st.initialize,data:{environment:this.environment,gatewayMerchantId:w.accountId,merchantName:this.merchantName,authToken:w.authToken,accountId:w.accountId}},this.iframeOrigin)}sendStartPayment(){var t;if(!(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow))return;const e={totalPrice:String(w.paymentAmount/100),totalPriceStatus:"FINAL",currencyCode:w.paymentCurrency||"USD"};this.iframeElement.contentWindow.postMessage({eventType:st.startPayment,data:e},this.iframeOrigin)}render(){return w.checkoutLoaded?w.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}},at=class{constructor(e){t(this,e),this.levels={h1:S,h2:O,h3:_},this.level="h1"}render(){return i(b,{key:"879e301ec35e7cc536dec135e11daf140c67eeed"},i(this.levels[this.level],{key:"1766cb9a4d84bee1b3365b4df93515274cf31565",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.handleApplePayStarted=()=>{w.isWalletProcessing=!0},this.handleGooglePayStarted=()=>{w.isWalletProcessing=!0},this.handleGooglePayCompleted=t=>{const{success:e,paymentMethodId:i,error:s}=t.detail||{};e&&i?(w.isWalletProcessing=!1,w.paymentToken=i,w.selectedPaymentMethod={type:V.GOOGLE_PAY},this.submitCheckout()):(w.isWalletProcessing=!1,this.errorEvent.emit({message:s&&s.message||"Google Pay payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR}))},this.handleGooglePayCancelled=()=>{w.isWalletProcessing=!1,w.paymentToken=void 0,w.selectedPaymentMethod=void 0},this.handleApplePayCompleted=t=>{const{success:e,token:i,paymentMethodId:s,error:n}=t.detail;e&&i?(w.isWalletProcessing=!1,w.paymentToken=s,w.selectedPaymentMethod={type:V.APPLE_PAY},this.submitCheckout()):(w.isWalletProcessing=!1,console.error("Apple Pay completed but failed:",n),this.errorEvent.emit({message:(null==n?void 0:n.message)||"Apple Pay payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR}))},this.handleApplePayError=t=>{w.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=()=>{w.isWalletProcessing=!1,w.paymentToken=void 0,w.selectedPaymentMethod=void 0}}connectedCallback(){this.observer=new MutationObserver((()=>{this.queryFormRefs(),this.setupApplePayListeners(),this.setupGooglePayListeners()})),this.observer.observe(this.hostEl,{childList:!0,subtree:!0}),w.checkoutId=this.checkoutId;const t={authToken:this.authToken,checkoutId:this.checkoutId,service:new F};this.getCheckout=(({authToken:t,checkoutId:e,service:i})=>async({onSuccess:s,onError:n})=>{var a;try{const o=await i.fetchCheckout(t,e);if(o.error)return n({error:Y(o.error),code:B(null===(a=o.error)||void 0===a?void 0:a.code),severity:p.ERROR});s({checkout:o.data})}catch(t){const e=B(null==t?void 0:t.code);return n({error:t.message||t,code:e,severity:p.ERROR})}})(t),this.completeCheckout=(({authToken:t,checkoutId:e,service:i})=>async({payment:s,onSuccess:n,onError:a})=>{var o;try{const r=await i.complete(t,e,s);if(r.error)return a({error:Y(r.error),code:B(null===(o=r.error)||void 0===o?void 0:o.code),severity:p.ERROR});n({checkout:r.data})}catch(t){const e=B(null==t?void 0:t.code);return a({error:t.message||t,code:e,severity:p.ERROR})}})(t),P((()=>{this.emitCheckoutChanged()}))}componentWillLoad(){this.analytics=new R(this),U(),w.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()}disconnectedCallback(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this.removeApplePayListeners(),this.removeGooglePayListeners()}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,n,a,o,r;w.accountId=t.account_id,w.checkoutLoaded=!0,w.paymentMethods=t.payment_methods.map((t=>new H(t))),w.paymentMethodGroupId=t.payment_method_group_id,w.paymentDescription=t.payment_description,w.totalAmount=t.total_amount,w.paymentAmount=t.payment_amount,w.bnplEnabled=t.payment_settings.bnpl_payments,w.insuranceEnabled=t.payment_settings.insurance_payments,w.bankAccountVerification=null===(e=t.payment_settings)||void 0===e?void 0:e.bank_account_verification,w.applePayEnabled=null===(i=t.payment_settings)||void 0===i?void 0:i.apple_payments,w.googlePayEnabled=null===(s=t.payment_settings)||void 0===s?void 0:s.google_payments,w.bnplProviderClientId=null===(n=null==t?void 0:t.bnpl)||void 0===n?void 0:n.provider_client_id,w.bnplProviderMode=null===(a=null==t?void 0:t.bnpl)||void 0===a?void 0:a.provider_mode,w.bnplProviderApiVersion=null===(o=null==t?void 0:t.bnpl)||void 0===o?void 0:o.provider_api_version,w.bnplProviderCheckoutUrl=null===(r=null==t?void 0:t.bnpl)||void 0===r?void 0:r.provider_checkout_url}emitCheckoutChanged(){const t={availablePaymentMethodTypes:T(),selectedPaymentMethod:w.selectedPaymentMethod,savedPaymentMethods:w.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.paymentMethodFormRef=this.hostEl.querySelector("justifi-card-form, justifi-bank-account-form, justifi-tokenize-payment-method"),!w.selectedPaymentMethod&&this.paymentMethodFormRef){const t=this.paymentMethodFormRef.tagName.toLowerCase();"justifi-card-form"===t?w.selectedPaymentMethod={type:V.NEW_CARD}:"justifi-bank-account-form"===t&&(w.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))}async tokenizePaymentMethod(t){var e,i,s;const n=null!==(i=await(null===(e=this.billingFormRef)||void 0===e?void 0:e.getValues()))&&void 0!==i?i:{},a=Object.assign(Object.assign({},t),n),o=Object.assign({accountId:w.accountId,payment_method_group_id:void 0},a);w.savePaymentMethod&&(o.payment_method_group_id=w.paymentMethodGroupId);const r=await(null===(s=this.paymentMethodFormRef)||void 0===s?void 0:s.tokenize({clientId:this.authToken,paymentMethodMetadata:o,account:w.accountId}));return r.error?r:(w.paymentToken=r.id,r.id)}async fillBillingForm(t){w.billingFormFields=t}async setSelectedPaymentMethod(t){w.selectedPaymentMethod=t,w.paymentToken=t.id||void 0}async validate(){var t,e;const i=[];w.insuranceEnabled&&this.insuranceFormRef&&i.push(this.insuranceFormRef.validate());const s=(null===(t=w.selectedPaymentMethod)||void 0===t?void 0:t.type)===V.NEW_CARD,n=(null===(e=w.selectedPaymentMethod)||void 0===e?void 0:e.type)===V.NEW_BANK_ACCOUNT;if((s||n)&&(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,n,a;if(w.isSubmitting)return;w.isSubmitting=!0;const o=await this.validate();if(!w.selectedPaymentMethod)return w.isSubmitting=!1,void this.errorEvent.emit({message:"No payment method selected.",errorCode:y.VALIDATION_ERROR,severity:p.ERROR});const r=(null===(e=w.selectedPaymentMethod)||void 0===e?void 0:e.type)===V.NEW_CARD,h=(null===(i=w.selectedPaymentMethod)||void 0===i?void 0:i.type)===V.NEW_BANK_ACCOUNT,l=(null===(s=w.selectedPaymentMethod)||void 0===s?void 0:s.type)===V.PLAID;if(r||h){const e=await this.tokenizePaymentMethod(t);if(null==e?void 0:e.error)return w.isSubmitting=!1,void this.errorEvent.emit({message:e.error.message,errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}if(l&&!w.paymentToken){const t=w.plaidPublicToken,e=w.plaidLinkTokenId;if(!t)return w.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(w.authToken,w.accountId,t,e||void 0,w.savePaymentMethod?w.paymentMethodGroupId:void 0);if(null==i?void 0:i.error)return w.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,a=(null===(n=null==s?void 0:s.bank_account)||void 0===n?void 0:n.token)||(null==s?void 0:s.token)||(null==s?void 0:s.id);w.paymentToken=a}catch(t){return w.isSubmitting=!1,void this.errorEvent.emit({message:(null==t?void 0:t.message)||"Plaid exchange error",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}}if(!o)return w.isSubmitting=!1,void this.errorEvent.emit({message:"Please fill in all required fields.",errorCode:y.VALIDATION_ERROR,severity:p.ERROR});if(!w.paymentToken)return w.isSubmitting=!1,void this.errorEvent.emit({message:"Payment token not found.",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR});let c;if(c={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 G.ECOM;case V.SEZZLE:return G.BNPL;case V.APPLE_PAY:return G.APPLE_PAY;case V.GOOGLE_PAY:return G.GOOGLE_PAY;default:return}})(null===(a=w.selectedPaymentMethod)||void 0===a?void 0:a.type),payment_token:w.paymentToken},this.preCompleteHook){const t=A();try{await new Promise(((e,i)=>{this.preCompleteHook(t,(()=>e()),(()=>i()))}))}catch(t){return w.isSubmitting=!1,void console.log("Checkout cancelled by preCompleteHook",t)}}this.completeCheckout({payment:c,onSuccess:({checkout:t})=>{w.isSubmitting=!1,this.submitEvent.emit({checkout:t,message:"Checkout completed successfully"})},onError:t=>{w.isSubmitting=!1,this.errorEvent.emit({message:t.message,errorCode:y.COMPLETE_CHECKOUT_ERROR,severity:p.ERROR})}})}render(){return i(s,{key:"c3de4a4b90c599a374678d98c324a6b24dbec50d"})}get hostEl(){return n(this)}},rt=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.waitForStoreAndInitialize=()=>{w.authToken&&w.accountId&&w.checkoutId?this.initializePlaidLink():setTimeout((()=>{this.waitForStoreAndInitialize()}),100)},this.initializePlaidLink=async()=>{try{if(void 0===window.Plaid)return void this.handleError({code:M.PLAID_SDK_LOAD_FAILED,message:g[M.PLAID_SDK_LOAD_FAILED],severity:f[M.PLAID_SDK_LOAD_FAILED],retryable:!0,userAction:"Refresh the page and try again"});if(await this.getLinkToken(),!this.linkToken)return void this.handleError({code:M.PLAID_LINK_TOKEN_FAILED,message:g[M.PLAID_LINK_TOKEN_FAILED],severity:f[M.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:M.PLAID_LINK_INIT_FAILED,message:g[M.PLAID_LINK_INIT_FAILED],severity:f[M.PLAID_LINK_INIT_FAILED],originalError:t,retryable:!0,userAction:"Click to try again"})}},this.getLinkToken=async()=>{var t,e,i,s,n;try{if(!w.authToken||!w.accountId)return void this.handleError({code:M.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(w.authToken,w.accountId,w.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&&(w.plaidLinkTokenId=this.linkTokenId)}catch(t){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null);let a=M.PLAID_LINK_TOKEN_FAILED,o=g[a],r=!0;"AbortError"===t.name?(a=M.PLAID_TIMEOUT,o=g[a],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"))?(a=M.PLAID_NETWORK_ERROR,o=g[a],r=!0):((null===(s=t.message)||void 0===s?void 0:s.includes("401"))||(null===(n=t.message)||void 0===n?void 0:n.includes("unauthorized")))&&(a=M.PLAID_INVALID_CREDENTIALS,o="Authentication failed. Please refresh the page and try again.",r=!1),this.handleError({code:a,message:o,severity:f[a],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 M.PLAID_RATE_LIMITED;if(t.includes("maintenance"))return M.PLAID_MAINTENANCE;if(t.includes("not_authenticated"))return M.PLAID_INVALID_CREDENTIALS}if(null==t?void 0:t.code)switch(t.code){case"rate_limited":return M.PLAID_RATE_LIMITED;case"maintenance":return M.PLAID_MAINTENANCE;case"not_authenticated":return M.PLAID_INVALID_CREDENTIALS;default:return M.PLAID_LINK_TOKEN_FAILED}return M.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,w.selectedPaymentMethod={type:V.PLAID}),this.plaidErrorRecovered.emit({code:"plaid-success",message:"Bank account connected successfully",severity:p.INFO}),w.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=M.PLAID_AUTHENTICATION_FAILED,i=g[e],s=!0,n="Click to try again";if(t.error_code)switch(t.error_code){case"INVALID_CREDENTIALS":e=M.PLAID_INVALID_CREDENTIALS,i=g[e],s=!0;break;case"ITEM_LOGIN_REQUIRED":e=M.PLAID_INVALID_CREDENTIALS,i="Your bank requires re-authentication. Please try again.",s=!0;break;case"ITEM_LOCKED":e=M.PLAID_ACCOUNT_LOCKED,i=g[e],s=!1,n="Contact your bank";break;case"INSTITUTION_NOT_RESPONDING":e=M.PLAID_MAINTENANCE,i=g[e],s=!0;break;case"RATE_LIMIT_EXCEEDED":e=M.PLAID_RATE_LIMITED,i=g[e],s=!0;break;case"INVALID_REQUEST":e=M.PLAID_AUTHENTICATION_FAILED,i="Invalid request. Please try again.",s=!0;break;case"PLAID_ERROR":e=M.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 a=t.error_message.toLowerCase();a.includes("not supported")||a.includes("unsupported")?(e=M.PLAID_BANK_NOT_SUPPORTED,i=g[e],s=!1,n="Try a different payment method"):(a.includes("expired")||a.includes("timeout"))&&(e=M.PLAID_TOKEN_EXPIRED,i=g[e],s=!0)}this.handleError({code:e,message:i,severity:f[e],originalError:t,retryable:s,userAction:n}),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=w.selectedPaymentMethod)||void 0===t?void 0:t.type)===V.PLAID;this.isSelected!==e&&(this.isSelected=e)}}onSelectionChange(t){var e;t&&(null===(e=w.selectedPaymentMethod)||void 0===e?void 0:e.type)!==V.PLAID&&(w.selectedPaymentMethod={type:V.PLAID}),!t||!this.plaidLink||this.publicToken||this.isAuthenticating||this.error||this.openPlaidLink()}componentWillLoad(){var t;this.isSelected=(null===(t=w.selectedPaymentMethod)||void 0===t?void 0:t.type)===V.PLAID,!0===w.bankAccountVerification&&(w.checkoutLoaded?this.loadPlaidSDK():j("checkoutLoaded",(t=>{t&&!0===w.bankAccountVerification&&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:M.PLAID_SDK_LOAD_FAILED,message:g[M.PLAID_SDK_LOAD_FAILED],severity:f[M.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 w.paymentToken}async handleSelectionClick(){if(this.isSelected=!0,w.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&&(w.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=j("selectedPaymentMethod",this.syncWithStore);this.unsubscribeFromStore=t}disconnectedCallback(){this.unsubscribeFromStore&&this.unsubscribeFromStore(),this.timeoutId&&clearTimeout(this.timeoutId),this.abortController&&this.abortController.abort()}render(){if(!0!==w.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(b,{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"]}}},ht=class{constructor(e){t(this,e),this.onPaymentMethodOptionClick=t=>e=>{e.preventDefault(),w.selectedPaymentMethod={id:t.id,type:t.type},w.paymentToken=t.id},this.isAllowedPaymentMethod=t=>!(t===V.SAVED_CARD&&w.disableCreditCard||t===V.SAVED_BANK_ACCOUNT&&w.disableBankAccount)}componentWillLoad(){w.checkoutLoaded&&(w.paymentMethods.length||console.warn("No saved payment methods available."),w.disablePaymentMethodGroup&&console.warn("Payment method group is disabled."))}render(){return w.disablePaymentMethodGroup?null:i(b,null,i("div",{class:"saved-payment-methods"},w.paymentMethods.length?w.paymentMethods.filter((t=>this.isAllowedPaymentMethod(t.type))).map((t=>i("div",{class:"radio-list-item p-3",part:C,onClick:this.onPaymentMethodOptionClick(t)},i("form-control-radio",{name:"paymentMethodType",value:null==t?void 0:t.id,checked:w.paymentToken===(null==t?void 0:t.id),label:`${q[null==t?void 0:t.brand]||""} *${null==t?void 0:t.acct_last_four}`})))):null))}},lt=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"}}),ct=class{constructor(i){t(this,i),this.paymentMethodOptionSelected=e(this,"paymentMethodOptionSelected",7),this.paymentMethodOptionId=V.SEZZLE,this.initializeSezzleCheckout=()=>{let t;this.sezzlePromise=new Promise((e=>{t=e}));const e=Number(w.paymentAmount),i=new(0,window.Checkout)({mode:"popup",publicKey:w.bnplProviderClientId,apiMode:w.bnplProviderMode,apiVersion:w.bnplProviderApiVersion});i.sezzleButtonElement=this.sezzleButtonRef,i.init({onClick:function(t){t.preventDefault(),i.startCheckout({checkout_url:w.bnplProviderCheckoutUrl})},onComplete:e=>t({bnpl:e.data}),onCancel:e=>t({bnpl:e.data}),onFailure:e=>t({bnpl:e.data})}),this.sezzleCheckout=i,this.installmentPlan=this.sezzleCheckout.getInstallmentPlan(e)}}componentDidRender(){this.scriptRef&&(this.scriptRef.onload=()=>{this.sezzleButtonRef=document.createElement("button"),this.initializeSezzleCheckout()})}async resolvePaymentMethod(t){return t.isValid?(this.sezzleButtonRef.click(),this.sezzlePromise):{validationError:!0}}async handleSelectionClick(){w.selectedPaymentMethod={type:V.SEZZLE},this.paymentMethodOptionSelected.emit(this.paymentMethodOptionId)}render(){var t,e;return w.bnplEnabled?i(b,{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 ",lt),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)}},dt={[V.NEW_BANK_ACCOUNT]:"New bank account",[V.NEW_CARD]:"New credit or debit card"},ut="Payment form not ready",pt="Validation error",yt=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,w.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:pt}),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){w.billingFormFields=t}async validate(){if(!this.areFormsReady())return{isValid:!1,errors:{general:ut}};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||w.authToken,account:this.accountId||w.accountId,paymentMethodMetadata:this.buildPaymentMethodMetadata(t)};return await this.paymentMethodFormRef.tokenize(e)}catch(t){return t}}validateRequiredProps(){this.authToken||w.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||w.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||(this.selectedPaymentMethod=V.NEW_BANK_ACCOUNT,w.selectedPaymentMethod={type:V.NEW_BANK_ACCOUNT}):(this.selectedPaymentMethod=V.NEW_CARD,w.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=[];return this.disableCreditCard||t.push(V.NEW_CARD),this.disableBankAccount||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",ut);try{const e=await this.validate();if(!e.isValid||!t.isValid){const t=Object.values(e.errors)[0]||pt;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||w.paymentMethodGroupId}get shouldSavePaymentMethod(){return!(!this.paymentMethodGroupId&&!w.savePaymentMethod)}get shouldHideRadioInput(){return this.disableCreditCard||this.disableBankAccount}renderPaymentMethodOption(t){const e=this.selectedPaymentMethod===t&&void 0===w.selectedPaymentMethod.id;return i("div",{class:"payment-method"},i("radio-list-item",{name:"paymentMethodType",value:t,checked:e,label:dt[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(b,{key:"2d4349f3e5ad632981cdeb14dbe4e483f79379da"},i("form",{key:"754afee2c5229cf016bd8fc0cf81041cf37270a8"},i("fieldset",{key:"01867151a09d384e1258ef7f62fbc88c526706cc"},i("div",{key:"7ba453d4629a0c2ef583daddcb9cf02ac5eee265",class:"row gy-3"},i("div",{key:"4148f2269c738a00f2684d69d4a83a4ab2424f2b",class:"col-12"},this.availablePaymentMethods.map((t=>this.renderPaymentMethodOption(t)))),i("div",{key:"e67b09357571aadfb3d2712f55954506748b3826",class:"col-12"},i("internal-button",{key:"c2e805060ff7e9e97144533ffad3b4a02433e792",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 n(this)}static get watchers(){return{disableCreditCard:["paymentMethodsChanged"],disableBankAccount:["paymentMethodsChanged"]}}};export{$ as justifi_apple_pay,tt as justifi_button,et as justifi_checkout_summary,nt as justifi_google_pay,at as justifi_header,ot as justifi_modular_checkout,rt as justifi_plaid_payment_method,W as justifi_radio_list_item,ht as justifi_saved_payment_methods,ct as justifi_sezzle_payment_method,yt as justifi_tokenize_payment_method}
1
+ import{r as t,c as e,h as i,H as s,g as n}from"./p-CV0Pyo1O.js";import{A as a}from"./p-CYQvLgSs.js";import{A as o,p as r,q as h,r as l,s as c,t as d,u,C as p,e as y,v as m,I as v,w as f,x as g,y as M}from"./p-NZS8uCtH.js";import{S as b}from"./p-BqNNwq6C.js";import"./p-CZfYo5-1.js";import{S as k}from"./p-uZ5KAseb.js";import{c as w,o as j,a as P,g as T,b as A}from"./p-BArmtmkq.js";import{t as N,r as C}from"./p-CPKMvyV_.js";import{f as I}from"./p-BRnBHsdq.js";import{w as E,c as D}from"./p-DVJaoI_m.js";import{H as S}from"./p-jIDKmNHy.js";import{H as O,b as L,h as x,i as z}from"./p-D-zwk1J3.js";import{H as _}from"./p-DYHjzFnJ.js";import{J as R}from"./p-DO9lqnbB.js";import{c as U}from"./p-DjjAx7PF.js";import"./p-HXpYMWUU.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import{g as B,a as Y}from"./p-Cm9f5fyh.js";import{C as F}from"./p-fE5A37L5.js";import{P as Q}from"./p-av6jyzyC.js";import{P as V,a as H,b as q}from"./p-DkoufM1t.js";import{C as G}from"./p-ZpPDShvP.js";import"./p-D8GTwl9v.js";import"./p-B6YPrwyC.js";const Z=class{constructor(i){t(this,i),this.radioClick=e(this,"radio-click",7),this.checked=!1,this.hidden=!1}render(){return i(b,{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 W;!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"}(W||(W={}));class J{constructor(){this.api=a()}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 h(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,n)=>{try{if("undefined"==typeof window||!("ApplePaySession"in window))return console.error("[ApplePayService] ApplePaySession not available on window"),n({success:!1,error:{code:W.UNAVAILABLE,message:"ApplePaySession API is not available in this environment"}});this.currentSession=new window.ApplePaySession(3,s),this.setupSessionEventHandlers(t,n,e,i),this.currentSession.begin()}catch(t){console.error("[ApplePayService] Exception while starting session:",t),n({success:!1,error:{code:W.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:W.MERCHANT_VALIDATION_ERROR,message:t instanceof Error?t.message:"Merchant validation failed"}})}},this.currentSession.onpaymentauthorized=async n=>{try{const a=n.payment,o=Object.assign(Object.assign({},a.token),{product_details:{name:this.currentPaymentRequest.total.label,price:r.parseAmount(this.currentPaymentRequest.total.amount),description:this.currentPaymentRequest.total.label}}),h=await this.processPayment(i,s,o);h.success?(this.currentSession.completePayment({status:l.STATUS_SUCCESS}),t({success:!0,token:a.token,paymentMethodId:h.data.id})):(console.error("PSP reported payment failure:",h.data),this.currentSession.completePayment({status:l.STATUS_FAILURE}),e({success:!1,error:{code:W.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:l.STATUS_FAILURE}),e({success:!1,error:{code:W.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:l.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:W.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:W.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(k,{height:"44px",width:"100%",styles:{borderRadius:"8px"}})))):null},X=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 ")),$=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.showSkeleton=!0,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:w.paymentCurrency,merchantCapabilities:[u.SUPPORTS_3DS,u.SUPPORTS_CREDIT,u.SUPPORTS_DEBIT],supportedNetworks:r.getDefaultSupportedNetworks(),total:r.createLineItem(w.paymentDescription,w.paymentAmount)},s=await this.applePayService.startPaymentSession(i,w.authToken,w.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)||$.ErrorCode.PAYMENT_FAILED}))}catch(t){if((null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.code)===W.USER_CANCELLED)this.applePayCancelled.emit();else{const e=t instanceof Error?t.message:"Payment failed";this.error=e,this.applePayError.emit({error:e,code:$.ErrorCode.PAYMENT_FAILED}),this.applePayCompleted.emit({success:!1,error:e})}}finally{this.isProcessing=!1}}}componentWillLoad(){this.isAvailable=r.isApplePaySupported(),this.isAvailable?w.checkoutLoaded?this.loadApplePaySDK():j("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(w.paymentAmount)&&Boolean(w.paymentCurrency)&&Boolean(w.authToken)))return this.error="Missing required Apple Pay configuration",this.isConfigValid=!1,this.applePayError.emit({error:this.error,code:$.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:$.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:$.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:$.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(!w.applePayEnabled)return null;if(!this.isAvailable)return null;const t=!this.isLoading&&this.isAvailable&&this.canMakePayments&&this.isConfigValid;return i(b,null,i("div",{class:"apple-pay-container"},i(K,{isLoading:this.isLoading}),t&&i(X,{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 "))}};$.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(b,{key:"f1ac17863df571d72e7db9b748b1980218145322"},i("internal-button",{key:"0b7052d216fb79ed5d9f90aacff97d39dce87473",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(b,{key:"4dda3e1e4f81cfda61011706c2f4e3104815d97c"},i("section",{key:"f8bbdeb389afbfc906e6cc956a68f9a3485ed43c"},i("div",{key:"2f8019ae43d5d4a5835ec6d5674304bd321d34b7"},i("div",{key:"67626fe735d0c0372fe638960198592027fb24f5",part:N},null==w?void 0:w.paymentDescription),i("div",{key:"48d8b4b930d2f3b199bc0a59c93ef4f1339f7649"},i("span",{key:"ca6413ce719ae81eaa4654911cdfc09d63f9a9db",part:N},"Total")," ",i("span",{key:"9ed165b192efa2ecf2f77a129d33161e36b1594f",part:N},I(+(null==w?void 0:w.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(k,{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 nt=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.environment="TEST",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 E(),this.iframeOrigin=D.iframeOrigin}componentDidLoad(){window.addEventListener("message",this.handleMessage)}disconnectedCallback(){window.removeEventListener("message",this.handleMessage)}sendInitialize(){var t;(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow)&&this.iframeElement.contentWindow.postMessage({eventType:st.initialize,data:{environment:this.environment,gatewayMerchantId:w.accountId,merchantName:this.merchantName,authToken:w.authToken,accountId:w.accountId}},this.iframeOrigin)}sendStartPayment(){var t;if(!(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow))return;const e={totalPrice:String(w.paymentAmount/100),totalPriceStatus:"FINAL",currencyCode:w.paymentCurrency||"USD"};this.iframeElement.contentWindow.postMessage({eventType:st.startPayment,data:e},this.iframeOrigin)}render(){return w.checkoutLoaded?w.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}},at=class{constructor(e){t(this,e),this.levels={h1:S,h2:O,h3:_},this.level="h1"}render(){return i(b,{key:"879e301ec35e7cc536dec135e11daf140c67eeed"},i(this.levels[this.level],{key:"1766cb9a4d84bee1b3365b4df93515274cf31565",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.handleApplePayStarted=()=>{w.isWalletProcessing=!0},this.handleGooglePayStarted=()=>{w.isWalletProcessing=!0},this.handleGooglePayCompleted=t=>{const{success:e,paymentMethodId:i,error:s}=t.detail||{};e&&i?(w.isWalletProcessing=!1,w.paymentToken=i,w.selectedPaymentMethod={type:V.GOOGLE_PAY},this.submitCheckout()):(w.isWalletProcessing=!1,this.errorEvent.emit({message:s&&s.message||"Google Pay payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR}))},this.handleGooglePayCancelled=()=>{w.isWalletProcessing=!1,w.paymentToken=void 0,w.selectedPaymentMethod=void 0},this.handleApplePayCompleted=t=>{const{success:e,token:i,paymentMethodId:s,error:n}=t.detail;e&&i?(w.isWalletProcessing=!1,w.paymentToken=s,w.selectedPaymentMethod={type:V.APPLE_PAY},this.submitCheckout()):(w.isWalletProcessing=!1,console.error("Apple Pay completed but failed:",n),this.errorEvent.emit({message:(null==n?void 0:n.message)||"Apple Pay payment failed",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR}))},this.handleApplePayError=t=>{w.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=()=>{w.isWalletProcessing=!1,w.paymentToken=void 0,w.selectedPaymentMethod=void 0}}connectedCallback(){this.observer=new MutationObserver((()=>{this.queryFormRefs(),this.setupApplePayListeners(),this.setupGooglePayListeners()})),this.observer.observe(this.hostEl,{childList:!0,subtree:!0}),w.checkoutId=this.checkoutId;const t={authToken:this.authToken,checkoutId:this.checkoutId,service:new F};this.getCheckout=(({authToken:t,checkoutId:e,service:i})=>async({onSuccess:s,onError:n})=>{var a;try{const o=await i.fetchCheckout(t,e);if(o.error)return n({error:Y(o.error),code:B(null===(a=o.error)||void 0===a?void 0:a.code),severity:p.ERROR});s({checkout:o.data})}catch(t){const e=B(null==t?void 0:t.code);return n({error:t.message||t,code:e,severity:p.ERROR})}})(t),this.completeCheckout=(({authToken:t,checkoutId:e,service:i})=>async({payment:s,onSuccess:n,onError:a})=>{var o;try{const r=await i.complete(t,e,s);if(r.error)return a({error:Y(r.error),code:B(null===(o=r.error)||void 0===o?void 0:o.code),severity:p.ERROR});n({checkout:r.data})}catch(t){const e=B(null==t?void 0:t.code);return a({error:t.message||t,code:e,severity:p.ERROR})}})(t),P((()=>{this.emitCheckoutChanged()}))}componentWillLoad(){this.analytics=new R(this),U(),w.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()}disconnectedCallback(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this.removeApplePayListeners(),this.removeGooglePayListeners()}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,n,a,o,r;w.accountId=t.account_id,w.checkoutLoaded=!0,w.paymentMethods=t.payment_methods.map((t=>new H(t))),w.paymentMethodGroupId=t.payment_method_group_id,w.paymentDescription=t.payment_description,w.totalAmount=t.total_amount,w.paymentAmount=t.payment_amount,w.bnplEnabled=t.payment_settings.bnpl_payments,w.insuranceEnabled=t.payment_settings.insurance_payments,w.bankAccountVerification=null===(e=t.payment_settings)||void 0===e?void 0:e.bank_account_verification,w.applePayEnabled=null===(i=t.payment_settings)||void 0===i?void 0:i.apple_payments,w.googlePayEnabled=null===(s=t.payment_settings)||void 0===s?void 0:s.google_payments,w.bnplProviderClientId=null===(n=null==t?void 0:t.bnpl)||void 0===n?void 0:n.provider_client_id,w.bnplProviderMode=null===(a=null==t?void 0:t.bnpl)||void 0===a?void 0:a.provider_mode,w.bnplProviderApiVersion=null===(o=null==t?void 0:t.bnpl)||void 0===o?void 0:o.provider_api_version,w.bnplProviderCheckoutUrl=null===(r=null==t?void 0:t.bnpl)||void 0===r?void 0:r.provider_checkout_url}emitCheckoutChanged(){const t={availablePaymentMethodTypes:T(),selectedPaymentMethod:w.selectedPaymentMethod,savedPaymentMethods:w.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.paymentMethodFormRef=this.hostEl.querySelector("justifi-card-form, justifi-bank-account-form, justifi-tokenize-payment-method"),!w.selectedPaymentMethod&&this.paymentMethodFormRef){const t=this.paymentMethodFormRef.tagName.toLowerCase();"justifi-card-form"===t?w.selectedPaymentMethod={type:V.NEW_CARD}:"justifi-bank-account-form"===t&&(w.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))}async tokenizePaymentMethod(t){var e,i,s;const n=null!==(i=await(null===(e=this.billingFormRef)||void 0===e?void 0:e.getValues()))&&void 0!==i?i:{},a=Object.assign(Object.assign({},t),n),o=Object.assign({accountId:w.accountId,payment_method_group_id:void 0},a);w.savePaymentMethod&&(o.payment_method_group_id=w.paymentMethodGroupId);const r=await(null===(s=this.paymentMethodFormRef)||void 0===s?void 0:s.tokenize({clientId:this.authToken,paymentMethodMetadata:o,account:w.accountId}));return r.error?r:(w.paymentToken=r.id,r.id)}async fillBillingForm(t){w.billingFormFields=t}async setSelectedPaymentMethod(t){w.selectedPaymentMethod=t,w.paymentToken=t.id||void 0}async validate(){var t,e;const i=[];w.insuranceEnabled&&this.insuranceFormRef&&i.push(this.insuranceFormRef.validate());const s=(null===(t=w.selectedPaymentMethod)||void 0===t?void 0:t.type)===V.NEW_CARD,n=(null===(e=w.selectedPaymentMethod)||void 0===e?void 0:e.type)===V.NEW_BANK_ACCOUNT;if((s||n)&&(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,n,a;if(w.isSubmitting)return;w.isSubmitting=!0;const o=await this.validate();if(!w.selectedPaymentMethod)return w.isSubmitting=!1,void this.errorEvent.emit({message:"No payment method selected.",errorCode:y.VALIDATION_ERROR,severity:p.ERROR});const r=(null===(e=w.selectedPaymentMethod)||void 0===e?void 0:e.type)===V.NEW_CARD,h=(null===(i=w.selectedPaymentMethod)||void 0===i?void 0:i.type)===V.NEW_BANK_ACCOUNT,l=(null===(s=w.selectedPaymentMethod)||void 0===s?void 0:s.type)===V.PLAID;if(r||h){const e=await this.tokenizePaymentMethod(t);if(null==e?void 0:e.error)return w.isSubmitting=!1,void this.errorEvent.emit({message:e.error.message,errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}if(l&&!w.paymentToken){const t=w.plaidPublicToken,e=w.plaidLinkTokenId;if(!t)return w.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(w.authToken,w.accountId,t,e||void 0,w.savePaymentMethod?w.paymentMethodGroupId:void 0);if(null==i?void 0:i.error)return w.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,a=(null===(n=null==s?void 0:s.bank_account)||void 0===n?void 0:n.token)||(null==s?void 0:s.token)||(null==s?void 0:s.id);w.paymentToken=a}catch(t){return w.isSubmitting=!1,void this.errorEvent.emit({message:(null==t?void 0:t.message)||"Plaid exchange error",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR})}}if(!o)return w.isSubmitting=!1,void this.errorEvent.emit({message:"Please fill in all required fields.",errorCode:y.VALIDATION_ERROR,severity:p.ERROR});if(!w.paymentToken)return w.isSubmitting=!1,void this.errorEvent.emit({message:"Payment token not found.",errorCode:y.TOKENIZE_ERROR,severity:p.ERROR});let c;if(c={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 q.ECOM;case V.SEZZLE:return q.BNPL;case V.APPLE_PAY:return q.APPLE_PAY;case V.GOOGLE_PAY:return q.GOOGLE_PAY;default:return}})(null===(a=w.selectedPaymentMethod)||void 0===a?void 0:a.type),payment_token:w.paymentToken},this.preCompleteHook){const t=A();try{await new Promise(((e,i)=>{this.preCompleteHook(t,(()=>e()),(()=>i()))}))}catch(t){return w.isSubmitting=!1,void console.log("Checkout cancelled by preCompleteHook",t)}}this.completeCheckout({payment:c,onSuccess:({checkout:t})=>{w.isSubmitting=!1,this.submitEvent.emit({checkout:t,message:"Checkout completed successfully"})},onError:t=>{w.isSubmitting=!1,this.errorEvent.emit({message:t.message,errorCode:y.COMPLETE_CHECKOUT_ERROR,severity:p.ERROR})}})}render(){return i(s,{key:"c3de4a4b90c599a374678d98c324a6b24dbec50d"})}get hostEl(){return n(this)}},rt=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.waitForStoreAndInitialize=()=>{w.authToken&&w.accountId&&w.checkoutId?this.initializePlaidLink():setTimeout((()=>{this.waitForStoreAndInitialize()}),100)},this.initializePlaidLink=async()=>{try{if(void 0===window.Plaid)return void this.handleError({code:M.PLAID_SDK_LOAD_FAILED,message:g[M.PLAID_SDK_LOAD_FAILED],severity:f[M.PLAID_SDK_LOAD_FAILED],retryable:!0,userAction:"Refresh the page and try again"});if(await this.getLinkToken(),!this.linkToken)return void this.handleError({code:M.PLAID_LINK_TOKEN_FAILED,message:g[M.PLAID_LINK_TOKEN_FAILED],severity:f[M.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:M.PLAID_LINK_INIT_FAILED,message:g[M.PLAID_LINK_INIT_FAILED],severity:f[M.PLAID_LINK_INIT_FAILED],originalError:t,retryable:!0,userAction:"Click to try again"})}},this.getLinkToken=async()=>{var t,e,i,s,n;try{if(!w.authToken||!w.accountId)return void this.handleError({code:M.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(w.authToken,w.accountId,w.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&&(w.plaidLinkTokenId=this.linkTokenId)}catch(t){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null);let a=M.PLAID_LINK_TOKEN_FAILED,o=g[a],r=!0;"AbortError"===t.name?(a=M.PLAID_TIMEOUT,o=g[a],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"))?(a=M.PLAID_NETWORK_ERROR,o=g[a],r=!0):((null===(s=t.message)||void 0===s?void 0:s.includes("401"))||(null===(n=t.message)||void 0===n?void 0:n.includes("unauthorized")))&&(a=M.PLAID_INVALID_CREDENTIALS,o="Authentication failed. Please refresh the page and try again.",r=!1),this.handleError({code:a,message:o,severity:f[a],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 M.PLAID_RATE_LIMITED;if(t.includes("maintenance"))return M.PLAID_MAINTENANCE;if(t.includes("not_authenticated"))return M.PLAID_INVALID_CREDENTIALS}if(null==t?void 0:t.code)switch(t.code){case"rate_limited":return M.PLAID_RATE_LIMITED;case"maintenance":return M.PLAID_MAINTENANCE;case"not_authenticated":return M.PLAID_INVALID_CREDENTIALS;default:return M.PLAID_LINK_TOKEN_FAILED}return M.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,w.selectedPaymentMethod={type:V.PLAID}),this.plaidErrorRecovered.emit({code:"plaid-success",message:"Bank account connected successfully",severity:p.INFO}),w.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=M.PLAID_AUTHENTICATION_FAILED,i=g[e],s=!0,n="Click to try again";if(t.error_code)switch(t.error_code){case"INVALID_CREDENTIALS":e=M.PLAID_INVALID_CREDENTIALS,i=g[e],s=!0;break;case"ITEM_LOGIN_REQUIRED":e=M.PLAID_INVALID_CREDENTIALS,i="Your bank requires re-authentication. Please try again.",s=!0;break;case"ITEM_LOCKED":e=M.PLAID_ACCOUNT_LOCKED,i=g[e],s=!1,n="Contact your bank";break;case"INSTITUTION_NOT_RESPONDING":e=M.PLAID_MAINTENANCE,i=g[e],s=!0;break;case"RATE_LIMIT_EXCEEDED":e=M.PLAID_RATE_LIMITED,i=g[e],s=!0;break;case"INVALID_REQUEST":e=M.PLAID_AUTHENTICATION_FAILED,i="Invalid request. Please try again.",s=!0;break;case"PLAID_ERROR":e=M.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 a=t.error_message.toLowerCase();a.includes("not supported")||a.includes("unsupported")?(e=M.PLAID_BANK_NOT_SUPPORTED,i=g[e],s=!1,n="Try a different payment method"):(a.includes("expired")||a.includes("timeout"))&&(e=M.PLAID_TOKEN_EXPIRED,i=g[e],s=!0)}this.handleError({code:e,message:i,severity:f[e],originalError:t,retryable:s,userAction:n}),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=w.selectedPaymentMethod)||void 0===t?void 0:t.type)===V.PLAID;this.isSelected!==e&&(this.isSelected=e)}}onSelectionChange(t){var e;t&&(null===(e=w.selectedPaymentMethod)||void 0===e?void 0:e.type)!==V.PLAID&&(w.selectedPaymentMethod={type:V.PLAID}),!t||!this.plaidLink||this.publicToken||this.isAuthenticating||this.error||this.openPlaidLink()}componentWillLoad(){var t;this.isSelected=(null===(t=w.selectedPaymentMethod)||void 0===t?void 0:t.type)===V.PLAID,!0===w.bankAccountVerification&&(w.checkoutLoaded?this.loadPlaidSDK():j("checkoutLoaded",(t=>{t&&!0===w.bankAccountVerification&&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:M.PLAID_SDK_LOAD_FAILED,message:g[M.PLAID_SDK_LOAD_FAILED],severity:f[M.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 w.paymentToken}async handleSelectionClick(){if(this.isSelected=!0,w.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&&(w.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=j("selectedPaymentMethod",this.syncWithStore);this.unsubscribeFromStore=t}disconnectedCallback(){this.unsubscribeFromStore&&this.unsubscribeFromStore(),this.timeoutId&&clearTimeout(this.timeoutId),this.abortController&&this.abortController.abort()}render(){if(!0!==w.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(b,{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"]}}},ht=class{constructor(e){t(this,e),this.onPaymentMethodOptionClick=t=>e=>{e.preventDefault(),w.selectedPaymentMethod={id:t.id,type:t.type},w.paymentToken=t.id},this.isAllowedPaymentMethod=t=>!(t===V.SAVED_CARD&&w.disableCreditCard||t===V.SAVED_BANK_ACCOUNT&&w.disableBankAccount)}componentWillLoad(){w.checkoutLoaded&&(w.paymentMethods.length||console.warn("No saved payment methods available."),w.disablePaymentMethodGroup&&console.warn("Payment method group is disabled."))}render(){return w.disablePaymentMethodGroup?null:i(b,null,i("div",{class:"saved-payment-methods"},w.paymentMethods.length?w.paymentMethods.filter((t=>this.isAllowedPaymentMethod(t.type))).map((t=>i("div",{class:"radio-list-item p-3",part:C,onClick:this.onPaymentMethodOptionClick(t)},i("form-control-radio",{name:"paymentMethodType",value:null==t?void 0:t.id,checked:w.paymentToken===(null==t?void 0:t.id),label:`${G[null==t?void 0:t.brand]||""} *${null==t?void 0:t.acct_last_four}`})))):null))}},lt=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"}}),ct=class{constructor(i){t(this,i),this.paymentMethodOptionSelected=e(this,"paymentMethodOptionSelected",7),this.paymentMethodOptionId=V.SEZZLE,this.initializeSezzleCheckout=()=>{let t;this.sezzlePromise=new Promise((e=>{t=e}));const e=Number(w.paymentAmount),i=new(0,window.Checkout)({mode:"popup",publicKey:w.bnplProviderClientId,apiMode:w.bnplProviderMode,apiVersion:w.bnplProviderApiVersion});i.sezzleButtonElement=this.sezzleButtonRef,i.init({onClick:function(t){t.preventDefault(),i.startCheckout({checkout_url:w.bnplProviderCheckoutUrl})},onComplete:e=>t({bnpl:e.data}),onCancel:e=>t({bnpl:e.data}),onFailure:e=>t({bnpl:e.data})}),this.sezzleCheckout=i,this.installmentPlan=this.sezzleCheckout.getInstallmentPlan(e)}}componentDidRender(){this.scriptRef&&(this.scriptRef.onload=()=>{this.sezzleButtonRef=document.createElement("button"),this.initializeSezzleCheckout()})}async resolvePaymentMethod(t){return t.isValid?(this.sezzleButtonRef.click(),this.sezzlePromise):{validationError:!0}}async handleSelectionClick(){w.selectedPaymentMethod={type:V.SEZZLE},this.paymentMethodOptionSelected.emit(this.paymentMethodOptionId)}render(){var t,e;return w.bnplEnabled?i(b,{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 ",lt),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)}},dt={[V.NEW_BANK_ACCOUNT]:"New bank account",[V.NEW_CARD]:"New credit or debit card"},ut="Payment form not ready",pt="Validation error",yt=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,w.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:pt}),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){w.billingFormFields=t}async validate(){if(!this.areFormsReady())return{isValid:!1,errors:{general:ut}};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||w.authToken,account:this.accountId||w.accountId,paymentMethodMetadata:this.buildPaymentMethodMetadata(t)};return await this.paymentMethodFormRef.tokenize(e)}catch(t){return t}}validateRequiredProps(){this.authToken||w.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||w.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||(this.selectedPaymentMethod=V.NEW_BANK_ACCOUNT,w.selectedPaymentMethod={type:V.NEW_BANK_ACCOUNT}):(this.selectedPaymentMethod=V.NEW_CARD,w.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=[];return this.disableCreditCard||t.push(V.NEW_CARD),this.disableBankAccount||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",ut);try{const e=await this.validate();if(!e.isValid||!t.isValid){const t=Object.values(e.errors)[0]||pt;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||w.paymentMethodGroupId}get shouldSavePaymentMethod(){return!(!this.paymentMethodGroupId&&!w.savePaymentMethod)}get shouldHideRadioInput(){return this.disableCreditCard||this.disableBankAccount}renderPaymentMethodOption(t){const e=this.selectedPaymentMethod===t&&void 0===w.selectedPaymentMethod.id;return i("div",{class:"payment-method"},i("radio-list-item",{name:"paymentMethodType",value:t,checked:e,label:dt[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(b,{key:"2d4349f3e5ad632981cdeb14dbe4e483f79379da"},i("form",{key:"754afee2c5229cf016bd8fc0cf81041cf37270a8"},i("fieldset",{key:"01867151a09d384e1258ef7f62fbc88c526706cc"},i("div",{key:"7ba453d4629a0c2ef583daddcb9cf02ac5eee265",class:"row gy-3"},i("div",{key:"4148f2269c738a00f2684d69d4a83a4ab2424f2b",class:"col-12"},this.availablePaymentMethods.map((t=>this.renderPaymentMethodOption(t)))),i("div",{key:"e67b09357571aadfb3d2712f55954506748b3826",class:"col-12"},i("internal-button",{key:"c2e805060ff7e9e97144533ffad3b4a02433e792",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 n(this)}static get watchers(){return{disableCreditCard:["paymentMethodsChanged"],disableBankAccount:["paymentMethodsChanged"]}}};export{$ as justifi_apple_pay,tt as justifi_button,et as justifi_checkout_summary,nt as justifi_google_pay,at as justifi_header,ot as justifi_modular_checkout,rt as justifi_plaid_payment_method,Z as justifi_radio_list_item,ht as justifi_saved_payment_methods,ct as justifi_sezzle_payment_method,yt as justifi_tokenize_payment_method}
@@ -1 +1 @@
1
- import{r as t,h as o}from"./p-CV0Pyo1O.js";import{c as a}from"./p-mF5zKtkx.js";import{J as s}from"./p-Cz_7BuGW.js";import{w as r}from"./p-DVJaoI_m.js";import{S as p}from"./p-BqNNwq6C.js";import"./p-CZfYo5-1.js";import"./p-OGt0dCJl.js";import"./p-CYQvLgSs.js";import"./p-BRnBHsdq.js";import"./p-HXpYMWUU.js";import"./p-NZS8uCtH.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-D8GTwl9v.js";const i=class{constructor(o){t(this,o)}async componentWillLoad(){await r(),a(),this.analytics=new s(this)}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}async validate(){return this.bankAccountFormElement.validate()}async tokenize({clientId:t,paymentMethodMetadata:o,account:a}){return this.bankAccountFormElement.tokenize({clientId:t,paymentMethodMetadata:o,account:a})}render(){return o(p,{key:"3a267a32b400d122cd124245979218ffc45453ee"},o("bank-account-form",{key:"72044965224da0d85455ad7688b3d1852a46126e",ref:t=>this.bankAccountFormElement=t}))}};export{i as justifi_bank_account_form}
1
+ import{r as t,h as o}from"./p-CV0Pyo1O.js";import{c as a}from"./p-DjjAx7PF.js";import{J as s}from"./p-DO9lqnbB.js";import{w as r}from"./p-DVJaoI_m.js";import{S as p}from"./p-BqNNwq6C.js";import"./p-CZfYo5-1.js";import"./p-B6YPrwyC.js";import"./p-CYQvLgSs.js";import"./p-BRnBHsdq.js";import"./p-HXpYMWUU.js";import"./p-NZS8uCtH.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-D8GTwl9v.js";const i=class{constructor(o){t(this,o)}async componentWillLoad(){await r(),a(),this.analytics=new s(this)}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}async validate(){return this.bankAccountFormElement.validate()}async tokenize({clientId:t,paymentMethodMetadata:o,account:a}){return this.bankAccountFormElement.tokenize({clientId:t,paymentMethodMetadata:o,account:a})}render(){return o(p,{key:"3a267a32b400d122cd124245979218ffc45453ee"},o("bank-account-form",{key:"72044965224da0d85455ad7688b3d1852a46126e",ref:t=>this.bankAccountFormElement=t}))}};export{i as justifi_bank_account_form}