@justifi/webcomponents 6.10.0 → 6.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/cjs/{check-pkg-version-DjlvidPw.js → check-pkg-version-PX_ogtrH.js} +18 -1
  2. package/dist/cjs/hidden-input_2.cjs.entry.js +1 -1
  3. package/dist/cjs/internal-tokenize-payment-method_7.cjs.entry.js +2 -2
  4. package/dist/cjs/justifi-additional-questions-form-step_9.cjs.entry.js +6 -0
  5. package/dist/cjs/justifi-apple-pay_8.cjs.entry.js +2 -2
  6. package/dist/cjs/justifi-business-details.cjs.entry.js +2 -2
  7. package/dist/cjs/justifi-business-form.cjs.entry.js +2 -2
  8. package/dist/cjs/justifi-checkout.cjs.entry.js +2 -2
  9. package/dist/cjs/justifi-checkouts-list.cjs.entry.js +2 -2
  10. package/dist/cjs/justifi-dispute-management.cjs.entry.js +2 -2
  11. package/dist/cjs/justifi-dispute-notification_3.cjs.entry.js +2 -2
  12. package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +2 -2
  13. package/dist/cjs/justifi-order-terminals.cjs.entry.js +2 -2
  14. package/dist/cjs/justifi-payment-details.cjs.entry.js +2 -2
  15. package/dist/cjs/justifi-payment-provisioning-core.cjs.entry.js +20 -0
  16. package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +2 -2
  17. package/dist/cjs/justifi-payment-transactions-list.cjs.entry.js +2 -2
  18. package/dist/cjs/justifi-payments-list.cjs.entry.js +2 -2
  19. package/dist/cjs/justifi-payout-details.cjs.entry.js +2 -2
  20. package/dist/cjs/justifi-payout-transactions-list.cjs.entry.js +2 -2
  21. package/dist/cjs/justifi-payouts-list.cjs.entry.js +2 -2
  22. package/dist/cjs/justifi-refund-payment.cjs.entry.js +2 -2
  23. package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +2 -2
  24. package/dist/cjs/justifi-terminal-orders-list.cjs.entry.js +2 -2
  25. package/dist/cjs/justifi-terminals-list.cjs.entry.js +2 -2
  26. package/dist/cjs/loader.cjs.js +1 -1
  27. package/dist/cjs/{package-C5inXJfW.js → package-uJFBawLq.js} +1 -1
  28. package/dist/cjs/webcomponents.cjs.js +1 -1
  29. package/dist/collection/components/business-forms/payment-provisioning/business-owners/business-owners-form-step.js +6 -0
  30. package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning-already-provisioned.js +6 -0
  31. package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning-core.js +15 -0
  32. package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning-submission-complete.js +6 -0
  33. package/dist/collection/utils/check-pkg-version.js +17 -0
  34. package/dist/docs.json +6 -73
  35. package/dist/esm/{check-pkg-version-wgHSN5sV.js → check-pkg-version-Dun0W_E2.js} +18 -1
  36. package/dist/esm/hidden-input_2.entry.js +1 -1
  37. package/dist/esm/internal-tokenize-payment-method_7.entry.js +2 -2
  38. package/dist/esm/justifi-additional-questions-form-step_9.entry.js +6 -0
  39. package/dist/esm/justifi-apple-pay_8.entry.js +2 -2
  40. package/dist/esm/justifi-business-details.entry.js +2 -2
  41. package/dist/esm/justifi-business-form.entry.js +2 -2
  42. package/dist/esm/justifi-checkout.entry.js +2 -2
  43. package/dist/esm/justifi-checkouts-list.entry.js +2 -2
  44. package/dist/esm/justifi-dispute-management.entry.js +2 -2
  45. package/dist/esm/justifi-dispute-notification_3.entry.js +2 -2
  46. package/dist/esm/justifi-gross-payment-chart.entry.js +2 -2
  47. package/dist/esm/justifi-order-terminals.entry.js +2 -2
  48. package/dist/esm/justifi-payment-details.entry.js +2 -2
  49. package/dist/esm/justifi-payment-provisioning-core.entry.js +21 -1
  50. package/dist/esm/justifi-payment-provisioning.entry.js +2 -2
  51. package/dist/esm/justifi-payment-transactions-list.entry.js +2 -2
  52. package/dist/esm/justifi-payments-list.entry.js +2 -2
  53. package/dist/esm/justifi-payout-details.entry.js +2 -2
  54. package/dist/esm/justifi-payout-transactions-list.entry.js +2 -2
  55. package/dist/esm/justifi-payouts-list.entry.js +2 -2
  56. package/dist/esm/justifi-refund-payment.entry.js +2 -2
  57. package/dist/esm/justifi-season-interruption-insurance.entry.js +2 -2
  58. package/dist/esm/justifi-terminal-orders-list.entry.js +2 -2
  59. package/dist/esm/justifi-terminals-list.entry.js +2 -2
  60. package/dist/esm/loader.js +1 -1
  61. package/dist/esm/{package-D4eE0MBI.js → package-CfQ5vkQ3.js} +1 -1
  62. package/dist/esm/webcomponents.js +1 -1
  63. package/dist/module/Analytics.js +17 -0
  64. package/dist/module/business-owners-form-step.js +6 -0
  65. package/dist/module/package.js +1 -1
  66. package/dist/module/payment-provisioning-core.js +22 -1
  67. package/dist/types/components/business-forms/payment-provisioning/payment-provisioning-already-provisioned.d.ts +1 -0
  68. package/dist/types/components/business-forms/payment-provisioning/payment-provisioning-core.d.ts +1 -0
  69. package/dist/types/components/business-forms/payment-provisioning/payment-provisioning-submission-complete.d.ts +1 -0
  70. package/dist/webcomponents/{p-38c1e9fa.entry.js → p-092653b6.entry.js} +1 -1
  71. package/dist/webcomponents/{p-ed4f8027.entry.js → p-18658148.entry.js} +1 -1
  72. package/dist/webcomponents/p-32a8b10f.entry.js +1 -0
  73. package/dist/webcomponents/{p-df61f19b.entry.js → p-334beb48.entry.js} +1 -1
  74. package/dist/webcomponents/{p-b4b540fa.entry.js → p-3798d389.entry.js} +1 -1
  75. package/dist/webcomponents/{p-423b63ad.entry.js → p-3bbacc8e.entry.js} +1 -1
  76. package/dist/webcomponents/{p-d766763a.entry.js → p-3c647db5.entry.js} +1 -1
  77. package/dist/webcomponents/{p-2438363d.entry.js → p-3caa3604.entry.js} +1 -1
  78. package/dist/webcomponents/{p-0e21749b.entry.js → p-4116808e.entry.js} +1 -1
  79. package/dist/webcomponents/{p-7769de83.entry.js → p-5f402409.entry.js} +1 -1
  80. package/dist/webcomponents/{p-d62da4f2.entry.js → p-660a04c0.entry.js} +1 -1
  81. package/dist/webcomponents/{p-f18e90b1.entry.js → p-917daf31.entry.js} +1 -1
  82. package/dist/webcomponents/{p-300002dd.entry.js → p-98158303.entry.js} +1 -1
  83. package/dist/webcomponents/{p-5cee4e33.entry.js → p-990d3709.entry.js} +1 -1
  84. package/dist/webcomponents/p-CfQ5vkQ3.js +1 -0
  85. package/dist/webcomponents/{p-eb1251bf.entry.js → p-a141c90b.entry.js} +1 -1
  86. package/dist/webcomponents/{p-c725dc53.entry.js → p-a713a90d.entry.js} +1 -1
  87. package/dist/webcomponents/{p-8728065b.entry.js → p-a87a7fad.entry.js} +1 -1
  88. package/dist/webcomponents/{p-e2bc6c68.entry.js → p-ab365375.entry.js} +1 -1
  89. package/dist/webcomponents/{p-2b679e5a.entry.js → p-ad962b59.entry.js} +1 -1
  90. package/dist/webcomponents/{p-979d22d0.entry.js → p-b6ffa313.entry.js} +1 -1
  91. package/dist/webcomponents/p-cb9abd2c.entry.js +1 -0
  92. package/dist/webcomponents/{p-d0813f21.entry.js → p-d5516a10.entry.js} +1 -1
  93. package/dist/webcomponents/{p-3971d6b7.entry.js → p-e8eeb4f1.entry.js} +1 -1
  94. package/dist/webcomponents/{p-CbTf_N6u.js → p-eEJvKFFX.js} +1 -1
  95. package/dist/webcomponents/{p-5d753fd4.entry.js → p-f5362ed9.entry.js} +1 -1
  96. package/dist/webcomponents/webcomponents.esm.js +1 -1
  97. package/package.json +3 -2
  98. package/dist/webcomponents/p-2bbd810a.entry.js +0 -1
  99. package/dist/webcomponents/p-D4eE0MBI.js +0 -1
  100. package/dist/webcomponents/p-afa2ebd9.entry.js +0 -1
@@ -1 +1 @@
1
- import{r as s,c as t,h as e,H as i}from"./p-CV0Pyo1O.js";import{C as r,a as n}from"./p-Cjcsf8ku.js";import{m as o,b as a,f as h,g as c}from"./p-R0FDNhyd.js";import{B as d,a as l,D as u}from"./p-DqtDbB8E.js";import{a as m,c as p,b}from"./p-BovgIz83.js";import{F as f,c as v,a as y,b as g,d as w}from"./p-CKiAlBsU.js";import{A as _,C as k,e as j,R as C,f as T}from"./p-BcNb9bVO.js";import{C as O,P as x}from"./p-CVaOFfrI.js";import{J as S,am as I,$ as E,Y as L,aG as A}from"./p-C4FLe2pT.js";import{P as D}from"./p-C3kbpEIZ.js";import{b as B,c as H}from"./p-Bt4GjEWL.js";import{a as P,B as V}from"./p-XYgDHrVL.js";import"./p-DVJaoI_m.js";import"./p-HXpYMWUU.js";import{E as F,p as q,q as W}from"./p-BiNakvsa.js";import"./p-CLHwhyvu.js";import"./p-BH0Xfn-F.js";import{A as Y,B as M,v as N,C as U,D as z,E as R,F as G}from"./p-HT_4DkD0.js";import{B as X}from"./p-DFiTyYE9.js";import"./p-CZfYo5-1.js";import{c as J}from"./p-_-2E_vYf.js";import{d as $,e as Q}from"./p-D8EGHc_m.js";import{A as Z}from"./p-55QcjheA.js";import"./p-D2muobcE.js";import"./p-BFTU3MAI.js";import"./p-DqVU8ohH.js";import"./p-D8GTwl9v.js";import"./p-MeSAYDNh.js";class K{constructor(s){this.id=s.id,this.account_owner_name=s.account_owner_name,this.full_name=s.full_name,this.account_type=s.account_type,this.account_number=s.account_number,this.acct_last_four=s.acct_last_four,this.account_number_last4=s.account_number_last4,this.routing_number=s.routing_number,this.institution_number=s.institution_number,this.transit_number=s.transit_number,this.bank_name=s.bank_name,this.country=s.country,this.currency=s.currency,this.nickname=s.nickname,this.metadata=s.metadata,this.business_id=s.business_id,this.platform_account_id=s.platform_account_id,this.created_at=s.created_at,this.updated_at=s.updated_at}get payload(){return{account_owner_name:this.account_owner_name||"",account_type:this.account_type||"",account_number:this.account_number||"",routing_number:this.routing_number||"",institution_number:this.institution_number||"",transit_number:this.transit_number||"",bank_name:this.bank_name||"",nickname:this.nickname||"",business_id:this.business_id||""}}}const ss=class{constructor(e){s(this,e),this.errorEvent=t(this,"error-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.formLoading=t(this,"formLoading",7),this.errors={},this.additional_questions={},this.recurringPayments=!1,this.isLoading=!1,this.getData=()=>{this.formLoading.emit(!0),this.isLoading=!0,this.getBusiness({onSuccess:s=>{this.additional_questions=new _(s.data.additional_questions||{}),this.formController.setInitialValues(Object.assign({},this.additional_questions))},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.formLoading.emit(!1),this.isLoading=!1}})},this.sendData=s=>{let t;this.formLoading.emit(!0),this.patchBusiness({payload:this.patchPayload,onSuccess:e=>{t=e,s()},onError:({error:s,code:e,severity:i})=>{t=s,this.errorEvent.emit({message:s,errorCode:e,severity:i})},final:()=>{this.stepCompleteEvent.emit({response:t,formStep:P.additionalQuestions}),this.formLoading.emit(!1)}})},this.inputHandler=(s,t)=>{this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[s]:t})),this.additional_questions=new _(Object.assign(Object.assign({},this.formController.values.getValue()),{[s]:t}))}}propChanged(){this.initializeApi()}recurringPaymentsWatcher(s){this.recurringPayments="Yes"===(null==s?void 0:s.business_recurring_payments)}async validateAndSubmit({onSuccess:s}){this.formController.validateAndSubmit((()=>this.sendData(s)))}get patchPayload(){return{additional_questions:new _(this.formController.values.getValue()).payload}}componentWillLoad(){this.initializeApi(),this.formController=new f(m(this.allowOptionalFields))}componentDidLoad(){this.getBusiness&&this.getData(),this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))}initializeApi(){this.authToken&&this.businessId?(this.getBusiness=o({authToken:this.authToken,businessId:this.businessId,service:new d}),this.patchBusiness=a({authToken:this.authToken,businessId:this.businessId,service:new d})):this.errorEvent.emit({message:"Missing required props",errorCode:n.MISSING_PROPS,severity:r.ERROR})}render(){var s,t,i,r,n;const o=this.formController.getInitialValues();return this.isLoading?e(D,null):e("form",null,e("fieldset",null,e("div",{class:"d-flex align-items-center gap-2"},e("legend",{class:"mb-0",part:S},"Additional Questions"),e("form-control-tooltip",{helpText:"This information helps us understand the business and identify and monitor trends to safeguard you and your customers."})),e("hr",{class:"mt-2"}),e("div",{class:"row gy-3"},e("div",{class:"col-12 col-md-6"},e("form-control-monetary-provisioning",{name:"business_revenue",label:"What is your business' estimated annual revenue from its primary business activities?",inputHandler:this.inputHandler,errorText:null===(s=this.errors)||void 0===s?void 0:s.business_revenue,defaultValue:null==o?void 0:o.business_revenue,maskOptions:O.WHOLE})),e("div",{class:"col-12 col-md-6"},e("form-control-monetary-provisioning",{name:"business_payment_volume",label:"What is your business' annual credit card & ACH volume anticipated to process?",inputHandler:this.inputHandler,errorText:null===(t=this.errors)||void 0===t?void 0:t.business_payment_volume,defaultValue:null==o?void 0:o.business_payment_volume,maskOptions:O.WHOLE})),e("div",{class:"col-12"},e("form-control-text",{name:"business_average_transaction_amount",label:"What is your average transaction size?",inputHandler:this.inputHandler,errorText:null===(i=this.errors)||void 0===i?void 0:i.business_average_transaction_amount,defaultValue:null==o?void 0:o.business_average_transaction_amount})),e("div",{class:"col-12"},e("form-control-select",{name:"business_when_service_received",label:"On average, how long after paying will your customers typically receive their goods or services?",inputHandler:this.inputHandler,errorText:null===(r=this.errors)||void 0===r?void 0:r.business_when_service_received,options:B,defaultValue:null==o?void 0:o.business_when_service_received})),e("div",{class:"col-12"},e("form-control-text",{name:"business_other_payment_details",label:"Is there anything else you would like us to know about how your customers pay the business? (optional)",inputHandler:this.inputHandler,errorText:null===(n=this.errors)||void 0===n?void 0:n.business_other_payment_details,defaultValue:null==o?void 0:o.business_other_payment_details})))))}static get watchers(){return{authToken:["propChanged"],businessId:["propChanged"],additional_questions:["recurringPaymentsWatcher"]}}},ts=(s,t)=>s.some((s=>s.document_type===t)),es=s=>s?{bank_name:z.nullable(),nickname:U.nullable(),account_owner_name:N.nullable(),account_type:M.nullable(),account_number:Y.nullable()}:{bank_name:z.required("Enter bank name"),nickname:U.required("Enter nickname"),account_owner_name:N.required("Enter account owner name"),account_type:M.required("Select account type"),account_number:Y.required("Enter account number")},is=(s,t)=>{if(t)return{voided_check:g().nullable(),bank_statement:g().nullable()};const e=ts(s,F.voidedCheck),i=ts(s,F.bankStatement),r=e||i,n="Please upload either a voided check or a bank statement. Only one is required.";return{voided_check:g().when("bank_statement",{is:s=>!s&&!r,then:s=>s.required(n),otherwise:s=>s.notRequired()}),bank_statement:g().when("voided_check",{is:s=>!s&&!r,then:s=>s.required(n),otherwise:s=>s.notRequired()})}},rs={[k.USA]:(s,t=[])=>((s,t)=>{const e=Object.assign(Object.assign(Object.assign({},es(t)),(s=>s?{routing_number:G.nullable()}:{routing_number:G.required("Enter routing number")})(t)),is(s,t));return v().shape(e,[["voided_check","bank_statement"]])})(t,s),[k.CAN]:(s,t=[])=>((s,t)=>{const e=Object.assign(Object.assign(Object.assign({},es(t)),(s=>{const t=y().length(3,"Institution number must be 3 digits").matches(R,"Enter valid institution number"),e=y().length(5,"Transit number must be 5 digits").matches(R,"Enter valid transit number");return s?{institution_number:t.nullable(),transit_number:e.nullable()}:{institution_number:t.required("Enter institution number"),transit_number:e.required("Enter transit number")}})(t)),is(s,t));return v().shape(e,[["voided_check","bank_statement"]])})(t,s)},ns=class{constructor(e){s(this,e),this.errorEvent=t(this,"error-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.formLoading=t(this,"formLoading",7),this.errors={},this.bankAccount={},this.existingDocuments=[],this.documentData=new q,this.isLoading=!1,this.isAddingNewBankAccount=!0,this.bankAccountVerification=!1,this.platformAccountId=null,this.getSchema=()=>(0,rs[this.country])(this.allowOptionalFields,this.existingDocuments),this.initializeFormController=()=>{this.formController=new f(this.getSchema()),this.formController.setInitialValues(this.isAddingNewBankAccount?{business_id:this.businessId}:Object.assign({},this.bankAccount)),this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))},this.inputHandler=(s,t)=>{this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[s]:t}))},this.storeFiles=s=>{const t=Array.from(s.detail.fileList),e=s.detail.document_type,i=t.map((s=>new W({file:s,document_type:e},this.businessId)));this.documentData[e]=i},this.getData=()=>{this.isLoading=!0,this.getBusiness({onSuccess:s=>{if(s.data.bank_accounts.length>0){const t=s.data.bank_accounts;this.bankAccount=new K(t[t.length-1]),this.isAddingNewBankAccount=!1}else this.bankAccount=new K({}),this.bankAccount.business_id=this.businessId;this.existingDocuments=s.data.documents,this.bankAccountVerification=!0===s.data.settings.bank_account_verification,this.platformAccountId=s.data.platform_account_id},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.initializeFormController(),this.isLoading=!1}})},this.handleChangeBankAccount=()=>{this.isAddingNewBankAccount=!0,this.documentData=new q,this.initializeFormController()},this.handleCancel=()=>{this.isAddingNewBankAccount=!1,this.documentData=new q,this.initializeFormController()},this.handleSaveBankAccount=async()=>{this.formController.validateAndSubmit((()=>{this.sendData((()=>{}))}))},this.postDocumentRecordData=async s=>{this.isLoading=!0;const t=s.record_data;return new Promise((e=>{this.postDocumentRecord({payload:t,onSuccess:t=>{e(this.handleDocRecordResponse(s,t))},onError:({error:s,code:t,severity:i})=>{this.errorEvent.emit({message:s,errorCode:t,severity:i}),e(!1)}})}))},this.handleDocRecordResponse=(s,t)=>t.error?(this.errorEvent.emit({errorCode:n.POST_ERROR,message:t.error.message,severity:r.ERROR,data:t.error}),!1):(s.setPresignedUrl(t.data.presigned_url),!0),this.uploadDocument=async s=>{if(!s.presigned_url)throw new Error("Presigned URL is not set");const t=await s.getFileData(),e=await fetch(s.presigned_url,{method:"PUT",body:t});return this.handleUploadResponse(e)},this.handleUploadResponse=s=>!s.error||(this.errorEvent.emit({errorCode:n.POST_ERROR,message:s.error.message,severity:r.ERROR,data:s.error}),!1)}propChanged(){this.initializeApi()}watchHandler(s){this.formLoading.emit(s)}async validateAndSubmit({onSuccess:s}){this.existingBankAccount&&!this.isAddingNewBankAccount?this.sendData(s):this.formController.validateAndSubmit((()=>this.sendData(s)))}componentWillLoad(){this.initializeApi(),this.getBusiness&&this.getData(),this.formController=new f(this.getSchema())}componentDidLoad(){this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))}initializeApi(){this.authToken&&this.businessId?(this.getBusiness=o({authToken:this.authToken,businessId:this.businessId,service:new d}),this.postBankAccount=h({authToken:this.authToken,service:new l}),this.postDocumentRecord=c({authToken:this.authToken,service:new u})):this.errorEvent.emit({message:"Missing required props",errorCode:n.MISSING_PROPS,severity:r.ERROR})}get postPayload(){const s=this.formController.values.getValue();return new K(s).payload}get existingBankAccount(){var s;return!!(null===(s=this.bankAccount)||void 0===s?void 0:s.id)}get showReadOnlyView(){return this.existingBankAccount&&!this.isAddingNewBankAccount}async sendData(s){try{if(this.isAddingNewBankAccount&&!await this.postBankAccountData())return;if(!await this.postBusinessDocuments())return;this.isAddingNewBankAccount&&(this.isAddingNewBankAccount=!1,await this.refreshBankAccountData()),s()}catch(s){this.errorEvent.emit({message:s,errorCode:n.POST_ERROR,severity:r.ERROR})}}async postBankAccountData(){let s;return this.isLoading=!0,new Promise((t=>{let e=!1;this.postBankAccount({payload:this.postPayload,onSuccess:t=>{s=t,e=!0},onError:({error:s,code:t,severity:i})=>{e=!1,this.errorEvent.emit({message:s,errorCode:t,severity:i})},final:()=>{this.stepCompleteEvent.emit({response:s,formStep:P.bankAccount}),this.isLoading=!1,t(e)}})}))}async refreshBankAccountData(){return new Promise((s=>{this.isLoading=!0,this.getBusiness({onSuccess:s=>{const{data:t}=s,{bank_accounts:e,documents:i,settings:r,platform_account_id:n}=t;e.length>0&&(this.bankAccount=new K(e[e.length-1])),this.existingDocuments=i,this.bankAccountVerification=!0===r.bank_account_verification,this.platformAccountId=n,this.initializeFormController()},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.isLoading=!1,s()}})}))}async postBusinessDocuments(){this.isLoading=!0;try{const s=Object.values(this.documentData).flat();return!s.length||!(await Promise.all(s.map((s=>this.postDocumentRecordData(s))))).includes(!1)&&!(await Promise.all(s.map((s=>this.uploadDocument(s))))).includes(!1)}finally{this.isLoading=!1}}render(){const s=this.formController.getInitialValues(),t=this.bankAccountVerification&&this.platformAccountId;return this.isLoading?e(D,null):e("form",null,e("fieldset",{class:"mb-4"},e("div",{class:"d-flex align-items-center gap-2"},e("legend",{class:"mb-0",part:S},"Bank Account Info"),e("form-control-tooltip",{helpText:"This direct deposit account is the designated bank account where incoming funds will be deposited. The name of this account must match the registered business name exactly. We are not able to accept personal accounts unless your business is a registered sole proprietorship."})),e("hr",{class:"mt-2"}),t&&e("div",{class:"mt-3"},e("plaid-verification",{authToken:this.authToken,accountId:this.platformAccountId,businessId:this.businessId,onPlaidVerificationSuccess:()=>{this.isAddingNewBankAccount=!1,this.refreshBankAccountData()}})),e(this.country===k.CAN?"bank-account-form-inputs-canada":"bank-account-form-inputs",{defaultValue:s,errors:this.errors,inputHandler:this.inputHandler,formDisabled:this.showReadOnlyView}),this.showReadOnlyView&&e("div",{class:"mt-3"},e(X,{variant:"secondary",type:"button",onClick:this.handleChangeBankAccount,disabled:this.isLoading,part:I},"Change Bank Account")),(!this.existingBankAccount||this.isAddingNewBankAccount)&&e("div",{class:"mt-3 d-flex gap-2"},this.isAddingNewBankAccount&&e(X,{variant:"secondary",type:"button",onClick:this.handleCancel,disabled:this.isLoading,part:I},"Cancel"),e(X,{variant:"primary",type:"button",onClick:this.handleSaveBankAccount,disabled:this.isLoading,isLoading:this.isLoading},"Save Bank Account"))),e("fieldset",{class:"mt-4"},e("div",{class:"d-flex align-items-center gap-2"},e("legend",{class:"mb-0",part:S},"Document Uploads"),e("form-control-tooltip",{helpText:"One document (voided check or bank statement) is required for underwriting purposes. It needs to visibly show the name tied to the account and the account number. Various file formats such as PDF, DOC, DOCX, JPEG are accepted. Multiple files can be uploaded for each document category."})),e("hr",{class:"mt-2"}),e("business-documents-on-file",{documents:this.existingDocuments,isLoading:this.isLoading}),e("bank-account-document-form-inputs",{inputHandler:this.inputHandler,errors:this.errors,storeFiles:this.storeFiles})))}static get watchers(){return{authToken:["propChanged"],businessId:["propChanged"],isLoading:["watchHandler"]}}},os=class{constructor(e){s(this,e),this.errorEvent=t(this,"error-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.formLoading=t(this,"formLoading",7),this.errors={},this.coreInfo={},this.isLoading=!1,this.isEditingTaxId=!1,this.getData=()=>{this.getBusiness&&(this.formLoading.emit(!0),this.isLoading=!0,this.getBusiness({onSuccess:s=>{this.coreInfo=new j(s.data),this.formController.setInitialValues(Object.assign({},this.coreInfo))},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.formLoading.emit(!1),this.isLoading=!1}}))},this.sendData=s=>{let t;this.formLoading.emit(!0),this.patchBusiness({payload:this.patchPayload,onSuccess:e=>{t=e,s(),this.isEditingTaxId=!1},onError:({error:s,code:e,severity:i,rawError:r})=>{t=s,r&&"object"==typeof r&&r.param&&this.formController.setFieldError(r.param,r.message),this.errorEvent.emit({message:s,errorCode:e,severity:i})},final:()=>{this.stepCompleteEvent.emit({response:t,formStep:P.businessInfo}),this.formLoading.emit(!1)}})},this.inputHandler=(s,t)=>{this.errors[s]&&this.formController.clearFieldError(s),this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[s]:t}))}}propChanged(){this.initializeApi()}async validateAndSubmit({onSuccess:s}){this.formController.validateAndSubmit((()=>this.sendData(s)))}get patchPayload(){return new j(this.formController.values.getValue()).payload}componentWillLoad(){this.initializeApi();const s=this.country===k.CAN?p(this.allowOptionalFields):b(this.allowOptionalFields);this.formController=new f(s),this.getData()}componentDidLoad(){this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))}initializeApi(){this.authToken&&this.businessId?(this.getBusiness=o({authToken:this.authToken,businessId:this.businessId,service:new d}),this.patchBusiness=a({authToken:this.authToken,businessId:this.businessId,service:new d})):this.errorEvent.emit({message:"Missing required props",errorCode:n.MISSING_PROPS,severity:r.ERROR})}render(){var s,t;const i=this.formController.getInitialValues();return this.isLoading?e(D,null):e("form",null,e("fieldset",null,e("div",{class:"d-flex align-items-center gap-2"},e("legend",{class:"mb-0",part:S},"Business Information")),e("hr",{class:"mt-2"}),e("div",{class:"row gy-3"},e("div",{class:"col-12"},e("form-control-text",{name:"legal_name",label:"Business Name",defaultValue:i.legal_name,errorText:this.errors.legal_name,inputHandler:this.inputHandler,helpText:"Enter this exactly as it appears on your tax records (don't use acronyms or abbreviations unless you registered that way)."})),e("div",{class:"col-12"},e("form-control-text",{name:"doing_business_as",label:"Doing Business As (DBA)",defaultValue:i.doing_business_as,errorText:this.errors.doing_business_as,inputHandler:this.inputHandler,helpText:"Enter this exactly as it appears on your tax records (leave blank if you don't have a registered DBA/trade name)"})),e("div",{class:"col-12 col-md-8"},e("form-control-select",{name:"classification",label:"Business Classification",options:H,defaultValue:i.classification,errorText:this.errors.classification,inputHandler:this.inputHandler})),e("div",{class:"col-12 col-md-4"},e("form-control-date",{name:"date_of_incorporation",label:"Date of Registration",defaultValue:i.date_of_incorporation,errorText:this.errors.date_of_incorporation,inputHandler:this.inputHandler})),e("div",{class:"col-12 col-md-6"},e("form-control-text",{name:"industry",label:"Industry",defaultValue:i.industry,errorText:this.errors.industry,inputHandler:this.inputHandler,helpText:"Describe what you sell"})),e("div",{class:"col-12 col-md-6"},!(null===(s=this.coreInfo)||void 0===s?void 0:s.tax_id_last4)||this.isEditingTaxId?e("form-control-number-masked",{name:"tax_id",label:J[this.country].taxIdLabel,defaultValue:this.isEditingTaxId?"":i.tax_id,errorText:this.errors.tax_id,inputHandler:this.inputHandler,mask:"000000000",helpText:J[this.country].taxIdHelpText}):e("div",null,e("label",{class:"form-label",part:E},J[this.country].taxIdLabel),e("div",{class:"input-group mb-3"},e("input",{type:"text",class:"form-control",part:L,value:`****${null===(t=this.coreInfo)||void 0===t?void 0:t.tax_id_last4}`,disabled:!0}),e("button",{class:"btn btn-secondary",type:"button",part:I,onClick:()=>{this.isEditingTaxId=!0,this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{tax_id:"",tax_id_last4:null}))}},"Change")))),e("div",{class:"col-12"},e("form-control-text",{name:"website_url",label:"Business Website URL",defaultValue:i.website_url,errorText:this.errors.website_url,inputHandler:this.inputHandler,helpText:"Don't have a live website? You can use your social media business page, app store link, or staging site URL."})),e("div",{class:"col-12 col-md-6"},e("form-control-text",{name:"email",label:"Business Email Address",defaultValue:i.email,errorText:this.errors.email,inputHandler:this.inputHandler})),e("div",{class:"col-12 col-md-6"},e("form-control-number-masked",{name:"phone",label:"Business Phone Number",defaultValue:i.phone,errorText:this.errors.phone,inputHandler:this.inputHandler,mask:x.US})))))}static get watchers(){return{authToken:["propChanged"],businessId:["propChanged"]}}},as=class{constructor(e){s(this,e),this.clickEvent=t(this,"click-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.errorEvent=t(this,"error-event",7),this.formLoading=t(this,"formLoading",7),this.ownersPayload=[],this.refs=[],this.isLoading=!1,this.representativeIsOwner=null,this.matchRef=(s,t)=>{if(null===s)return;const e=this.ownersPayload.findIndex((s=>s.id===t));-1!==e&&(this.refs.length!==this.ownersPayload.length&&this.manageRefs(),this.refs[e]=s)},this.getData=()=>{this.formLoading.emit(!0),this.isLoading=!0,this.getBusiness({onSuccess:s=>{this.representative=new C(s.data.representative||{}),s.data.owners.length?this.ownersPayload=s.data.owners.map((s=>({id:s.id}))):this.addOwnerForm()},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.formLoading.emit(!1),this.isLoading=!1,this.manageRefs()}})},this.sendData=async s=>{let t;this.formLoading.emit(!0),this.patchBusiness({payload:{owners:this.ownersPayload},onSuccess:e=>{t=e,s()},onError:({error:s,code:e,severity:i})=>{t=s,this.errorEvent.emit({message:s,errorCode:e,severity:i})},final:()=>{this.stepCompleteEvent.emit({response:t,formStep:P.owners}),this.formLoading.emit(!1)}})},this.addOwnerForm=s=>{this.newFormOpen=!0,this.ownersPayload=[...this.ownersPayload,{id:""}],s&&this.clickEvent.emit({name:V.addOwnerForm})},this.removeOwnerForm=s=>{this.ownersPayload=this.ownersPayload.filter((t=>t.id!==s)),this.newFormOpen&&(this.newFormOpen=!1)},this.handleRepresentativeIsOwnerChange=s=>{this.representativeIsOwner=s,this.representativeIsOwner&&(this.ownersPayload=this.ownersPayload.filter((s=>""!==s.id)),this.patchBusiness({payload:{owners:[{id:this.representative.id},...this.ownersPayload]},onSuccess:()=>{this.getData(),this.newFormOpen=!1}}))}}propChanged(){this.initializeApi()}get showAddOwnerButton(){return this.ownersPayload.length<4&&!this.newFormOpen}manageRefs(){this.refs=this.ownersPayload.map((s=>s.id))}async validateAndSubmit({onSuccess:s}){const t=this.refs.map((s=>s.validate()));if(!(await Promise.all(t)).every((s=>s)))return;const e=this.refs.map((s=>s.submit()));(await Promise.all(e)).every((s=>s))&&this.sendData(s)}componentWillLoad(){this.initializeApi(),this.getBusiness&&this.getData()}initializeApi(){this.authToken&&this.businessId?(this.getBusiness=o({authToken:this.authToken,businessId:this.businessId,service:new d}),this.patchBusiness=a({authToken:this.authToken,businessId:this.businessId,service:new d})):this.errorEvent.emit({message:"Missing required props",errorCode:n.MISSING_PROPS,severity:r.ERROR})}ownersWatcher(){this.manageRefs()}handleOwnerSubmit(s){const t=s.detail,e=this.ownersPayload.map((s=>s.id===t.id?t:s));e.includes(t)||(e[this.ownersPayload.findIndex((s=>!s.id))]=t,this.newFormOpen&&(this.newFormOpen=!1)),this.ownersPayload=e}render(){if(this.isLoading)return e(i,null,e(D,null));const s=this.ownersPayload.some((s=>s.id===this.representative.id)),t=null===this.representativeIsOwner&&!s;return e(i,null,e("div",null,e("div",{class:"d-flex align-items-center gap-2"},e("legend",{class:"mb-0",part:S},"Owners"),e("form-control-tooltip",{helpText:"For partnerships, LLCs or privately held corporations, the business is required to apply with all individuals with 25% or more ownership to the application. For charities and registered non-profits, the business is required to apply with 1 individual with substantial control over the entity, such as a board member or director."})),e("hr",{class:"mt-2"}),t&&e("div",{class:"alert alert-warning mb-3",part:A},e("div",{class:"card-body"},e("div",{class:"d-flex align-items-center mb-3"},e("strong",null,"Is the representative of this business also an owner?")),e("div",{class:"d-flex gap-2"},e(X,{variant:"primary",onClick:()=>this.handleRepresentativeIsOwnerChange(!0)},"Yes"),e(X,{variant:"secondary",onClick:()=>this.handleRepresentativeIsOwnerChange(!1)},"No")))),e("div",{class:"row gy-3"},this.ownersPayload.map((s=>e("justifi-owner-form",{key:s.id,authToken:this.authToken,businessId:this.businessId,ownerId:s.id,removeOwner:this.removeOwnerForm,newFormOpen:this.newFormOpen,ownersLength:this.ownersPayload.length,country:this.country,allowOptionalFields:this.allowOptionalFields,ref:t=>this.matchRef(t,s.id)})))),e("div",{class:"d-flex justify-content-start"},e("div",{class:"gap-2"},e(X,{variant:"primary",onClick:()=>this.addOwnerForm(!0),hidden:!this.showAddOwnerButton},"Add Owner")))))}static get watchers(){return{authToken:["propChanged"],businessId:["propChanged"],ownersPayload:["ownersWatcher"]}}},hs=class{constructor(e){s(this,e),this.errorEvent=t(this,"error-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.formLoading=t(this,"formLoading",7),this.errors={},this.representative={},this.isLoading=!1,this.getData=()=>{this.getBusiness&&this.formController&&(this.formLoading.emit(!0),this.isLoading=!0,this.getBusiness({onSuccess:s=>{this.representative=new C(s.data.representative||{}),this.representative.address.country=this.country,this.formController.setInitialValues(Object.assign({},this.representative))},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.formLoading.emit(!1),this.isLoading=!1}}))},this.sendData=s=>{let t;this.formLoading.emit(!0),this.patchBusiness({payload:this.patchPayload,onSuccess:e=>{t=e,s()},onError:({error:s,code:e,severity:i})=>{t=s,this.errorEvent.emit({message:s,errorCode:e,severity:i})},final:()=>{this.stepCompleteEvent.emit({response:t,formStep:P.representative}),this.formLoading.emit(!1)}})}}propChanged(){this.initializeApi(),this.getData()}async validateAndSubmit({onSuccess:s}){this.formController.validateAndSubmit((()=>this.sendData(s)))}componentWillLoad(){this.initializeApi(),this.initializeForm()}initializeApi(){this.authToken&&this.businessId?(this.getBusiness=o({authToken:this.authToken,businessId:this.businessId,service:new d}),this.patchBusiness=a({authToken:this.authToken,businessId:this.businessId,service:new d})):this.errorEvent.emit({message:"Missing required props",errorCode:n.MISSING_PROPS,severity:r.ERROR})}initializeForm(){const s=$[this.country];s?(this.formController=new f(s("representative",this.allowOptionalFields)),this.getData()):this.errorEvent.emit({message:"Missing schema for selected country",errorCode:n.MISSING_PROPS,severity:r.ERROR})}componentDidLoad(){this.formController&&this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))}get patchPayload(){return{representative:new C(this.formController.values.getValue()).payload}}render(){return!this.formController||this.isLoading?e(D,null):e("justifi-business-representative-form-inputs",{representativeDefaultValue:this.formController.getInitialValues(),errors:this.errors,formController:this.formController,country:this.country})}static get watchers(){return{authToken:["propChanged"],businessId:["propChanged"]}}},cs=class{constructor(e){s(this,e),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.errorEvent=t(this,"error-event",7),this.formLoading=t(this,"formLoading",7),this.formCompleted=t(this,"formCompleted",7),this.errors={},this.fetchData=async()=>{this.formLoading.emit(!0);try{const s=await this.api.get({endpoint:this.businessEndpoint,authToken:this.authToken});this.acceptedTermsBefore=s.data.terms_conditions_accepted}catch(s){this.errorEvent.emit({errorCode:n.FETCH_ERROR,message:s.message,severity:r.ERROR,data:s})}finally{this.formLoading.emit(!1)}},this.sendData=async s=>{this.formLoading.emit(!0);try{const t=this.termsPayload,e=await this.api.post({endpoint:this.termsConditionsEndpoint,body:t,authToken:this.authToken});this.handleResponse(e,s)}catch(s){this.errorEvent.emit({errorCode:n.POST_ERROR,message:s.message,severity:r.ERROR,data:s})}finally{this.formLoading.emit(!1)}},this.inputHandler=(s,t)=>{this.acceptedTerms=t,this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[s]:t}))}}get businessEndpoint(){return`entities/business/${this.businessId}`}get termsConditionsEndpoint(){return"entities/terms_and_conditions"}get formHelperText(){return this.acceptedTermsBefore?"You have already accepted the terms and conditions.":null}get termsPayload(){return{business_id:this.businessId,accepted:this.formController.values.getValue().accepted,user_agent:window.navigator.userAgent}}async componentWillLoad(){this.api=Z(),this.formController=new f((s=>{const t=v({accepted:w().oneOf([!0],"You must agree to the terms and conditions to continue").required("You must agree to the terms and conditions to continue")}),e=v({accepted:w().nullable()});return s?e:t})(this.allowOptionalFields)),this.businessId&&this.authToken&&this.fetchData()}handleResponse(s,t){s.error?this.errorEvent.emit({errorCode:n.POST_ERROR,message:s.error.message,severity:r.ERROR,data:s.error}):t(),this.stepCompleteEvent.emit({response:s,formStep:P.termsAndConditions}),this.formCompleted.emit()}async validateAndSubmit({onSuccess:s}){this.acceptedTermsBefore?(this.stepCompleteEvent.emit({response:null,formStep:P.termsAndConditions,metadata:"no data submitted"}),this.formCompleted.emit(),s()):this.formController.validateAndSubmit((()=>this.sendData(s)))}componentDidLoad(){this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))}get merchantAgreementLink(){return e("a",{href:"https://justifi.tech/merchant-agreement/",target:"_blank",rel:"noopener noreferrer"},"merchant agreement")}render(){return e("form",{key:"33336d0a66d63ce39951822fd570a9a0689e714d"},e("fieldset",{key:"fcfdb59eef671cb408ed99e2dad20d6be706688a"},e("legend",{key:"f0cf7f0ac15c90cf36ee25d4bf986c0e781a2e92",part:S},"Terms and Conditions"),e("hr",{key:"d5c820e7d6523f931040a994bd103d69fd644c45"}),e("div",{key:"681b584de14afe121f5dc69ee0bad1cab51ba0d1"},e("p",{key:"7c597bf891a108d303739126b806ded5220f56ab"},"Please read and accept the ",this.merchantAgreementLink," to submit your provisioning request.")),e("br",{key:"52854c5a07611180be40df21a5f60d7d9d4c4cb7"}),e("div",{key:"7448b3f6138b996edac137b961367725e3b40556",class:"row-gy-3"},e("div",{key:"c732deb4e1e3a2d04dd4e09914543a7f594af108",class:"col-12"},e("form-control-checkbox",{key:"fca18e4843aef20d13790029b114b2ecaeb6ffa2",name:"accepted",label:"I agree to the terms and conditions",inputHandler:this.inputHandler,errorText:this.errors.accepted,disabled:this.acceptedTermsBefore,helpText:this.formHelperText,checked:this.acceptedTerms})))))}},ds=class{constructor(e){s(this,e),this.errorEvent=t(this,"error-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.formLoading=t(this,"formLoading",7),this.errors={},this.legal_address={},this.isLoading=!1,this.getData=()=>{this.getBusiness&&(this.formLoading.emit(!0),this.isLoading=!0,this.getBusiness({onSuccess:s=>{const t=new T((s.data||{}).legal_address||{});this.legal_address=Object.assign(Object.assign({},t),{country:this.country}),this.formController.setInitialValues(Object.assign({},this.legal_address))},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.formLoading.emit(!1),this.isLoading=!1}}))},this.sendData=s=>{let t;this.formLoading.emit(!0),this.patchBusiness({payload:this.patchPayload,onSuccess:e=>{t=e,s()},onError:({error:s,code:e,severity:i})=>{t=s,this.errorEvent.emit({message:s,errorCode:e,severity:i})},final:()=>{this.stepCompleteEvent.emit({response:t,formStep:P.legalAddress}),this.formLoading.emit(!1)}})},this.inputHandler=(s,t)=>{this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[s]:t}))}}propChanged(){this.initializeApi()}async validateAndSubmit({onSuccess:s}){this.formController.validateAndSubmit((()=>this.sendData(s)))}get patchPayload(){return{legal_address:new T(this.formController.values.getValue()).payload}}componentWillLoad(){this.initializeApi(),this.formController=new f((0,Q[this.country])(this.allowOptionalFields)),this.getData()}componentDidLoad(){this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))}initializeApi(){this.authToken&&this.businessId?(this.getBusiness=o({authToken:this.authToken,businessId:this.businessId,service:new d}),this.patchBusiness=a({authToken:this.authToken,businessId:this.businessId,service:new d})):this.errorEvent.emit({message:"Missing required props",errorCode:n.MISSING_PROPS,severity:r.ERROR})}render(){var s;const t=null===(s=this.formController)||void 0===s?void 0:s.getInitialValues();return this.isLoading?e(D,null):e("form",null,e("fieldset",null,e("div",{class:"d-flex align-items-center gap-2"},e("legend",{class:"mb-0",part:S},"Legal Address of your Business"),e("form-control-tooltip",{helpText:"No PO Boxes."})),e("hr",{class:"mt-2"}),e("justifi-form-address-fields",{country:this.country,errors:this.errors,defaultValues:t,inputHandler:this.inputHandler})))}static get watchers(){return{authToken:["propChanged"],businessId:["propChanged"]}}},ls=class{constructor(t){s(this,t)}get showPreviousStepButton(){return this.currentStep>0}get showNextStepButton(){return this.currentStep<this.totalSteps}get showSubmitButton(){return this.currentStep===this.totalSteps}render(){return e("div",{key:"53ba6c809e1968712b333f4bcf2798dbca186ddb",class:"d-flex gap-2"},e(X,{key:"b45c60083ccf6589cae0c63ce6b66c18da340dc7",variant:"secondary",type:"button",onClick:()=>this.previousStepButtonOnClick(),disabled:this.formDisabled,hidden:!this.showPreviousStepButton},"Previous"),e(X,{key:"27372798da0276de44d1563a4688486e7cc91d64",variant:"primary",type:"button",onClick:s=>this.nextStepButtonOnClick(s,V.nextStep),disabled:this.formDisabled,isLoading:this.formLoading,hidden:!this.showNextStepButton},"Next"),e(X,{key:"8bc14ca8fe951caf276f8ed03e502486e11acbe2",variant:"primary",type:"submit",onClick:s=>this.nextStepButtonOnClick(s,V.submit),disabled:this.formDisabled,isLoading:this.formLoading,hidden:!this.showSubmitButton},"Submit"))}},us=class{constructor(t){s(this,t),this.allowOptionalFields=!1,this.country=k.USA,this.componentStepMapping={0:()=>e("justifi-business-core-info-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[0]=s,allowOptionalFields:this.allowOptionalFields,country:this.country}),1:()=>e("justifi-legal-address-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[1]=s,allowOptionalFields:this.allowOptionalFields,country:this.country}),2:()=>e("justifi-additional-questions-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[2]=s,allowOptionalFields:this.allowOptionalFields}),3:()=>e("justifi-business-representative-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[3]=s,allowOptionalFields:this.allowOptionalFields,country:this.country}),4:()=>e("justifi-business-owners-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[4]=s,allowOptionalFields:this.allowOptionalFields,country:this.country}),5:()=>e("justifi-business-bank-account-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[5]=s,allowOptionalFields:this.allowOptionalFields,country:this.country}),6:()=>e("justifi-business-terms-conditions-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[6]=s,onFormLoading:this.handleFormLoading,allowOptionalFields:this.allowOptionalFields})}}get currentStepComponent(){return this.componentStepMapping[this.currentStep]()}render(){return e("div",{key:"ff7c9e688009383fdbe18c9824fa578d2338900c",class:"col-12 mb-4"},this.currentStepComponent)}};export{ss as justifi_additional_questions_form_step,ns as justifi_business_bank_account_form_step,os as justifi_business_core_info_form_step,as as justifi_business_owners_form_step,hs as justifi_business_representative_form_step,cs as justifi_business_terms_conditions_form_step,ds as justifi_legal_address_form_step,ls as justifi_payment_provisioning_form_buttons,us as justifi_payment_provisioning_form_steps}
1
+ import{r as s,c as t,h as e,H as i}from"./p-CV0Pyo1O.js";import{C as r,a as n}from"./p-Cjcsf8ku.js";import{m as o,b as a,f as h,g as c}from"./p-R0FDNhyd.js";import{B as l,a as d,D as u}from"./p-DqtDbB8E.js";import{a as m,c as p,b}from"./p-BovgIz83.js";import{F as f,c as v,a as y,b as g,d as w}from"./p-CKiAlBsU.js";import{A as _,C as k,e as j,R as C,f as T}from"./p-BcNb9bVO.js";import{C as O,P as x}from"./p-CVaOFfrI.js";import{J as S,am as I,$ as E,Y as L,aG as A}from"./p-C4FLe2pT.js";import{P as D}from"./p-C3kbpEIZ.js";import{b as B,c as H}from"./p-Bt4GjEWL.js";import{a as P,B as V}from"./p-XYgDHrVL.js";import"./p-DVJaoI_m.js";import"./p-HXpYMWUU.js";import{E as F,p as q,q as W}from"./p-BiNakvsa.js";import"./p-CLHwhyvu.js";import"./p-BH0Xfn-F.js";import{A as Y,B as M,v as N,C as U,D as z,E as R,F as G}from"./p-HT_4DkD0.js";import{B as X}from"./p-DFiTyYE9.js";import"./p-CZfYo5-1.js";import{c as J}from"./p-_-2E_vYf.js";import{d as $,e as Q}from"./p-D8EGHc_m.js";import{A as Z}from"./p-55QcjheA.js";import"./p-D2muobcE.js";import"./p-BFTU3MAI.js";import"./p-DqVU8ohH.js";import"./p-D8GTwl9v.js";import"./p-MeSAYDNh.js";class K{constructor(s){this.id=s.id,this.account_owner_name=s.account_owner_name,this.full_name=s.full_name,this.account_type=s.account_type,this.account_number=s.account_number,this.acct_last_four=s.acct_last_four,this.account_number_last4=s.account_number_last4,this.routing_number=s.routing_number,this.institution_number=s.institution_number,this.transit_number=s.transit_number,this.bank_name=s.bank_name,this.country=s.country,this.currency=s.currency,this.nickname=s.nickname,this.metadata=s.metadata,this.business_id=s.business_id,this.platform_account_id=s.platform_account_id,this.created_at=s.created_at,this.updated_at=s.updated_at}get payload(){return{account_owner_name:this.account_owner_name||"",account_type:this.account_type||"",account_number:this.account_number||"",routing_number:this.routing_number||"",institution_number:this.institution_number||"",transit_number:this.transit_number||"",bank_name:this.bank_name||"",nickname:this.nickname||"",business_id:this.business_id||""}}}const ss=class{constructor(e){s(this,e),this.errorEvent=t(this,"error-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.formLoading=t(this,"formLoading",7),this.errors={},this.additional_questions={},this.recurringPayments=!1,this.isLoading=!1,this.getData=()=>{this.formLoading.emit(!0),this.isLoading=!0,this.getBusiness({onSuccess:s=>{this.additional_questions=new _(s.data.additional_questions||{}),this.formController.setInitialValues(Object.assign({},this.additional_questions))},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.formLoading.emit(!1),this.isLoading=!1}})},this.sendData=s=>{let t;this.formLoading.emit(!0),this.patchBusiness({payload:this.patchPayload,onSuccess:e=>{t=e,s()},onError:({error:s,code:e,severity:i})=>{t=s,this.errorEvent.emit({message:s,errorCode:e,severity:i})},final:()=>{this.stepCompleteEvent.emit({response:t,formStep:P.additionalQuestions}),this.formLoading.emit(!1)}})},this.inputHandler=(s,t)=>{this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[s]:t})),this.additional_questions=new _(Object.assign(Object.assign({},this.formController.values.getValue()),{[s]:t}))}}propChanged(){this.initializeApi()}recurringPaymentsWatcher(s){this.recurringPayments="Yes"===(null==s?void 0:s.business_recurring_payments)}async validateAndSubmit({onSuccess:s}){this.formController.validateAndSubmit((()=>this.sendData(s)))}get patchPayload(){return{additional_questions:new _(this.formController.values.getValue()).payload}}componentWillLoad(){this.initializeApi(),this.formController=new f(m(this.allowOptionalFields))}componentDidLoad(){this.getBusiness&&this.getData(),this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))}initializeApi(){this.authToken&&this.businessId?(this.getBusiness=o({authToken:this.authToken,businessId:this.businessId,service:new l}),this.patchBusiness=a({authToken:this.authToken,businessId:this.businessId,service:new l})):this.errorEvent.emit({message:"Missing required props",errorCode:n.MISSING_PROPS,severity:r.ERROR})}render(){var s,t,i,r,n;const o=this.formController.getInitialValues();return this.isLoading?e(D,null):e("form",null,e("fieldset",null,e("div",{class:"d-flex align-items-center gap-2"},e("legend",{class:"mb-0",part:S},"Additional Questions"),e("form-control-tooltip",{helpText:"This information helps us understand the business and identify and monitor trends to safeguard you and your customers."})),e("hr",{class:"mt-2"}),e("div",{class:"row gy-3"},e("div",{class:"col-12 col-md-6"},e("form-control-monetary-provisioning",{name:"business_revenue",label:"What is your business' estimated annual revenue from its primary business activities?",inputHandler:this.inputHandler,errorText:null===(s=this.errors)||void 0===s?void 0:s.business_revenue,defaultValue:null==o?void 0:o.business_revenue,maskOptions:O.WHOLE})),e("div",{class:"col-12 col-md-6"},e("form-control-monetary-provisioning",{name:"business_payment_volume",label:"What is your business' annual credit card & ACH volume anticipated to process?",inputHandler:this.inputHandler,errorText:null===(t=this.errors)||void 0===t?void 0:t.business_payment_volume,defaultValue:null==o?void 0:o.business_payment_volume,maskOptions:O.WHOLE})),e("div",{class:"col-12"},e("form-control-text",{name:"business_average_transaction_amount",label:"What is your average transaction size?",inputHandler:this.inputHandler,errorText:null===(i=this.errors)||void 0===i?void 0:i.business_average_transaction_amount,defaultValue:null==o?void 0:o.business_average_transaction_amount})),e("div",{class:"col-12"},e("form-control-select",{name:"business_when_service_received",label:"On average, how long after paying will your customers typically receive their goods or services?",inputHandler:this.inputHandler,errorText:null===(r=this.errors)||void 0===r?void 0:r.business_when_service_received,options:B,defaultValue:null==o?void 0:o.business_when_service_received})),e("div",{class:"col-12"},e("form-control-text",{name:"business_other_payment_details",label:"Is there anything else you would like us to know about how your customers pay the business? (optional)",inputHandler:this.inputHandler,errorText:null===(n=this.errors)||void 0===n?void 0:n.business_other_payment_details,defaultValue:null==o?void 0:o.business_other_payment_details})))))}static get watchers(){return{authToken:["propChanged"],businessId:["propChanged"],additional_questions:["recurringPaymentsWatcher"]}}},ts=(s,t)=>s.some((s=>s.document_type===t)),es=s=>s?{bank_name:z.nullable(),nickname:U.nullable(),account_owner_name:N.nullable(),account_type:M.nullable(),account_number:Y.nullable()}:{bank_name:z.required("Enter bank name"),nickname:U.required("Enter nickname"),account_owner_name:N.required("Enter account owner name"),account_type:M.required("Select account type"),account_number:Y.required("Enter account number")},is=(s,t)=>{if(t)return{voided_check:g().nullable(),bank_statement:g().nullable()};const e=ts(s,F.voidedCheck),i=ts(s,F.bankStatement),r=e||i,n="Please upload either a voided check or a bank statement. Only one is required.";return{voided_check:g().when("bank_statement",{is:s=>!s&&!r,then:s=>s.required(n),otherwise:s=>s.notRequired()}),bank_statement:g().when("voided_check",{is:s=>!s&&!r,then:s=>s.required(n),otherwise:s=>s.notRequired()})}},rs={[k.USA]:(s,t=[])=>((s,t)=>{const e=Object.assign(Object.assign(Object.assign({},es(t)),(s=>s?{routing_number:G.nullable()}:{routing_number:G.required("Enter routing number")})(t)),is(s,t));return v().shape(e,[["voided_check","bank_statement"]])})(t,s),[k.CAN]:(s,t=[])=>((s,t)=>{const e=Object.assign(Object.assign(Object.assign({},es(t)),(s=>{const t=y().length(3,"Institution number must be 3 digits").matches(R,"Enter valid institution number"),e=y().length(5,"Transit number must be 5 digits").matches(R,"Enter valid transit number");return s?{institution_number:t.nullable(),transit_number:e.nullable()}:{institution_number:t.required("Enter institution number"),transit_number:e.required("Enter transit number")}})(t)),is(s,t));return v().shape(e,[["voided_check","bank_statement"]])})(t,s)},ns=class{constructor(e){s(this,e),this.errorEvent=t(this,"error-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.formLoading=t(this,"formLoading",7),this.errors={},this.bankAccount={},this.existingDocuments=[],this.documentData=new q,this.isLoading=!1,this.isAddingNewBankAccount=!0,this.bankAccountVerification=!1,this.platformAccountId=null,this.getSchema=()=>(0,rs[this.country])(this.allowOptionalFields,this.existingDocuments),this.initializeFormController=()=>{this.formController=new f(this.getSchema()),this.formController.setInitialValues(this.isAddingNewBankAccount?{business_id:this.businessId}:Object.assign({},this.bankAccount)),this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))},this.inputHandler=(s,t)=>{this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[s]:t}))},this.storeFiles=s=>{const t=Array.from(s.detail.fileList),e=s.detail.document_type,i=t.map((s=>new W({file:s,document_type:e},this.businessId)));this.documentData[e]=i},this.getData=()=>{this.isLoading=!0,this.getBusiness({onSuccess:s=>{if(s.data.bank_accounts.length>0){const t=s.data.bank_accounts;this.bankAccount=new K(t[t.length-1]),this.isAddingNewBankAccount=!1}else this.bankAccount=new K({}),this.bankAccount.business_id=this.businessId;this.existingDocuments=s.data.documents,this.bankAccountVerification=!0===s.data.settings.bank_account_verification,this.platformAccountId=s.data.platform_account_id},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.initializeFormController(),this.isLoading=!1}})},this.handleChangeBankAccount=()=>{this.isAddingNewBankAccount=!0,this.documentData=new q,this.initializeFormController()},this.handleCancel=()=>{this.isAddingNewBankAccount=!1,this.documentData=new q,this.initializeFormController()},this.handleSaveBankAccount=async()=>{this.formController.validateAndSubmit((()=>{this.sendData((()=>{}))}))},this.postDocumentRecordData=async s=>{this.isLoading=!0;const t=s.record_data;return new Promise((e=>{this.postDocumentRecord({payload:t,onSuccess:t=>{e(this.handleDocRecordResponse(s,t))},onError:({error:s,code:t,severity:i})=>{this.errorEvent.emit({message:s,errorCode:t,severity:i}),e(!1)}})}))},this.handleDocRecordResponse=(s,t)=>t.error?(this.errorEvent.emit({errorCode:n.POST_ERROR,message:t.error.message,severity:r.ERROR,data:t.error}),!1):(s.setPresignedUrl(t.data.presigned_url),!0),this.uploadDocument=async s=>{if(!s.presigned_url)throw new Error("Presigned URL is not set");const t=await s.getFileData(),e=await fetch(s.presigned_url,{method:"PUT",body:t});return this.handleUploadResponse(e)},this.handleUploadResponse=s=>!s.error||(this.errorEvent.emit({errorCode:n.POST_ERROR,message:s.error.message,severity:r.ERROR,data:s.error}),!1)}propChanged(){this.initializeApi()}watchHandler(s){this.formLoading.emit(s)}async validateAndSubmit({onSuccess:s}){this.existingBankAccount&&!this.isAddingNewBankAccount?this.sendData(s):this.formController.validateAndSubmit((()=>this.sendData(s)))}componentWillLoad(){this.initializeApi(),this.getBusiness&&this.getData(),this.formController=new f(this.getSchema())}componentDidLoad(){this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))}initializeApi(){this.authToken&&this.businessId?(this.getBusiness=o({authToken:this.authToken,businessId:this.businessId,service:new l}),this.postBankAccount=h({authToken:this.authToken,service:new d}),this.postDocumentRecord=c({authToken:this.authToken,service:new u})):this.errorEvent.emit({message:"Missing required props",errorCode:n.MISSING_PROPS,severity:r.ERROR})}get postPayload(){const s=this.formController.values.getValue();return new K(s).payload}get existingBankAccount(){var s;return!!(null===(s=this.bankAccount)||void 0===s?void 0:s.id)}get showReadOnlyView(){return this.existingBankAccount&&!this.isAddingNewBankAccount}async sendData(s){try{if(this.isAddingNewBankAccount&&!await this.postBankAccountData())return;if(!await this.postBusinessDocuments())return;this.isAddingNewBankAccount&&(this.isAddingNewBankAccount=!1,await this.refreshBankAccountData()),s()}catch(s){this.errorEvent.emit({message:s,errorCode:n.POST_ERROR,severity:r.ERROR})}}async postBankAccountData(){let s;return this.isLoading=!0,new Promise((t=>{let e=!1;this.postBankAccount({payload:this.postPayload,onSuccess:t=>{s=t,e=!0},onError:({error:s,code:t,severity:i})=>{e=!1,this.errorEvent.emit({message:s,errorCode:t,severity:i})},final:()=>{this.stepCompleteEvent.emit({response:s,formStep:P.bankAccount}),this.isLoading=!1,t(e)}})}))}async refreshBankAccountData(){return new Promise((s=>{this.isLoading=!0,this.getBusiness({onSuccess:s=>{const{data:t}=s,{bank_accounts:e,documents:i,settings:r,platform_account_id:n}=t;e.length>0&&(this.bankAccount=new K(e[e.length-1])),this.existingDocuments=i,this.bankAccountVerification=!0===r.bank_account_verification,this.platformAccountId=n,this.initializeFormController()},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.isLoading=!1,s()}})}))}async postBusinessDocuments(){this.isLoading=!0;try{const s=Object.values(this.documentData).flat();return!s.length||!(await Promise.all(s.map((s=>this.postDocumentRecordData(s))))).includes(!1)&&!(await Promise.all(s.map((s=>this.uploadDocument(s))))).includes(!1)}finally{this.isLoading=!1}}render(){const s=this.formController.getInitialValues(),t=this.bankAccountVerification&&this.platformAccountId;return this.isLoading?e(D,null):e("form",null,e("fieldset",{class:"mb-4"},e("div",{class:"d-flex align-items-center gap-2"},e("legend",{class:"mb-0",part:S},"Bank Account Info"),e("form-control-tooltip",{helpText:"This direct deposit account is the designated bank account where incoming funds will be deposited. The name of this account must match the registered business name exactly. We are not able to accept personal accounts unless your business is a registered sole proprietorship."})),e("hr",{class:"mt-2"}),t&&e("div",{class:"mt-3"},e("plaid-verification",{authToken:this.authToken,accountId:this.platformAccountId,businessId:this.businessId,onPlaidVerificationSuccess:()=>{this.isAddingNewBankAccount=!1,this.refreshBankAccountData()}})),e(this.country===k.CAN?"bank-account-form-inputs-canada":"bank-account-form-inputs",{defaultValue:s,errors:this.errors,inputHandler:this.inputHandler,formDisabled:this.showReadOnlyView}),this.showReadOnlyView&&e("div",{class:"mt-3"},e(X,{variant:"secondary",type:"button",onClick:this.handleChangeBankAccount,disabled:this.isLoading,part:I},"Change Bank Account")),(!this.existingBankAccount||this.isAddingNewBankAccount)&&e("div",{class:"mt-3 d-flex gap-2"},this.isAddingNewBankAccount&&e(X,{variant:"secondary",type:"button",onClick:this.handleCancel,disabled:this.isLoading,part:I},"Cancel"),e(X,{variant:"primary",type:"button",onClick:this.handleSaveBankAccount,disabled:this.isLoading,isLoading:this.isLoading},"Save Bank Account"))),e("fieldset",{class:"mt-4"},e("div",{class:"d-flex align-items-center gap-2"},e("legend",{class:"mb-0",part:S},"Document Uploads"),e("form-control-tooltip",{helpText:"One document (voided check or bank statement) is required for underwriting purposes. It needs to visibly show the name tied to the account and the account number. Various file formats such as PDF, DOC, DOCX, JPEG are accepted. Multiple files can be uploaded for each document category."})),e("hr",{class:"mt-2"}),e("business-documents-on-file",{documents:this.existingDocuments,isLoading:this.isLoading}),e("bank-account-document-form-inputs",{inputHandler:this.inputHandler,errors:this.errors,storeFiles:this.storeFiles})))}static get watchers(){return{authToken:["propChanged"],businessId:["propChanged"],isLoading:["watchHandler"]}}},os=class{constructor(e){s(this,e),this.errorEvent=t(this,"error-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.formLoading=t(this,"formLoading",7),this.errors={},this.coreInfo={},this.isLoading=!1,this.isEditingTaxId=!1,this.getData=()=>{this.getBusiness&&(this.formLoading.emit(!0),this.isLoading=!0,this.getBusiness({onSuccess:s=>{this.coreInfo=new j(s.data),this.formController.setInitialValues(Object.assign({},this.coreInfo))},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.formLoading.emit(!1),this.isLoading=!1}}))},this.sendData=s=>{let t;this.formLoading.emit(!0),this.patchBusiness({payload:this.patchPayload,onSuccess:e=>{t=e,s(),this.isEditingTaxId=!1},onError:({error:s,code:e,severity:i,rawError:r})=>{t=s,r&&"object"==typeof r&&r.param&&this.formController.setFieldError(r.param,r.message),this.errorEvent.emit({message:s,errorCode:e,severity:i})},final:()=>{this.stepCompleteEvent.emit({response:t,formStep:P.businessInfo}),this.formLoading.emit(!1)}})},this.inputHandler=(s,t)=>{this.errors[s]&&this.formController.clearFieldError(s),this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[s]:t}))}}propChanged(){this.initializeApi()}async validateAndSubmit({onSuccess:s}){this.formController.validateAndSubmit((()=>this.sendData(s)))}get patchPayload(){return new j(this.formController.values.getValue()).payload}componentWillLoad(){this.initializeApi();const s=this.country===k.CAN?p(this.allowOptionalFields):b(this.allowOptionalFields);this.formController=new f(s),this.getData()}componentDidLoad(){this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))}initializeApi(){this.authToken&&this.businessId?(this.getBusiness=o({authToken:this.authToken,businessId:this.businessId,service:new l}),this.patchBusiness=a({authToken:this.authToken,businessId:this.businessId,service:new l})):this.errorEvent.emit({message:"Missing required props",errorCode:n.MISSING_PROPS,severity:r.ERROR})}render(){var s,t;const i=this.formController.getInitialValues();return this.isLoading?e(D,null):e("form",null,e("fieldset",null,e("div",{class:"d-flex align-items-center gap-2"},e("legend",{class:"mb-0",part:S},"Business Information")),e("hr",{class:"mt-2"}),e("div",{class:"row gy-3"},e("div",{class:"col-12"},e("form-control-text",{name:"legal_name",label:"Business Name",defaultValue:i.legal_name,errorText:this.errors.legal_name,inputHandler:this.inputHandler,helpText:"Enter this exactly as it appears on your tax records (don't use acronyms or abbreviations unless you registered that way)."})),e("div",{class:"col-12"},e("form-control-text",{name:"doing_business_as",label:"Doing Business As (DBA)",defaultValue:i.doing_business_as,errorText:this.errors.doing_business_as,inputHandler:this.inputHandler,helpText:"Enter this exactly as it appears on your tax records (leave blank if you don't have a registered DBA/trade name)"})),e("div",{class:"col-12 col-md-8"},e("form-control-select",{name:"classification",label:"Business Classification",options:H,defaultValue:i.classification,errorText:this.errors.classification,inputHandler:this.inputHandler})),e("div",{class:"col-12 col-md-4"},e("form-control-date",{name:"date_of_incorporation",label:"Date of Registration",defaultValue:i.date_of_incorporation,errorText:this.errors.date_of_incorporation,inputHandler:this.inputHandler})),e("div",{class:"col-12 col-md-6"},e("form-control-text",{name:"industry",label:"Industry",defaultValue:i.industry,errorText:this.errors.industry,inputHandler:this.inputHandler,helpText:"Describe what you sell"})),e("div",{class:"col-12 col-md-6"},!(null===(s=this.coreInfo)||void 0===s?void 0:s.tax_id_last4)||this.isEditingTaxId?e("form-control-number-masked",{name:"tax_id",label:J[this.country].taxIdLabel,defaultValue:this.isEditingTaxId?"":i.tax_id,errorText:this.errors.tax_id,inputHandler:this.inputHandler,mask:"000000000",helpText:J[this.country].taxIdHelpText}):e("div",null,e("label",{class:"form-label",part:E},J[this.country].taxIdLabel),e("div",{class:"input-group mb-3"},e("input",{type:"text",class:"form-control",part:L,value:`****${null===(t=this.coreInfo)||void 0===t?void 0:t.tax_id_last4}`,disabled:!0}),e("button",{class:"btn btn-secondary",type:"button",part:I,onClick:()=>{this.isEditingTaxId=!0,this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{tax_id:"",tax_id_last4:null}))}},"Change")))),e("div",{class:"col-12"},e("form-control-text",{name:"website_url",label:"Business Website URL",defaultValue:i.website_url,errorText:this.errors.website_url,inputHandler:this.inputHandler,helpText:"Don't have a live website? You can use your social media business page, app store link, or staging site URL."})),e("div",{class:"col-12 col-md-6"},e("form-control-text",{name:"email",label:"Business Email Address",defaultValue:i.email,errorText:this.errors.email,inputHandler:this.inputHandler})),e("div",{class:"col-12 col-md-6"},e("form-control-number-masked",{name:"phone",label:"Business Phone Number",defaultValue:i.phone,errorText:this.errors.phone,inputHandler:this.inputHandler,mask:x.US})))))}static get watchers(){return{authToken:["propChanged"],businessId:["propChanged"]}}},as=class{constructor(e){s(this,e),this.clickEvent=t(this,"click-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.errorEvent=t(this,"error-event",7),this.formLoading=t(this,"formLoading",7),this.ownersPayload=[],this.refs=[],this.isLoading=!1,this.representativeIsOwner=null,this.matchRef=(s,t)=>{if(null===s)return;const e=this.ownersPayload.findIndex((s=>s.id===t));-1!==e&&(this.refs.length!==this.ownersPayload.length&&this.manageRefs(),this.refs[e]=s)},this.getData=()=>{this.formLoading.emit(!0),this.isLoading=!0,this.getBusiness({onSuccess:s=>{this.representative=new C(s.data.representative||{}),s.data.owners.length?this.ownersPayload=s.data.owners.map((s=>({id:s.id}))):this.addOwnerForm()},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.formLoading.emit(!1),this.isLoading=!1,this.manageRefs()}})},this.sendData=async s=>{let t;this.formLoading.emit(!0),this.patchBusiness({payload:{owners:this.ownersPayload},onSuccess:e=>{t=e,s()},onError:({error:s,code:e,severity:i})=>{t=s,this.errorEvent.emit({message:s,errorCode:e,severity:i})},final:()=>{this.stepCompleteEvent.emit({response:t,formStep:P.owners}),this.formLoading.emit(!1)}})},this.addOwnerForm=s=>{this.newFormOpen=!0,this.ownersPayload=[...this.ownersPayload,{id:""}],s&&this.clickEvent.emit({name:V.addOwnerForm})},this.removeOwnerForm=s=>{this.ownersPayload=this.ownersPayload.filter((t=>t.id!==s)),this.newFormOpen&&(this.newFormOpen=!1)},this.handleRepresentativeIsOwnerChange=s=>{this.representativeIsOwner=s,this.representativeIsOwner&&(this.formLoading.emit(!0),this.isLoading=!0,this.ownersPayload=this.ownersPayload.filter((s=>""!==s.id)),this.patchBusiness({payload:{owners:[{id:this.representative.id},...this.ownersPayload]},onSuccess:()=>{this.getData(),this.newFormOpen=!1},finally:()=>{this.isLoading=!1,this.formLoading.emit(!1)}}))}}propChanged(){this.initializeApi()}get showAddOwnerButton(){return this.ownersPayload.length<4&&!this.newFormOpen}manageRefs(){this.refs=this.ownersPayload.map((s=>s.id))}async validateAndSubmit({onSuccess:s}){const t=this.refs.map((s=>s.validate()));if(!(await Promise.all(t)).every((s=>s)))return;const e=this.refs.map((s=>s.submit()));(await Promise.all(e)).every((s=>s))&&this.sendData(s)}componentWillLoad(){this.initializeApi(),this.getBusiness&&this.getData()}initializeApi(){this.authToken&&this.businessId?(this.getBusiness=o({authToken:this.authToken,businessId:this.businessId,service:new l}),this.patchBusiness=a({authToken:this.authToken,businessId:this.businessId,service:new l})):this.errorEvent.emit({message:"Missing required props",errorCode:n.MISSING_PROPS,severity:r.ERROR})}ownersWatcher(){this.manageRefs()}handleOwnerSubmit(s){const t=s.detail,e=this.ownersPayload.map((s=>s.id===t.id?t:s));e.includes(t)||(e[this.ownersPayload.findIndex((s=>!s.id))]=t,this.newFormOpen&&(this.newFormOpen=!1)),this.ownersPayload=e}render(){if(this.isLoading)return e(i,null,e(D,null));const s=this.ownersPayload.some((s=>s.id===this.representative.id)),t=null===this.representativeIsOwner&&!s;return e(i,null,e("div",null,e("div",{class:"d-flex align-items-center gap-2"},e("legend",{class:"mb-0",part:S},"Owners"),e("form-control-tooltip",{helpText:"For partnerships, LLCs or privately held corporations, the business is required to apply with all individuals with 25% or more ownership to the application. For charities and registered non-profits, the business is required to apply with 1 individual with substantial control over the entity, such as a board member or director."})),e("hr",{class:"mt-2"}),t&&e("div",{class:"alert alert-warning mb-3",part:A},e("div",{class:"card-body"},e("div",{class:"d-flex align-items-center mb-3"},e("strong",null,"Is the representative of this business also an owner?")),e("div",{class:"d-flex gap-2"},e(X,{variant:"primary",onClick:()=>this.handleRepresentativeIsOwnerChange(!0)},"Yes"),e(X,{variant:"secondary",onClick:()=>this.handleRepresentativeIsOwnerChange(!1)},"No")))),e("div",{class:"row gy-3"},this.ownersPayload.map((s=>e("justifi-owner-form",{key:s.id,authToken:this.authToken,businessId:this.businessId,ownerId:s.id,removeOwner:this.removeOwnerForm,newFormOpen:this.newFormOpen,ownersLength:this.ownersPayload.length,country:this.country,allowOptionalFields:this.allowOptionalFields,ref:t=>this.matchRef(t,s.id)})))),e("div",{class:"d-flex justify-content-start"},e("div",{class:"gap-2"},e(X,{variant:"primary",onClick:()=>this.addOwnerForm(!0),hidden:!this.showAddOwnerButton},"Add Owner")))))}static get watchers(){return{authToken:["propChanged"],businessId:["propChanged"],ownersPayload:["ownersWatcher"]}}},hs=class{constructor(e){s(this,e),this.errorEvent=t(this,"error-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.formLoading=t(this,"formLoading",7),this.errors={},this.representative={},this.isLoading=!1,this.getData=()=>{this.getBusiness&&this.formController&&(this.formLoading.emit(!0),this.isLoading=!0,this.getBusiness({onSuccess:s=>{this.representative=new C(s.data.representative||{}),this.representative.address.country=this.country,this.formController.setInitialValues(Object.assign({},this.representative))},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.formLoading.emit(!1),this.isLoading=!1}}))},this.sendData=s=>{let t;this.formLoading.emit(!0),this.patchBusiness({payload:this.patchPayload,onSuccess:e=>{t=e,s()},onError:({error:s,code:e,severity:i})=>{t=s,this.errorEvent.emit({message:s,errorCode:e,severity:i})},final:()=>{this.stepCompleteEvent.emit({response:t,formStep:P.representative}),this.formLoading.emit(!1)}})}}propChanged(){this.initializeApi(),this.getData()}async validateAndSubmit({onSuccess:s}){this.formController.validateAndSubmit((()=>this.sendData(s)))}componentWillLoad(){this.initializeApi(),this.initializeForm()}initializeApi(){this.authToken&&this.businessId?(this.getBusiness=o({authToken:this.authToken,businessId:this.businessId,service:new l}),this.patchBusiness=a({authToken:this.authToken,businessId:this.businessId,service:new l})):this.errorEvent.emit({message:"Missing required props",errorCode:n.MISSING_PROPS,severity:r.ERROR})}initializeForm(){const s=$[this.country];s?(this.formController=new f(s("representative",this.allowOptionalFields)),this.getData()):this.errorEvent.emit({message:"Missing schema for selected country",errorCode:n.MISSING_PROPS,severity:r.ERROR})}componentDidLoad(){this.formController&&this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))}get patchPayload(){return{representative:new C(this.formController.values.getValue()).payload}}render(){return!this.formController||this.isLoading?e(D,null):e("justifi-business-representative-form-inputs",{representativeDefaultValue:this.formController.getInitialValues(),errors:this.errors,formController:this.formController,country:this.country})}static get watchers(){return{authToken:["propChanged"],businessId:["propChanged"]}}},cs=class{constructor(e){s(this,e),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.errorEvent=t(this,"error-event",7),this.formLoading=t(this,"formLoading",7),this.formCompleted=t(this,"formCompleted",7),this.errors={},this.fetchData=async()=>{this.formLoading.emit(!0);try{const s=await this.api.get({endpoint:this.businessEndpoint,authToken:this.authToken});this.acceptedTermsBefore=s.data.terms_conditions_accepted}catch(s){this.errorEvent.emit({errorCode:n.FETCH_ERROR,message:s.message,severity:r.ERROR,data:s})}finally{this.formLoading.emit(!1)}},this.sendData=async s=>{this.formLoading.emit(!0);try{const t=this.termsPayload,e=await this.api.post({endpoint:this.termsConditionsEndpoint,body:t,authToken:this.authToken});this.handleResponse(e,s)}catch(s){this.errorEvent.emit({errorCode:n.POST_ERROR,message:s.message,severity:r.ERROR,data:s})}finally{this.formLoading.emit(!1)}},this.inputHandler=(s,t)=>{this.acceptedTerms=t,this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[s]:t}))}}get businessEndpoint(){return`entities/business/${this.businessId}`}get termsConditionsEndpoint(){return"entities/terms_and_conditions"}get formHelperText(){return this.acceptedTermsBefore?"You have already accepted the terms and conditions.":null}get termsPayload(){return{business_id:this.businessId,accepted:this.formController.values.getValue().accepted,user_agent:window.navigator.userAgent}}async componentWillLoad(){this.api=Z(),this.formController=new f((s=>{const t=v({accepted:w().oneOf([!0],"You must agree to the terms and conditions to continue").required("You must agree to the terms and conditions to continue")}),e=v({accepted:w().nullable()});return s?e:t})(this.allowOptionalFields)),this.businessId&&this.authToken&&this.fetchData()}handleResponse(s,t){s.error?this.errorEvent.emit({errorCode:n.POST_ERROR,message:s.error.message,severity:r.ERROR,data:s.error}):t(),this.stepCompleteEvent.emit({response:s,formStep:P.termsAndConditions}),this.formCompleted.emit()}async validateAndSubmit({onSuccess:s}){this.acceptedTermsBefore?(this.stepCompleteEvent.emit({response:null,formStep:P.termsAndConditions,metadata:"no data submitted"}),this.formCompleted.emit(),s()):this.formController.validateAndSubmit((()=>this.sendData(s)))}componentDidLoad(){this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))}get merchantAgreementLink(){return e("a",{href:"https://justifi.tech/merchant-agreement/",target:"_blank",rel:"noopener noreferrer"},"merchant agreement")}render(){return e("form",{key:"33336d0a66d63ce39951822fd570a9a0689e714d"},e("fieldset",{key:"fcfdb59eef671cb408ed99e2dad20d6be706688a"},e("legend",{key:"f0cf7f0ac15c90cf36ee25d4bf986c0e781a2e92",part:S},"Terms and Conditions"),e("hr",{key:"d5c820e7d6523f931040a994bd103d69fd644c45"}),e("div",{key:"681b584de14afe121f5dc69ee0bad1cab51ba0d1"},e("p",{key:"7c597bf891a108d303739126b806ded5220f56ab"},"Please read and accept the ",this.merchantAgreementLink," to submit your provisioning request.")),e("br",{key:"52854c5a07611180be40df21a5f60d7d9d4c4cb7"}),e("div",{key:"7448b3f6138b996edac137b961367725e3b40556",class:"row-gy-3"},e("div",{key:"c732deb4e1e3a2d04dd4e09914543a7f594af108",class:"col-12"},e("form-control-checkbox",{key:"fca18e4843aef20d13790029b114b2ecaeb6ffa2",name:"accepted",label:"I agree to the terms and conditions",inputHandler:this.inputHandler,errorText:this.errors.accepted,disabled:this.acceptedTermsBefore,helpText:this.formHelperText,checked:this.acceptedTerms})))))}},ls=class{constructor(e){s(this,e),this.errorEvent=t(this,"error-event",7),this.stepCompleteEvent=t(this,"complete-form-step-event",7),this.formLoading=t(this,"formLoading",7),this.errors={},this.legal_address={},this.isLoading=!1,this.getData=()=>{this.getBusiness&&(this.formLoading.emit(!0),this.isLoading=!0,this.getBusiness({onSuccess:s=>{const t=new T((s.data||{}).legal_address||{});this.legal_address=Object.assign(Object.assign({},t),{country:this.country}),this.formController.setInitialValues(Object.assign({},this.legal_address))},onError:({error:s,code:t,severity:e})=>{this.errorEvent.emit({message:s,errorCode:t,severity:e})},final:()=>{this.formLoading.emit(!1),this.isLoading=!1}}))},this.sendData=s=>{let t;this.formLoading.emit(!0),this.patchBusiness({payload:this.patchPayload,onSuccess:e=>{t=e,s()},onError:({error:s,code:e,severity:i})=>{t=s,this.errorEvent.emit({message:s,errorCode:e,severity:i})},final:()=>{this.stepCompleteEvent.emit({response:t,formStep:P.legalAddress}),this.formLoading.emit(!1)}})},this.inputHandler=(s,t)=>{this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[s]:t}))}}propChanged(){this.initializeApi()}async validateAndSubmit({onSuccess:s}){this.formController.validateAndSubmit((()=>this.sendData(s)))}get patchPayload(){return{legal_address:new T(this.formController.values.getValue()).payload}}componentWillLoad(){this.initializeApi(),this.formController=new f((0,Q[this.country])(this.allowOptionalFields)),this.getData()}componentDidLoad(){this.formController.errors.subscribe((s=>{this.errors=Object.assign({},s)}))}initializeApi(){this.authToken&&this.businessId?(this.getBusiness=o({authToken:this.authToken,businessId:this.businessId,service:new l}),this.patchBusiness=a({authToken:this.authToken,businessId:this.businessId,service:new l})):this.errorEvent.emit({message:"Missing required props",errorCode:n.MISSING_PROPS,severity:r.ERROR})}render(){var s;const t=null===(s=this.formController)||void 0===s?void 0:s.getInitialValues();return this.isLoading?e(D,null):e("form",null,e("fieldset",null,e("div",{class:"d-flex align-items-center gap-2"},e("legend",{class:"mb-0",part:S},"Legal Address of your Business"),e("form-control-tooltip",{helpText:"No PO Boxes."})),e("hr",{class:"mt-2"}),e("justifi-form-address-fields",{country:this.country,errors:this.errors,defaultValues:t,inputHandler:this.inputHandler})))}static get watchers(){return{authToken:["propChanged"],businessId:["propChanged"]}}},ds=class{constructor(t){s(this,t)}get showPreviousStepButton(){return this.currentStep>0}get showNextStepButton(){return this.currentStep<this.totalSteps}get showSubmitButton(){return this.currentStep===this.totalSteps}render(){return e("div",{key:"53ba6c809e1968712b333f4bcf2798dbca186ddb",class:"d-flex gap-2"},e(X,{key:"b45c60083ccf6589cae0c63ce6b66c18da340dc7",variant:"secondary",type:"button",onClick:()=>this.previousStepButtonOnClick(),disabled:this.formDisabled,hidden:!this.showPreviousStepButton},"Previous"),e(X,{key:"27372798da0276de44d1563a4688486e7cc91d64",variant:"primary",type:"button",onClick:s=>this.nextStepButtonOnClick(s,V.nextStep),disabled:this.formDisabled,isLoading:this.formLoading,hidden:!this.showNextStepButton},"Next"),e(X,{key:"8bc14ca8fe951caf276f8ed03e502486e11acbe2",variant:"primary",type:"submit",onClick:s=>this.nextStepButtonOnClick(s,V.submit),disabled:this.formDisabled,isLoading:this.formLoading,hidden:!this.showSubmitButton},"Submit"))}},us=class{constructor(t){s(this,t),this.allowOptionalFields=!1,this.country=k.USA,this.componentStepMapping={0:()=>e("justifi-business-core-info-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[0]=s,allowOptionalFields:this.allowOptionalFields,country:this.country}),1:()=>e("justifi-legal-address-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[1]=s,allowOptionalFields:this.allowOptionalFields,country:this.country}),2:()=>e("justifi-additional-questions-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[2]=s,allowOptionalFields:this.allowOptionalFields}),3:()=>e("justifi-business-representative-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[3]=s,allowOptionalFields:this.allowOptionalFields,country:this.country}),4:()=>e("justifi-business-owners-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[4]=s,allowOptionalFields:this.allowOptionalFields,country:this.country}),5:()=>e("justifi-business-bank-account-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[5]=s,allowOptionalFields:this.allowOptionalFields,country:this.country}),6:()=>e("justifi-business-terms-conditions-form-step",{businessId:this.businessId,authToken:this.authToken,ref:s=>this.refs[6]=s,onFormLoading:this.handleFormLoading,allowOptionalFields:this.allowOptionalFields})}}get currentStepComponent(){return this.componentStepMapping[this.currentStep]()}render(){return e("div",{key:"ff7c9e688009383fdbe18c9824fa578d2338900c",class:"col-12 mb-4"},this.currentStepComponent)}};export{ss as justifi_additional_questions_form_step,ns as justifi_business_bank_account_form_step,os as justifi_business_core_info_form_step,as as justifi_business_owners_form_step,hs as justifi_business_representative_form_step,cs as justifi_business_terms_conditions_form_step,ls as justifi_legal_address_form_step,ds as justifi_payment_provisioning_form_buttons,us as justifi_payment_provisioning_form_steps}
@@ -1 +1 @@
1
- import{r as t,c as s,h as i}from"./p-CV0Pyo1O.js";import{P as o}from"./p-8Wa_-5QM.js";import"./p-DVJaoI_m.js";import"./p-HXpYMWUU.js";import{C as r,a as e}from"./p-Cjcsf8ku.js";import{e as a}from"./p-BiNakvsa.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-BH0Xfn-F.js";import{g as p,a as h}from"./p-D2muobcE.js";import{E as n}from"./p-DAZtHA62.js";import{c,J as m}from"./p-CbTf_N6u.js";import{m as d}from"./p-DYGIC0QH.js";import"./p-55QcjheA.js";import"./p-MeSAYDNh.js";import"./p-D8GTwl9v.js";import"./p-C4FLe2pT.js";import"./p-D4eE0MBI.js";const u=class{constructor(i){t(this,i),this.errorEvent=s(this,"error-event",7),this.enableRecordClick=!1,this.errorMessage=null,this.handleErrorEvent=t=>{this.errorMessage=t.detail.message,this.errorEvent.emit(t.detail)}}componentWillLoad(){c(),this.analytics=new m(this),this.initializeServices()}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}propChanged(){this.initializeServices()}initializeServices(){this.payoutId&&this.authToken?(this.getPayout=(({id:t,authToken:s,service:i})=>async({onSuccess:o,onError:e})=>{var n;try{const c=await i.fetchPayout(t,s);c.error?e({error:h(c.error),code:p(null===(n=c.error)||void 0===n?void 0:n.code),severity:r.ERROR}):o(new a(c.data))}catch(t){e({error:h(t),code:p(null==t?void 0:t.code),severity:r.ERROR})}})({id:this.payoutId,authToken:this.authToken,service:new o}),this.getPayoutCSV=d({authToken:this.authToken,service:new o})):(this.errorMessage="Failed to load payout details. payoutId or authToken is not provided.",this.errorEvent.emit({message:this.errorMessage,errorCode:e.MISSING_PROPS,severity:r.ERROR}))}render(){return this.errorMessage?n(this.errorMessage):i("payout-details-core",{getPayout:this.getPayout,getPayoutCSV:this.getPayoutCSV,"onError-event":this.handleErrorEvent,enableRecordClick:this.enableRecordClick})}static get watchers(){return{payoutId:["propChanged"],authToken:["propChanged"]}}};export{u as justifi_payout_details}
1
+ import{r as t,c as s,h as i}from"./p-CV0Pyo1O.js";import{P as o}from"./p-8Wa_-5QM.js";import"./p-DVJaoI_m.js";import"./p-HXpYMWUU.js";import{C as r,a as e}from"./p-Cjcsf8ku.js";import{e as a}from"./p-BiNakvsa.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-BH0Xfn-F.js";import{g as p,a as h}from"./p-D2muobcE.js";import{E as n}from"./p-DAZtHA62.js";import{c,J as m}from"./p-eEJvKFFX.js";import{m as d}from"./p-DYGIC0QH.js";import"./p-55QcjheA.js";import"./p-MeSAYDNh.js";import"./p-D8GTwl9v.js";import"./p-C4FLe2pT.js";import"./p-CfQ5vkQ3.js";const u=class{constructor(i){t(this,i),this.errorEvent=s(this,"error-event",7),this.enableRecordClick=!1,this.errorMessage=null,this.handleErrorEvent=t=>{this.errorMessage=t.detail.message,this.errorEvent.emit(t.detail)}}componentWillLoad(){c(),this.analytics=new m(this),this.initializeServices()}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}propChanged(){this.initializeServices()}initializeServices(){this.payoutId&&this.authToken?(this.getPayout=(({id:t,authToken:s,service:i})=>async({onSuccess:o,onError:e})=>{var n;try{const c=await i.fetchPayout(t,s);c.error?e({error:h(c.error),code:p(null===(n=c.error)||void 0===n?void 0:n.code),severity:r.ERROR}):o(new a(c.data))}catch(t){e({error:h(t),code:p(null==t?void 0:t.code),severity:r.ERROR})}})({id:this.payoutId,authToken:this.authToken,service:new o}),this.getPayoutCSV=d({authToken:this.authToken,service:new o})):(this.errorMessage="Failed to load payout details. payoutId or authToken is not provided.",this.errorEvent.emit({message:this.errorMessage,errorCode:e.MISSING_PROPS,severity:r.ERROR}))}render(){return this.errorMessage?n(this.errorMessage):i("payout-details-core",{getPayout:this.getPayout,getPayoutCSV:this.getPayoutCSV,"onError-event":this.handleErrorEvent,enableRecordClick:this.enableRecordClick})}static get watchers(){return{payoutId:["propChanged"],authToken:["propChanged"]}}};export{u as justifi_payout_details}
@@ -1 +1 @@
1
- import{h as t,r as e,c as s}from"./p-CV0Pyo1O.js";import{c as r,a as i,F as n}from"./p-CKiAlBsU.js";import{f as o}from"./p-MeSAYDNh.js";import"./p-DVJaoI_m.js";import{C as a,a as u}from"./p-Cjcsf8ku.js";import{R as h,l as c}from"./p-BiNakvsa.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-BH0Xfn-F.js";import{B as l}from"./p-DFiTyYE9.js";import{S as m}from"./p-BqNNwq6C.js";import"./p-CZfYo5-1.js";import{P as d}from"./p-B_KHnbK8.js";import{m as p}from"./p-CkX7qWsc.js";import{c as f,J as v}from"./p-CbTf_N6u.js";import{g as y,a as j}from"./p-D2muobcE.js";import{A as b}from"./p-55QcjheA.js";import{S as w}from"./p-DqVU8ohH.js";import"./p-BFTU3MAI.js";import"./p-HXpYMWUU.js";import"./p-D8GTwl9v.js";import"./p-C4FLe2pT.js";import"./p-D4eE0MBI.js";const C=t=>{const e=+t;return i().required("Amount is required").test("max-amount",`Refund amount cannot be more than payment amount: ${o(e)}`,(function(t){return+t<=+e})).test("min-amount","Refund amount must be greater than 0",(function(t){return+t>0}))},T=t=>{if(t)return r({amount:C(t),description:i().optional(),reason:i().optional().oneOf([h.customerRequest,h.duplicate,h.fraudulent],"Select a reason")})},k=[{label:"Select a reason",value:""},{label:"Customer requested a refund",value:"customer_request"},{label:"Customer was double-charged",value:"duplicate"},{label:"Payment was reported as fraud",value:"fraudulent"}],A=b();class I{async postRefund(t,e,s,r){return A.post({endpoint:`payments/${t}/refunds`,headers:{"Sub-Account":e},body:r,authToken:s})}}const g=b();class S{async postVoid(t,e,s){return g.post({endpoint:`payments/${t}/void`,headers:{"Sub-Account":e},authToken:s})}}const B=()=>t("div",{class:"row gap-3"},t("div",{class:"col-12"},t(w,{width:"100%",height:"40px"}))),x=()=>t(m,null,t("div",{class:"row gap-5"},t(B,null),t(B,null),t(B,null))),D=class{constructor(t){e(this,t),this.errorEvent=s(this,"error-event",7),this.submitEvent=s(this,"submit-event",7),this.refundPayload={},this.displayAmount="",this.errors={},this.paymentLoading=!0,this.refundLoading=!1,this.hideSubmitButton=!1,this.inputHandler=(t,e)=>{this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[t]:e}))}}componentWillLoad(){f(),this.analytics=new v(this),this.initializeApi(),this.formController=new n(T())}handleError(t,e,s){this.errorEvent.emit({errorCode:t,message:e,severity:s})}checkAmount(t){return t>0}handleInvalidAmount(){this.submitDisabled=!0,this.handleError(u.INVALID_REFUND_AMOUNT,"Refund amount must be greater than 0",a.ERROR)}isPaymentCreatedWithin25Minutes(){var t;if(!this.payment||!(null===(t=this.payment)||void 0===t?void 0:t.created_at))return!1;const e=new Date(this.payment.created_at);return((new Date).getTime()-e.getTime())/6e4<=25}initializeFormController(){const t=this.refundPayload.amount,e=t?t.toString():"0";this.formController=new n(T(e)),this.formController.setInitialValues({amount:e}),this.formController.values.subscribe((t=>{this.refundPayload=Object.assign({},t)})),this.formController.errors.subscribe((t=>{this.errors=Object.assign({},t)}))}initializeApi(){this.paymentId&&this.authToken?p({id:this.paymentId,authToken:this.authToken,service:new d})({onSuccess:({payment:t})=>{this.payment=t,this.refundPayload=new c({amount:t.amount_refundable})},onError:({error:t,code:e,severity:s})=>{this.handleError(e,t,s)},final:()=>{this.checkAmount(this.refundPayload.amount)?this.initializeFormController():this.handleInvalidAmount(),this.paymentLoading=!1}}):this.handleError(u.MISSING_PROPS,"Payment ID and Auth Token are required",a.ERROR)}async refundPayment(t){if(t&&t.preventDefault(),!await this.formController.validate())return;const e=this.formController.values.getValue();return this.refundLoading=!0,this.isPaymentCreatedWithin25Minutes()?this.tryVoidPayment():this.processRefund(e)}async tryVoidPayment(){const t=(({authToken:t,accountId:e,paymentId:s,service:r})=>async({onSuccess:i,onError:n,final:o})=>{var u;try{const o=await r.postVoid(s,e,t);if(o.error)return n({error:j(o.error),code:y(null===(u=o.error)||void 0===u?void 0:u.code),severity:a.ERROR});i(o)}catch(t){const e=y(null==t?void 0:t.code);return n({error:t.message||t,code:e,severity:a.ERROR})}finally{return o()}})({authToken:this.authToken,accountId:this.accountId,paymentId:this.paymentId,service:new S});return new Promise((e=>{let s,r=!1;const i=this.formController.values.getValue();t({onSuccess:t=>{s=t,r=!0},onError:({error:t,code:s,severity:n})=>{r=!0,this.handleError(t,s,n),this.processRefund(i).then(e)},final:()=>{s&&!s.error&&r&&(this.submitEvent.emit({response:s}),this.submitDisabled=!0,this.refundLoading=!1,e(s.data))}})}))}async processRefund(t){const e=(({authToken:t,accountId:e,paymentId:s,service:r})=>async({refundBody:i,onSuccess:n,onError:o,final:u})=>{var h;try{const u=await r.postRefund(s,e,t,i);if(u.error)return o({error:j(u.error),code:y(null===(h=u.error)||void 0===h?void 0:h.code),severity:a.ERROR});n(u)}catch(t){const e=y(null==t?void 0:t.code);return o({error:t.message||t,code:e,severity:a.ERROR})}finally{return u()}})({authToken:this.authToken,accountId:this.accountId,paymentId:this.paymentId,service:new I});return new Promise((s=>{let r;e({refundBody:t,onSuccess:t=>{r=t},onError:({error:t,code:e,severity:s})=>{r=t,this.handleError(t,e,s)},final:()=>{this.submitEvent.emit({response:r}),this.submitDisabled=!0,this.refundLoading=!1,s(r.data)}})}))}render(){if(this.paymentLoading)return t(x,null);const e=this.formController.getInitialValues(),s=this.refundPayload.amount;return t(m,null,t("form",null,t("fieldset",null,t("div",{class:"row gy-3"},t("div",{class:"col-12"},t("form-control-monetary",{name:"amount",label:"Refund Amount",defaultValue:e.amount,inputHandler:this.inputHandler,errorText:this.errors.amount})),t("div",{class:"col-12"},t("form-control-select",{name:"reason",label:"Reason for refund (optional)",defaultValue:e.reason,inputHandler:this.inputHandler,options:k,errorText:this.errors.reason})),t("div",{class:"col-12"},t("form-control-textarea",{name:"description",label:"Note (optional)",defaultValue:e.description,inputHandler:this.inputHandler,maxLength:250,errorText:this.errors.description})),t("div",{class:"form-group d-flex flex-row-reverse"},t(l,{variant:"primary",type:"submit",onClick:this.refundPayment.bind(this),isLoading:this.paymentLoading||this.refundLoading,hidden:this.hideSubmitButton,disabled:this.submitDisabled},`Refund ${o(+s)}`))))))}};export{D as justifi_refund_payment}
1
+ import{h as t,r as e,c as s}from"./p-CV0Pyo1O.js";import{c as r,a as i,F as n}from"./p-CKiAlBsU.js";import{f as o}from"./p-MeSAYDNh.js";import"./p-DVJaoI_m.js";import{C as a,a as u}from"./p-Cjcsf8ku.js";import{R as h,l as c}from"./p-BiNakvsa.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-BH0Xfn-F.js";import{B as l}from"./p-DFiTyYE9.js";import{S as m}from"./p-BqNNwq6C.js";import"./p-CZfYo5-1.js";import{P as d}from"./p-B_KHnbK8.js";import{m as p}from"./p-CkX7qWsc.js";import{c as f,J as v}from"./p-eEJvKFFX.js";import{g as y,a as j}from"./p-D2muobcE.js";import{A as b}from"./p-55QcjheA.js";import{S as w}from"./p-DqVU8ohH.js";import"./p-BFTU3MAI.js";import"./p-HXpYMWUU.js";import"./p-D8GTwl9v.js";import"./p-C4FLe2pT.js";import"./p-CfQ5vkQ3.js";const C=t=>{const e=+t;return i().required("Amount is required").test("max-amount",`Refund amount cannot be more than payment amount: ${o(e)}`,(function(t){return+t<=+e})).test("min-amount","Refund amount must be greater than 0",(function(t){return+t>0}))},T=t=>{if(t)return r({amount:C(t),description:i().optional(),reason:i().optional().oneOf([h.customerRequest,h.duplicate,h.fraudulent],"Select a reason")})},k=[{label:"Select a reason",value:""},{label:"Customer requested a refund",value:"customer_request"},{label:"Customer was double-charged",value:"duplicate"},{label:"Payment was reported as fraud",value:"fraudulent"}],A=b();class g{async postRefund(t,e,s,r){return A.post({endpoint:`payments/${t}/refunds`,headers:{"Sub-Account":e},body:r,authToken:s})}}const I=b();class S{async postVoid(t,e,s){return I.post({endpoint:`payments/${t}/void`,headers:{"Sub-Account":e},authToken:s})}}const x=()=>t("div",{class:"row gap-3"},t("div",{class:"col-12"},t(w,{width:"100%",height:"40px"}))),B=()=>t(m,null,t("div",{class:"row gap-5"},t(x,null),t(x,null),t(x,null))),D=class{constructor(t){e(this,t),this.errorEvent=s(this,"error-event",7),this.submitEvent=s(this,"submit-event",7),this.refundPayload={},this.displayAmount="",this.errors={},this.paymentLoading=!0,this.refundLoading=!1,this.hideSubmitButton=!1,this.inputHandler=(t,e)=>{this.formController.setValues(Object.assign(Object.assign({},this.formController.values.getValue()),{[t]:e}))}}componentWillLoad(){f(),this.analytics=new v(this),this.initializeApi(),this.formController=new n(T())}handleError(t,e,s){this.errorEvent.emit({errorCode:t,message:e,severity:s})}checkAmount(t){return t>0}handleInvalidAmount(){this.submitDisabled=!0,this.handleError(u.INVALID_REFUND_AMOUNT,"Refund amount must be greater than 0",a.ERROR)}isPaymentCreatedWithin25Minutes(){var t;if(!this.payment||!(null===(t=this.payment)||void 0===t?void 0:t.created_at))return!1;const e=new Date(this.payment.created_at);return((new Date).getTime()-e.getTime())/6e4<=25}initializeFormController(){const t=this.refundPayload.amount,e=t?t.toString():"0";this.formController=new n(T(e)),this.formController.setInitialValues({amount:e}),this.formController.values.subscribe((t=>{this.refundPayload=Object.assign({},t)})),this.formController.errors.subscribe((t=>{this.errors=Object.assign({},t)}))}initializeApi(){this.paymentId&&this.authToken?p({id:this.paymentId,authToken:this.authToken,service:new d})({onSuccess:({payment:t})=>{this.payment=t,this.refundPayload=new c({amount:t.amount_refundable})},onError:({error:t,code:e,severity:s})=>{this.handleError(e,t,s)},final:()=>{this.checkAmount(this.refundPayload.amount)?this.initializeFormController():this.handleInvalidAmount(),this.paymentLoading=!1}}):this.handleError(u.MISSING_PROPS,"Payment ID and Auth Token are required",a.ERROR)}async refundPayment(t){if(t&&t.preventDefault(),!await this.formController.validate())return;const e=this.formController.values.getValue();return this.refundLoading=!0,this.isPaymentCreatedWithin25Minutes()?this.tryVoidPayment():this.processRefund(e)}async tryVoidPayment(){const t=(({authToken:t,accountId:e,paymentId:s,service:r})=>async({onSuccess:i,onError:n,final:o})=>{var u;try{const o=await r.postVoid(s,e,t);if(o.error)return n({error:j(o.error),code:y(null===(u=o.error)||void 0===u?void 0:u.code),severity:a.ERROR});i(o)}catch(t){const e=y(null==t?void 0:t.code);return n({error:t.message||t,code:e,severity:a.ERROR})}finally{return o()}})({authToken:this.authToken,accountId:this.accountId,paymentId:this.paymentId,service:new S});return new Promise((e=>{let s,r=!1;const i=this.formController.values.getValue();t({onSuccess:t=>{s=t,r=!0},onError:({error:t,code:s,severity:n})=>{r=!0,this.handleError(t,s,n),this.processRefund(i).then(e)},final:()=>{s&&!s.error&&r&&(this.submitEvent.emit({response:s}),this.submitDisabled=!0,this.refundLoading=!1,e(s.data))}})}))}async processRefund(t){const e=(({authToken:t,accountId:e,paymentId:s,service:r})=>async({refundBody:i,onSuccess:n,onError:o,final:u})=>{var h;try{const u=await r.postRefund(s,e,t,i);if(u.error)return o({error:j(u.error),code:y(null===(h=u.error)||void 0===h?void 0:h.code),severity:a.ERROR});n(u)}catch(t){const e=y(null==t?void 0:t.code);return o({error:t.message||t,code:e,severity:a.ERROR})}finally{return u()}})({authToken:this.authToken,accountId:this.accountId,paymentId:this.paymentId,service:new g});return new Promise((s=>{let r;e({refundBody:t,onSuccess:t=>{r=t},onError:({error:t,code:e,severity:s})=>{r=t,this.handleError(t,e,s)},final:()=>{this.submitEvent.emit({response:r}),this.submitDisabled=!0,this.refundLoading=!1,s(r.data)}})}))}render(){if(this.paymentLoading)return t(B,null);const e=this.formController.getInitialValues(),s=this.refundPayload.amount;return t(m,null,t("form",null,t("fieldset",null,t("div",{class:"row gy-3"},t("div",{class:"col-12"},t("form-control-monetary",{name:"amount",label:"Refund Amount",defaultValue:e.amount,inputHandler:this.inputHandler,errorText:this.errors.amount})),t("div",{class:"col-12"},t("form-control-select",{name:"reason",label:"Reason for refund (optional)",defaultValue:e.reason,inputHandler:this.inputHandler,options:k,errorText:this.errors.reason})),t("div",{class:"col-12"},t("form-control-textarea",{name:"description",label:"Note (optional)",defaultValue:e.description,inputHandler:this.inputHandler,maxLength:250,errorText:this.errors.description})),t("div",{class:"form-group d-flex flex-row-reverse"},t(l,{variant:"primary",type:"submit",onClick:this.refundPayment.bind(this),isLoading:this.paymentLoading||this.refundLoading,hidden:this.hideSubmitButton,disabled:this.submitDisabled},`Refund ${o(+s)}`))))))}};export{D as justifi_refund_payment}
@@ -1 +1 @@
1
- import{r as e,h as n,H as t,c as i,g as o}from"./p-CV0Pyo1O.js";import{c as r}from"./p-D8GTwl9v.js";import{ar as s,X as a,Z as c,_ as d,$ as u}from"./p-C4FLe2pT.js";import{g as f}from"./p-BFTU3MAI.js";import{F as l}from"./p--Kvji7o2.js";import{p as h}from"./p-D4eE0MBI.js";const m=r({focused:{boxShadow:"",border:""},focusedAndInvalid:{boxShadow:"",border:""},fontStyles:{fontFamily:"",fontSize:"",fontWeight:"",lineHeight:"",margin:"",padding:""}}),{state:w,set:g}=m,b=class{constructor(n){e(this,n),this.isFocused=!1,this.errorText=""}focusWithoutPageScroll(e){if(e)try{e.focus({preventScroll:!0})}catch(n){const{scrollX:t,scrollY:i}=window;e.focus(),window.scrollTo(t,i)}}async componentDidLoad(){const e=await this.getBaseFontStyles();g("fontStyles",e);const n=await this.getFocusedStyles();g("focused",n);const t=await this.getFocusedAndInvalidStyles();g("focusedAndInvalid",t)}async getBaseFontStyles(){return new Promise((e=>{setTimeout((()=>{const n=getComputedStyle(this.hiddenInput);e({fontFamily:n.fontFamily,fontSize:n.fontSize,fontWeight:n.fontWeight,lineHeight:n.lineHeight,margin:n.margin,padding:n.padding,color:n.color})}),500)}))}async getFocusedStyles(){return new Promise((e=>{this.focusWithoutPageScroll(this.hiddenInput),setTimeout((()=>{this.hiddenInput.blur();let n=getComputedStyle(this.hiddenInput);e({boxShadow:n.boxShadow,border:n.border})}),500)}))}async getFocusedAndInvalidStyles(){return new Promise((e=>{this.focusWithoutPageScroll(this.hiddenInput),this.errorText="Error",setTimeout((()=>{const n=getComputedStyle(this.hiddenInput),t={boxShadow:n.boxShadow,border:n.border};this.hiddenInput.blur(),e(t)}),500)}))}get part(){return this.isFocused&&this.errorText?s:this.errorText?a:this.isFocused?c:d}render(){return n(t,{key:"05cefc92dac95360d470070c64fbc0318c666214"},n("input",{key:"02c9a6001a394b96cbc09b6d906287b81c20e98f",ref:e=>this.hiddenInput=e,type:"text",class:this.errorText?"form-control is-invalid":"form-control",onFocus:()=>this.isFocused=!0,onBlur:()=>this.isFocused=!1,part:this.part,tabindex:"-1",style:{height:"0",opacity:"0",pointerEvents:"none",animation:"none"}}))}};var p,y,v={exports:{}},k=f((p||(p=1,y=v,console.info("\nIFRAME-RESIZER\n\nIframe-Resizer 5 is now available via the following two packages:\n\n * @iframe-resizer/parent\n * @iframe-resizer/child\n\nAdditionally their are also new versions of iframe-resizer for React, Vue, and jQuery.\n\nVersion 5 of iframe-resizer has been extensively rewritten to use modern browser APIs, which has enabled significantly better performance and greater accuracy in the detection of content resizing events.\n\nPlease see https://iframe-resizer.com/upgrade for more details.\n"),function(e){if("undefined"!=typeof window){var n,t,i=0,o=!1,r=!1,s="[iFrameSizer]",a=null,c=window.requestAnimationFrame,d=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),u={},f=null,l=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,license:"1jqr0si6pnt",log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){k("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}}),h={};window.jQuery!==e&&((t=window.jQuery).fn?t.fn.iFrameResize||(t.fn.iFrameResize=function(e){return this.filter("iframe").each((function(n,t){W(t,e)})).end()}):v("","Unable to bind to jQuery, it is not fully loaded.")),y.exports=H(),window.iFrameResize=window.iFrameResize||H()}function m(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function w(e,n,t){e.addEventListener(n,t,!1)}function g(e,n,t){e.removeEventListener(n,t,!1)}function b(e){return u[e]?u[e].log:o}function p(e,n){x("log",e,n,b(e))}function v(e,n){x("info",e,n,b(e))}function k(e,n){x("warn",e,n,!0)}function x(e,n,t,i){!0===i&&"object"==typeof window.console&&console[e](function(e){return s+"["+function(e){var n="Host page: "+e;return window.top!==window.self&&(n=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+e:"Nested host page: "+e),n}(e)+"]"}(n),t)}function I(e){function n(){t("Height"),t("Width"),C((function(){R(A),T(L),l("onResized",A)}),A,"init")}function t(e){var n=Number(u[L]["max"+e]),t=Number(u[L]["min"+e]),i=e.toLowerCase(),o=Number(A[i]);p(L,"Checking "+i+" is in range "+t+"-"+n),o<t&&(o=t,p(L,"Set "+i+" to min value")),o>n&&(o=n,p(L,"Set "+i+" to max value")),A[i]=""+o}function i(e){return W.slice(W.indexOf(":")+7+e)}function o(e,n){var t,i;t=function(){var t,i;E("Send Page Info","pageInfo:"+(t=document.body.getBoundingClientRect(),i=A.iframe.getBoundingClientRect(),JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(i.top-t.top,10),offsetLeft:parseInt(i.left-t.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})),e,n)},h[i=n]||(h[i]=setTimeout((function(){h[i]=null,t()}),32))}function r(e){var n=e.getBoundingClientRect();return M(L),{x:Math.floor(Number(n.left)+Number(a.x)),y:Math.floor(Number(n.top)+Number(a.y))}}function c(e){var n=e?r(A.iframe):{x:0,y:0},t={x:Number(A.width)+n.x,y:Number(A.height)+n.y};p(L,"Reposition requested from iFrame (offset x:"+n.x+" y:"+n.y+")"),window.top===window.self?(a=t,d(),p(L,"--")):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](t.x,t.y):k(L,"Unable to scroll to requested position, window.parentIFrame not found")}function d(){!1===l("onScroll",a)?j():T(L)}function f(e){var n={};if(0===Number(A.width)&&0===Number(A.height)){var t=i(9).split(":");n={x:t[1],y:t[0]}}else n={x:A.width,y:A.height};l(e,{iframe:A.iframe,screenX:Number(n.x),screenY:Number(n.y),type:A.type})}function l(e,n){return F(L,e,n)}var m,b,y,x,I,S,W=e.data,A={},L=null;"[iFrameResizerChild]Ready"===W?function(){for(var e in u)E("iFrame requested init",N(e),u[e].iframe,e)}():s===(""+W).slice(0,13)&&W.slice(13).split(":")[0]in u?(x=(y=W.slice(13).split(":"))[1]?parseInt(y[1],10):0,I=u[y[0]]&&u[y[0]].iframe,S=getComputedStyle(I),A={iframe:I,id:y[0],height:x+function(e){return"border-box"!==e.boxSizing?0:(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}(S)+function(e){return"border-box"!==e.boxSizing?0:(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}(S),width:y[2],type:y[3]},u[L=A.id]&&(u[L].loaded=!0),(b=A.type in{true:1,false:1,undefined:1})&&p(L,"Ignoring init message from meta parent page"),!b&&function(e){var n=!0;return u[e]||(n=!1,k(A.type+" No settings for "+e+". Message was: "+W)),n}(L)&&(p(L,"Received: "+W),m=!0,null===A.iframe&&(k(L,"IFrame ("+A.id+") not found"),m=!1),m&&function(){var n,t=e.origin,i=u[L]&&u[L].checkOrigin;if(i&&""+t!="null"&&!(i.constructor===Array?function(){var e=0,n=!1;for(p(L,"Checking connection is from allowed list of origins: "+i);e<i.length;e++)if(i[e]===t){n=!0;break}return n}():(p(L,"Checking connection is from: "+(n=u[L]&&u[L].remoteHost)),t===n)))throw new Error("Unexpected message received from: "+t+" for "+A.iframe.id+". Message was: "+e.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}()&&function(){switch(u[L]&&u[L].firstRun&&u[L]&&(u[L].firstRun=!1),A.type){case"close":z(A.iframe);break;case"message":m=i(6),p(L,"onMessage passed: {iframe: "+A.iframe.id+", message: "+m+"}"),l("onMessage",{iframe:A.iframe,message:JSON.parse(m)}),p(L,"--");break;case"mouseenter":f("onMouseEnter");break;case"mouseleave":f("onMouseLeave");break;case"autoResize":u[L].autoResize=JSON.parse(i(9));break;case"scrollTo":c(!1);break;case"scrollToOffset":c(!0);break;case"pageInfo":o(u[L]&&u[L].iframe,L),function(){function e(e,i){function r(){u[t]?o(u[t].iframe,t):n()}["scroll","resize"].forEach((function(n){p(t,e+n+" listener for sendPageInfo"),i(window,n,r)}))}function n(){e("Remove ",g)}var t=L;e("Add ",w),u[t]&&(u[t].stopPageInfo=n)}();break;case"pageInfoStop":u[L]&&u[L].stopPageInfo&&(u[L].stopPageInfo(),delete u[L].stopPageInfo);break;case"inPageLink":t=i(9).split("#")[1]||"",s=decodeURIComponent(t),(h=document.getElementById(s)||document.getElementsByName(s)[0])?(e=r(h),p(L,"Moving to in page link (#"+t+") at x: "+e.x+" y: "+e.y),a={x:e.x,y:e.y},d(),p(L,"--")):window.top===window.self?p(L,"In page link #"+t+" not found"):window.parentIFrame?window.parentIFrame.moveToAnchor(t):p(L,"In page link #"+t+" not found and window.parentIFrame not found");break;case"reset":O(A);break;case"init":n(),l("onInit",A.iframe);break;default:0===Number(A.width)&&0===Number(A.height)?k("Unsupported message received ("+A.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):n()}var e,t,s,h,m}())):v(L,"Ignored: "+W)}function F(e,n,t){var i=null,o=null;if(u[e]){if("function"!=typeof(i=u[e][n]))throw new TypeError(n+" on iFrame["+e+"] is not a function");o=i(t)}return o}function S(e){delete u[e.id]}function z(e){var t=e.id;if(!1!==F(t,"onClose",t)){p(t,"Removing iFrame: "+t);try{e.parentNode&&e.parentNode.removeChild(e)}catch(e){k(e)}F(t,"onClosed",t),p(t,"--"),S(e),n&&(n.disconnect(),n=null)}else p(t,"Close iframe cancelled by onClose event")}function M(n){null===a&&p(n,"Get page position: "+(a={x:window.pageXOffset===e?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===e?document.documentElement.scrollTop:window.pageYOffset}).x+","+a.y)}function T(e){null!==a&&(window.scrollTo(a.x,a.y),p(e,"Set page position: "+a.x+","+a.y),j())}function j(){a=null}function O(e){p(e.id,"Size reset requested by "+("init"===e.type?"host page":"iFrame")),M(e.id),C((function(){R(e),E("reset","reset",e.iframe,e.id)}),e,"reset")}function R(e){function n(n){r||"0"!==e[n]||(r=!0,p(i,"Hidden iFrame detected, creating visibility listener"),function(){function e(){Object.keys(u).forEach((function(e){!function(e){function n(n){return"0px"===(u[e]&&u[e].iframe.style[n])}u[e]&&null!==u[e].iframe.offsetParent&&(n("height")||n("width"))&&E("Visibility change","resize",u[e].iframe,e)}(e)}))}function n(n){p("window","Mutation observed: "+n[0].target+" "+n[0].type),A(e,16)}var t,i=m();i&&(t=document.querySelector("body"),new i(n).observe(t,{attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0}))}())}function t(t){!function(n){e.id?(e.iframe.style[n]=e[n]+"px",p(e.id,"IFrame ("+i+") "+n+" set to "+e[n]+"px")):p("undefined","messageData id not set")}(t),n(t)}var i=e.iframe.id;u[i]&&(u[i].sizeHeight&&t("height"),u[i].sizeWidth&&t("width"))}function C(e,n,t){t!==n.type&&c&&!window.jasmine?(p(n.id,"Requesting animation frame"),c(e)):e()}function E(e,n,t,i,o){var r,a=!1;u[i=i||t.id]&&(t&&"contentWindow"in t&&null!==t.contentWindow?(p(i,"["+e+"] Sending msg to iframe["+i+"] ("+n+") targetOrigin: "+(r=u[i]&&u[i].targetOrigin)),t.contentWindow.postMessage(s+n,r)):k(i,"["+e+"] IFrame("+i+") not found"),o&&u[i]&&u[i].warningTimeout&&(u[i].msgTimeout=setTimeout((function(){!u[i]||u[i].loaded||a||(a=!0,k(i,"IFrame has not responded within "+u[i].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}),u[i].warningTimeout)))}function N(e){return e+":"+u[e].bodyMarginV1+":"+u[e].sizeWidth+":"+u[e].log+":"+u[e].interval+":"+u[e].enablePublicMethods+":"+u[e].autoResize+":"+u[e].bodyMargin+":"+u[e].heightCalculationMethod+":"+u[e].bodyBackground+":"+u[e].bodyPadding+":"+u[e].tolerance+":"+u[e].inPageLinks+":"+u[e].resizeFrom+":"+u[e].widthCalculationMethod+":"+u[e].mouseEvents}function W(t,r){function s(e){var n=e.split("Callback");if(2===n.length){var t="on"+n[0].charAt(0).toUpperCase()+n[0].slice(1);this[t]=this[e],delete this[e],k(f,"Deprecated: '"+e+"' has been renamed '"+t+"'. The old method will be removed in the next major version.")}}var a,c,f=function(e){if("string"!=typeof e)throw new TypeError("Invaild id for iFrame. Expected String");var n;return""===e&&(t.id=(n=r&&r.id||l.id+i++,null!==document.getElementById(n)&&(n+=i++),e=n),o=(r||{}).log,p(e,"Added missing iframe ID: "+e+" ("+t.src+")")),e}(t.id);f in u&&"iFrameResizer"in t?k(f,"Ignored iFrame, already setup."):(function(e){var n;e=e||{},u[f]=Object.create(null),u[f].iframe=t,u[f].firstRun=!0,u[f].remoteHost=t.src&&t.src.split("/").slice(0,3).join("/"),function(e){if("object"!=typeof e)throw new TypeError("Options is not an object")}(e),Object.keys(e).forEach(s,e),function(e){for(var n in l)Object.prototype.hasOwnProperty.call(l,n)&&(u[f][n]=Object.prototype.hasOwnProperty.call(e,n)?e[n]:l[n])}(e),u[f]&&(u[f].targetOrigin=!0===u[f].checkOrigin?""===(n=u[f].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*")}(r),function(){switch(p(f,"IFrame scrolling "+(u[f]&&u[f].scrolling?"enabled":"disabled")+" for "+f),t.style.overflow=!1===(u[f]&&u[f].scrolling)?"hidden":"auto",u[f]&&u[f].scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=u[f]?u[f].scrolling:"no"}}(),function(){function e(e){var n=u[f][e];1/0!==n&&0!==n&&(t.style[e]="number"==typeof n?n+"px":n,p(f,"Set "+e+" = "+t.style[e]))}function n(e){if(u[f]["min"+e]>u[f]["max"+e])throw new Error("Value for min"+e+" can not be greater than max"+e)}n("Height"),n("Width"),e("maxHeight"),e("minHeight"),e("maxWidth"),e("minWidth")}(),"number"!=typeof(u[f]&&u[f].bodyMargin)&&"0"!==(u[f]&&u[f].bodyMargin)||(u[f].bodyMarginV1=u[f].bodyMargin,u[f].bodyMargin=u[f].bodyMargin+"px"),a=N(f),(c=m())&&(n=function(e){if(!t.parentNode)return null;var n=new e((function(e){e.forEach((function(e){Array.prototype.slice.call(e.removedNodes).forEach((function(e){e===t&&z(t)}))}))}));return n.observe(t.parentNode,{childList:!0}),n}(c)),w(t,"load",(function(){E("iFrame.onload",a,t,e,!0),(!u[f]||!u[f].firstRun)&&u[f]&&u[f].heightCalculationMethod in d&&O({iframe:t,height:0,width:0,type:"init"})})),E("init",a,t,e,!0),u[f]&&(u[f].iframe.iFrameResizer={close:z.bind(null,u[f].iframe),removeListeners:S.bind(null,u[f].iframe),resize:E.bind(null,"Window resize","resize",u[f].iframe),moveToAnchor:function(e){E("Move to anchor","moveToAnchor:"+e,u[f].iframe,f)},sendMessage:function(e){E("Send Message","message:"+(e=JSON.stringify(e)),u[f].iframe,f)}}))}function A(e,n){null===f&&(f=setTimeout((function(){f=null,e()}),n))}function L(){"hidden"!==document.visibilityState&&(p("document","Trigger event: Visibility change"),A((function(){P("Tab Visible","resize")}),16))}function P(e,n){Object.keys(u).forEach((function(t){(function(e){return u[e]&&"parent"===u[e].resizeFrom&&u[e].autoResize&&!u[e].firstRun})(t)&&E(e,n,u[t].iframe,t)}))}function H(){function n(e,n){n&&(function(){if(!n.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==n.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+n.tagName+">")}(),W(n,e),t.push(n))}var t;return function(){var e,n=["moz","webkit","o","ms"];for(e=0;e<n.length&&!c;e+=1)c=window[n[e]+"RequestAnimationFrame"];c?c=c.bind(window):p("setup","RequestAnimationFrame not supported")}(),w(window,"message",I),w(window,"resize",(function(){p("window","Trigger event: resize"),A((function(){P("Window resize","resize")}),16)})),w(document,"visibilitychange",L),w(document,"-webkit-visibilitychange",L),function(i,o){switch(t=[],function(e){e&&e.enablePublicMethods&&k("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}(i),typeof o){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(o||"iframe"),n.bind(e,i));break;case"object":n(i,o);break;default:throw new TypeError("Unexpected data type ("+typeof o+")")}return t}}}()),v.exports));class x{constructor(e,n){this.iframe=e,this.iframeOrigin=n}postMessage(e,n){const t=Object.assign({eventType:e},n);this.iframe.contentWindow.postMessage(t,this.iframeOrigin)}addMessageListener(e){window.addEventListener("message",e)}removeMessageListener(e){window.removeEventListener("message",e)}postMessageWithResponseListener(e,n){return new Promise((t=>{const i=n=>{n.data.eventType===e&&(window.removeEventListener("message",i),t(n.data.data))};window.addEventListener("message",i),this.postMessage(e,n)}))}}const I=class{constructor(n){e(this,n),this.iframeLoaded=i(this,"iframeLoaded",7),this.isFocused=!1,this.isValid=!0,this.dispatchMessageEvent=e=>{const{eventType:n,data:t}=e.data;(null==t?void 0:t.id)===this.inputId&&("focused"===n&&(this.isFocused=!0),"blurred"===n&&(this.isFocused=!1))}}disconnectedCallback(){this.frameService.removeMessageListener(this.dispatchMessageEvent)}async validate(){const e=await this.frameService.postMessageWithResponseListener("validate");return this.isValid=e.isValid,this.errorText=e.error.message,e}async tokenize(e,n,t){return this.frameService.postMessageWithResponseListener("tokenize",{clientId:e,paymentMethodMetadata:n,account:t,componentVersion:h.version})}initializeFrameCommunicationService(){var e;this.frameService=new x(this.iframeElement,this.iframeOrigin),null===(e=this.frameService)||void 0===e||e.addMessageListener(this.dispatchMessageEvent)}get part(){return this.isFocused&&!this.isValid?s:this.isValid?this.isFocused?c:d:a}get style(){return this.isFocused?this.isValid?w.focused:w.focusedAndInvalid:null}get urlParams(){const e=Object.fromEntries(Object.entries(w.fontStyles).map((([e,n])=>[e,btoa(String(n))])));return new URLSearchParams(e).toString()}render(){return n(t,{key:"ebf24e9c73ea9a7f352dfc7368678117144745c3",class:"form-group d-flex flex-column"},n("div",{key:"e88393af9005c217ad3cc2504e8285629339402c",style:{visibility:this.iframeLoaded?"visible":"hidden",height:this.iframeLoaded?"auto":"0"}},n("label",{key:"47591ac9c82096e9bde5b5706b08c9dc8461788b",class:"form-label",htmlFor:"",part:u},this.label||""),n("div",{key:"b39265660ede091bd365d983a702202469adab97",class:"p-0 d-flex form-control "+(this.isValid?"":"is-invalid"),part:this.part,style:Object.assign(Object.assign({},this.style),{overflow:"hidden"})},n("iframe",{key:"12354fce7a91119a17d577df02c2f627ebc10b98",id:this.inputId,name:this.inputId,src:`${this.iframeOrigin}?${this.urlParams}`,ref:e=>{this.iframeElement=e,this.initializeFrameCommunicationService()},width:"100%",onLoad:()=>{k({log:!1,onResized:()=>{this.iframeLoaded.emit()}},this.iframeElement)}})),n(l,{key:"604488d6da7e2ff87e24e3eed0a77b3a6231106e",errorText:this.errorText,name:this.inputId})))}get el(){return o(this)}};export{b as hidden_input,I as iframe_input}
1
+ import{r as e,h as n,H as t,c as i,g as o}from"./p-CV0Pyo1O.js";import{c as r}from"./p-D8GTwl9v.js";import{ar as s,X as a,Z as c,_ as d,$ as u}from"./p-C4FLe2pT.js";import{g as f}from"./p-BFTU3MAI.js";import{F as l}from"./p--Kvji7o2.js";import{p as h}from"./p-CfQ5vkQ3.js";const m=r({focused:{boxShadow:"",border:""},focusedAndInvalid:{boxShadow:"",border:""},fontStyles:{fontFamily:"",fontSize:"",fontWeight:"",lineHeight:"",margin:"",padding:""}}),{state:w,set:g}=m,b=class{constructor(n){e(this,n),this.isFocused=!1,this.errorText=""}focusWithoutPageScroll(e){if(e)try{e.focus({preventScroll:!0})}catch(n){const{scrollX:t,scrollY:i}=window;e.focus(),window.scrollTo(t,i)}}async componentDidLoad(){const e=await this.getBaseFontStyles();g("fontStyles",e);const n=await this.getFocusedStyles();g("focused",n);const t=await this.getFocusedAndInvalidStyles();g("focusedAndInvalid",t)}async getBaseFontStyles(){return new Promise((e=>{setTimeout((()=>{const n=getComputedStyle(this.hiddenInput);e({fontFamily:n.fontFamily,fontSize:n.fontSize,fontWeight:n.fontWeight,lineHeight:n.lineHeight,margin:n.margin,padding:n.padding,color:n.color})}),500)}))}async getFocusedStyles(){return new Promise((e=>{this.focusWithoutPageScroll(this.hiddenInput),setTimeout((()=>{this.hiddenInput.blur();let n=getComputedStyle(this.hiddenInput);e({boxShadow:n.boxShadow,border:n.border})}),500)}))}async getFocusedAndInvalidStyles(){return new Promise((e=>{this.focusWithoutPageScroll(this.hiddenInput),this.errorText="Error",setTimeout((()=>{const n=getComputedStyle(this.hiddenInput),t={boxShadow:n.boxShadow,border:n.border};this.hiddenInput.blur(),e(t)}),500)}))}get part(){return this.isFocused&&this.errorText?s:this.errorText?a:this.isFocused?c:d}render(){return n(t,{key:"05cefc92dac95360d470070c64fbc0318c666214"},n("input",{key:"02c9a6001a394b96cbc09b6d906287b81c20e98f",ref:e=>this.hiddenInput=e,type:"text",class:this.errorText?"form-control is-invalid":"form-control",onFocus:()=>this.isFocused=!0,onBlur:()=>this.isFocused=!1,part:this.part,tabindex:"-1",style:{height:"0",opacity:"0",pointerEvents:"none",animation:"none"}}))}};var p,y,v={exports:{}},k=f((p||(p=1,y=v,console.info("\nIFRAME-RESIZER\n\nIframe-Resizer 5 is now available via the following two packages:\n\n * @iframe-resizer/parent\n * @iframe-resizer/child\n\nAdditionally their are also new versions of iframe-resizer for React, Vue, and jQuery.\n\nVersion 5 of iframe-resizer has been extensively rewritten to use modern browser APIs, which has enabled significantly better performance and greater accuracy in the detection of content resizing events.\n\nPlease see https://iframe-resizer.com/upgrade for more details.\n"),function(e){if("undefined"!=typeof window){var n,t,i=0,o=!1,r=!1,s="[iFrameSizer]",a=null,c=window.requestAnimationFrame,d=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),u={},f=null,l=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,license:"1jqr0si6pnt",log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){k("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}}),h={};window.jQuery!==e&&((t=window.jQuery).fn?t.fn.iFrameResize||(t.fn.iFrameResize=function(e){return this.filter("iframe").each((function(n,t){W(t,e)})).end()}):v("","Unable to bind to jQuery, it is not fully loaded.")),y.exports=H(),window.iFrameResize=window.iFrameResize||H()}function m(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function w(e,n,t){e.addEventListener(n,t,!1)}function g(e,n,t){e.removeEventListener(n,t,!1)}function b(e){return u[e]?u[e].log:o}function p(e,n){x("log",e,n,b(e))}function v(e,n){x("info",e,n,b(e))}function k(e,n){x("warn",e,n,!0)}function x(e,n,t,i){!0===i&&"object"==typeof window.console&&console[e](function(e){return s+"["+function(e){var n="Host page: "+e;return window.top!==window.self&&(n=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+e:"Nested host page: "+e),n}(e)+"]"}(n),t)}function F(e){function n(){t("Height"),t("Width"),C((function(){R(A),T(L),l("onResized",A)}),A,"init")}function t(e){var n=Number(u[L]["max"+e]),t=Number(u[L]["min"+e]),i=e.toLowerCase(),o=Number(A[i]);p(L,"Checking "+i+" is in range "+t+"-"+n),o<t&&(o=t,p(L,"Set "+i+" to min value")),o>n&&(o=n,p(L,"Set "+i+" to max value")),A[i]=""+o}function i(e){return W.slice(W.indexOf(":")+7+e)}function o(e,n){var t,i;t=function(){var t,i;E("Send Page Info","pageInfo:"+(t=document.body.getBoundingClientRect(),i=A.iframe.getBoundingClientRect(),JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(i.top-t.top,10),offsetLeft:parseInt(i.left-t.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})),e,n)},h[i=n]||(h[i]=setTimeout((function(){h[i]=null,t()}),32))}function r(e){var n=e.getBoundingClientRect();return M(L),{x:Math.floor(Number(n.left)+Number(a.x)),y:Math.floor(Number(n.top)+Number(a.y))}}function c(e){var n=e?r(A.iframe):{x:0,y:0},t={x:Number(A.width)+n.x,y:Number(A.height)+n.y};p(L,"Reposition requested from iFrame (offset x:"+n.x+" y:"+n.y+")"),window.top===window.self?(a=t,d(),p(L,"--")):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](t.x,t.y):k(L,"Unable to scroll to requested position, window.parentIFrame not found")}function d(){!1===l("onScroll",a)?j():T(L)}function f(e){var n={};if(0===Number(A.width)&&0===Number(A.height)){var t=i(9).split(":");n={x:t[1],y:t[0]}}else n={x:A.width,y:A.height};l(e,{iframe:A.iframe,screenX:Number(n.x),screenY:Number(n.y),type:A.type})}function l(e,n){return I(L,e,n)}var m,b,y,x,F,S,W=e.data,A={},L=null;"[iFrameResizerChild]Ready"===W?function(){for(var e in u)E("iFrame requested init",N(e),u[e].iframe,e)}():s===(""+W).slice(0,13)&&W.slice(13).split(":")[0]in u?(x=(y=W.slice(13).split(":"))[1]?parseInt(y[1],10):0,F=u[y[0]]&&u[y[0]].iframe,S=getComputedStyle(F),A={iframe:F,id:y[0],height:x+function(e){return"border-box"!==e.boxSizing?0:(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}(S)+function(e){return"border-box"!==e.boxSizing?0:(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}(S),width:y[2],type:y[3]},u[L=A.id]&&(u[L].loaded=!0),(b=A.type in{true:1,false:1,undefined:1})&&p(L,"Ignoring init message from meta parent page"),!b&&function(e){var n=!0;return u[e]||(n=!1,k(A.type+" No settings for "+e+". Message was: "+W)),n}(L)&&(p(L,"Received: "+W),m=!0,null===A.iframe&&(k(L,"IFrame ("+A.id+") not found"),m=!1),m&&function(){var n,t=e.origin,i=u[L]&&u[L].checkOrigin;if(i&&""+t!="null"&&!(i.constructor===Array?function(){var e=0,n=!1;for(p(L,"Checking connection is from allowed list of origins: "+i);e<i.length;e++)if(i[e]===t){n=!0;break}return n}():(p(L,"Checking connection is from: "+(n=u[L]&&u[L].remoteHost)),t===n)))throw new Error("Unexpected message received from: "+t+" for "+A.iframe.id+". Message was: "+e.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}()&&function(){switch(u[L]&&u[L].firstRun&&u[L]&&(u[L].firstRun=!1),A.type){case"close":z(A.iframe);break;case"message":m=i(6),p(L,"onMessage passed: {iframe: "+A.iframe.id+", message: "+m+"}"),l("onMessage",{iframe:A.iframe,message:JSON.parse(m)}),p(L,"--");break;case"mouseenter":f("onMouseEnter");break;case"mouseleave":f("onMouseLeave");break;case"autoResize":u[L].autoResize=JSON.parse(i(9));break;case"scrollTo":c(!1);break;case"scrollToOffset":c(!0);break;case"pageInfo":o(u[L]&&u[L].iframe,L),function(){function e(e,i){function r(){u[t]?o(u[t].iframe,t):n()}["scroll","resize"].forEach((function(n){p(t,e+n+" listener for sendPageInfo"),i(window,n,r)}))}function n(){e("Remove ",g)}var t=L;e("Add ",w),u[t]&&(u[t].stopPageInfo=n)}();break;case"pageInfoStop":u[L]&&u[L].stopPageInfo&&(u[L].stopPageInfo(),delete u[L].stopPageInfo);break;case"inPageLink":t=i(9).split("#")[1]||"",s=decodeURIComponent(t),(h=document.getElementById(s)||document.getElementsByName(s)[0])?(e=r(h),p(L,"Moving to in page link (#"+t+") at x: "+e.x+" y: "+e.y),a={x:e.x,y:e.y},d(),p(L,"--")):window.top===window.self?p(L,"In page link #"+t+" not found"):window.parentIFrame?window.parentIFrame.moveToAnchor(t):p(L,"In page link #"+t+" not found and window.parentIFrame not found");break;case"reset":O(A);break;case"init":n(),l("onInit",A.iframe);break;default:0===Number(A.width)&&0===Number(A.height)?k("Unsupported message received ("+A.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):n()}var e,t,s,h,m}())):v(L,"Ignored: "+W)}function I(e,n,t){var i=null,o=null;if(u[e]){if("function"!=typeof(i=u[e][n]))throw new TypeError(n+" on iFrame["+e+"] is not a function");o=i(t)}return o}function S(e){delete u[e.id]}function z(e){var t=e.id;if(!1!==I(t,"onClose",t)){p(t,"Removing iFrame: "+t);try{e.parentNode&&e.parentNode.removeChild(e)}catch(e){k(e)}I(t,"onClosed",t),p(t,"--"),S(e),n&&(n.disconnect(),n=null)}else p(t,"Close iframe cancelled by onClose event")}function M(n){null===a&&p(n,"Get page position: "+(a={x:window.pageXOffset===e?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===e?document.documentElement.scrollTop:window.pageYOffset}).x+","+a.y)}function T(e){null!==a&&(window.scrollTo(a.x,a.y),p(e,"Set page position: "+a.x+","+a.y),j())}function j(){a=null}function O(e){p(e.id,"Size reset requested by "+("init"===e.type?"host page":"iFrame")),M(e.id),C((function(){R(e),E("reset","reset",e.iframe,e.id)}),e,"reset")}function R(e){function n(n){r||"0"!==e[n]||(r=!0,p(i,"Hidden iFrame detected, creating visibility listener"),function(){function e(){Object.keys(u).forEach((function(e){!function(e){function n(n){return"0px"===(u[e]&&u[e].iframe.style[n])}u[e]&&null!==u[e].iframe.offsetParent&&(n("height")||n("width"))&&E("Visibility change","resize",u[e].iframe,e)}(e)}))}function n(n){p("window","Mutation observed: "+n[0].target+" "+n[0].type),A(e,16)}var t,i=m();i&&(t=document.querySelector("body"),new i(n).observe(t,{attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0}))}())}function t(t){!function(n){e.id?(e.iframe.style[n]=e[n]+"px",p(e.id,"IFrame ("+i+") "+n+" set to "+e[n]+"px")):p("undefined","messageData id not set")}(t),n(t)}var i=e.iframe.id;u[i]&&(u[i].sizeHeight&&t("height"),u[i].sizeWidth&&t("width"))}function C(e,n,t){t!==n.type&&c&&!window.jasmine?(p(n.id,"Requesting animation frame"),c(e)):e()}function E(e,n,t,i,o){var r,a=!1;u[i=i||t.id]&&(t&&"contentWindow"in t&&null!==t.contentWindow?(p(i,"["+e+"] Sending msg to iframe["+i+"] ("+n+") targetOrigin: "+(r=u[i]&&u[i].targetOrigin)),t.contentWindow.postMessage(s+n,r)):k(i,"["+e+"] IFrame("+i+") not found"),o&&u[i]&&u[i].warningTimeout&&(u[i].msgTimeout=setTimeout((function(){!u[i]||u[i].loaded||a||(a=!0,k(i,"IFrame has not responded within "+u[i].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}),u[i].warningTimeout)))}function N(e){return e+":"+u[e].bodyMarginV1+":"+u[e].sizeWidth+":"+u[e].log+":"+u[e].interval+":"+u[e].enablePublicMethods+":"+u[e].autoResize+":"+u[e].bodyMargin+":"+u[e].heightCalculationMethod+":"+u[e].bodyBackground+":"+u[e].bodyPadding+":"+u[e].tolerance+":"+u[e].inPageLinks+":"+u[e].resizeFrom+":"+u[e].widthCalculationMethod+":"+u[e].mouseEvents}function W(t,r){function s(e){var n=e.split("Callback");if(2===n.length){var t="on"+n[0].charAt(0).toUpperCase()+n[0].slice(1);this[t]=this[e],delete this[e],k(f,"Deprecated: '"+e+"' has been renamed '"+t+"'. The old method will be removed in the next major version.")}}var a,c,f=function(e){if("string"!=typeof e)throw new TypeError("Invaild id for iFrame. Expected String");var n;return""===e&&(t.id=(n=r&&r.id||l.id+i++,null!==document.getElementById(n)&&(n+=i++),e=n),o=(r||{}).log,p(e,"Added missing iframe ID: "+e+" ("+t.src+")")),e}(t.id);f in u&&"iFrameResizer"in t?k(f,"Ignored iFrame, already setup."):(function(e){var n;e=e||{},u[f]=Object.create(null),u[f].iframe=t,u[f].firstRun=!0,u[f].remoteHost=t.src&&t.src.split("/").slice(0,3).join("/"),function(e){if("object"!=typeof e)throw new TypeError("Options is not an object")}(e),Object.keys(e).forEach(s,e),function(e){for(var n in l)Object.prototype.hasOwnProperty.call(l,n)&&(u[f][n]=Object.prototype.hasOwnProperty.call(e,n)?e[n]:l[n])}(e),u[f]&&(u[f].targetOrigin=!0===u[f].checkOrigin?""===(n=u[f].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*")}(r),function(){switch(p(f,"IFrame scrolling "+(u[f]&&u[f].scrolling?"enabled":"disabled")+" for "+f),t.style.overflow=!1===(u[f]&&u[f].scrolling)?"hidden":"auto",u[f]&&u[f].scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=u[f]?u[f].scrolling:"no"}}(),function(){function e(e){var n=u[f][e];1/0!==n&&0!==n&&(t.style[e]="number"==typeof n?n+"px":n,p(f,"Set "+e+" = "+t.style[e]))}function n(e){if(u[f]["min"+e]>u[f]["max"+e])throw new Error("Value for min"+e+" can not be greater than max"+e)}n("Height"),n("Width"),e("maxHeight"),e("minHeight"),e("maxWidth"),e("minWidth")}(),"number"!=typeof(u[f]&&u[f].bodyMargin)&&"0"!==(u[f]&&u[f].bodyMargin)||(u[f].bodyMarginV1=u[f].bodyMargin,u[f].bodyMargin=u[f].bodyMargin+"px"),a=N(f),(c=m())&&(n=function(e){if(!t.parentNode)return null;var n=new e((function(e){e.forEach((function(e){Array.prototype.slice.call(e.removedNodes).forEach((function(e){e===t&&z(t)}))}))}));return n.observe(t.parentNode,{childList:!0}),n}(c)),w(t,"load",(function(){E("iFrame.onload",a,t,e,!0),(!u[f]||!u[f].firstRun)&&u[f]&&u[f].heightCalculationMethod in d&&O({iframe:t,height:0,width:0,type:"init"})})),E("init",a,t,e,!0),u[f]&&(u[f].iframe.iFrameResizer={close:z.bind(null,u[f].iframe),removeListeners:S.bind(null,u[f].iframe),resize:E.bind(null,"Window resize","resize",u[f].iframe),moveToAnchor:function(e){E("Move to anchor","moveToAnchor:"+e,u[f].iframe,f)},sendMessage:function(e){E("Send Message","message:"+(e=JSON.stringify(e)),u[f].iframe,f)}}))}function A(e,n){null===f&&(f=setTimeout((function(){f=null,e()}),n))}function L(){"hidden"!==document.visibilityState&&(p("document","Trigger event: Visibility change"),A((function(){P("Tab Visible","resize")}),16))}function P(e,n){Object.keys(u).forEach((function(t){(function(e){return u[e]&&"parent"===u[e].resizeFrom&&u[e].autoResize&&!u[e].firstRun})(t)&&E(e,n,u[t].iframe,t)}))}function H(){function n(e,n){n&&(function(){if(!n.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==n.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+n.tagName+">")}(),W(n,e),t.push(n))}var t;return function(){var e,n=["moz","webkit","o","ms"];for(e=0;e<n.length&&!c;e+=1)c=window[n[e]+"RequestAnimationFrame"];c?c=c.bind(window):p("setup","RequestAnimationFrame not supported")}(),w(window,"message",F),w(window,"resize",(function(){p("window","Trigger event: resize"),A((function(){P("Window resize","resize")}),16)})),w(document,"visibilitychange",L),w(document,"-webkit-visibilitychange",L),function(i,o){switch(t=[],function(e){e&&e.enablePublicMethods&&k("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}(i),typeof o){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(o||"iframe"),n.bind(e,i));break;case"object":n(i,o);break;default:throw new TypeError("Unexpected data type ("+typeof o+")")}return t}}}()),v.exports));class x{constructor(e,n){this.iframe=e,this.iframeOrigin=n}postMessage(e,n){const t=Object.assign({eventType:e},n);this.iframe.contentWindow.postMessage(t,this.iframeOrigin)}addMessageListener(e){window.addEventListener("message",e)}removeMessageListener(e){window.removeEventListener("message",e)}postMessageWithResponseListener(e,n){return new Promise((t=>{const i=n=>{n.data.eventType===e&&(window.removeEventListener("message",i),t(n.data.data))};window.addEventListener("message",i),this.postMessage(e,n)}))}}const F=class{constructor(n){e(this,n),this.iframeLoaded=i(this,"iframeLoaded",7),this.isFocused=!1,this.isValid=!0,this.dispatchMessageEvent=e=>{const{eventType:n,data:t}=e.data;(null==t?void 0:t.id)===this.inputId&&("focused"===n&&(this.isFocused=!0),"blurred"===n&&(this.isFocused=!1))}}disconnectedCallback(){this.frameService.removeMessageListener(this.dispatchMessageEvent)}async validate(){const e=await this.frameService.postMessageWithResponseListener("validate");return this.isValid=e.isValid,this.errorText=e.error.message,e}async tokenize(e,n,t){return this.frameService.postMessageWithResponseListener("tokenize",{clientId:e,paymentMethodMetadata:n,account:t,componentVersion:h.version})}initializeFrameCommunicationService(){var e;this.frameService=new x(this.iframeElement,this.iframeOrigin),null===(e=this.frameService)||void 0===e||e.addMessageListener(this.dispatchMessageEvent)}get part(){return this.isFocused&&!this.isValid?s:this.isValid?this.isFocused?c:d:a}get style(){return this.isFocused?this.isValid?w.focused:w.focusedAndInvalid:null}get urlParams(){const e=Object.fromEntries(Object.entries(w.fontStyles).map((([e,n])=>[e,btoa(String(n))])));return new URLSearchParams(e).toString()}render(){return n(t,{key:"ebf24e9c73ea9a7f352dfc7368678117144745c3",class:"form-group d-flex flex-column"},n("div",{key:"e88393af9005c217ad3cc2504e8285629339402c",style:{visibility:this.iframeLoaded?"visible":"hidden",height:this.iframeLoaded?"auto":"0"}},n("label",{key:"47591ac9c82096e9bde5b5706b08c9dc8461788b",class:"form-label",htmlFor:"",part:u},this.label||""),n("div",{key:"b39265660ede091bd365d983a702202469adab97",class:"p-0 d-flex form-control "+(this.isValid?"":"is-invalid"),part:this.part,style:Object.assign(Object.assign({},this.style),{overflow:"hidden"})},n("iframe",{key:"12354fce7a91119a17d577df02c2f627ebc10b98",id:this.inputId,name:this.inputId,src:`${this.iframeOrigin}?${this.urlParams}`,ref:e=>{this.iframeElement=e,this.initializeFrameCommunicationService()},width:"100%",onLoad:()=>{k({log:!1,onResized:()=>{this.iframeLoaded.emit()}},this.iframeElement)}})),n(l,{key:"604488d6da7e2ff87e24e3eed0a77b3a6231106e",errorText:this.errorText,name:this.inputId})))}get el(){return o(this)}};export{b as hidden_input,F as iframe_input}
@@ -1 +1 @@
1
- import{r as t,c as s,h as i}from"./p-CV0Pyo1O.js";import{P as e}from"./p-B_KHnbK8.js";import{m as r}from"./p-CkX7qWsc.js";import{E as o}from"./p-DAZtHA62.js";import{C as p,a}from"./p-Cjcsf8ku.js";import{c as h,J as n}from"./p-CbTf_N6u.js";import"./p-55QcjheA.js";import"./p-DVJaoI_m.js";import"./p-D8GTwl9v.js";import"./p-MeSAYDNh.js";import"./p-HXpYMWUU.js";import"./p-BiNakvsa.js";import"./p-BH0Xfn-F.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-D2muobcE.js";import"./p-C4FLe2pT.js";import"./p-D4eE0MBI.js";const m=class{constructor(i){t(this,i),this.errorEvent=s(this,"error-event",7),this.recordClickEvent=s(this,"record-click-event",7),this.errorMessage=null,this.paymentService=new e,this.handleErrorEvent=t=>{this.errorMessage=t.detail.message,this.errorEvent.emit(t.detail)},this.handleRecordClickEvent=t=>{this.recordClickEvent.emit({id:t.detail.id,type:t.detail.type})}}componentWillLoad(){h(),this.analytics=new n(this),this.initializeGetPaymentDetails()}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}propChanged(){this.initializeGetPaymentDetails()}initializeGetPaymentDetails(){this.paymentId&&this.authToken?this.getPaymentDetails=r({id:this.paymentId,authToken:this.authToken,service:new e}):(this.errorMessage="Payment ID and Auth Token are required",this.errorEvent.emit({message:this.errorMessage,errorCode:a.MISSING_PROPS,severity:p.ERROR}))}render(){return this.errorMessage?o(this.errorMessage):i("payment-details-core",{getPaymentDetails:this.getPaymentDetails,"onError-event":this.handleErrorEvent,"onRecord-click-event":this.handleRecordClickEvent,"enable-record-click":"true"})}static get watchers(){return{paymentId:["propChanged"],authToken:["propChanged"]}}};export{m as justifi_payment_details}
1
+ import{r as t,c as s,h as i}from"./p-CV0Pyo1O.js";import{P as e}from"./p-B_KHnbK8.js";import{m as r}from"./p-CkX7qWsc.js";import{E as o}from"./p-DAZtHA62.js";import{C as p,a}from"./p-Cjcsf8ku.js";import{c as h,J as n}from"./p-eEJvKFFX.js";import"./p-55QcjheA.js";import"./p-DVJaoI_m.js";import"./p-D8GTwl9v.js";import"./p-MeSAYDNh.js";import"./p-HXpYMWUU.js";import"./p-BiNakvsa.js";import"./p-BH0Xfn-F.js";import"./p-CLHwhyvu.js";import"./p-BcNb9bVO.js";import"./p-D2muobcE.js";import"./p-C4FLe2pT.js";import"./p-CfQ5vkQ3.js";const m=class{constructor(i){t(this,i),this.errorEvent=s(this,"error-event",7),this.recordClickEvent=s(this,"record-click-event",7),this.errorMessage=null,this.paymentService=new e,this.handleErrorEvent=t=>{this.errorMessage=t.detail.message,this.errorEvent.emit(t.detail)},this.handleRecordClickEvent=t=>{this.recordClickEvent.emit({id:t.detail.id,type:t.detail.type})}}componentWillLoad(){h(),this.analytics=new n(this),this.initializeGetPaymentDetails()}disconnectedCallback(){var t;null===(t=this.analytics)||void 0===t||t.cleanup()}propChanged(){this.initializeGetPaymentDetails()}initializeGetPaymentDetails(){this.paymentId&&this.authToken?this.getPaymentDetails=r({id:this.paymentId,authToken:this.authToken,service:new e}):(this.errorMessage="Payment ID and Auth Token are required",this.errorEvent.emit({message:this.errorMessage,errorCode:a.MISSING_PROPS,severity:p.ERROR}))}render(){return this.errorMessage?o(this.errorMessage):i("payment-details-core",{getPaymentDetails:this.getPaymentDetails,"onError-event":this.handleErrorEvent,"onRecord-click-event":this.handleRecordClickEvent,"enable-record-click":"true"})}static get watchers(){return{paymentId:["propChanged"],authToken:["propChanged"]}}};export{m as justifi_payment_details}
@@ -0,0 +1 @@
1
+ import{h as s,r as t,c as i}from"./p-CV0Pyo1O.js";import{C as e,a as o}from"./p-Cjcsf8ku.js";import{C as r,B as n,c as h}from"./p-BcNb9bVO.js";import{H as a}from"./p-C4FLe2pT.js";import{S as p}from"./p-BqNNwq6C.js";import{H as l}from"./p-BoO2BHR_.js";import"./p-CZfYo5-1.js";import{B as c}from"./p-XYgDHrVL.js";import{P as u}from"./p-C3kbpEIZ.js";import"./p-DqVU8ohH.js";const m=()=>s("div",{class:"row gap-3 p-5"},s("div",{class:"col-12"},s(l,{text:"Business Already Provisioned"})),s("div",{class:"col-12",part:a},s("p",null,"We have already received the onboarding information for this business."))),d=()=>s("div",{class:"row gap-3 p5"},s("div",{class:"col-12"},s(l,{text:"You're all set for now"})),s("div",{class:"col-12",part:a},s("p",null,"We're reviewing your information and working on your approval. We'll be in touch to let you know once you've been approved (or if we find anything that needs fixing). Have a good one!"))),f=class{constructor(s){t(this,s),this.clickEvent=i(this,"click-event",7),this.errorEvent=i(this,"error-event",7),this.submitEvent=i(this,"submit-event",7),this.loading=!1,this.businessLoading=!0,this.businessProvisioned=!1,this.formSubmitted=!1,this.currentStep=0,this.country=r.USA,this.allowOptionalFields=!1,this.setBusinessProvisioned=()=>new Promise((s=>{this.getBusiness({onSuccess:t=>{const i=new n(t.data);this.businessProvisioned=h(i),this.country=i.country_of_establishment,this.businessProvisioned&&this.errorEvent.emit({message:"A request to provision payments for this business has already been submitted.",errorCode:o.PROVISIONING_REQUESTED,severity:e.INFO}),this.businessLoading=!1,s()},onError:({error:t,code:i,severity:e})=>{this.errorEvent.emit({message:t,errorCode:i,severity:e}),this.businessLoading=!1,s()}})})),this.postProvisioningData=()=>{this.postProvisioning({onSuccess:s=>{this.formSubmitted=!0,this.submitEvent.emit({response:s})},onError:({error:s,code:t,severity:i})=>{this.submitEvent.emit({response:{error:s}}),this.errorEvent.emit({message:s,errorCode:t,severity:i})}})},this.refs=[],this.incrementSteps=()=>{if(this.currentStep<this.totalSteps)return this.currentStep++},this.decrementSteps=()=>this.currentStep--,this.previousStepButtonOnClick=()=>{this.clickEvent.emit({name:c.previousStep}),this.decrementSteps()},this.nextStepButtonOnClick=(s,t)=>{s.preventDefault(),this.clickEvent.emit({name:t}),this.refs[this.currentStep].validateAndSubmit({onSuccess:this.incrementSteps})}}handleFormCompleted(){this.postProvisioningData()}async componentWillLoad(){this.getBusiness?await this.setBusinessProvisioned():this.businessLoading=!1,this.refs=[this.coreInfoRef,this.legalAddressRef,this.additionalQuestionsRef,this.representativeRef,this.ownersRef,this.bankAccountRef,this.termsRef]}get businessEndpoint(){return`entities/business/${this.businessId}`}get formDisabled(){return this.loading||this.businessProvisioned}get totalSteps(){return this.refs.length-1}get stepCounter(){return`Step ${this.currentStep+1} of ${this.totalSteps+1}`}handleFormLoading(s){this.loading=s.detail}render(){return s(p,null,this.businessLoading?s(u,null):this.businessProvisioned?s(m,null):this.formSubmitted?s(d,null):s("div",{class:"row gap-3"},s(l,{text:this.formTitle}),s("justifi-payment-provisioning-form-steps",{businessId:this.businessId,authToken:this.authToken,refs:this.refs,currentStep:this.currentStep,allowOptionalFields:this.allowOptionalFields,country:this.country,handleFormLoading:this.handleFormLoading}),s("div",{class:"d-flex justify-content-between align-items-center"},s("div",{class:"d-flex align-items-center",part:a},this.stepCounter),s("justifi-payment-provisioning-form-buttons",{currentStep:this.currentStep,totalSteps:this.totalSteps,formLoading:this.loading,formDisabled:this.formDisabled,previousStepButtonOnClick:this.previousStepButtonOnClick,nextStepButtonOnClick:this.nextStepButtonOnClick}))))}};export{f as justifi_payment_provisioning_core}