­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ (()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n",{id:"form_success",class:"ff-message-success ff_authorizenet_text"}).html(i.data.message).insertAfter(e.$form),"initAuthorizeNetModal"===i.data.actionName?e.initAuthorizeNetModal(i.data):console.error("No method found")})}},{key:"initAuthorizeNetModal",value:function(e){var t=this,n=e.modal_data;!function e(){"undefined"!=typeof Accept?new s(n,t):setTimeout(e,100)}()}}])}(),s=function(){return i(function e(n,i){t(this,e),this.config=n,this.handler=i,this.paymentForm=null,this.errorDiv=null,this.submitButton=null,this.isProcessing=!1,this.init()},[{key:"init",value:function(){this.createPaymentForm(),this.showLityModal()}},{key:"addLityStyles",value:function(){if(!document.getElementById("ff-authorizenet-lity-styles")){var e='");document.head.insertAdjacentHTML("beforeend",e)}}},{key:"createPaymentForm",value:function(){this.addLityStyles();var e="ff_authorizenet_payment_form_"+this.config.submission_id,t='\n
\n
\n

'.concat(this.config.i18n.payment_details,"

\n

").concat(this.config.i18n.provide_card_details,'

\n
Amount: ').concat(this.config.currency_symbol).concat(this.config.formatted_amount,'
\n
\n
\n
\n \n \n
\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n ');this.formHtml=t,this.formId=e}},{key:"showLityModal",value:function(){var e=this;"function"==typeof window.lity?(this.lityInstance=window.lity(this.formHtml),setTimeout(function(){document.getElementById(e.formId)&&e.setupFormElements()},100)):console.error("Lity is not loaded. Please ensure Lity library is enqueued.")}},{key:"setupFormElements",value:function(){if(this.paymentForm=document.getElementById(this.formId),this.errorDiv=document.getElementById("ff_authorizenet_payment_errors"),this.submitButton=document.getElementById("ff_authorizenet_submit_button"),this.paymentForm)if(this.errorDiv)if(this.submitButton){this.bindEvents();var e=this.paymentForm.querySelector("input");e&&e.focus()}else console.error("Submit button not found");else console.error("Error div not found");else console.error("Payment form not found:",this.formId)}},{key:"bindEvents",value:function(){var e=this;this.paymentForm.addEventListener("submit",function(t){t.preventDefault(),e.processPayment()}),document.getElementById("ff_authorizenet_card_number").addEventListener("input",function(e){for(var t=e.target.value.replace(/\s+/g,"").replace(/[^0-9]/gi,""),n="",i=0;i0&&i%4==0&&(n+=" "),n+=t[i];e.target.value=n}),document.getElementById("ff_authorizenet_card_expiry").addEventListener("input",function(e){var t=e.target.value.replace(/\s+/g,"").replace(/[^0-9]/gi,"");t.length>2&&(t=t.substring(0,2)+"/"+t.substring(2,4)),e.target.value=t}),document.getElementById("ff_authorizenet_card_cvc").addEventListener("input",function(e){e.target.value=e.target.value.replace(/[^0-9]/gi,"").substring(0,4)})}},{key:"hideModal",value:function(){this.lityInstance&&this.lityInstance.close(),this.handler&&this.handler.$form&&(this.handler.$form.parent().find(".ff_authorizenet_text").remove(),this.handler.$form.parent().find(".ff-message-success").remove(),this.handler.$form.parent().find(".ff-message-error").remove(),this.handler.$form.parent().find(".ff_msg_temp").remove())}},{key:"setButtonLoading",value:function(e){if(this.submitButton){var t=this.submitButton.querySelector(".ff-authorizenet-btn-text"),n=this.submitButton.querySelector(".ff-authorizenet-btn-spinner");e?(this.submitButton.disabled=!0,t&&(t.style.display="none"),n&&(n.style.display="block")):(this.submitButton.disabled=!1,t&&(t.style.display="block"),n&&(n.style.display="none"))}else console.error("Submit button not found")}},{key:"showError",value:function(e){this.errorDiv.textContent=e,this.errorDiv.style.display="block",this.submitButton.disabled=!1,this.submitButton.textContent=this.config.i18n.submit}},{key:"hideError",value:function(){this.errorDiv&&(this.errorDiv.style.display="none")}},{key:"processPayment",value:function(){var e=this;if(!this.isProcessing){this.isProcessing=!0,this.setButtonLoading(!0),this.hideError();var t=document.getElementById("ff_authorizenet_card_number"),n=document.getElementById("ff_authorizenet_card_expiry"),i=document.getElementById("ff_authorizenet_card_cvc");if(!t||!n||!i)return this.showError("Form elements not found. Please try again."),void(this.isProcessing=!1);var r=t.value.replace(/\s+/g,""),o=n.value,s=i.value,a=o.split("/");if(2===a.length){var u=a[0].trim(),f=a[1].trim();if(2===f.length&&(f="20"+f),!r||r.length<13||r.length>19)return this.isProcessing=!1,void this.showError("Please enter a valid card number");if(!u||u<1||u>12)return this.isProcessing=!1,void this.showError("Please enter a valid expiration month");if(!f||f.length<2)return this.isProcessing=!1,void this.showError("Please enter a valid expiration year");if(!s||s.length<3||s.length>4)return this.isProcessing=!1,void this.showError("Please enter a valid CVC");if(!this.config.public_client_key||!this.config.api_login_id)return this.isProcessing=!1,void this.showError("Payment configuration error. Please contact support.");var l={cardData:{cardNumber:r,month:u,year:f,cardCode:s},authData:{clientKey:this.config.public_client_key,apiLoginID:this.config.api_login_id}};"undefined"!=typeof Accept?Accept.dispatchData(l,function(t){if(t&&t.messages&&"Error"===t.messages.resultCode){var n="";if(t.messages.message&&t.messages.message.length>0)for(var i=0;i",{id:this.handler.formId+"_success",class:"ff-message-success ff_msg_temp ff_authorizenet_text"}).html("Confirming Payment, Please wait...").insertAfter(this.handler.$form),this.handler.formInstance.showFormSubmissionProgress(this.handler.$form);var t={action:"fluentform_authorizenet_process_payment",form_id:this.handler.formId,submission_id:this.config.submission_id,transaction_hash:this.config.transaction_hash,opaque_data_descriptor:e.dataDescriptor,opaque_data_value:e.dataValue};try{this.handler.formInstance.sendData(this.handler.$form,t)}catch(e){console.error("Error calling sendData:",e)}}else console.error("jQuery not available")}}])}();function a(e){e.each(e("form.fluentform_has_payment"),function(){var t=e(this);function n(e,n){new o(t,n).init()}t.off("fluentform_init_single","",n),t.on("fluentform_init_single",n),e(document).on("lity:close",function(e){var n=t.parent().find(".ff_authorizenet_text");n.length&&n.remove()})})}a(jQuery),jQuery(document).ready(function(e){a(e)})})();