function t_prod__init(e){var t=document.querySelector("#rec"+e);if(t){var r=t.querySelectorAll(".js-product");Array.prototype.forEach.call(r,(function(e){e.querySelector(".js-product-option")&&t_prod__initProduct(e)}))}}function t_prod__initProduct(e,t){"string"==typeof e&&(e=t),t_prod__initPrice(e),t_prod__addEvents__options(e),t_prod__updatePrice(e,t)}function t_prod__initPrice(e){if(e instanceof Element||(e=e[0]),e){var t=e.querySelector(".js-product-price");t||(e.insertAdjacentHTML("beforeend",''),t=e.querySelector(".js-product-price"));var r=t.textContent,c=t.getAttribute("data-product-price-def"),n=t.getAttribute("data-product-price-def-str");if(r){if(!c&&!n){var i=t_prod__cleanPrice(r);t.setAttribute("data-product-price-def",i),t.setAttribute("data-product-price-def-str",r.replace(/"/g,""))}}else t.setAttribute("data-product-price-def",0)}}function t_prod__updatePrice(e,t){if(e instanceof Element||(e=e[0]),e){var r=e.querySelector(".js-product-price:not(.js-store-prod-price-range-val)"),c=e.querySelectorAll(".js-product-option-variants"),n=0,i=0;if(r){var o=r.getAttribute("data-product-price-def");o*=1;var a=0;Array.prototype.forEach.call(c,(function(e){if(e){var t=e.querySelector("option:checked").getAttribute("data-product-variant-price");if(t){var r=t_prod__cleanPrice(t);-1!==t.indexOf("+")?i+=r:0!==parseFloat(r)&&(o=r)}else a+=1}}));var d=a===c.length,p=e.classList.contains("js-store-product");if((n=o+i)>0){var u=t_prod__showPrice(t_prod__roundPrice(n),t),s=r.getAttribute("data-product-price-def-str");if(d&&!p){var _=t_prod__saveUserInputInPrice(n,u,s);r.innerHTML=_}else r.innerHTML=u}else r.innerHTML=r.getAttribute("data-product-price-def-str")}}}function t_prod__saveUserInputInPrice(e,t,r){if(!r)return t;if(-1!==r.indexOf(t))return r;if(e=e.toString(),t!==r)if(window.tcart&&"00"===window.tcart.currency_dec){var c=window.tcart.currency_sep,n=t.replace(c+"00","");if(-1!==r.indexOf(n))return r.replace(n,t);if(-1!==r.indexOf(e))return r.replace(e,t)}else if(-1!==r.indexOf(e))return r.replace(e,t);return t}function t_prod__addEvents__options(e){if(e instanceof Element||(e=e[0]),e){var t=e.querySelectorAll(".js-product-option-variants");Array.prototype.forEach.call(t,(function(e){var t=e.closest(".js-product");e.addEventListener("change",(function(){t_prod__updatePrice(t),t_triggerEvent(document.body,"twishlist_addbtn")}))}))}}function t_prod__cleanPrice(e){return e?(e=(e=e.toString()).replace(",",".").replace(/[^0-9.]/g,""),e=parseFloat(e).toFixed(2),isNaN(e)&&(e=0),e=parseFloat(e),(e*=1)<0&&(e=0)):e=0,e}function t_prod__roundPrice(e){return e?(e=parseFloat(e).toFixed(2),e=parseFloat(e),(e*=1)<0&&(e=0)):e=0,e}function t_prod__showPrice(e,t){if(e){var r;if(e=e.toString(),window.tcart&&window.tcart.currency_dec&&"00"===window.tcart.currency_dec||t&&t.currencyDecimal&&"00"===t.currencyDecimal)if(-1===e.indexOf(".")&&-1===e.indexOf(","))e+=".00";else 1===e.substr(e.indexOf(".")+1).length&&(e+="0");e=e.replace(/\B(?=(\d{3})+(?!\d))/g," "),e=window.tcart&&window.tcart.currency_sep&&"."===window.tcart.currency_sep||t&&t.currencySeparator&&"."===t.currencySeparator?e.replace(",","."):e.replace(".",",")}else e="";return e}function t_triggerEvent(e,t){var r;document.createEvent?(r=document.createEvent("HTMLEvents")).initEvent(t,!0,!1):document.createEventObject&&((r=document.createEventObject()).eventType=t),r.eventName=t,e.dispatchEvent?e.dispatchEvent(r):e.fireEvent?e.fireEvent("on"+r.eventType,r):e[t]?e[t]():e["on"+t]&&e["on"+t]()}