!function(t){"use strict";var i=function(){this.variationPrice="",this.othersPrice="",this.qty=1,this.removeAttr=!1,this.init=function(){this.btn=document.querySelector("button.single_add_to_cart_button[data-price-atc-val]"),this.btn&&(this.numberFormat=wNumb({mark:reyParams.price_decimal_separator,thousand:reyParams.price_thousand_separator,decimals:reyParams.price_decimal_precision}),this.mainPrice=this.btn.getAttribute("data-price-atc-val"),this.form=this.btn.closest("form.cart"),this.isVariableProduct=this.form.classList.contains("variations_form"),this.events())},this.events=function(){t(this.form).on("found_variation",((t,i)=>{i.display_price&&(this.variationPrice=i.display_price,this.setPriceAttr())})),t(this.form).on("reset_data",(()=>{this.variationPrice="",this.setPriceAttr()})),t(document).ajaxSuccess(((i,e,r)=>{if("rightpress_product_price_live_update"===new URLSearchParams(r.data).get("action")){var a=t(".rightpress_product_price_live_update .price");a.length&&(this.othersPrice=this.numberFormat.from(a.text()),this.othersPrice&&this.setPriceAttr())}})),rey.dom.delegate(document,"change",".quantity .qty",(t=>{t.initiator.classList.contains("--disabled")||t.initiator.closest(".product.product-type-grouped")||this.isVariableProduct&&this.form.querySelector(".wc-variation-selection-needed")||(this.qty=parseFloat(t.initiator.value)||1,this.setPriceAttr())})),rey.dom.delegate(document,"change","input[name=subscribe-to-action-input]",(t=>{var i="no"===t.initiator.value;this.removeAttr=!i,i?this.setPriceAttr():this.btn.setAttribute("data-price-atc-val","")}))},this.setPriceAttr=function(){var t;this.removeAttr?this.btn.setAttribute("data-price-atc-val",""):(t=this.othersPrice?this.othersPrice:this.variationPrice?this.variationPrice:this.numberFormat.from(this.mainPrice))&&this.btn.setAttribute("data-price-atc-val",reyParams.price_format.replace("{{price}}",this.numberFormat.to(t*this.qty)))},this.init()};document.addEventListener("rey-DOMContentLoaded",(function(t){new i}))}(jQuery);