@justifi/webcomponents 6.13.1 → 6.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/cjs/{Analytics-DMppKXYI.js → Analytics-F9eGV4SU.js} +1 -1
  2. package/dist/cjs/bank-account-form.cjs.entry.js +2 -2
  3. package/dist/cjs/card-form.cjs.entry.js +2 -2
  4. package/dist/cjs/{check-pkg-version-DcgenUqU.js → check-pkg-version--A_rGEJu.js} +1 -1
  5. package/dist/cjs/dispute-notification_2.cjs.entry.js +3 -3
  6. package/dist/cjs/hidden-input_2.cjs.entry.js +1 -1
  7. package/dist/cjs/justifi-apple-pay_11.cjs.entry.js +3 -3
  8. package/dist/cjs/justifi-bank-account-billing-form-simple.cjs.entry.js +3 -3
  9. package/dist/cjs/justifi-bank-account-form.cjs.entry.js +3 -3
  10. package/dist/cjs/justifi-business-details.cjs.entry.js +3 -3
  11. package/dist/cjs/justifi-business-form.cjs.entry.js +3 -3
  12. package/dist/cjs/justifi-card-form.cjs.entry.js +3 -3
  13. package/dist/cjs/justifi-checkout-qr-code.cjs.entry.js +3 -3
  14. package/dist/cjs/justifi-checkout.cjs.entry.js +3 -3
  15. package/dist/cjs/justifi-checkouts-list.cjs.entry.js +3 -3
  16. package/dist/cjs/justifi-dispute-management.cjs.entry.js +3 -3
  17. package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +3 -3
  18. package/dist/cjs/justifi-order-terminals.cjs.entry.js +3 -3
  19. package/dist/cjs/justifi-payment-details.cjs.entry.js +3 -3
  20. package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +3 -3
  21. package/dist/cjs/justifi-payment-transactions-list.cjs.entry.js +3 -3
  22. package/dist/cjs/justifi-payments-list.cjs.entry.js +3 -3
  23. package/dist/cjs/justifi-payout-details.cjs.entry.js +3 -3
  24. package/dist/cjs/justifi-payout-transactions-list.cjs.entry.js +10 -4
  25. package/dist/cjs/justifi-payouts-list.cjs.entry.js +3 -3
  26. package/dist/cjs/justifi-qr-terminal.cjs.entry.js +3 -3
  27. package/dist/cjs/justifi-refund-payment.cjs.entry.js +3 -3
  28. package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +3 -3
  29. package/dist/cjs/justifi-terminal-orders-list.cjs.entry.js +3 -3
  30. package/dist/cjs/justifi-terminals-list.cjs.entry.js +3 -3
  31. package/dist/cjs/{package-CS22fAzw.js → package-Cuwhrp-b.js} +1 -1
  32. package/dist/collection/components/payout-transactions-list/payout-transactions-table.js +7 -1
  33. package/dist/docs.json +1 -1
  34. package/dist/esm/{Analytics-CTY3Jgn8.js → Analytics-CQwgYl2v.js} +1 -1
  35. package/dist/esm/bank-account-form.entry.js +2 -2
  36. package/dist/esm/card-form.entry.js +2 -2
  37. package/dist/esm/{check-pkg-version-BOQqkWpf.js → check-pkg-version-2VZtm0yL.js} +1 -1
  38. package/dist/esm/dispute-notification_2.entry.js +3 -3
  39. package/dist/esm/hidden-input_2.entry.js +1 -1
  40. package/dist/esm/justifi-apple-pay_11.entry.js +3 -3
  41. package/dist/esm/justifi-bank-account-billing-form-simple.entry.js +3 -3
  42. package/dist/esm/justifi-bank-account-form.entry.js +3 -3
  43. package/dist/esm/justifi-business-details.entry.js +3 -3
  44. package/dist/esm/justifi-business-form.entry.js +3 -3
  45. package/dist/esm/justifi-card-form.entry.js +3 -3
  46. package/dist/esm/justifi-checkout-qr-code.entry.js +3 -3
  47. package/dist/esm/justifi-checkout.entry.js +3 -3
  48. package/dist/esm/justifi-checkouts-list.entry.js +3 -3
  49. package/dist/esm/justifi-dispute-management.entry.js +3 -3
  50. package/dist/esm/justifi-gross-payment-chart.entry.js +3 -3
  51. package/dist/esm/justifi-order-terminals.entry.js +3 -3
  52. package/dist/esm/justifi-payment-details.entry.js +3 -3
  53. package/dist/esm/justifi-payment-provisioning.entry.js +3 -3
  54. package/dist/esm/justifi-payment-transactions-list.entry.js +3 -3
  55. package/dist/esm/justifi-payments-list.entry.js +3 -3
  56. package/dist/esm/justifi-payout-details.entry.js +3 -3
  57. package/dist/esm/justifi-payout-transactions-list.entry.js +10 -4
  58. package/dist/esm/justifi-payouts-list.entry.js +3 -3
  59. package/dist/esm/justifi-qr-terminal.entry.js +3 -3
  60. package/dist/esm/justifi-refund-payment.entry.js +3 -3
  61. package/dist/esm/justifi-season-interruption-insurance.entry.js +3 -3
  62. package/dist/esm/justifi-terminal-orders-list.entry.js +3 -3
  63. package/dist/esm/justifi-terminals-list.entry.js +3 -3
  64. package/dist/esm/{package-DNd24RUQ.js → package-BtzgeLyZ.js} +1 -1
  65. package/dist/module/justifi-payout-transactions-list.js +7 -1
  66. package/dist/module/package.js +1 -1
  67. package/dist/types/components/payout-transactions-list/payout-transactions-table.d.ts +6 -0
  68. package/dist/webcomponents/{p-fca0ca4d.entry.js → p-10f3b8df.entry.js} +1 -1
  69. package/dist/webcomponents/{p-f52fe722.entry.js → p-1ac357f9.entry.js} +1 -1
  70. package/dist/webcomponents/{p-1737a7fc.entry.js → p-4821c092.entry.js} +1 -1
  71. package/dist/webcomponents/p-4bb9d772.entry.js +1 -0
  72. package/dist/webcomponents/{p-ac08992c.entry.js → p-5111a9f5.entry.js} +1 -1
  73. package/dist/webcomponents/{p-2bab43ac.entry.js → p-54e343d3.entry.js} +3 -3
  74. package/dist/webcomponents/{p-5d9d6dd5.entry.js → p-5e59e283.entry.js} +1 -1
  75. package/dist/webcomponents/{p-e8875186.entry.js → p-64840a3d.entry.js} +1 -1
  76. package/dist/webcomponents/{p-f60bfe16.entry.js → p-648c6cb1.entry.js} +1 -1
  77. package/dist/webcomponents/{p-e711f221.entry.js → p-7d04803e.entry.js} +1 -1
  78. package/dist/webcomponents/p-85b155b0.entry.js +1 -0
  79. package/dist/webcomponents/{p-e63cd41f.entry.js → p-87427a4f.entry.js} +1 -1
  80. package/dist/webcomponents/{p-c47db9f5.entry.js → p-9c1a0efc.entry.js} +1 -1
  81. package/dist/webcomponents/{p-2757b61e.entry.js → p-9c7bce35.entry.js} +1 -1
  82. package/dist/webcomponents/p-BtzgeLyZ.js +1 -0
  83. package/dist/webcomponents/{p-CQqmTKij.js → p-C_SQBHCI.js} +1 -1
  84. package/dist/webcomponents/{p-_GBnYSuR.js → p-DYL3RR2S.js} +1 -1
  85. package/dist/webcomponents/p-a125318a.entry.js +1 -0
  86. package/dist/webcomponents/{p-a5913b33.entry.js → p-a404b995.entry.js} +1 -1
  87. package/dist/webcomponents/{p-b73c5779.entry.js → p-b08c76da.entry.js} +1 -1
  88. package/dist/webcomponents/{p-fb2e1557.entry.js → p-bd882260.entry.js} +1 -1
  89. package/dist/webcomponents/{p-2ebc862f.entry.js → p-c2de24fe.entry.js} +1 -1
  90. package/dist/webcomponents/{p-ec845aa4.entry.js → p-d1cbeb65.entry.js} +1 -1
  91. package/dist/webcomponents/{p-0dc3c605.entry.js → p-d5197891.entry.js} +1 -1
  92. package/dist/webcomponents/{p-ebd1c09f.entry.js → p-d93d9d58.entry.js} +1 -1
  93. package/dist/webcomponents/{p-863daddf.entry.js → p-d9fd1c50.entry.js} +1 -1
  94. package/dist/webcomponents/{p-6d1299db.entry.js → p-e4bc8c7c.entry.js} +1 -1
  95. package/dist/webcomponents/{p-2092b278.entry.js → p-ebf178d2.entry.js} +1 -1
  96. package/dist/webcomponents/{p-a7bd5651.entry.js → p-ee97795a.entry.js} +1 -1
  97. package/dist/webcomponents/{p-a5cc55af.entry.js → p-f0961751.entry.js} +1 -1
  98. package/dist/webcomponents/{p-32ee9101.entry.js → p-fa21fe56.entry.js} +1 -1
  99. package/dist/webcomponents/webcomponents.esm.js +1 -1
  100. package/package.json +1 -1
  101. package/dist/webcomponents/p-5984e9df.entry.js +0 -1
  102. package/dist/webcomponents/p-70a2f59a.entry.js +0 -1
  103. package/dist/webcomponents/p-90c5af69.entry.js +0 -1
  104. package/dist/webcomponents/p-DNd24RUQ.js +0 -1
@@ -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-De4Pig-y.js";import{A as o,r,s as l,t as h,u as c,v as d,w as u,C as p,b as y,c as m,I as v,x as g,y as f,z as b}from"./p-DXTa04jn.js";import{S as M}from"./p-DzEdYT8R.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-DyPk4BJt.js";import{t as N,r as C}from"./p-CPKMvyV_.js";import{f as I}from"./p-BSs-2JKu.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-C-Jgmek8.js";import{H as _}from"./p-DYHjzFnJ.js";import{J as R}from"./p-_GBnYSuR.js";import{c as U}from"./p-CQqmTKij.js";import"./p-HXpYMWUU.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import{m as B,a as Y}from"./p-B62JX_Dh.js";import{C as F}from"./p-Cn7z5L7J.js";import{P as Q}from"./p-DP9ysr2K.js";import{P as V,a as H,b as G}from"./p-DkoufM1t.js";import{C as W}from"./p-ZpPDShvP.js";import"./p-D8GTwl9v.js";import"./p-DNd24RUQ.js";import"./p-CdwzNfP1.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(M,{key:"02955940079320bd9c6bf94e239545385ac36458"},i("radio-list-item",{key:"fc6b98e456e4326b843b2b3248b7327436767cf4",name:this.name,value:this.value,label:this.label,checked:this.checked,hidden:this.hidden,class:this.class,"onRadio-click":t=>this.radioClick.emit(t.detail)}))}};var J;!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"}(J||(J={}));class q{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 l(t);if(!s.isValid){const t=[];throw s.countryCode||t.push("countryCode"),s.currencyCode||t.push("currencyCode"),s.merchantCapabilities&&0!==s.merchantCapabilities.length||t.push("merchantCapabilities"),s.supportedNetworks&&0!==s.supportedNetworks.length||t.push("supportedNetworks"),s.total&&s.total.label&&s.total.amount||t.push("total"),console.error("[ApplePayService] Payment request is invalid. Missing/invalid:",t),new Error("Invalid payment request provided")}return this.currentPaymentRequest=s,new Promise(((t,n)=>{try{if("undefined"==typeof window||!("ApplePaySession"in window))return console.error("[ApplePayService] ApplePaySession not available on window"),n({success:!1,error:{code:J.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:J.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:J.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}}),l=await this.processPayment(i,s,o);l.success?(this.currentSession.completePayment({status:h.STATUS_SUCCESS}),t({success:!0,token:a.token,paymentMethodId:l.data.id})):(console.error("PSP reported payment failure:",l.data),this.currentSession.completePayment({status:h.STATUS_FAILURE}),e({success:!1,error:{code:J.PAYMENT_PROCESSING_ERROR,message:"Payment processing failed"}}))}catch(t){console.error("=== PAYMENT PROCESSING ERROR ==="),console.error("Error processing payment:",t),t&&t.stack&&console.error("Error stack:",t.stack),this.currentSession.completePayment({status:h.STATUS_FAILURE}),e({success:!1,error:{code:J.PAYMENT_PROCESSING_ERROR,message:t instanceof Error?t.message:"Payment processing failed"}})}finally{this.currentSession=void 0,this.currentPaymentRequest=void 0}},this.currentSession.onpaymentmethodselected=()=>{const t={newTotal:this.currentPaymentRequest.total,newLineItems:this.currentPaymentRequest.lineItems||[]};try{this.currentSession.completePaymentMethodSelection(t)}catch(t){console.error("Error completing payment method selection:",t),this.currentSession.abort()}},this.currentSession.onshippingmethodselected=()=>{this.currentSession.completeShippingMethodSelection({status:h.STATUS_SUCCESS,newTotal:this.currentPaymentRequest.total,newLineItems:this.currentPaymentRequest.lineItems||[]})},this.currentSession.oncancel=t=>{if(t.sessionError)switch(console.error(t.sessionError),t.sessionError.code){case"unknown":console.error("Unknown error - likely merchant validation issue"),console.error("This usually means:"),console.error("1. Merchant certificate is invalid or expired"),console.error("2. Merchant identifier mismatch"),console.error("3. Backend validation endpoint issues");break;case"invalidMerchantSession":console.error("Invalid merchant session provided"),console.error("Check that the merchant session from backend is valid");break;case"userCancel":console.error("User cancelled the payment");break;default:console.error("Other error code:",t.sessionError.code)}this.currentSession=void 0,this.currentPaymentRequest=void 0,e({success:!1,error:{code:J.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:J.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.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)===J.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 q,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(M,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(M,{key:"241fe8903788f0442b42bf5a6835d152d1944967"},i("internal-button",{key:"7c13bd1fa53cf9faae26e521af5a40a08659fe92",text:this.text,variant:this.variant,isLoading:this.isLoading,clickHandler:this.clickHandler,type:this.type,disabled:this.disabled,class:this.class,customStyle:this.customStyle,hidden:this.hidden}))}},et=class{constructor(e){t(this,e)}render(){return i(M,{key:"336fa6563952ee7905c2ed4a3330d73bbb33a0eb"},i("section",{key:"48b8798a925d618f5a2c52d743190207b78eb70a"},i("div",{key:"81d91167c10ccc49acb039ea54a9f97f4aa6e305"},i("div",{key:"9744242f2c2c3082e9c1a3af6e716ec4cb28f1fd",part:N},null==w?void 0:w.paymentDescription),i("div",{key:"438062935abd2f00495c432ef6652e3808e5215f"},i("span",{key:"e3f24d9c52ddae0206cbefe61bd08f24697fe28e",part:N},"Total")," ",i("span",{key:"9835cb60de31a2c8946b7ac2dd6d1fa82f223110",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.merchantDisplayName="JustiFi Checkout",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)}googlePayEnvironment(){return void 0!==this.environment?this.environment:"test"===w.checkoutMode?"TEST":"PRODUCTION"}sendInitialize(){var t;if(!(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow))return;const e={environment:this.googlePayEnvironment(),gatewayMerchantId:w.accountId,merchantName:this.merchantDisplayName,authToken:w.authToken,accountId:w.accountId};this.iframeElement.contentWindow.postMessage({eventType:st.initialize,data:e},this.iframeOrigin)}sendStartPayment(){var t;if(!(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow))return;const e={totalPrice:String(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(M,{key:"5a0872ee486bdba3ba1c86145946889bb7d151f2"},i(this.levels[this.level],{key:"89807e249cdf64f7ef80800276cb50966083f28e",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=B(t),this.completeCheckout=Y(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,l;w.accountId=t.account_id,w.checkoutLoaded=!0;const h=null!=t.mode?String(t.mode).toLowerCase():"";w.checkoutMode="test"===h?"test":"live"===h?"live":null;const c=t.payment_methods.map((t=>new H(t))),d=Boolean(null===(e=t.payment_settings)||void 0===e?void 0:e.ach_payments);w.paymentMethods=c.filter((t=>t.type!==V.SAVED_BANK_ACCOUNT||d)),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===(i=t.payment_settings)||void 0===i?void 0:i.bank_account_verification,w.applePayEnabled=null===(s=t.payment_settings)||void 0===s?void 0:s.apple_payments,w.googlePayEnabled=null===(n=t.payment_settings)||void 0===n?void 0:n.google_payments,w.achPaymentsEnabled=d,w.bnplProviderClientId=null===(a=null==t?void 0:t.bnpl)||void 0===a?void 0:a.provider_client_id,w.bnplProviderMode=null===(o=null==t?void 0:t.bnpl)||void 0===o?void 0:o.provider_mode,w.bnplProviderApiVersion=null===(r=null==t?void 0:t.bnpl)||void 0===r?void 0:r.provider_api_version,w.bnplProviderCheckoutUrl=null===(l=null==t?void 0:t.bnpl)||void 0===l?void 0:l.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.checkoutLoaded&&!w.achPaymentsEnabled||(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,l=(null===(i=w.selectedPaymentMethod)||void 0===i?void 0:i.type)===V.NEW_BANK_ACCOUNT,h=(null===(s=w.selectedPaymentMethod)||void 0===s?void 0:s.type)===V.PLAID;if(r||l){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(h&&!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});const 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};if(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:"545e1cb07252ba0dc78fa980bd17ee5572559f6c"})}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.hasLoggedAchPaymentsDisabledWarning=!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:b.PLAID_SDK_LOAD_FAILED,message:f[b.PLAID_SDK_LOAD_FAILED],severity:g[b.PLAID_SDK_LOAD_FAILED],retryable:!0,userAction:"Refresh the page and try again"});if(await this.getLinkToken(),!this.linkToken)return void this.handleError({code:b.PLAID_LINK_TOKEN_FAILED,message:f[b.PLAID_LINK_TOKEN_FAILED],severity:g[b.PLAID_LINK_TOKEN_FAILED],retryable:!0,userAction:"Click to try again"});const t=window.Plaid;this.plaidLink=t.create({token:this.linkToken,onSuccess:this.handlePlaidSuccess,onExit:this.handlePlaidExit,onEvent:this.handlePlaidEvent,onLoad:this.handlePlaidLoad})}catch(t){this.handleError({code:b.PLAID_LINK_INIT_FAILED,message:f[b.PLAID_LINK_INIT_FAILED],severity:g[b.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:b.PLAID_LINK_TOKEN_FAILED,message:"Missing authentication. Please refresh the page and try again.",severity:p.ERROR,retryable:!1,userAction:"Refresh the page"});this.abortController=new AbortController,this.timeoutId=setTimeout((()=>{var t;null===(t=this.abortController)||void 0===t||t.abort()}),3e4);const e=await this.plaidService.getLinkToken(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=b.PLAID_LINK_TOKEN_FAILED,o=f[a],r=!0;"AbortError"===t.name?(a=b.PLAID_TIMEOUT,o=f[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=b.PLAID_NETWORK_ERROR,o=f[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=b.PLAID_INVALID_CREDENTIALS,o="Authentication failed. Please refresh the page and try again.",r=!1),this.handleError({code:a,message:o,severity:g[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 b.PLAID_RATE_LIMITED;if(t.includes("maintenance"))return b.PLAID_MAINTENANCE;if(t.includes("not_authenticated"))return b.PLAID_INVALID_CREDENTIALS}if(null==t?void 0:t.code)switch(t.code){case"rate_limited":return b.PLAID_RATE_LIMITED;case"maintenance":return b.PLAID_MAINTENANCE;case"not_authenticated":return b.PLAID_INVALID_CREDENTIALS;default:return b.PLAID_LINK_TOKEN_FAILED}return b.PLAID_LINK_TOKEN_FAILED},this.openPlaidLink=()=>{this.plaidLink&&this.linkToken&&(this.isAuthenticating=!0,this.clearError(),this.plaidLink.open())},this.handlePlaidSuccess=t=>{this.publicToken=t,this.isAuthenticating=!1,this.clearError(),this.retryCount=0,this.isSelected||(this.isSelected=!0,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=b.PLAID_AUTHENTICATION_FAILED,i=f[e],s=!0,n="Click to try again";if(t.error_code)switch(t.error_code){case"INVALID_CREDENTIALS":e=b.PLAID_INVALID_CREDENTIALS,i=f[e],s=!0;break;case"ITEM_LOGIN_REQUIRED":e=b.PLAID_INVALID_CREDENTIALS,i="Your bank requires re-authentication. Please try again.",s=!0;break;case"ITEM_LOCKED":e=b.PLAID_ACCOUNT_LOCKED,i=f[e],s=!1,n="Contact your bank";break;case"INSTITUTION_NOT_RESPONDING":e=b.PLAID_MAINTENANCE,i=f[e],s=!0;break;case"RATE_LIMIT_EXCEEDED":e=b.PLAID_RATE_LIMITED,i=f[e],s=!0;break;case"INVALID_REQUEST":e=b.PLAID_AUTHENTICATION_FAILED,i="Invalid request. Please try again.",s=!0;break;case"PLAID_ERROR":e=b.PLAID_AUTHENTICATION_FAILED,i=t.error_message||"Bank authentication failed. Please try again.",s=!0;break;default:t.error_message&&(i=t.error_message)}if(t.error_message){const a=t.error_message.toLowerCase();a.includes("not supported")||a.includes("unsupported")?(e=b.PLAID_BANK_NOT_SUPPORTED,i=f[e],s=!1,n="Try a different payment method"):(a.includes("expired")||a.includes("timeout"))&&(e=b.PLAID_TOKEN_EXPIRED,i=f[e],s=!0)}this.handleError({code:e,message:i,severity:g[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?w.achPaymentsEnabled&&this.loadPlaidSDK():j("checkoutLoaded",(t=>{t&&!0===w.bankAccountVerification&&w.achPaymentsEnabled&&this.loadPlaidSDK()})))}loadPlaidSDK(){if(this.sdkLoaded)return;this.sdkLoaded=!0;const t=document.createElement("script");t.src="https://cdn.plaid.com/link/v2/stable/link-initialize.js",t.async=!0,t.onload=()=>this.initializePlaidLink(),t.onerror=()=>{this.handleError({code:b.PLAID_SDK_LOAD_FAILED,message:f[b.PLAID_SDK_LOAD_FAILED],severity:g[b.PLAID_SDK_LOAD_FAILED],retryable:!0,userAction:"Refresh the page and try again"})},document.head.appendChild(t)}async resolvePaymentMethod(){return this.publicToken?{token:this.publicToken,data:{type:"bank_account",plaid_public_token:this.publicToken}}:{validationError:!0}}async getPaymentToken(){return 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(w.checkoutLoaded&&!w.achPaymentsEnabled)return this.hasLoggedAchPaymentsDisabledWarning||(console.warn("[JustifiPlaidPaymentMethod] ACH payments are disabled for this checkout. Component will not render."),this.hasLoggedAchPaymentsDisabledWarning=!0),null;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(M,{class:"payment-method"},i("div",{title:"Pay with Plaid"},i("div",{onClick:t=>{t.preventDefault(),this.handleSelectionClick()}},"Pay with Bank Account ",t," "),(()=>this.error?i("div",{class:(this.error.severity===p.ERROR?"text-danger":this.error.severity===p.WARNING?"text-warning":"text-info")+" mt-2"},i("small",null,this.error.message),i("br",null),i("small",{class:"text-muted"},this.error.userAction,this.error.retryable&&this.retryCount<this.maxRetries&&i("span",null," • Auto-retry in progress..."))):null)(),(()=>this.error?null:this.isAuthenticating?i("div",{class:"text-info mt-2"},i("small",null,"Connecting to your bank...")):this.publicToken?i("div",{class:"text-success mt-2"},i("small",null,"✓ Bank account connected successfully")):!this.isSelected||this.publicToken||this.error||this.isAuthenticating?null:i("div",{class:"text-muted mt-2"},i("small",null,"Click to connect your bank account")))()))}static get watchers(){return{isSelected:["onSelectionChange"]}}},lt=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(M,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:`${W[null==t?void 0:t.brand]||""} *${null==t?void 0:t.acct_last_four}`})))):null))}},ht=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(M,{class:"payment-method"},i("script",{src:"https://checkout-sdk.sezzle.com/checkout.min.js",async:!0,ref:t=>this.scriptRef=t}),i("div",null,i("div",null,"Buy now, pay later with ",ht),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||w.checkoutLoaded&&!w.achPaymentsEnabled||(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=[],e=!w.checkoutLoaded||w.achPaymentsEnabled;return this.disableCreditCard||t.push(V.NEW_CARD),!this.disableBankAccount&&e&&t.push(V.NEW_BANK_ACCOUNT),t}areFormsReady(){return!(!this.billingFormRef||!this.paymentMethodFormRef)}emitError(t){this.errorEvent.emit(Object.assign(Object.assign({},t),{severity:p.ERROR}))}createErrorResponse(t,e){return{error:{code:t,message:e,decline_code:void 0}}}async resolvePaymentMethod(t){if(!this.areFormsReady())return this.createErrorResponse("form_not_ready",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(M,{key:"bc76697688be332ef84db56e61b6b455a6d1e986"},i("form",{key:"8f64f55f945d4ff4ed0f144c724dbd71278ec771"},i("fieldset",{key:"15b6d388117738391089cf91f999247cddb29714"},i("div",{key:"a4e23f7808b446dff6f7da437dba3cb57d2d62aa",class:"row gy-3"},i("div",{key:"63b0584d217d9bb50036eb7d5837e7287be58760",class:"col-12"},this.availablePaymentMethods.map((t=>this.renderPaymentMethodOption(t)))),i("div",{key:"c9345be3429cd8ab01a84e8584270938feceba39",class:"col-12"},i("internal-button",{key:"aa56df7b6b1250e9b81fbc281b969d2a37a05428",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,lt 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-De4Pig-y.js";import{A as o,r,s as l,t as h,u as c,v as d,w as u,C as p,b as y,c as m,I as v,x as g,y as f,z as b}from"./p-DXTa04jn.js";import{S as M}from"./p-DzEdYT8R.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-DyPk4BJt.js";import{t as C,r as N}from"./p-CPKMvyV_.js";import{f as I}from"./p-BSs-2JKu.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-C-Jgmek8.js";import{H as _}from"./p-DYHjzFnJ.js";import{J as R}from"./p-DYL3RR2S.js";import{c as U}from"./p-C_SQBHCI.js";import"./p-HXpYMWUU.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import{m as B,a as Y}from"./p-B62JX_Dh.js";import{C as F}from"./p-Cn7z5L7J.js";import{P as Q}from"./p-DP9ysr2K.js";import{P as V,a as H,b as G}from"./p-DkoufM1t.js";import{C as Z}from"./p-ZpPDShvP.js";import"./p-D8GTwl9v.js";import"./p-BtzgeLyZ.js";import"./p-CdwzNfP1.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(M,{key:"02955940079320bd9c6bf94e239545385ac36458"},i("radio-list-item",{key:"fc6b98e456e4326b843b2b3248b7327436767cf4",name:this.name,value:this.value,label:this.label,checked:this.checked,hidden:this.hidden,class:this.class,"onRadio-click":t=>this.radioClick.emit(t.detail)}))}};var J;!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"}(J||(J={}));class q{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 l(t);if(!s.isValid){const t=[];throw s.countryCode||t.push("countryCode"),s.currencyCode||t.push("currencyCode"),s.merchantCapabilities&&0!==s.merchantCapabilities.length||t.push("merchantCapabilities"),s.supportedNetworks&&0!==s.supportedNetworks.length||t.push("supportedNetworks"),s.total&&s.total.label&&s.total.amount||t.push("total"),console.error("[ApplePayService] Payment request is invalid. Missing/invalid:",t),new Error("Invalid payment request provided")}return this.currentPaymentRequest=s,new Promise(((t,n)=>{try{if("undefined"==typeof window||!("ApplePaySession"in window))return console.error("[ApplePayService] ApplePaySession not available on window"),n({success:!1,error:{code:J.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:J.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:J.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}}),l=await this.processPayment(i,s,o);l.success?(this.currentSession.completePayment({status:h.STATUS_SUCCESS}),t({success:!0,token:a.token,paymentMethodId:l.data.id})):(console.error("PSP reported payment failure:",l.data),this.currentSession.completePayment({status:h.STATUS_FAILURE}),e({success:!1,error:{code:J.PAYMENT_PROCESSING_ERROR,message:"Payment processing failed"}}))}catch(t){console.error("=== PAYMENT PROCESSING ERROR ==="),console.error("Error processing payment:",t),t&&t.stack&&console.error("Error stack:",t.stack),this.currentSession.completePayment({status:h.STATUS_FAILURE}),e({success:!1,error:{code:J.PAYMENT_PROCESSING_ERROR,message:t instanceof Error?t.message:"Payment processing failed"}})}finally{this.currentSession=void 0,this.currentPaymentRequest=void 0}},this.currentSession.onpaymentmethodselected=()=>{const t={newTotal:this.currentPaymentRequest.total,newLineItems:this.currentPaymentRequest.lineItems||[]};try{this.currentSession.completePaymentMethodSelection(t)}catch(t){console.error("Error completing payment method selection:",t),this.currentSession.abort()}},this.currentSession.onshippingmethodselected=()=>{this.currentSession.completeShippingMethodSelection({status:h.STATUS_SUCCESS,newTotal:this.currentPaymentRequest.total,newLineItems:this.currentPaymentRequest.lineItems||[]})},this.currentSession.oncancel=t=>{if(t.sessionError)switch(console.error(t.sessionError),t.sessionError.code){case"unknown":console.error("Unknown error - likely merchant validation issue"),console.error("This usually means:"),console.error("1. Merchant certificate is invalid or expired"),console.error("2. Merchant identifier mismatch"),console.error("3. Backend validation endpoint issues");break;case"invalidMerchantSession":console.error("Invalid merchant session provided"),console.error("Check that the merchant session from backend is valid");break;case"userCancel":console.error("User cancelled the payment");break;default:console.error("Other error code:",t.sessionError.code)}this.currentSession=void 0,this.currentPaymentRequest=void 0,e({success:!1,error:{code:J.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:J.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.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)===J.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 q,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(M,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(M,{key:"241fe8903788f0442b42bf5a6835d152d1944967"},i("internal-button",{key:"7c13bd1fa53cf9faae26e521af5a40a08659fe92",text:this.text,variant:this.variant,isLoading:this.isLoading,clickHandler:this.clickHandler,type:this.type,disabled:this.disabled,class:this.class,customStyle:this.customStyle,hidden:this.hidden}))}},et=class{constructor(e){t(this,e)}render(){return i(M,{key:"336fa6563952ee7905c2ed4a3330d73bbb33a0eb"},i("section",{key:"48b8798a925d618f5a2c52d743190207b78eb70a"},i("div",{key:"81d91167c10ccc49acb039ea54a9f97f4aa6e305"},i("div",{key:"9744242f2c2c3082e9c1a3af6e716ec4cb28f1fd",part:C},null==w?void 0:w.paymentDescription),i("div",{key:"438062935abd2f00495c432ef6652e3808e5215f"},i("span",{key:"e3f24d9c52ddae0206cbefe61bd08f24697fe28e",part:C},"Total")," ",i("span",{key:"9835cb60de31a2c8946b7ac2dd6d1fa82f223110",part:C},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.merchantDisplayName="JustiFi Checkout",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)}googlePayEnvironment(){return void 0!==this.environment?this.environment:"test"===w.checkoutMode?"TEST":"PRODUCTION"}sendInitialize(){var t;if(!(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow))return;const e={environment:this.googlePayEnvironment(),gatewayMerchantId:w.accountId,merchantName:this.merchantDisplayName,authToken:w.authToken,accountId:w.accountId};this.iframeElement.contentWindow.postMessage({eventType:st.initialize,data:e},this.iframeOrigin)}sendStartPayment(){var t;if(!(null===(t=this.iframeElement)||void 0===t?void 0:t.contentWindow))return;const e={totalPrice:String(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(M,{key:"5a0872ee486bdba3ba1c86145946889bb7d151f2"},i(this.levels[this.level],{key:"89807e249cdf64f7ef80800276cb50966083f28e",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=B(t),this.completeCheckout=Y(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,l;w.accountId=t.account_id,w.checkoutLoaded=!0;const h=null!=t.mode?String(t.mode).toLowerCase():"";w.checkoutMode="test"===h?"test":"live"===h?"live":null;const c=t.payment_methods.map((t=>new H(t))),d=Boolean(null===(e=t.payment_settings)||void 0===e?void 0:e.ach_payments);w.paymentMethods=c.filter((t=>t.type!==V.SAVED_BANK_ACCOUNT||d)),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===(i=t.payment_settings)||void 0===i?void 0:i.bank_account_verification,w.applePayEnabled=null===(s=t.payment_settings)||void 0===s?void 0:s.apple_payments,w.googlePayEnabled=null===(n=t.payment_settings)||void 0===n?void 0:n.google_payments,w.achPaymentsEnabled=d,w.bnplProviderClientId=null===(a=null==t?void 0:t.bnpl)||void 0===a?void 0:a.provider_client_id,w.bnplProviderMode=null===(o=null==t?void 0:t.bnpl)||void 0===o?void 0:o.provider_mode,w.bnplProviderApiVersion=null===(r=null==t?void 0:t.bnpl)||void 0===r?void 0:r.provider_api_version,w.bnplProviderCheckoutUrl=null===(l=null==t?void 0:t.bnpl)||void 0===l?void 0:l.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.checkoutLoaded&&!w.achPaymentsEnabled||(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,l=(null===(i=w.selectedPaymentMethod)||void 0===i?void 0:i.type)===V.NEW_BANK_ACCOUNT,h=(null===(s=w.selectedPaymentMethod)||void 0===s?void 0:s.type)===V.PLAID;if(r||l){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(h&&!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});const 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};if(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:"545e1cb07252ba0dc78fa980bd17ee5572559f6c"})}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.hasLoggedAchPaymentsDisabledWarning=!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:b.PLAID_SDK_LOAD_FAILED,message:f[b.PLAID_SDK_LOAD_FAILED],severity:g[b.PLAID_SDK_LOAD_FAILED],retryable:!0,userAction:"Refresh the page and try again"});if(await this.getLinkToken(),!this.linkToken)return void this.handleError({code:b.PLAID_LINK_TOKEN_FAILED,message:f[b.PLAID_LINK_TOKEN_FAILED],severity:g[b.PLAID_LINK_TOKEN_FAILED],retryable:!0,userAction:"Click to try again"});const t=window.Plaid;this.plaidLink=t.create({token:this.linkToken,onSuccess:this.handlePlaidSuccess,onExit:this.handlePlaidExit,onEvent:this.handlePlaidEvent,onLoad:this.handlePlaidLoad})}catch(t){this.handleError({code:b.PLAID_LINK_INIT_FAILED,message:f[b.PLAID_LINK_INIT_FAILED],severity:g[b.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:b.PLAID_LINK_TOKEN_FAILED,message:"Missing authentication. Please refresh the page and try again.",severity:p.ERROR,retryable:!1,userAction:"Refresh the page"});this.abortController=new AbortController,this.timeoutId=setTimeout((()=>{var t;null===(t=this.abortController)||void 0===t||t.abort()}),3e4);const e=await this.plaidService.getLinkToken(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=b.PLAID_LINK_TOKEN_FAILED,o=f[a],r=!0;"AbortError"===t.name?(a=b.PLAID_TIMEOUT,o=f[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=b.PLAID_NETWORK_ERROR,o=f[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=b.PLAID_INVALID_CREDENTIALS,o="Authentication failed. Please refresh the page and try again.",r=!1),this.handleError({code:a,message:o,severity:g[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 b.PLAID_RATE_LIMITED;if(t.includes("maintenance"))return b.PLAID_MAINTENANCE;if(t.includes("not_authenticated"))return b.PLAID_INVALID_CREDENTIALS}if(null==t?void 0:t.code)switch(t.code){case"rate_limited":return b.PLAID_RATE_LIMITED;case"maintenance":return b.PLAID_MAINTENANCE;case"not_authenticated":return b.PLAID_INVALID_CREDENTIALS;default:return b.PLAID_LINK_TOKEN_FAILED}return b.PLAID_LINK_TOKEN_FAILED},this.openPlaidLink=()=>{this.plaidLink&&this.linkToken&&(this.isAuthenticating=!0,this.clearError(),this.plaidLink.open())},this.handlePlaidSuccess=t=>{this.publicToken=t,this.isAuthenticating=!1,this.clearError(),this.retryCount=0,this.isSelected||(this.isSelected=!0,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=b.PLAID_AUTHENTICATION_FAILED,i=f[e],s=!0,n="Click to try again";if(t.error_code)switch(t.error_code){case"INVALID_CREDENTIALS":e=b.PLAID_INVALID_CREDENTIALS,i=f[e],s=!0;break;case"ITEM_LOGIN_REQUIRED":e=b.PLAID_INVALID_CREDENTIALS,i="Your bank requires re-authentication. Please try again.",s=!0;break;case"ITEM_LOCKED":e=b.PLAID_ACCOUNT_LOCKED,i=f[e],s=!1,n="Contact your bank";break;case"INSTITUTION_NOT_RESPONDING":e=b.PLAID_MAINTENANCE,i=f[e],s=!0;break;case"RATE_LIMIT_EXCEEDED":e=b.PLAID_RATE_LIMITED,i=f[e],s=!0;break;case"INVALID_REQUEST":e=b.PLAID_AUTHENTICATION_FAILED,i="Invalid request. Please try again.",s=!0;break;case"PLAID_ERROR":e=b.PLAID_AUTHENTICATION_FAILED,i=t.error_message||"Bank authentication failed. Please try again.",s=!0;break;default:t.error_message&&(i=t.error_message)}if(t.error_message){const a=t.error_message.toLowerCase();a.includes("not supported")||a.includes("unsupported")?(e=b.PLAID_BANK_NOT_SUPPORTED,i=f[e],s=!1,n="Try a different payment method"):(a.includes("expired")||a.includes("timeout"))&&(e=b.PLAID_TOKEN_EXPIRED,i=f[e],s=!0)}this.handleError({code:e,message:i,severity:g[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?w.achPaymentsEnabled&&this.loadPlaidSDK():j("checkoutLoaded",(t=>{t&&!0===w.bankAccountVerification&&w.achPaymentsEnabled&&this.loadPlaidSDK()})))}loadPlaidSDK(){if(this.sdkLoaded)return;this.sdkLoaded=!0;const t=document.createElement("script");t.src="https://cdn.plaid.com/link/v2/stable/link-initialize.js",t.async=!0,t.onload=()=>this.initializePlaidLink(),t.onerror=()=>{this.handleError({code:b.PLAID_SDK_LOAD_FAILED,message:f[b.PLAID_SDK_LOAD_FAILED],severity:g[b.PLAID_SDK_LOAD_FAILED],retryable:!0,userAction:"Refresh the page and try again"})},document.head.appendChild(t)}async resolvePaymentMethod(){return this.publicToken?{token:this.publicToken,data:{type:"bank_account",plaid_public_token:this.publicToken}}:{validationError:!0}}async getPaymentToken(){return 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(w.checkoutLoaded&&!w.achPaymentsEnabled)return this.hasLoggedAchPaymentsDisabledWarning||(console.warn("[JustifiPlaidPaymentMethod] ACH payments are disabled for this checkout. Component will not render."),this.hasLoggedAchPaymentsDisabledWarning=!0),null;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(M,{class:"payment-method"},i("div",{title:"Pay with Plaid"},i("div",{onClick:t=>{t.preventDefault(),this.handleSelectionClick()}},"Pay with Bank Account ",t," "),(()=>this.error?i("div",{class:(this.error.severity===p.ERROR?"text-danger":this.error.severity===p.WARNING?"text-warning":"text-info")+" mt-2"},i("small",null,this.error.message),i("br",null),i("small",{class:"text-muted"},this.error.userAction,this.error.retryable&&this.retryCount<this.maxRetries&&i("span",null," • Auto-retry in progress..."))):null)(),(()=>this.error?null:this.isAuthenticating?i("div",{class:"text-info mt-2"},i("small",null,"Connecting to your bank...")):this.publicToken?i("div",{class:"text-success mt-2"},i("small",null,"✓ Bank account connected successfully")):!this.isSelected||this.publicToken||this.error||this.isAuthenticating?null:i("div",{class:"text-muted mt-2"},i("small",null,"Click to connect your bank account")))()))}static get watchers(){return{isSelected:["onSelectionChange"]}}},lt=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(M,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:N,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:`${Z[null==t?void 0:t.brand]||""} *${null==t?void 0:t.acct_last_four}`})))):null))}},ht=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(M,{class:"payment-method"},i("script",{src:"https://checkout-sdk.sezzle.com/checkout.min.js",async:!0,ref:t=>this.scriptRef=t}),i("div",null,i("div",null,"Buy now, pay later with ",ht),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||w.checkoutLoaded&&!w.achPaymentsEnabled||(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=[],e=!w.checkoutLoaded||w.achPaymentsEnabled;return this.disableCreditCard||t.push(V.NEW_CARD),!this.disableBankAccount&&e&&t.push(V.NEW_BANK_ACCOUNT),t}areFormsReady(){return!(!this.billingFormRef||!this.paymentMethodFormRef)}emitError(t){this.errorEvent.emit(Object.assign(Object.assign({},t),{severity:p.ERROR}))}createErrorResponse(t,e){return{error:{code:t,message:e,decline_code:void 0}}}async resolvePaymentMethod(t){if(!this.areFormsReady())return this.createErrorResponse("form_not_ready",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(M,{key:"bc76697688be332ef84db56e61b6b455a6d1e986"},i("form",{key:"8f64f55f945d4ff4ed0f144c724dbd71278ec771"},i("fieldset",{key:"15b6d388117738391089cf91f999247cddb29714"},i("div",{key:"a4e23f7808b446dff6f7da437dba3cb57d2d62aa",class:"row gy-3"},i("div",{key:"63b0584d217d9bb50036eb7d5837e7287be58760",class:"col-12"},this.availablePaymentMethods.map((t=>this.renderPaymentMethodOption(t)))),i("div",{key:"c9345be3429cd8ab01a84e8584270938feceba39",class:"col-12"},i("internal-button",{key:"aa56df7b6b1250e9b81fbc281b969d2a37a05428",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,lt as justifi_saved_payment_methods,ct as justifi_sezzle_payment_method,yt as justifi_tokenize_payment_method}
@@ -1 +1 @@
1
- import{h as t,r as s,c as e}from"./p-CV0Pyo1O.js";import{k as a,C as i,b as o}from"./p-DXTa04jn.js";import{J as r}from"./p-_GBnYSuR.js";import{c as h}from"./p-CQqmTKij.js";import{P as c}from"./p-CO8ZGkfN.js";import"./p-DVJaoI_m.js";import"./p-HXpYMWUU.js";import{p as n}from"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import{g as p,a as d}from"./p-CdwzNfP1.js";import{M as u,m}from"./p-zZn1OXja.js";import{m as f,S as l}from"./p-BUHsyQpA.js";import{S as y}from"./p-DzEdYT8R.js";import{T as b,a as g,b as v,c as j,d as C,e as _,f as k,g as w,h as S,i as T,j as P,k as O,l as A}from"./p-BICxxa69.js";import{T as D}from"./p-CZfYo5-1.js";import{a as I}from"./p-BSs-2JKu.js";import{a6 as E,a7 as V}from"./p-CPKMvyV_.js";import{o as x,g as z}from"./p-AMVhBsGv.js";import"./p-DNd24RUQ.js";import"./p-De4Pig-y.js";import"./p-D8GTwl9v.js";import"./p-CHw7tICr.js";import"./p-CqiVXthx.js";const B={created_at:()=>t("th",{part:E,scope:"col",title:"The date the payout was deposited"},"Created"),sub_account_name:()=>t("th",{part:E,scope:"col",title:"The sub account associated with the payout"},"Sub Account"),payments_total:()=>t("th",{part:E,scope:"col",title:"The total payments amount associated with the payout"},"Payments"),refunds_total:()=>t("th",{part:E,scope:"col",title:"The total refunds amount associated with the payout"},"Refunds"),fees_total:()=>t("th",{part:E,scope:"col",title:"The total fees amount associated with the payout"},"Fees"),other_total:()=>t("th",{part:E,scope:"col",title:"The total other amount"},"Other"),amount:()=>t("th",{part:E,scope:"col",title:"The total amount of the payout"},"Amount"),status:()=>t("th",{part:E,scope:"col",title:"The real-time status of each payout"},"Status"),csv:()=>t("th",{part:E,scope:"col",title:"Export CSV"})},G=class{constructor(t){s(this,t),this.errorEvent=e(this,"error-event",7),this.clickEvent=e(this,"click-event",7),this.errorMessage=null,this.payouts=[],this.subAccounts=[],this.loading=!0,this.paging=n,this.pagingParams={},this.columns="created_at,amount,status,payments_total,refunds_total,fees_total,other_total,csv",this.downloadCSV=t=>{this.getPayoutCSV({payoutId:t,onError:()=>{this.errorEvent.emit({errorCode:o.FETCH_ERROR,message:"Failed to download CSV",severity:i.ERROR})}})},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 s=t.target.closest("tr"),e=s.dataset.rowEntityId;if(!e)return;if(s.querySelector("a")===t.target)return;const a=this.payouts.find((t=>t.id===e));this.clickEvent.emit({name:D.row,data:a})}}componentWillLoad(){var s;h(),this.analytics=new r(this),this.initializeGetData(),this.payoutsTable=new b(this.payouts,this.columns,B,(s=this.downloadCSV,{created_at:(s,e)=>t("td",{part:V(e)},t("div",{class:"fw-bold"},I(s.created_at,{showDisplayDate:!0}))),sub_account_name:(s,e)=>t("td",{part:V(e)},s.sub_account_name),payments_total:(s,e)=>t("td",{part:V(e)},s.formattedPaymentAmount(s.payments_total)),refunds_total:(s,e)=>t("td",{part:V(e)},s.formattedPaymentAmount(s.refunds_total)),fees_total:(s,e)=>t("td",{part:V(e)},s.formattedPaymentAmount(s.fees_total)),other_total:(s,e)=>t("td",{part:V(e)},s.formattedPaymentAmount(s.other_total)),amount:(s,e)=>t("td",{part:V(e)},s.formattedPaymentAmount(s.amount)),status:(s,e)=>t("td",{part:V(e)},u(s.status)),csv:(e,a)=>t("td",{part:V(a)},t("a",{href:"#",onClick:t=>{t.preventDefault(),s(e.id)}},"CSV"))})),this.getPayouts&&this.getSubAccounts&&this.fetchData(),x("set",(()=>{this.pagingParams={}})),x("reset",(()=>{this.pagingParams={},this.errorMessage=""}))}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}propChanged(){this.initializeGetData()}updateOnPropChange(){this.fetchData()}initializeGetData(){this.initializePayoutsServices(),this.initializeGetSubAccounts()}initializePayoutsServices(){if(this.accountId&&this.authToken){const t={id:this.accountId,authToken:this.authToken,service:new c};this.getPayouts=(({id:t,authToken:s,service:e})=>async({params:o,onSuccess:r,onError:h})=>{var c,n;try{const u=await e.fetchPayouts(t,s,o);if(u.error)return h({error:d(u.error),code:p(null===(n=u.error)||void 0===n?void 0:n.code),severity:i.ERROR});{const t=Object.assign({},u.page_info);r({payouts:(null===(c=u.data)||void 0===c?void 0:c.map((t=>new a(t))))||[],pagingInfo:t})}}catch(t){const s=p(null==t?void 0:t.code);return h({error:t.message||t,code:s,severity:i.ERROR})}})(t),this.getPayoutCSV=m(t)}else this.errorMessage="Account ID and Auth Token are required",this.errorEvent.emit({errorCode:o.MISSING_PROPS,message:this.errorMessage,severity:i.ERROR})}initializeGetSubAccounts(){this.accountId&&this.authToken&&(this.getSubAccounts=f({primaryAccountId:this.accountId,authToken:this.authToken,service:new l}))}fetchData(){this.loading=!0,this.getPayouts({params:this.payoutParams,onSuccess:({payouts:t,pagingInfo:s})=>{this.payouts=t,this.paging=s,this.payoutsTable.collectionData=this.payouts,this.payoutsTable.columnKeys.includes("sub_account_name")?this.fetchSubAccounts():this.loading=!1},onError:({error:t,code:s,severity:e})=>{this.errorMessage=t,this.errorEvent.emit({errorCode:s,message:t,severity:e}),this.loading=!1}})}async fetchSubAccounts(){this.getSubAccounts({params:this.subAccountParams,onSuccess:({subAccounts:t})=>{this.subAccounts=t,this.payouts=this.payouts.map((t=>{var s;return t.sub_account_name=null===(s=this.subAccounts.find((s=>s.id===t.account_id)))||void 0===s?void 0:s.name,t})),this.loading=!1},onError:({error:t,code:s,severity:e})=>{this.errorMessage=t,this.errorEvent.emit({errorCode:s,message:t,severity:e}),this.loading=!1}})}get payoutParams(){const t=z();return Object.assign(Object.assign({},t),this.pagingParams)}get subAccountParams(){const t=this.payouts.map((t=>t.account_id));return{sub_account_id:[...new Set(t)].join(",")}}get entityId(){return this.payouts.map((t=>t.id))}get showEmptyState(){return!this.loading&&!this.errorMessage&&this.payoutsTable.rowData.length<1}get showErrorState(){return!this.loading&&!!this.errorMessage}get showRowData(){return!this.showEmptyState&&!this.showErrorState&&!this.loading}render(){return t(y,{key:"653896fabc4becf531ec119d252cbaea301a0dc6"},t(g,{key:"63787473d67118a7f092bad666c47346872a7834"},t(v,{key:"c17ecce261475c8bfe357ff30d06f189c8f96480"},t(j,{key:"cc23edeff6a1e595671b77fa51c73ff313692b16"},t(C,{key:"4ed5b5ee149538d2de60ee6e27edde55e8d11eaa"},this.payoutsTable.columnData.map((t=>t)))),t(_,{key:"a0a886e70ba99ececd78e5bc34aec065466fe6ce"},t(k,{key:"38bf9109ca73ecfd5c85529a8f7232069ffcdb00",columnSpan:this.payoutsTable.columnKeys.length,isLoading:this.loading}),t(w,{key:"6f5341305ef71f86bbf3680e2c6d0dc461f3d09f",isEmpty:this.showEmptyState,columnSpan:this.payoutsTable.columnKeys.length}),t(S,{key:"bd5e8cc72b460238636546a568645c797807f2d9",columnSpan:this.payoutsTable.columnKeys.length,errorMessage:this.errorMessage}),this.showRowData&&this.payoutsTable.rowData.map(((s,e)=>t(T,{"data-test-id":"table-row","data-row-entity-id":this.entityId[e],onClick:this.rowClickHandler},s)))),this.paging&&t(P,{key:"15145b7ef9cc37a2ad70cea5698d53df069979bf"},t(O,{key:"2d4ed5a1ab5eaf0eaae0bbe35f02edf59c23b22e"},t(A,{key:"11c8505cfd97117afaf79ea68a3fb00570a9c7cb",colSpan:this.payoutsTable.columnData.length},t("pagination-menu",{key:"b8e7e29d4d932f43b3381235de57b63cc6a5283b",paging:Object.assign(Object.assign({},this.paging),{handleClickPrevious:this.handleClickPrevious,handleClickNext:this.handleClickNext})})))))))}static get watchers(){return{accountId:["propChanged"],authToken:["propChanged"],pagingParams:["updateOnPropChange"],getPayouts:["updateOnPropChange"],getSubAccounts:["updateOnPropChange"]}}};export{G as justifi_payouts_list}
1
+ import{h as t,r as s,c as e}from"./p-CV0Pyo1O.js";import{k as a,C as i,b as o}from"./p-DXTa04jn.js";import{J as r}from"./p-DYL3RR2S.js";import{c as h}from"./p-C_SQBHCI.js";import{P as c}from"./p-CO8ZGkfN.js";import"./p-DVJaoI_m.js";import"./p-HXpYMWUU.js";import{p as n}from"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import{g as p,a as d}from"./p-CdwzNfP1.js";import{M as u,m as f}from"./p-zZn1OXja.js";import{m,S as l}from"./p-BUHsyQpA.js";import{S as y}from"./p-DzEdYT8R.js";import{T as b,a as g,b as v,c as C,d as j,e as _,f as k,g as w,h as S,i as T,j as P,k as O,l as A}from"./p-BICxxa69.js";import{T as D}from"./p-CZfYo5-1.js";import{a as I}from"./p-BSs-2JKu.js";import{a6 as E,a7 as V}from"./p-CPKMvyV_.js";import{o as z,g as B}from"./p-AMVhBsGv.js";import"./p-BtzgeLyZ.js";import"./p-De4Pig-y.js";import"./p-D8GTwl9v.js";import"./p-CHw7tICr.js";import"./p-CqiVXthx.js";const x={created_at:()=>t("th",{part:E,scope:"col",title:"The date the payout was deposited"},"Created"),sub_account_name:()=>t("th",{part:E,scope:"col",title:"The sub account associated with the payout"},"Sub Account"),payments_total:()=>t("th",{part:E,scope:"col",title:"The total payments amount associated with the payout"},"Payments"),refunds_total:()=>t("th",{part:E,scope:"col",title:"The total refunds amount associated with the payout"},"Refunds"),fees_total:()=>t("th",{part:E,scope:"col",title:"The total fees amount associated with the payout"},"Fees"),other_total:()=>t("th",{part:E,scope:"col",title:"The total other amount"},"Other"),amount:()=>t("th",{part:E,scope:"col",title:"The total amount of the payout"},"Amount"),status:()=>t("th",{part:E,scope:"col",title:"The real-time status of each payout"},"Status"),csv:()=>t("th",{part:E,scope:"col",title:"Export CSV"})},G=class{constructor(t){s(this,t),this.errorEvent=e(this,"error-event",7),this.clickEvent=e(this,"click-event",7),this.errorMessage=null,this.payouts=[],this.subAccounts=[],this.loading=!0,this.paging=n,this.pagingParams={},this.columns="created_at,amount,status,payments_total,refunds_total,fees_total,other_total,csv",this.downloadCSV=t=>{this.getPayoutCSV({payoutId:t,onError:()=>{this.errorEvent.emit({errorCode:o.FETCH_ERROR,message:"Failed to download CSV",severity:i.ERROR})}})},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 s=t.target.closest("tr"),e=s.dataset.rowEntityId;if(!e)return;if(s.querySelector("a")===t.target)return;const a=this.payouts.find((t=>t.id===e));this.clickEvent.emit({name:D.row,data:a})}}componentWillLoad(){var s;h(),this.analytics=new r(this),this.initializeGetData(),this.payoutsTable=new b(this.payouts,this.columns,x,(s=this.downloadCSV,{created_at:(s,e)=>t("td",{part:V(e)},t("div",{class:"fw-bold"},I(s.created_at,{showDisplayDate:!0}))),sub_account_name:(s,e)=>t("td",{part:V(e)},s.sub_account_name),payments_total:(s,e)=>t("td",{part:V(e)},s.formattedPaymentAmount(s.payments_total)),refunds_total:(s,e)=>t("td",{part:V(e)},s.formattedPaymentAmount(s.refunds_total)),fees_total:(s,e)=>t("td",{part:V(e)},s.formattedPaymentAmount(s.fees_total)),other_total:(s,e)=>t("td",{part:V(e)},s.formattedPaymentAmount(s.other_total)),amount:(s,e)=>t("td",{part:V(e)},s.formattedPaymentAmount(s.amount)),status:(s,e)=>t("td",{part:V(e)},u(s.status)),csv:(e,a)=>t("td",{part:V(a)},t("a",{href:"#",onClick:t=>{t.preventDefault(),s(e.id)}},"CSV"))})),this.getPayouts&&this.getSubAccounts&&this.fetchData(),z("set",(()=>{this.pagingParams={}})),z("reset",(()=>{this.pagingParams={},this.errorMessage=""}))}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}propChanged(){this.initializeGetData()}updateOnPropChange(){this.fetchData()}initializeGetData(){this.initializePayoutsServices(),this.initializeGetSubAccounts()}initializePayoutsServices(){if(this.accountId&&this.authToken){const t={id:this.accountId,authToken:this.authToken,service:new c};this.getPayouts=(({id:t,authToken:s,service:e})=>async({params:o,onSuccess:r,onError:h})=>{var c,n;try{const u=await e.fetchPayouts(t,s,o);if(u.error)return h({error:d(u.error),code:p(null===(n=u.error)||void 0===n?void 0:n.code),severity:i.ERROR});{const t=Object.assign({},u.page_info);r({payouts:(null===(c=u.data)||void 0===c?void 0:c.map((t=>new a(t))))||[],pagingInfo:t})}}catch(t){const s=p(null==t?void 0:t.code);return h({error:t.message||t,code:s,severity:i.ERROR})}})(t),this.getPayoutCSV=f(t)}else this.errorMessage="Account ID and Auth Token are required",this.errorEvent.emit({errorCode:o.MISSING_PROPS,message:this.errorMessage,severity:i.ERROR})}initializeGetSubAccounts(){this.accountId&&this.authToken&&(this.getSubAccounts=m({primaryAccountId:this.accountId,authToken:this.authToken,service:new l}))}fetchData(){this.loading=!0,this.getPayouts({params:this.payoutParams,onSuccess:({payouts:t,pagingInfo:s})=>{this.payouts=t,this.paging=s,this.payoutsTable.collectionData=this.payouts,this.payoutsTable.columnKeys.includes("sub_account_name")?this.fetchSubAccounts():this.loading=!1},onError:({error:t,code:s,severity:e})=>{this.errorMessage=t,this.errorEvent.emit({errorCode:s,message:t,severity:e}),this.loading=!1}})}async fetchSubAccounts(){this.getSubAccounts({params:this.subAccountParams,onSuccess:({subAccounts:t})=>{this.subAccounts=t,this.payouts=this.payouts.map((t=>{var s;return t.sub_account_name=null===(s=this.subAccounts.find((s=>s.id===t.account_id)))||void 0===s?void 0:s.name,t})),this.loading=!1},onError:({error:t,code:s,severity:e})=>{this.errorMessage=t,this.errorEvent.emit({errorCode:s,message:t,severity:e}),this.loading=!1}})}get payoutParams(){const t=B();return Object.assign(Object.assign({},t),this.pagingParams)}get subAccountParams(){const t=this.payouts.map((t=>t.account_id));return{sub_account_id:[...new Set(t)].join(",")}}get entityId(){return this.payouts.map((t=>t.id))}get showEmptyState(){return!this.loading&&!this.errorMessage&&this.payoutsTable.rowData.length<1}get showErrorState(){return!this.loading&&!!this.errorMessage}get showRowData(){return!this.showEmptyState&&!this.showErrorState&&!this.loading}render(){return t(y,{key:"653896fabc4becf531ec119d252cbaea301a0dc6"},t(g,{key:"63787473d67118a7f092bad666c47346872a7834"},t(v,{key:"c17ecce261475c8bfe357ff30d06f189c8f96480"},t(C,{key:"cc23edeff6a1e595671b77fa51c73ff313692b16"},t(j,{key:"4ed5b5ee149538d2de60ee6e27edde55e8d11eaa"},this.payoutsTable.columnData.map((t=>t)))),t(_,{key:"a0a886e70ba99ececd78e5bc34aec065466fe6ce"},t(k,{key:"38bf9109ca73ecfd5c85529a8f7232069ffcdb00",columnSpan:this.payoutsTable.columnKeys.length,isLoading:this.loading}),t(w,{key:"6f5341305ef71f86bbf3680e2c6d0dc461f3d09f",isEmpty:this.showEmptyState,columnSpan:this.payoutsTable.columnKeys.length}),t(S,{key:"bd5e8cc72b460238636546a568645c797807f2d9",columnSpan:this.payoutsTable.columnKeys.length,errorMessage:this.errorMessage}),this.showRowData&&this.payoutsTable.rowData.map(((s,e)=>t(T,{"data-test-id":"table-row","data-row-entity-id":this.entityId[e],onClick:this.rowClickHandler},s)))),this.paging&&t(P,{key:"15145b7ef9cc37a2ad70cea5698d53df069979bf"},t(O,{key:"2d4ed5a1ab5eaf0eaae0bbe35f02edf59c23b22e"},t(A,{key:"11c8505cfd97117afaf79ea68a3fb00570a9c7cb",colSpan:this.payoutsTable.columnData.length},t("pagination-menu",{key:"b8e7e29d4d932f43b3381235de57b63cc6a5283b",paging:Object.assign(Object.assign({},this.paging),{handleClickPrevious:this.handleClickPrevious,handleClickNext:this.handleClickNext})})))))))}static get watchers(){return{accountId:["propChanged"],authToken:["propChanged"],pagingParams:["updateOnPropChange"],getPayouts:["updateOnPropChange"],getSubAccounts:["updateOnPropChange"]}}};export{G as justifi_payouts_list}
@@ -1 +1 @@
1
- import{h as e,r as t,c as a}from"./p-CV0Pyo1O.js";import{P as s}from"./p-NzPaWKbY.js";import{m as i}from"./p-BB8Ce9rp.js";import{C as d,b as c,i as f,h as l}from"./p-DXTa04jn.js";import{J as r}from"./p-_GBnYSuR.js";import{c as h}from"./p-CQqmTKij.js";import"./p-DVJaoI_m.js";import{b as o,d as b,s as p}from"./p-BSs-2JKu.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-DzEdYT8R.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-De4Pig-y.js";import"./p-HXpYMWUU.js";import"./p-CdwzNfP1.js";import"./p-DNd24RUQ.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%"}))),T=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:"f304cb665f17ce96b6d97a38d94907629f559413"},this.loading&&e(x,{key:"709acde31230bd9e825e4e9669234492aff3cc3a"}),!this.loading&&this.errorMessage&&C(this.errorMessage),!this.loading&&!this.errorMessage&&this.payment&&e("justifi-details",{key:"09a4a2559fb89a5b4b57d81b0fd48952c219d348",errorMessage:this.errorMessage},e(y,{key:"7cbfece91ce9e5fab75d561ad369080ecbe76fa4",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:"4aa014d77def141d2053c3745b8215cc03a53ac7",classes:"border-1 border-end",title:"Updated At",value:`${o(this.payment.updated_at)} ${b(this.payment.updated_at)}`}),e(u,{key:"f344398f4fd4db6e1e7ca1335c3aa55630668475",classes:"border-1 border-end",title:"Created At",value:`${o(this.payment.created_at)} ${b(this.payment.created_at)}`}),e(u,{key:"a01e5a04400b996cfb2a9e563c8f383b8e8d7c66",title:"ID",value:this.payment.id})),e("div",{key:"ef0c63d53031dfa8910dfbdedede1e20ac09e78a",slot:"detail-sections"},e(v,{key:"5053784a7e3bd8932562a816921564aadd6d79c8",sectionTitle:"Details"}),e("div",{key:"43c56ee5a39589ea7a0107f32e274be439adf33a",class:"d-flex flex-column gap-2 w-100"},e(k,{key:"fcee2dd211c9bf951cdd6855ac3fa844632391ce",title:"Amount",value:this.payment.formattedPaymentAmount(this.payment.amount)}),e(k,{key:"44d055f3445f02feaeb4519b5f4777333089a8c6",title:"Fees",value:this.payment.formattedPaymentAmount(this.payment.fee_amount)}),e(k,{key:"906b584174bd5c329974274a2f1e1ef7e9e8fde0",title:"Refunded",value:this.payment.formattedPaymentAmount(this.payment.amount_refunded)}),e(k,{key:"809429e88eac8ebe8142bb0028f8b86447977697",title:"Net",value:this.payment.formattedPaymentAmount(this.payment.balance)}),e(k,{key:"e08c02efc64f105ce3180e9773584a331ae19a9b",title:"Status",value:m(this.PaymentStatus)}),e(k,{key:"fbb910b7006f9d4bff9b14ffd4fc2f7da8b68020",title:"Payment ID",value:this.payment.id}),e(k,{key:"09fefc2d1a750ab2f5dfb2043db08d5f16d6d9aa",title:"Processing Fees",value:this.payment.formattedPaymentAmount(this.payment.fee_amount)}),e(k,{key:"1d96f4557823f1d82d5c6e0e46a984c13c6f018b",title:"Statement Descriptor",value:this.payment.statement_descriptor}),e(k,{key:"51bfae7ef30f36c99c0fa1b25dc5397720ef88ff",title:"Description",value:this.payment.description}),e(k,{key:"5c44b3d40bfe6b2fbf258fee90f55ff24d0b3c28",title:"Expedited",value:this.payment.expedited?"Yes":"No"})),this.payment.payment_method.card&&[e(v,{key:"3d652ba331824448b7e7af969b2ead216f358e28",sectionTitle:"Payment Method"}),e("div",{key:"49ad00ec9d703d196a025fa17b03f4af7cdc4dc5",class:"d-flex flex-column gap-2 w-100"},e(k,{key:"2b1b3f57e74fd65dc4b82d727a94afbe14803c52",title:"ID",value:this.payment.payment_method.card.id}),e(k,{key:"b23d5263566ff11d469dea9a245d20a7689540f8",title:"Payment Type",value:"Card"}),e(k,{key:"f5f76d6d9ac609884aac18fe2743d4fad2192b86",title:"Last 4 Numbers",value:this.payment.payment_method.lastFourDigits}),e(k,{key:"22f296966b6f1aaf516b1d70144cff4f59b82c05",title:"Brand",value:p(this.payment.payment_method.card.brand)}),e(k,{key:"d7dcd0f7a74ed2cc5ba6406a7d48522ca06a7546",title:"Cardholder",value:this.payment.payment_method.payersName}))],this.payment.payment_method.bank_account&&[e(v,{key:"37a2a20c462cb94baa01ca7763d43ced04b4543c",sectionTitle:"Payment Method"}),e("div",{key:"f6de7746d5ff64d27368edef51b3c4e0ff7c658b",class:"d-flex flex-column gap-2 w-100"},e(k,{key:"34e9b26c6d20e9b5e86e4cc11fb925ff1ef5ce94",title:"ID",value:this.payment.payment_method.bank_account.id}),e(k,{key:"32cd6da4d7234aca403bd699de23e1cf889bf14f",title:"Last 4 Numbers",value:this.payment.last_four_digits}),e(k,{key:"f1313ac7c15d5ae2d9dfa2b6d3ec794d0987252b",title:"Bank Name",value:this.payment.payment_method.bank_account.brand}),e(k,{key:"76d1ac1961e530a7a6e1ba5512b982cd70df9470",title:"Account Owner",value:this.payment.payment_method.payersName}))],this.payment.metadata&&[e(v,{key:"1cff262d07acda5bc742f325a23f4199c22f3a01",sectionTitle:"Metadata"}),e("div",{key:"77379785d2559d39a26a253757fdaf02795c53a1",class:"d-table gap-2 w-100"},e(j,{key:"92cb32f3dd6b45094210194e2e40927d7f9d6bde",metadata:this.payment.metadata}))])))}static get watchers(){return{paymentId:["propChanged"],authToken:["propChanged"],getPaymentDetails:["updateOnPropChange"]}}};export{T 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-NzPaWKbY.js";import{m as i}from"./p-BB8Ce9rp.js";import{C as d,b as c,i as f,h as l}from"./p-DXTa04jn.js";import{J as r}from"./p-DYL3RR2S.js";import{c as h}from"./p-C_SQBHCI.js";import"./p-DVJaoI_m.js";import{b as o,d as b,s as p}from"./p-BSs-2JKu.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-DzEdYT8R.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-De4Pig-y.js";import"./p-HXpYMWUU.js";import"./p-CdwzNfP1.js";import"./p-BtzgeLyZ.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%"}))),T=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:"f304cb665f17ce96b6d97a38d94907629f559413"},this.loading&&e(x,{key:"709acde31230bd9e825e4e9669234492aff3cc3a"}),!this.loading&&this.errorMessage&&C(this.errorMessage),!this.loading&&!this.errorMessage&&this.payment&&e("justifi-details",{key:"09a4a2559fb89a5b4b57d81b0fd48952c219d348",errorMessage:this.errorMessage},e(y,{key:"7cbfece91ce9e5fab75d561ad369080ecbe76fa4",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:"4aa014d77def141d2053c3745b8215cc03a53ac7",classes:"border-1 border-end",title:"Updated At",value:`${o(this.payment.updated_at)} ${b(this.payment.updated_at)}`}),e(u,{key:"f344398f4fd4db6e1e7ca1335c3aa55630668475",classes:"border-1 border-end",title:"Created At",value:`${o(this.payment.created_at)} ${b(this.payment.created_at)}`}),e(u,{key:"a01e5a04400b996cfb2a9e563c8f383b8e8d7c66",title:"ID",value:this.payment.id})),e("div",{key:"ef0c63d53031dfa8910dfbdedede1e20ac09e78a",slot:"detail-sections"},e(v,{key:"5053784a7e3bd8932562a816921564aadd6d79c8",sectionTitle:"Details"}),e("div",{key:"43c56ee5a39589ea7a0107f32e274be439adf33a",class:"d-flex flex-column gap-2 w-100"},e(k,{key:"fcee2dd211c9bf951cdd6855ac3fa844632391ce",title:"Amount",value:this.payment.formattedPaymentAmount(this.payment.amount)}),e(k,{key:"44d055f3445f02feaeb4519b5f4777333089a8c6",title:"Fees",value:this.payment.formattedPaymentAmount(this.payment.fee_amount)}),e(k,{key:"906b584174bd5c329974274a2f1e1ef7e9e8fde0",title:"Refunded",value:this.payment.formattedPaymentAmount(this.payment.amount_refunded)}),e(k,{key:"809429e88eac8ebe8142bb0028f8b86447977697",title:"Net",value:this.payment.formattedPaymentAmount(this.payment.balance)}),e(k,{key:"e08c02efc64f105ce3180e9773584a331ae19a9b",title:"Status",value:m(this.PaymentStatus)}),e(k,{key:"fbb910b7006f9d4bff9b14ffd4fc2f7da8b68020",title:"Payment ID",value:this.payment.id}),e(k,{key:"09fefc2d1a750ab2f5dfb2043db08d5f16d6d9aa",title:"Processing Fees",value:this.payment.formattedPaymentAmount(this.payment.fee_amount)}),e(k,{key:"1d96f4557823f1d82d5c6e0e46a984c13c6f018b",title:"Statement Descriptor",value:this.payment.statement_descriptor}),e(k,{key:"51bfae7ef30f36c99c0fa1b25dc5397720ef88ff",title:"Description",value:this.payment.description}),e(k,{key:"5c44b3d40bfe6b2fbf258fee90f55ff24d0b3c28",title:"Expedited",value:this.payment.expedited?"Yes":"No"})),this.payment.payment_method.card&&[e(v,{key:"3d652ba331824448b7e7af969b2ead216f358e28",sectionTitle:"Payment Method"}),e("div",{key:"49ad00ec9d703d196a025fa17b03f4af7cdc4dc5",class:"d-flex flex-column gap-2 w-100"},e(k,{key:"2b1b3f57e74fd65dc4b82d727a94afbe14803c52",title:"ID",value:this.payment.payment_method.card.id}),e(k,{key:"b23d5263566ff11d469dea9a245d20a7689540f8",title:"Payment Type",value:"Card"}),e(k,{key:"f5f76d6d9ac609884aac18fe2743d4fad2192b86",title:"Last 4 Numbers",value:this.payment.payment_method.lastFourDigits}),e(k,{key:"22f296966b6f1aaf516b1d70144cff4f59b82c05",title:"Brand",value:p(this.payment.payment_method.card.brand)}),e(k,{key:"d7dcd0f7a74ed2cc5ba6406a7d48522ca06a7546",title:"Cardholder",value:this.payment.payment_method.payersName}))],this.payment.payment_method.bank_account&&[e(v,{key:"37a2a20c462cb94baa01ca7763d43ced04b4543c",sectionTitle:"Payment Method"}),e("div",{key:"f6de7746d5ff64d27368edef51b3c4e0ff7c658b",class:"d-flex flex-column gap-2 w-100"},e(k,{key:"34e9b26c6d20e9b5e86e4cc11fb925ff1ef5ce94",title:"ID",value:this.payment.payment_method.bank_account.id}),e(k,{key:"32cd6da4d7234aca403bd699de23e1cf889bf14f",title:"Last 4 Numbers",value:this.payment.last_four_digits}),e(k,{key:"f1313ac7c15d5ae2d9dfa2b6d3ec794d0987252b",title:"Bank Name",value:this.payment.payment_method.bank_account.brand}),e(k,{key:"76d1ac1961e530a7a6e1ba5512b982cd70df9470",title:"Account Owner",value:this.payment.payment_method.payersName}))],this.payment.metadata&&[e(v,{key:"1cff262d07acda5bc742f325a23f4199c22f3a01",sectionTitle:"Metadata"}),e("div",{key:"77379785d2559d39a26a253757fdaf02795c53a1",class:"d-table gap-2 w-100"},e(j,{key:"92cb32f3dd6b45094210194e2e40927d7f9d6bde",metadata:this.payment.metadata}))])))}static get watchers(){return{paymentId:["propChanged"],authToken:["propChanged"],getPaymentDetails:["updateOnPropChange"]}}};export{T as justifi_payment_details}
@@ -1 +1 @@
1
- import{r as i,h as s}from"./p-CV0Pyo1O.js";import{J as o}from"./p-_GBnYSuR.js";import{c as r}from"./p-CQqmTKij.js";import{w as t}from"./p-DVJaoI_m.js";import{S as p}from"./p-DzEdYT8R.js";import"./p-CZfYo5-1.js";import"./p-DNd24RUQ.js";import"./p-De4Pig-y.js";import"./p-BSs-2JKu.js";import"./p-HXpYMWUU.js";import"./p-DXTa04jn.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-D8GTwl9v.js";const a=class{constructor(s){i(this,s)}async componentWillLoad(){await t(),r(),this.analytics=new o(this)}disconnectedCallback(){var i;null===(i=this.analytics)||void 0===i||i.cleanup()}async getValues(){var i,s;return null!==(s=null===(i=this.bankAccountBillingFormSimpleRef)||void 0===i?void 0:i.getValues())&&void 0!==s?s:{}}async validate(){var i,s;return null!==(s=null===(i=this.bankAccountBillingFormSimpleRef)||void 0===i?void 0:i.validate())&&void 0!==s?s:{isValid:!1,errors:{}}}render(){return s(p,{key:"669227ed02e4f0791882b95ed814ea1865db80de"},s("bank-account-billing-form-simple",{key:"97cbe9637d8969023b1f7d3a6b3091a246112032",legend:this.legend,ref:i=>this.bankAccountBillingFormSimpleRef=i}))}};export{a as justifi_bank_account_billing_form_simple}
1
+ import{r as i,h as s}from"./p-CV0Pyo1O.js";import{J as o}from"./p-DYL3RR2S.js";import{c as r}from"./p-C_SQBHCI.js";import{w as t}from"./p-DVJaoI_m.js";import{S as p}from"./p-DzEdYT8R.js";import"./p-CZfYo5-1.js";import"./p-BtzgeLyZ.js";import"./p-De4Pig-y.js";import"./p-BSs-2JKu.js";import"./p-HXpYMWUU.js";import"./p-DXTa04jn.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-D8GTwl9v.js";const a=class{constructor(s){i(this,s)}async componentWillLoad(){await t(),r(),this.analytics=new o(this)}disconnectedCallback(){var i;null===(i=this.analytics)||void 0===i||i.cleanup()}async getValues(){var i,s;return null!==(s=null===(i=this.bankAccountBillingFormSimpleRef)||void 0===i?void 0:i.getValues())&&void 0!==s?s:{}}async validate(){var i,s;return null!==(s=null===(i=this.bankAccountBillingFormSimpleRef)||void 0===i?void 0:i.validate())&&void 0!==s?s:{isValid:!1,errors:{}}}render(){return s(p,{key:"669227ed02e4f0791882b95ed814ea1865db80de"},s("bank-account-billing-form-simple",{key:"97cbe9637d8969023b1f7d3a6b3091a246112032",legend:this.legend,ref:i=>this.bankAccountBillingFormSimpleRef=i}))}};export{a as justifi_bank_account_billing_form_simple}
@@ -1 +1 @@
1
- import{r as t,c as e,h as s}from"./p-CV0Pyo1O.js";import{m as i}from"./p-B62JX_Dh.js";import{C as h}from"./p-Cn7z5L7J.js";import{C as r,b as o,I as a,c as l,d as n}from"./p-DXTa04jn.js";import{J as c}from"./p-_GBnYSuR.js";import{c as d}from"./p-CQqmTKij.js";import"./p-CdwzNfP1.js";import"./p-De4Pig-y.js";import"./p-DVJaoI_m.js";import"./p-D8GTwl9v.js";import"./p-BSs-2JKu.js";import"./p-HXpYMWUU.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-DNd24RUQ.js";const u=class{constructor(s){t(this,s),this.checkoutCompleted=e(this,"checkout-completed",7),this.checkoutExpired=e(this,"checkout-expired",7),this.errorEvent=e(this,"error-event",7),this.pollIntervalMs=3e3,this.pollTimeoutMs=6e5,this.terminalState="loading",this.paymentStatus="",this.errorMessage="",this.pollIntervalHandle=null,this.pollTimeoutHandle=null,this.failedDismissHandle=null,this.seenCompletionCreatedAts=new Set,this.inFlight=!1}componentWillLoad(){d(),this.analytics=new c(this),this.initialize()}disconnectedCallback(){var t;this.stopAll(),null===(t=this.analytics)||void 0===t||t.cleanup()}propChanged(){this.stopAll(),this.initialize()}suppressInnerErrors(t){t.stopPropagation()}get effectivePollInterval(){return Math.max(1e3,this.pollIntervalMs)}initialize(){this.authToken&&this.checkoutId?(this.terminalState="loading",this.getCheckout=i({authToken:this.authToken,checkoutId:this.checkoutId,service:new h}),this.getCheckout({onSuccess:({checkout:t})=>this.handleInitialLoad(t),onError:({error:t,code:e,severity:s})=>{this.terminalState="error",this.errorMessage=t,this.errorEvent.emit({message:t,errorCode:e,severity:s})}})):this.errorEvent.emit({message:"authToken and checkoutId are required",errorCode:o.MISSING_PROPS,severity:r.ERROR})}handleInitialLoad(t){var e;switch(t.status){case a.expired:this.terminalState="expired",this.checkoutExpired.emit({checkoutId:this.checkoutId}),this.errorEvent.emit({message:l.CHECKOUT_EXPIRED,errorCode:o.CHECKOUT_EXPIRED,severity:r.ERROR});break;case a.completed:this.terminalState="completed",this.paymentStatus=this.resolvePaymentStatus(t),this.checkoutCompleted.emit({checkoutId:this.checkoutId,paymentStatus:this.paymentStatus});break;default:(null!==(e=t.completions)&&void 0!==e?e:[]).forEach((t=>this.seenCompletionCreatedAts.add(t.created_at))),this.terminalState="ready",this.startPolling()}}startPolling(){this.pollTimeoutHandle=setTimeout((()=>{this.stopAll(),this.terminalState="error",this.errorMessage="Checkout polling timed out",this.errorEvent.emit({message:"Checkout polling timed out",errorCode:o.FETCH_ERROR,severity:r.ERROR})}),this.pollTimeoutMs),this.pollIntervalHandle=setInterval((()=>this.tick()),this.effectivePollInterval)}tick(){this.inFlight||(this.inFlight=!0,this.getCheckout({onSuccess:({checkout:t})=>{this.inFlight=!1,this.handlePollResult(t)},onError:({error:t,code:e,severity:s})=>{this.inFlight=!1,this.stopAll(),this.terminalState="error",this.errorMessage=t,this.errorEvent.emit({message:t,errorCode:e,severity:s})}}))}handlePollResult(t){var e;const s=(null!==(e=t.completions)&&void 0!==e?e:[]).filter((t=>!this.seenCompletionCreatedAts.has(t.created_at)&&"failed"===t.payment_status));if(s.forEach((t=>this.seenCompletionCreatedAts.add(t.created_at))),s.length>0&&(this.terminalState="payment-failed",this.failedDismissHandle&&clearTimeout(this.failedDismissHandle),this.failedDismissHandle=setTimeout((()=>{"payment-failed"===this.terminalState&&(this.terminalState="ready")}),3e3)),t.status===a.completed)return this.stopAll(),this.terminalState="completed",this.paymentStatus=this.resolvePaymentStatus(t),void this.checkoutCompleted.emit({checkoutId:this.checkoutId,paymentStatus:this.paymentStatus});t.status===a.expired&&(this.stopAll(),this.terminalState="expired",this.checkoutExpired.emit({checkoutId:this.checkoutId}),this.errorEvent.emit({message:l.CHECKOUT_EXPIRED,errorCode:o.CHECKOUT_EXPIRED,severity:r.ERROR}))}resolvePaymentStatus(t){var e,s;const i=null===(s=[...null!==(e=t.completions)&&void 0!==e?e:[]].sort(((t,e)=>new Date(e.updated_at).getTime()-new Date(t.updated_at).getTime()))[0])||void 0===s?void 0:s.payment_status;return i===n.succeeded||null==i&&t.successful_payment_id?"succeeded":"pending"}stopAll(){this.pollIntervalHandle&&(clearInterval(this.pollIntervalHandle),this.pollIntervalHandle=null),this.pollTimeoutHandle&&(clearTimeout(this.pollTimeoutHandle),this.pollTimeoutHandle=null),this.failedDismissHandle&&(clearTimeout(this.failedDismissHandle),this.failedDismissHandle=null),this.inFlight=!1}render(){return this.authToken&&this.checkoutId?s("div",null,"loading"===this.terminalState&&null,("ready"===this.terminalState||"payment-failed"===this.terminalState)&&s("div",null,s("justifi-checkout-qr-code",{checkoutId:this.checkoutId}),"payment-failed"===this.terminalState&&s("p",null,"Payment failed. Please try again."),"ready"===this.terminalState&&s("p",null,"Scan to pay")),"completed"===this.terminalState&&s("div",null,s("p",null,"succeeded"===this.paymentStatus?"Payment received":"Payment pending")),"expired"===this.terminalState&&s("p",null,"Checkout expired. Please create a new checkout."),"error"===this.terminalState&&s("p",null,this.errorMessage)):null}static get watchers(){return{authToken:["propChanged"],checkoutId:["propChanged"]}}};export{u as justifi_qr_terminal}
1
+ import{r as t,c as e,h as s}from"./p-CV0Pyo1O.js";import{m as i}from"./p-B62JX_Dh.js";import{C as h}from"./p-Cn7z5L7J.js";import{C as r,b as o,I as a,c as l,d as n}from"./p-DXTa04jn.js";import{J as c}from"./p-DYL3RR2S.js";import{c as d}from"./p-C_SQBHCI.js";import"./p-CdwzNfP1.js";import"./p-De4Pig-y.js";import"./p-DVJaoI_m.js";import"./p-D8GTwl9v.js";import"./p-BSs-2JKu.js";import"./p-HXpYMWUU.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-BtzgeLyZ.js";const u=class{constructor(s){t(this,s),this.checkoutCompleted=e(this,"checkout-completed",7),this.checkoutExpired=e(this,"checkout-expired",7),this.errorEvent=e(this,"error-event",7),this.pollIntervalMs=3e3,this.pollTimeoutMs=6e5,this.terminalState="loading",this.paymentStatus="",this.errorMessage="",this.pollIntervalHandle=null,this.pollTimeoutHandle=null,this.failedDismissHandle=null,this.seenCompletionCreatedAts=new Set,this.inFlight=!1}componentWillLoad(){d(),this.analytics=new c(this),this.initialize()}disconnectedCallback(){var t;this.stopAll(),null===(t=this.analytics)||void 0===t||t.cleanup()}propChanged(){this.stopAll(),this.initialize()}suppressInnerErrors(t){t.stopPropagation()}get effectivePollInterval(){return Math.max(1e3,this.pollIntervalMs)}initialize(){this.authToken&&this.checkoutId?(this.terminalState="loading",this.getCheckout=i({authToken:this.authToken,checkoutId:this.checkoutId,service:new h}),this.getCheckout({onSuccess:({checkout:t})=>this.handleInitialLoad(t),onError:({error:t,code:e,severity:s})=>{this.terminalState="error",this.errorMessage=t,this.errorEvent.emit({message:t,errorCode:e,severity:s})}})):this.errorEvent.emit({message:"authToken and checkoutId are required",errorCode:o.MISSING_PROPS,severity:r.ERROR})}handleInitialLoad(t){var e;switch(t.status){case a.expired:this.terminalState="expired",this.checkoutExpired.emit({checkoutId:this.checkoutId}),this.errorEvent.emit({message:l.CHECKOUT_EXPIRED,errorCode:o.CHECKOUT_EXPIRED,severity:r.ERROR});break;case a.completed:this.terminalState="completed",this.paymentStatus=this.resolvePaymentStatus(t),this.checkoutCompleted.emit({checkoutId:this.checkoutId,paymentStatus:this.paymentStatus});break;default:(null!==(e=t.completions)&&void 0!==e?e:[]).forEach((t=>this.seenCompletionCreatedAts.add(t.created_at))),this.terminalState="ready",this.startPolling()}}startPolling(){this.pollTimeoutHandle=setTimeout((()=>{this.stopAll(),this.terminalState="error",this.errorMessage="Checkout polling timed out",this.errorEvent.emit({message:"Checkout polling timed out",errorCode:o.FETCH_ERROR,severity:r.ERROR})}),this.pollTimeoutMs),this.pollIntervalHandle=setInterval((()=>this.tick()),this.effectivePollInterval)}tick(){this.inFlight||(this.inFlight=!0,this.getCheckout({onSuccess:({checkout:t})=>{this.inFlight=!1,this.handlePollResult(t)},onError:({error:t,code:e,severity:s})=>{this.inFlight=!1,this.stopAll(),this.terminalState="error",this.errorMessage=t,this.errorEvent.emit({message:t,errorCode:e,severity:s})}}))}handlePollResult(t){var e;const s=(null!==(e=t.completions)&&void 0!==e?e:[]).filter((t=>!this.seenCompletionCreatedAts.has(t.created_at)&&"failed"===t.payment_status));if(s.forEach((t=>this.seenCompletionCreatedAts.add(t.created_at))),s.length>0&&(this.terminalState="payment-failed",this.failedDismissHandle&&clearTimeout(this.failedDismissHandle),this.failedDismissHandle=setTimeout((()=>{"payment-failed"===this.terminalState&&(this.terminalState="ready")}),3e3)),t.status===a.completed)return this.stopAll(),this.terminalState="completed",this.paymentStatus=this.resolvePaymentStatus(t),void this.checkoutCompleted.emit({checkoutId:this.checkoutId,paymentStatus:this.paymentStatus});t.status===a.expired&&(this.stopAll(),this.terminalState="expired",this.checkoutExpired.emit({checkoutId:this.checkoutId}),this.errorEvent.emit({message:l.CHECKOUT_EXPIRED,errorCode:o.CHECKOUT_EXPIRED,severity:r.ERROR}))}resolvePaymentStatus(t){var e,s;const i=null===(s=[...null!==(e=t.completions)&&void 0!==e?e:[]].sort(((t,e)=>new Date(e.updated_at).getTime()-new Date(t.updated_at).getTime()))[0])||void 0===s?void 0:s.payment_status;return i===n.succeeded||null==i&&t.successful_payment_id?"succeeded":"pending"}stopAll(){this.pollIntervalHandle&&(clearInterval(this.pollIntervalHandle),this.pollIntervalHandle=null),this.pollTimeoutHandle&&(clearTimeout(this.pollTimeoutHandle),this.pollTimeoutHandle=null),this.failedDismissHandle&&(clearTimeout(this.failedDismissHandle),this.failedDismissHandle=null),this.inFlight=!1}render(){return this.authToken&&this.checkoutId?s("div",null,"loading"===this.terminalState&&null,("ready"===this.terminalState||"payment-failed"===this.terminalState)&&s("div",null,s("justifi-checkout-qr-code",{checkoutId:this.checkoutId}),"payment-failed"===this.terminalState&&s("p",null,"Payment failed. Please try again."),"ready"===this.terminalState&&s("p",null,"Scan to pay")),"completed"===this.terminalState&&s("div",null,s("p",null,"succeeded"===this.paymentStatus?"Payment received":"Payment pending")),"expired"===this.terminalState&&s("p",null,"Checkout expired. Please create a new checkout."),"error"===this.terminalState&&s("p",null,this.errorMessage)):null}static get watchers(){return{authToken:["propChanged"],checkoutId:["propChanged"]}}};export{u as justifi_qr_terminal}
@@ -1 +1 @@
1
- import{r as e,c as t,h as i}from"./p-CV0Pyo1O.js";import{J as s}from"./p-_GBnYSuR.js";import{c as a}from"./p-CQqmTKij.js";import{c}from"./p-DyPk4BJt.js";import{c as d}from"./p-CPKMvyV_.js";import{S as o}from"./p-DzEdYT8R.js";import"./p-CZfYo5-1.js";import{P as b}from"./p-DkoufM1t.js";import"./p-DNd24RUQ.js";import"./p-De4Pig-y.js";import"./p-DVJaoI_m.js";import"./p-D8GTwl9v.js";import"./p-BSs-2JKu.js";import"./p-HXpYMWUU.js";import"./p-DXTa04jn.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";const h=class{constructor(i){e(this,i),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(){a(),this.analytics=new s(this)}disconnectedCallback(){var e;null===(e=this.analytics)||void 0===e||e.cleanup()}checkoutComplete(e){c.isSubmitting=!1}checkoutError(e){c.isSubmitting=!1}checkoutChanged(e){this.availablePaymentMethods=this.disableBnpl?e.detail.availablePaymentMethodTypes.filter((e=>e!==b.SEZZLE)):e.detail.availablePaymentMethodTypes}async fillBillingForm(e){c.billingFormFields=e}async validate(){var e;return{isValid:await(null===(e=this.modularCheckoutRef)||void 0===e?void 0:e.validate())}}updateStore(){c.checkoutId=this.checkoutId,c.authToken=this.authToken,c.disableCreditCard=this.disableCreditCard,c.disableBankAccount=this.disableBankAccount,c.disablePaymentMethodGroup=this.disablePaymentMethodGroup}async submit(e){var t;null===(t=this.modularCheckoutRef)||void 0===t||t.submitCheckout(c.billingFormFields)}get showPaymentTypeHeader(){return!this.disableCreditCard&&!this.disableBankAccount}render(){var e,t;return i(o,{key:"bc8428227b2fc0e0753c4ef4e2370cd34bd34e82"},i("justifi-modular-checkout",{key:"9fda18728d6fb5b20716070cefc2fcf8ef097459",ref:e=>{this.modularCheckoutRef=e},authToken:this.authToken,checkoutId:this.checkoutId,preCompleteHook:this.preCompleteHook},i("div",{key:"e39f9871696d44cea2080198c7b91d03b706f2fd",class:"row gy-3 jfi-checkout-core"},i("div",{key:"df6045e9394b10f9b3e4b86e1a2242db30cc9b7b",class:"col-12",part:d},i("justifi-header",{key:"8f4332bd43371106faf4e264fd5b27c97cb589aa",text:"Summary",level:"h2",class:"fs-5 fw-bold pb-3"}),i("section",{key:"a7170276f18b9fa4b085c4d5de35979d55935929"},i("justifi-checkout-summary",{key:"109aceb53ad2500e927230b3f82bbb07ab3f604c"}))),i("div",{key:"902e040bbd591408c9d292a592ca4d31fc838d85",class:"col-12 mt-4"},i("slot",{key:"2677cb4952d88a8ce8f0198b96ed2638d4f4e6eb",name:"insurance"})),i("div",{key:"32c033bba12a7b7bf26159bd1878d6fa4ed913d9",class:"col-12 mt-4"},i("justifi-header",{key:"74543b63c1b94a5200ad36236818fce7345d5d76",text:"Payment",level:"h2",class:"fs-5 fw-bold pb-3"}),this.showPaymentTypeHeader&&i("justifi-header",{key:"8e7c56c75bb779211b72c0b8561df8283b731ca1",text:"Select payment type",level:"h3",class:"fs-6 fw-bold lh-lg"}),i("div",{key:"c2b0a875169b46dcd7d73428e3f1a4825b380ce5",class:"d-flex flex-column"},i("section",{key:"c5f007674c058e88d271c17f0b6b9c959bd0e044"},i("div",{key:"2c4ecdd0f8708f9f80bae50362ba7fab295f788f"},this.availablePaymentMethods.includes(b.APPLE_PAY)&&i("div",{key:"5ac363a3b7c38cb3f10e9c2c7916825f0f5dc2d8",class:"mb-3"},i("justifi-apple-pay",{key:"498c03630e4057b54ebd12a3cd87b6b6bdb00c4b"})),this.availablePaymentMethods.includes(b.GOOGLE_PAY)&&i("div",{key:"8c8114d142927739a3217d3a0a44c34c89e58f83",class:"mb-3"},i("justifi-google-pay",Object.assign({key:"a2fbc5b99a83fbc52698422d2f57a3380f97733f",ref:e=>this.googlePayRef=e},null!=this.googlePayEnv?{environment:this.googlePayEnv}:{}))),i("justifi-saved-payment-methods",{key:"2e5b27eea7ef433e950feadae0b0a07f8b613533"}),this.availablePaymentMethods.includes(b.SEZZLE)&&i("justifi-radio-list-item",{key:"fb1501c51eaf836579547bc50c295ebb67cb09c1",name:"paymentMethodType",value:b.SEZZLE,checked:(null===(e=null==c?void 0:c.selectedPaymentMethod)||void 0===e?void 0:e.type)===b.SEZZLE,label:i("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(b.PLAID)&&!this.disableBnpl&&i("justifi-radio-list-item",{key:"49e0687b4955fb92935783250540fe38350bbdcc",name:"paymentMethodType",value:b.PLAID,checked:(null===(t=null==c?void 0:c.selectedPaymentMethod)||void 0===t?void 0:t.type)===b.PLAID,label:i("justifi-plaid-payment-method",{ref:e=>this.plaidPaymentMethodRef=e}),"onRadio-click":()=>{var e;null===(e=this.plaidPaymentMethodRef)||void 0===e||e.handleSelectionClick()}}),i("justifi-tokenize-payment-method",{key:"ba793274de073c8a60c063e9caedcf32780b4bbf",ref:e=>this.tokenizePaymentMethodRef=e,authToken:this.authToken,accountId:c.accountId,disableCreditCard:this.disableCreditCard,disableBankAccount:this.disableBankAccount,hideCardBillingForm:this.hideCardBillingForm,hideBankAccountBillingForm:this.hideBankAccountBillingForm,hideSubmitButton:!0,paymentMethodGroupId:c.paymentMethodGroupId}))))),i("div",{key:"ed7be422c4e369382fd42e0b0162357df7de2031",class:"mt-4"},i("justifi-button",{key:"849d648feec5ce805d6eb87acacf94d62e7a8f1b",text:"Pay",type:"submit",variant:"primary",clickHandler:e=>this.submit(e),disabled:c.isSubmitting||c.isWalletProcessing,isLoading:c.isSubmitting||c.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 i}from"./p-CV0Pyo1O.js";import{J as s}from"./p-DYL3RR2S.js";import{c as a}from"./p-C_SQBHCI.js";import{c}from"./p-DyPk4BJt.js";import{c as d}from"./p-CPKMvyV_.js";import{S as o}from"./p-DzEdYT8R.js";import"./p-CZfYo5-1.js";import{P as b}from"./p-DkoufM1t.js";import"./p-BtzgeLyZ.js";import"./p-De4Pig-y.js";import"./p-DVJaoI_m.js";import"./p-D8GTwl9v.js";import"./p-BSs-2JKu.js";import"./p-HXpYMWUU.js";import"./p-DXTa04jn.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";const h=class{constructor(i){e(this,i),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(){a(),this.analytics=new s(this)}disconnectedCallback(){var e;null===(e=this.analytics)||void 0===e||e.cleanup()}checkoutComplete(e){c.isSubmitting=!1}checkoutError(e){c.isSubmitting=!1}checkoutChanged(e){this.availablePaymentMethods=this.disableBnpl?e.detail.availablePaymentMethodTypes.filter((e=>e!==b.SEZZLE)):e.detail.availablePaymentMethodTypes}async fillBillingForm(e){c.billingFormFields=e}async validate(){var e;return{isValid:await(null===(e=this.modularCheckoutRef)||void 0===e?void 0:e.validate())}}updateStore(){c.checkoutId=this.checkoutId,c.authToken=this.authToken,c.disableCreditCard=this.disableCreditCard,c.disableBankAccount=this.disableBankAccount,c.disablePaymentMethodGroup=this.disablePaymentMethodGroup}async submit(e){var t;null===(t=this.modularCheckoutRef)||void 0===t||t.submitCheckout(c.billingFormFields)}get showPaymentTypeHeader(){return!this.disableCreditCard&&!this.disableBankAccount}render(){var e,t;return i(o,{key:"bc8428227b2fc0e0753c4ef4e2370cd34bd34e82"},i("justifi-modular-checkout",{key:"9fda18728d6fb5b20716070cefc2fcf8ef097459",ref:e=>{this.modularCheckoutRef=e},authToken:this.authToken,checkoutId:this.checkoutId,preCompleteHook:this.preCompleteHook},i("div",{key:"e39f9871696d44cea2080198c7b91d03b706f2fd",class:"row gy-3 jfi-checkout-core"},i("div",{key:"df6045e9394b10f9b3e4b86e1a2242db30cc9b7b",class:"col-12",part:d},i("justifi-header",{key:"8f4332bd43371106faf4e264fd5b27c97cb589aa",text:"Summary",level:"h2",class:"fs-5 fw-bold pb-3"}),i("section",{key:"a7170276f18b9fa4b085c4d5de35979d55935929"},i("justifi-checkout-summary",{key:"109aceb53ad2500e927230b3f82bbb07ab3f604c"}))),i("div",{key:"902e040bbd591408c9d292a592ca4d31fc838d85",class:"col-12 mt-4"},i("slot",{key:"2677cb4952d88a8ce8f0198b96ed2638d4f4e6eb",name:"insurance"})),i("div",{key:"32c033bba12a7b7bf26159bd1878d6fa4ed913d9",class:"col-12 mt-4"},i("justifi-header",{key:"74543b63c1b94a5200ad36236818fce7345d5d76",text:"Payment",level:"h2",class:"fs-5 fw-bold pb-3"}),this.showPaymentTypeHeader&&i("justifi-header",{key:"8e7c56c75bb779211b72c0b8561df8283b731ca1",text:"Select payment type",level:"h3",class:"fs-6 fw-bold lh-lg"}),i("div",{key:"c2b0a875169b46dcd7d73428e3f1a4825b380ce5",class:"d-flex flex-column"},i("section",{key:"c5f007674c058e88d271c17f0b6b9c959bd0e044"},i("div",{key:"2c4ecdd0f8708f9f80bae50362ba7fab295f788f"},this.availablePaymentMethods.includes(b.APPLE_PAY)&&i("div",{key:"5ac363a3b7c38cb3f10e9c2c7916825f0f5dc2d8",class:"mb-3"},i("justifi-apple-pay",{key:"498c03630e4057b54ebd12a3cd87b6b6bdb00c4b"})),this.availablePaymentMethods.includes(b.GOOGLE_PAY)&&i("div",{key:"8c8114d142927739a3217d3a0a44c34c89e58f83",class:"mb-3"},i("justifi-google-pay",Object.assign({key:"a2fbc5b99a83fbc52698422d2f57a3380f97733f",ref:e=>this.googlePayRef=e},null!=this.googlePayEnv?{environment:this.googlePayEnv}:{}))),i("justifi-saved-payment-methods",{key:"2e5b27eea7ef433e950feadae0b0a07f8b613533"}),this.availablePaymentMethods.includes(b.SEZZLE)&&i("justifi-radio-list-item",{key:"fb1501c51eaf836579547bc50c295ebb67cb09c1",name:"paymentMethodType",value:b.SEZZLE,checked:(null===(e=null==c?void 0:c.selectedPaymentMethod)||void 0===e?void 0:e.type)===b.SEZZLE,label:i("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(b.PLAID)&&!this.disableBnpl&&i("justifi-radio-list-item",{key:"49e0687b4955fb92935783250540fe38350bbdcc",name:"paymentMethodType",value:b.PLAID,checked:(null===(t=null==c?void 0:c.selectedPaymentMethod)||void 0===t?void 0:t.type)===b.PLAID,label:i("justifi-plaid-payment-method",{ref:e=>this.plaidPaymentMethodRef=e}),"onRadio-click":()=>{var e;null===(e=this.plaidPaymentMethodRef)||void 0===e||e.handleSelectionClick()}}),i("justifi-tokenize-payment-method",{key:"ba793274de073c8a60c063e9caedcf32780b4bbf",ref:e=>this.tokenizePaymentMethodRef=e,authToken:this.authToken,accountId:c.accountId,disableCreditCard:this.disableCreditCard,disableBankAccount:this.disableBankAccount,hideCardBillingForm:this.hideCardBillingForm,hideBankAccountBillingForm:this.hideBankAccountBillingForm,hideSubmitButton:!0,paymentMethodGroupId:c.paymentMethodGroupId}))))),i("div",{key:"ed7be422c4e369382fd42e0b0162357df7de2031",class:"mt-4"},i("justifi-button",{key:"849d648feec5ce805d6eb87acacf94d62e7a8f1b",text:"Pay",type:"submit",variant:"primary",clickHandler:e=>this.submit(e),disabled:c.isSubmitting||c.isWalletProcessing,isLoading:c.isSubmitting||c.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 +1 @@
1
- import{r as e,c as t,h as s}from"./p-CV0Pyo1O.js";import{f as i}from"./p-BSs-2JKu.js";import{t as a,a8 as r}from"./p-CPKMvyV_.js";import{B as d}from"./p-CHo7TfsM.js";import{S as c}from"./p-uZ5KAseb.js";import"./p-CZfYo5-1.js";import{C as o,b as n}from"./p-DXTa04jn.js";import{g as h,a as p}from"./p-CdwzNfP1.js";import{D as f,a as l}from"./p-C7hX61pS.js";import{c as b}from"./p-CQqmTKij.js";import{J as u}from"./p-_GBnYSuR.js";import"./p-HXpYMWUU.js";import"./p-De4Pig-y.js";import"./p-DVJaoI_m.js";import"./p-D8GTwl9v.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-DNd24RUQ.js";const y=({authToken:e,disputeId:t,service:s})=>async({payload:i,onSuccess:a,onError:r,final:d=()=>{}})=>{var c;try{const d=await s.submitDisputeResponse(t,e,i);if(d.error){return r({error:p(d.error),code:h(null===(c=d.error)||void 0===c?void 0:c.code),severity:o.ERROR})}a(d)}catch(e){const t=h(null==e?void 0:e.code);return r({error:e.message||e,code:t,severity:o.ERROR})}finally{d()}},v=class{constructor(s){e(this,s),this.clickEvent=t(this,"click-event",7),this.errorEvent=t(this,"error-event",7),this.submitEvent=t(this,"submit-event",7)}acceptDispute(){y({disputeId:this.dispute.id,authToken:this.authToken,service:new l})({payload:{forfeit:!0},onSuccess:e=>{this.submitEvent.emit({response:e})},onError:({error:e,code:t,severity:s})=>{this.errorEvent.emit({errorCode:t,message:e,severity:s})}})}initiateRespondToDispute(){this.clickEvent.emit({name:f.respondToDispute})}isDueDatePassed(){var e;if(!(null===(e=this.dispute)||void 0===e?void 0:e.due_date))return!1;const t=new Date(this.dispute.due_date.replace(/-/g,"/").replace(/T.+/,"")),s=new Date;return s.setHours(0,0,0,0),t.setHours(0,0,0,0),t<s}render(){var e,t,o,n,h,p,f,l,b;return s("div",{key:"325018c414e82b5c1bc7d9c5aa444b5a9d4e83d6",class:"dispute-notification-root"},this.isLoading&&s("div",{key:"deffb8ef248e32962aca084a564e83aa5f222b0a",style:{marginBottom:"8px"}},s(c,{key:"6f6c630b3122b1b2fd480470f5df7683f19de612",height:"28px",width:"70%",styles:{marginBottom:"16px"}}),s(c,{key:"11f46711fed1094496c64551f084351c08f598be",height:"18px",styles:{marginBottom:"8px"}}),s(c,{key:"fc7e2eac76e1cbc329147f3da39a8c28c51a7b6a",height:"18px",styles:{marginBottom:"8px"}})),(null===(e=this.dispute)||void 0===e?void 0:e.needsResponse)&&this.isDueDatePassed()&&s("div",{key:"0ef159acf9fe5b12dc0dcddab6b7583e5fc9a799",part:a},s("h1",{key:"db263006990c5b4cf178f7f81650ad7602765532",class:"h4",part:r},"The due date (",null===(t=this.dispute)||void 0===t?void 0:t.due_date,") for this dispute has passed"),s("p",{key:"185c6f952ef46e3aec625cab73c943b3046ef6b4"},"You can no longer submit evidence to counter this dispute.")),(null===(o=this.dispute)||void 0===o?void 0:o.needsResponse)&&!this.isDueDatePassed()&&s("div",{key:"d4536104addc500277fbde990b7b33ba8ff54c7e",part:a},s("h1",{key:"198138cc6541c0aeeae458e2de1e3ae0c695328d",class:"h4",part:r},"This payment is disputed"),s("p",{key:"6902ce5e3e94ab7f71ee6d0c6a7604ef97f0e740"},"The cardholder is disputing this payment. You may accept this dispute, or proceed to provide evidence in a counter dispute."),s("h2",{key:"f49d1ac855365480edc61e0af117230e2f3dbe1f",class:"h5"},"Dispute details"),s("div",{key:"f3868a098dbc4a613d676b8580c053527f9d5fad",class:"d-table gap-2"},s("div",{key:"7699bc619b652ffe1c77cf6e5e0dac967679b1e6",class:"d-table-row gap-2"},s("span",{key:"9de67b45877120f54f724f1efe7b3f4d4b035d30",part:"detail-section-item-title",class:"fw-bold d-table-cell pe-4"},"Amount"),s("span",{key:"bfd79f86b5b81daf2a34f5874fcff03a05d1e64d",part:"detail-section-item-data",class:"flex-1 d-table-cell text-wrap"},i(null===(n=this.dispute)||void 0===n?void 0:n.amount))),s("div",{key:"0e57d56172859eb5857a1930cb837569157026d9",class:"d-table-row gap-2"},s("span",{key:"0b615bd8f9a9add7d18d50be4f4f644707576de2",part:"detail-section-item-title",class:"fw-bold d-table-cell pe-4"},"Reason"),s("span",{key:"46288c67be32fe2d95fea88f5b0148f22552a2c9",part:"detail-section-item-data",class:"flex-1 d-table-cell text-wrap"},null===(h=this.dispute)||void 0===h?void 0:h.reason)),s("div",{key:"c68280b0f36280804fb6231236d942174c189456",class:"d-table-row gap-2"},s("span",{key:"ed3f145aa0f2c949b80d7033e4ecb818a4a4fa68",part:"detail-section-item-title",class:"fw-bold d-table-cell pe-4"},"Due Date"),s("span",{key:"4c4530acbc570fb13b5f53947714bd250ff99cab",part:"detail-section-item-data",class:"flex-1 d-table-cell text-wrap"},null===(p=this.dispute)||void 0===p?void 0:p.due_date))),s("div",{key:"3244bb6bdbed2b4e28c479c2d4db2d0ae152f2f0",class:"d-flex gap-2 mt-4 justify-content-end"},s(d,{key:"3716a28cec93e70690ad96bfc0c5f3b7b56f8ecb",variant:"secondary",onClick:()=>this.acceptDispute()},"Accept dispute"),s(d,{key:"7f326ed6f298c9f1091b160c63e386864329190e",variant:"primary",onClick:()=>this.initiateRespondToDispute()},"Counter dispute"))),(null===(f=this.dispute)||void 0===f?void 0:f.underReview)&&s("div",{key:"d705ae48c1f30b904ac31bbdbab9e955868f51e1",part:a},s("h1",{key:"712cebef3699a8c2a97bcb69ae68e0b491090c88",class:"h4",part:r},"This payment is disputed and under review"),s("p",{key:"ca95b2c8bdc6083a3fbb1dd63c6bdaa4699ae2a7"},"The cardholder is disputing this payment. A counter dispute has been submitted and is under review.")),(null===(l=this.dispute)||void 0===l?void 0:l.won)&&s("div",{key:"c0cb4c8342aa4f022d76e95123a047b7b707f562",part:a},s("h1",{key:"797966d237d4b46eb1b880deb7fa21746f5b3b1e",class:"h4",part:r},"This payment was disputed"),s("p",{key:"2f9eed1a5f34f772206112488af22aa8b35c07b6"},"The cardholder disputed this payment and the card issuer has settled it in your favor.")),(null===(b=this.dispute)||void 0===b?void 0:b.lost)&&s("div",{key:"9a90af51218ed921e27519363995f12e29713bfd",part:a},s("h1",{key:"736ee5cf8f65d780d4812e24ea9050dcc0d109a4",class:"h4",part:r},"This payment was disputed"),s("p",{key:"9ca83087b028e1078bcc2cd0b552e8f5379932d1"},"The cardholder disputed this payment and the card issuer has settled it in their favor.")))}},m=class{constructor(i){e(this,i),this.clickEvent=t(this,"click-event",7),this.errorEvent=t(this,"error-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.submitEvent=t(this,"submit-event",7),this.errorMessage=null,this.disputeResponse={},this.apiOrigin="https://wc-proxy.justifi.ai",this.isLoading=!1,this.documentList=[],this.documentErrors={},this.currentStep=0,this.componentStepMapping=[()=>s("product-or-service",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("customer-details",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("cancellation-policy",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("refund-policy",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("duplicate-charge",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("electronic-evidence",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("shipping-details",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("additional-statement",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors})],this.saveData=async(e,t)=>{if(Object.keys(e).length)return this.isLastStep?this.submitDisputeResponse({payload:e,onSuccess:e=>{this.submitEvent.emit({response:e}),this.stepCompleteEvent.emit({response:e,formStep:t})},onError:({error:e,code:t,severity:s})=>{this.errorEvent.emit({errorCode:t,message:e,severity:s})}}):this.updateDisputeResponse({payload:e,onSuccess:e=>{this.disputeResponse=Object.assign({},e.data),this.stepCompleteEvent.emit({response:e,formStep:t})},onError:({error:e,code:t,severity:s})=>{this.errorEvent.emit({errorCode:t,message:e,severity:s})}});this.stepCompleteEvent.emit({response:null,formStep:t})},this.initializeMakePresignedURLs=async()=>{const e=this.documentList.map((e=>this.getPresignedFileUrl(e)));return await Promise.all(e)},this.initializeFileUploads=async()=>{const e=this.documentList.map((e=>this.uploadDocument(e)));return Promise.all(e)},this.getPresignedFileUrl=async e=>this.createDisputeEvidence({payload:{file_name:e.file_name,file_type:e.file_type,dispute_evidence_type:e.dispute_evidence_type},onSuccess:t=>{e.presignedUrl=t.data.presigned_url},onError:({error:t,code:s,severity:i})=>{const a={[e.dispute_evidence_type]:t};this.documentErrors=Object.assign(Object.assign({},this.documentErrors),a),this.errorEvent.emit({errorCode:s,message:t,severity:i})}}),this.uploadDocument=async e=>{const t=await e.getFileString();if(!e.presignedUrl)throw new Error("Presigned URL is not set");return await fetch(e.presignedUrl,{method:"PUT",body:t})},this.handleSubmit=async(e,t,s)=>{if(this.isLoading=!0,t.length){if(this.documentErrors={},this.documentList=t,await this.initializeMakePresignedURLs(),Object.keys(this.documentErrors).length)throw this.isLoading=!1,new Error("Could not presign all documents");await this.initializeFileUploads()}await this.saveData(e,s),this.isLoading=!1},this.onCancel=()=>{this.clickEvent.emit({name:f.cancelDispute})},this.onBack=async()=>{await this.currentStepComponentRef.validateAndSubmit((async(e,t,s)=>{this.clickEvent.emit({name:f.previousStep}),await this.handleSubmit(e,t,s),this.currentStep--}))},this.onNext=async()=>{await this.currentStepComponentRef.validateAndSubmit((async(e,t,s)=>{this.clickEvent.emit({name:f.nextStep}),await this.handleSubmit(e,t,s),this.currentStep++}))},this.onSubmit=async()=>{await this.currentStepComponentRef.validateAndSubmit((async(e,t,s)=>{this.clickEvent.emit({name:f.submit});const i=Object.assign(Object.assign({},e),{forfeit:!1});await this.handleSubmit(i,t,s)}))}}componentWillLoad(){b(),this.analytics=new u(this),this.initializeDisputeServiceMethods()}disconnectedCallback(){var e;null===(e=this.analytics)||void 0===e||e.cleanup()}propChanged(){this.initializeDisputeServiceMethods()}initializeDisputeServiceMethods(){this.disputeId&&this.authToken?(this.updateDisputeResponse=(({authToken:e,disputeId:t,service:s})=>async({payload:i,onSuccess:a,onError:r,final:d=()=>{}})=>{var c;try{const d=await s.updateDisputeResponse(t,e,i);if(d.error)return r({error:p(d.error),code:h(null===(c=d.error)||void 0===c?void 0:c.code),severity:o.ERROR});a(d)}catch(e){const t=h(null==e?void 0:e.code);return r({error:e.message||e,code:t,severity:o.ERROR})}finally{d()}})({disputeId:this.disputeId,authToken:this.authToken,service:new l}),this.createDisputeEvidence=(({authToken:e,disputeId:t,service:s})=>async({payload:i,onSuccess:a,onError:r,final:d=()=>{}})=>{var c;try{const d=await s.createDisputeEvidence(t,e,i);if(d.error)return r({error:p(d.error),code:h(null===(c=d.error)||void 0===c?void 0:c.code),severity:o.ERROR});a(d)}catch(e){const t=h(null==e?void 0:e.code);return r({error:e.message||e,code:t,severity:o.ERROR})}finally{d()}})({disputeId:this.disputeId,authToken:this.authToken,service:new l}),this.submitDisputeResponse=y({disputeId:this.disputeId,authToken:this.authToken,service:new l})):(this.errorMessage="Account ID and Auth Token are required",this.errorEvent.emit({errorCode:n.MISSING_PROPS,message:this.errorMessage,severity:o.ERROR}))}get currentStepComponent(){return this.componentStepMapping[this.currentStep]()}get isLastStep(){return this.currentStep===this.componentStepMapping.length-1}get isFirstStep(){return 0===this.currentStep}render(){return s("div",{key:"7f9c8d56cfb86cea73ab2f299b83ff0de28f5c3e",class:"dispute-response-root"},s("div",{key:"a805bf54df79453127557bf651c3d776a381241f",class:"row gy-3"},s("div",{key:"2e6bc9cbe369e0ea5d200bc0934b4cad50f3c76f",class:"col-12"},s("h1",{key:"9876e9c87c6dfb405e7bad46d64fdb40ad048142",class:"h4",part:r},"Counter dispute")),s("div",{key:"045028232da5331c7041ad222c4e98364674ace3",class:"col-12"},this.currentStepComponent),s("div",{key:"0455c4856a44340ce25c1c4c8f776abb197f919f",class:"col-12"},s("div",{key:"5b990cc1d41b3a7152d727c941e9758ed70f75a1",class:"d-flex gap-2 mt-4 justify-content-end"},this.isFirstStep?s(d,{variant:"secondary",onClick:()=>this.onCancel(),disabled:this.isLoading,isLoading:this.isLoading},"Cancel"):s(d,{variant:"secondary",onClick:()=>this.onBack(),disabled:this.isLoading,isLoading:this.isLoading},"Back"),this.isLastStep?s(d,{variant:"primary",onClick:()=>this.onSubmit(),disabled:this.isLoading,isLoading:this.isLoading},"Submit Counter Dispute"):s(d,{variant:"primary",onClick:()=>this.onNext(),disabled:this.isLoading,isLoading:this.isLoading},"Next")))))}static get watchers(){return{disputeId:["propChanged"],authToken:["propChanged"]}}};export{v as dispute_notification,m as dispute_response}
1
+ import{r as e,c as t,h as s}from"./p-CV0Pyo1O.js";import{f as i}from"./p-BSs-2JKu.js";import{t as a,a8 as r}from"./p-CPKMvyV_.js";import{B as d}from"./p-CHo7TfsM.js";import{S as c}from"./p-uZ5KAseb.js";import"./p-CZfYo5-1.js";import{C as o,b as n}from"./p-DXTa04jn.js";import{g as h,a as p}from"./p-CdwzNfP1.js";import{D as f,a as l}from"./p-C7hX61pS.js";import{c as b}from"./p-C_SQBHCI.js";import{J as u}from"./p-DYL3RR2S.js";import"./p-HXpYMWUU.js";import"./p-De4Pig-y.js";import"./p-DVJaoI_m.js";import"./p-D8GTwl9v.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-BtzgeLyZ.js";const y=({authToken:e,disputeId:t,service:s})=>async({payload:i,onSuccess:a,onError:r,final:d=()=>{}})=>{var c;try{const d=await s.submitDisputeResponse(t,e,i);if(d.error){return r({error:p(d.error),code:h(null===(c=d.error)||void 0===c?void 0:c.code),severity:o.ERROR})}a(d)}catch(e){const t=h(null==e?void 0:e.code);return r({error:e.message||e,code:t,severity:o.ERROR})}finally{d()}},v=class{constructor(s){e(this,s),this.clickEvent=t(this,"click-event",7),this.errorEvent=t(this,"error-event",7),this.submitEvent=t(this,"submit-event",7)}acceptDispute(){y({disputeId:this.dispute.id,authToken:this.authToken,service:new l})({payload:{forfeit:!0},onSuccess:e=>{this.submitEvent.emit({response:e})},onError:({error:e,code:t,severity:s})=>{this.errorEvent.emit({errorCode:t,message:e,severity:s})}})}initiateRespondToDispute(){this.clickEvent.emit({name:f.respondToDispute})}isDueDatePassed(){var e;if(!(null===(e=this.dispute)||void 0===e?void 0:e.due_date))return!1;const t=new Date(this.dispute.due_date.replace(/-/g,"/").replace(/T.+/,"")),s=new Date;return s.setHours(0,0,0,0),t.setHours(0,0,0,0),t<s}render(){var e,t,o,n,h,p,f,l,b;return s("div",{key:"325018c414e82b5c1bc7d9c5aa444b5a9d4e83d6",class:"dispute-notification-root"},this.isLoading&&s("div",{key:"deffb8ef248e32962aca084a564e83aa5f222b0a",style:{marginBottom:"8px"}},s(c,{key:"6f6c630b3122b1b2fd480470f5df7683f19de612",height:"28px",width:"70%",styles:{marginBottom:"16px"}}),s(c,{key:"11f46711fed1094496c64551f084351c08f598be",height:"18px",styles:{marginBottom:"8px"}}),s(c,{key:"fc7e2eac76e1cbc329147f3da39a8c28c51a7b6a",height:"18px",styles:{marginBottom:"8px"}})),(null===(e=this.dispute)||void 0===e?void 0:e.needsResponse)&&this.isDueDatePassed()&&s("div",{key:"0ef159acf9fe5b12dc0dcddab6b7583e5fc9a799",part:a},s("h1",{key:"db263006990c5b4cf178f7f81650ad7602765532",class:"h4",part:r},"The due date (",null===(t=this.dispute)||void 0===t?void 0:t.due_date,") for this dispute has passed"),s("p",{key:"185c6f952ef46e3aec625cab73c943b3046ef6b4"},"You can no longer submit evidence to counter this dispute.")),(null===(o=this.dispute)||void 0===o?void 0:o.needsResponse)&&!this.isDueDatePassed()&&s("div",{key:"d4536104addc500277fbde990b7b33ba8ff54c7e",part:a},s("h1",{key:"198138cc6541c0aeeae458e2de1e3ae0c695328d",class:"h4",part:r},"This payment is disputed"),s("p",{key:"6902ce5e3e94ab7f71ee6d0c6a7604ef97f0e740"},"The cardholder is disputing this payment. You may accept this dispute, or proceed to provide evidence in a counter dispute."),s("h2",{key:"f49d1ac855365480edc61e0af117230e2f3dbe1f",class:"h5"},"Dispute details"),s("div",{key:"f3868a098dbc4a613d676b8580c053527f9d5fad",class:"d-table gap-2"},s("div",{key:"7699bc619b652ffe1c77cf6e5e0dac967679b1e6",class:"d-table-row gap-2"},s("span",{key:"9de67b45877120f54f724f1efe7b3f4d4b035d30",part:"detail-section-item-title",class:"fw-bold d-table-cell pe-4"},"Amount"),s("span",{key:"bfd79f86b5b81daf2a34f5874fcff03a05d1e64d",part:"detail-section-item-data",class:"flex-1 d-table-cell text-wrap"},i(null===(n=this.dispute)||void 0===n?void 0:n.amount))),s("div",{key:"0e57d56172859eb5857a1930cb837569157026d9",class:"d-table-row gap-2"},s("span",{key:"0b615bd8f9a9add7d18d50be4f4f644707576de2",part:"detail-section-item-title",class:"fw-bold d-table-cell pe-4"},"Reason"),s("span",{key:"46288c67be32fe2d95fea88f5b0148f22552a2c9",part:"detail-section-item-data",class:"flex-1 d-table-cell text-wrap"},null===(h=this.dispute)||void 0===h?void 0:h.reason)),s("div",{key:"c68280b0f36280804fb6231236d942174c189456",class:"d-table-row gap-2"},s("span",{key:"ed3f145aa0f2c949b80d7033e4ecb818a4a4fa68",part:"detail-section-item-title",class:"fw-bold d-table-cell pe-4"},"Due Date"),s("span",{key:"4c4530acbc570fb13b5f53947714bd250ff99cab",part:"detail-section-item-data",class:"flex-1 d-table-cell text-wrap"},null===(p=this.dispute)||void 0===p?void 0:p.due_date))),s("div",{key:"3244bb6bdbed2b4e28c479c2d4db2d0ae152f2f0",class:"d-flex gap-2 mt-4 justify-content-end"},s(d,{key:"3716a28cec93e70690ad96bfc0c5f3b7b56f8ecb",variant:"secondary",onClick:()=>this.acceptDispute()},"Accept dispute"),s(d,{key:"7f326ed6f298c9f1091b160c63e386864329190e",variant:"primary",onClick:()=>this.initiateRespondToDispute()},"Counter dispute"))),(null===(f=this.dispute)||void 0===f?void 0:f.underReview)&&s("div",{key:"d705ae48c1f30b904ac31bbdbab9e955868f51e1",part:a},s("h1",{key:"712cebef3699a8c2a97bcb69ae68e0b491090c88",class:"h4",part:r},"This payment is disputed and under review"),s("p",{key:"ca95b2c8bdc6083a3fbb1dd63c6bdaa4699ae2a7"},"The cardholder is disputing this payment. A counter dispute has been submitted and is under review.")),(null===(l=this.dispute)||void 0===l?void 0:l.won)&&s("div",{key:"c0cb4c8342aa4f022d76e95123a047b7b707f562",part:a},s("h1",{key:"797966d237d4b46eb1b880deb7fa21746f5b3b1e",class:"h4",part:r},"This payment was disputed"),s("p",{key:"2f9eed1a5f34f772206112488af22aa8b35c07b6"},"The cardholder disputed this payment and the card issuer has settled it in your favor.")),(null===(b=this.dispute)||void 0===b?void 0:b.lost)&&s("div",{key:"9a90af51218ed921e27519363995f12e29713bfd",part:a},s("h1",{key:"736ee5cf8f65d780d4812e24ea9050dcc0d109a4",class:"h4",part:r},"This payment was disputed"),s("p",{key:"9ca83087b028e1078bcc2cd0b552e8f5379932d1"},"The cardholder disputed this payment and the card issuer has settled it in their favor.")))}},m=class{constructor(i){e(this,i),this.clickEvent=t(this,"click-event",7),this.errorEvent=t(this,"error-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.submitEvent=t(this,"submit-event",7),this.errorMessage=null,this.disputeResponse={},this.apiOrigin="https://wc-proxy.justifi.ai",this.isLoading=!1,this.documentList=[],this.documentErrors={},this.currentStep=0,this.componentStepMapping=[()=>s("product-or-service",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("customer-details",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("cancellation-policy",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("refund-policy",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("duplicate-charge",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("electronic-evidence",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("shipping-details",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors}),()=>s("additional-statement",{ref:e=>this.currentStepComponentRef=e,disputeResponse:this.disputeResponse,documentErrors:this.documentErrors})],this.saveData=async(e,t)=>{if(Object.keys(e).length)return this.isLastStep?this.submitDisputeResponse({payload:e,onSuccess:e=>{this.submitEvent.emit({response:e}),this.stepCompleteEvent.emit({response:e,formStep:t})},onError:({error:e,code:t,severity:s})=>{this.errorEvent.emit({errorCode:t,message:e,severity:s})}}):this.updateDisputeResponse({payload:e,onSuccess:e=>{this.disputeResponse=Object.assign({},e.data),this.stepCompleteEvent.emit({response:e,formStep:t})},onError:({error:e,code:t,severity:s})=>{this.errorEvent.emit({errorCode:t,message:e,severity:s})}});this.stepCompleteEvent.emit({response:null,formStep:t})},this.initializeMakePresignedURLs=async()=>{const e=this.documentList.map((e=>this.getPresignedFileUrl(e)));return await Promise.all(e)},this.initializeFileUploads=async()=>{const e=this.documentList.map((e=>this.uploadDocument(e)));return Promise.all(e)},this.getPresignedFileUrl=async e=>this.createDisputeEvidence({payload:{file_name:e.file_name,file_type:e.file_type,dispute_evidence_type:e.dispute_evidence_type},onSuccess:t=>{e.presignedUrl=t.data.presigned_url},onError:({error:t,code:s,severity:i})=>{const a={[e.dispute_evidence_type]:t};this.documentErrors=Object.assign(Object.assign({},this.documentErrors),a),this.errorEvent.emit({errorCode:s,message:t,severity:i})}}),this.uploadDocument=async e=>{const t=await e.getFileString();if(!e.presignedUrl)throw new Error("Presigned URL is not set");return await fetch(e.presignedUrl,{method:"PUT",body:t})},this.handleSubmit=async(e,t,s)=>{if(this.isLoading=!0,t.length){if(this.documentErrors={},this.documentList=t,await this.initializeMakePresignedURLs(),Object.keys(this.documentErrors).length)throw this.isLoading=!1,new Error("Could not presign all documents");await this.initializeFileUploads()}await this.saveData(e,s),this.isLoading=!1},this.onCancel=()=>{this.clickEvent.emit({name:f.cancelDispute})},this.onBack=async()=>{await this.currentStepComponentRef.validateAndSubmit((async(e,t,s)=>{this.clickEvent.emit({name:f.previousStep}),await this.handleSubmit(e,t,s),this.currentStep--}))},this.onNext=async()=>{await this.currentStepComponentRef.validateAndSubmit((async(e,t,s)=>{this.clickEvent.emit({name:f.nextStep}),await this.handleSubmit(e,t,s),this.currentStep++}))},this.onSubmit=async()=>{await this.currentStepComponentRef.validateAndSubmit((async(e,t,s)=>{this.clickEvent.emit({name:f.submit});const i=Object.assign(Object.assign({},e),{forfeit:!1});await this.handleSubmit(i,t,s)}))}}componentWillLoad(){b(),this.analytics=new u(this),this.initializeDisputeServiceMethods()}disconnectedCallback(){var e;null===(e=this.analytics)||void 0===e||e.cleanup()}propChanged(){this.initializeDisputeServiceMethods()}initializeDisputeServiceMethods(){this.disputeId&&this.authToken?(this.updateDisputeResponse=(({authToken:e,disputeId:t,service:s})=>async({payload:i,onSuccess:a,onError:r,final:d=()=>{}})=>{var c;try{const d=await s.updateDisputeResponse(t,e,i);if(d.error)return r({error:p(d.error),code:h(null===(c=d.error)||void 0===c?void 0:c.code),severity:o.ERROR});a(d)}catch(e){const t=h(null==e?void 0:e.code);return r({error:e.message||e,code:t,severity:o.ERROR})}finally{d()}})({disputeId:this.disputeId,authToken:this.authToken,service:new l}),this.createDisputeEvidence=(({authToken:e,disputeId:t,service:s})=>async({payload:i,onSuccess:a,onError:r,final:d=()=>{}})=>{var c;try{const d=await s.createDisputeEvidence(t,e,i);if(d.error)return r({error:p(d.error),code:h(null===(c=d.error)||void 0===c?void 0:c.code),severity:o.ERROR});a(d)}catch(e){const t=h(null==e?void 0:e.code);return r({error:e.message||e,code:t,severity:o.ERROR})}finally{d()}})({disputeId:this.disputeId,authToken:this.authToken,service:new l}),this.submitDisputeResponse=y({disputeId:this.disputeId,authToken:this.authToken,service:new l})):(this.errorMessage="Account ID and Auth Token are required",this.errorEvent.emit({errorCode:n.MISSING_PROPS,message:this.errorMessage,severity:o.ERROR}))}get currentStepComponent(){return this.componentStepMapping[this.currentStep]()}get isLastStep(){return this.currentStep===this.componentStepMapping.length-1}get isFirstStep(){return 0===this.currentStep}render(){return s("div",{key:"7f9c8d56cfb86cea73ab2f299b83ff0de28f5c3e",class:"dispute-response-root"},s("div",{key:"a805bf54df79453127557bf651c3d776a381241f",class:"row gy-3"},s("div",{key:"2e6bc9cbe369e0ea5d200bc0934b4cad50f3c76f",class:"col-12"},s("h1",{key:"9876e9c87c6dfb405e7bad46d64fdb40ad048142",class:"h4",part:r},"Counter dispute")),s("div",{key:"045028232da5331c7041ad222c4e98364674ace3",class:"col-12"},this.currentStepComponent),s("div",{key:"0455c4856a44340ce25c1c4c8f776abb197f919f",class:"col-12"},s("div",{key:"5b990cc1d41b3a7152d727c941e9758ed70f75a1",class:"d-flex gap-2 mt-4 justify-content-end"},this.isFirstStep?s(d,{variant:"secondary",onClick:()=>this.onCancel(),disabled:this.isLoading,isLoading:this.isLoading},"Cancel"):s(d,{variant:"secondary",onClick:()=>this.onBack(),disabled:this.isLoading,isLoading:this.isLoading},"Back"),this.isLastStep?s(d,{variant:"primary",onClick:()=>this.onSubmit(),disabled:this.isLoading,isLoading:this.isLoading},"Submit Counter Dispute"):s(d,{variant:"primary",onClick:()=>this.onNext(),disabled:this.isLoading,isLoading:this.isLoading},"Next")))))}static get watchers(){return{disputeId:["propChanged"],authToken:["propChanged"]}}};export{v as dispute_notification,m as dispute_response}