!function(t){new class{constructor(){this.smart_button_id="#wfacp_smart_buttons",this.loading_gif="wfacp-dynamic-checkout-loading",this.button_displayed=!1,this.available_buttons={},this.wcEvents()}wcEvents(){"loading"!==document.readyState?this.DOMLoaded():document.addEventListener("DOMContentLoaded",()=>{this.DOMLoaded()})}isMobilePhone(){return"yes"===wfacp_frontend.is_mobile_phone}DOMLoaded(){t(document.body).on("updated_checkout",this.handleCheckout.bind(this)),t(document.body).on("fkwcs_smart_buttons_showed",this.handleWfgsGateway.bind(this)),this.checkButtons()}updateWrapperClass(){let e=Object.keys(this.available_buttons).length;e>0&&t(".wfacp_smart_button_outer_buttons").attr("count",e)}handleCheckout(){this.updateWrapperClass(),this.show_hide_smart_button()}handleWfgsGateway(){let e=t("#wfacp_smart_button_fkwcs_gpay_apay");0!==e.length&&(e.show(),this.showButtons())}show_hide_smart_button(){let t=200;"yes"===wfacp_frontend.is_desktop&&"yes"===wfacp_frontend.stripe_smart_show_on_desktop?t=wfacp_frontend.smart_button_hide_timeout:"no"===wfacp_frontend.is_desktop&&(t=wfacp_frontend.smart_button_hide_timeout_m),1==this.button_displayed&&(t=this.isMobilePhone()?500:100),setTimeout(()=>{!0===this.button_displayed?this.showButtons():this.hideButtons()},t)}getAvailableButtons(){return{"#wfacp_smart_button_stripe_gpay_apay":"#wfacp_smart_button_stripe_gpay_apay","#wfacp_smart_button_wc_payment_gpay_apay #wcpay-payment-request-wrapper #wcpay-payment-request-button":"#wfacp_smart_button_wc_payment_gpay_apay","#wfacp_smart_button_woo_braintree_braintree_paypal .wc_braintree_banner_gateway_braintree_paypal":"#wfacp_smart_button_woo_braintree_braintree_paypal","#wfacp_smart_button_woo_braintree_braintree_googlepay .wc_braintree_banner_gateway_braintree_googlepay":"#wfacp_smart_button_woo_braintree_braintree_googlepay","#wfacp_smart_button_woo_braintree_braintree_applepay .wc_braintree_banner_gateway_braintree_applepay":"#wfacp_smart_button_woo_braintree_braintree_applepay","#wfacp_smart_button_paymentplugins_wc_stripe .banner_payment_method_stripe_googlepay":"#wfacp_smart_button_paymentplugins_wc_stripe","#wfacp_smart_button_paymentplugins_wc_stripe .banner_payment_method_stripe_applepay":"#wfacp_smart_button_paymentplugins_wc_stripe","#wfacp_smart_button_paymentplugins_wc_stripe .banner_payment_method_stripe_payment_request":"#wfacp_smart_button_paymentplugins_wc_stripe","#wfacp_smart_button_paypal_express #checkout_paypal_message .angelleye_smart_button_checkout_top":"#wfacp_smart_button_paypal_express","#wfacp_smart_button_angelleye_ppcp #angelleye_ppcp_checkout_top":"#wfacp_smart_button_angelleye_ppcp"}}noConflictButton(){return["#wfacp_smart_button_wc_braintree .sv-wc-apple-pay-button","#wfacp_smart_button_amazon_pay #pay_with_amazon","#wfacp_smart_button_paymentplugins_wc_ppcp","#wfacp_smart_button_wffn_fake_cc","#wfacp_smart_button_wffn_fake_paypal"]}checkButtons(){let t=this.noConflictButton();for(let e=0;e<t.length;e++)this.findButtonElements(t[e]);let e=this.getAvailableButtons();for(let t in e){let a=e[t];this.domInsert(a,t)}}findButtonElements(t){null!=document.querySelector(t)&&(this.showButton(t),this.showButtonOnMobile())}domInsert(t,e){let a=document.querySelector(e);null!=a&&a.addEventListener("DOMNodeInserted",()=>{this.showButton(t),this.showButtonOnMobile()})}showButtonOnMobile(){this.isMobilePhone()&&this.showButtons()}showButton(t){let e=document.querySelector(t);null!=e&&(this.available_buttons[t]="yes",e.style.display="block",this.updateWrapperClass(),this.button_displayed=!0)}showButtons(){let t=document.querySelector(this.smart_button_id);null!=t&&(t.style.display="block",t.classList.remove(this.loading_gif),this.button_displayed=!0,this.handleAmazonButton(t))}handleAmazonButton(){null!=document.querySelector("#pay_with_amazon .amazonpay-button-inner-image")&&document.querySelector("#pay_with_amazon").classList.add("wfacp-amazon-active-image")}hideButtons(){let t=document.querySelector(this.smart_button_id);null!=t&&(t.style.display="none",this.button_displayed=!1)}}}(jQuery);