!function(e,r,t,i){var n=function(t){var i=this;if(i.params=wc_gzd_unit_price_observer_params,i.$wrapper=t.closest(i.params.wrapper),i.$form=i.$wrapper.find(".variations_form, .cart").length>0&&i.$wrapper.find(".variations_form, .cart"),i.isVar=!!i.$form&&i.$form.hasClass("variations_form"),i.$product=i.$wrapper.closest(".product"),i.requests=[],i.observer={},i.timeout=!1,i.priceData=!1,i.productId=0,i.$wrapper.length<=0&&(i.$wrapper=i.$product),i.replacePrice=!i.$wrapper.hasClass("bundled_product")&&i.params.replace_price,"MutationObserver"in r||"WebKitMutationObserver"in r||"MozMutationObserver"in r){if(i.$wrapper.addClass("has-unit-price-observer"),i.initObservers(i),i.isVar&&i.$form)i.productId=parseInt(i.$form.find("input[name=product_id]").length>0?i.$form.find("input[name=product_id]").val():i.$form.data("product_id")),i.variationId=parseInt(i.$form.find("input[name=variation_id]").length>0?i.$form.find("input[name=variation_id]").val():0),i.$form.find("input[name=variation_id]").length<=0&&(i.variationId=parseInt(i.$form.find("input.variation_id").length>0?i.$form.find("input.variation_id").val():0)),i.$form.on("reset_data.unit-price-observer",{GermanizedUnitPriceObserver:i},i.onResetVariation),i.$form.on("found_variation.unit-price-observer",{GermanizedUnitPriceObserver:i},i.onFoundVariation);else if(i.$form&&i.$form.find("*[name=add-to-cart][type=submit]").length>0)i.productId=parseInt(i.$form.find("*[name=add-to-cart][type=submit]").val());else if(i.$form&&i.$form.data("product_id"))i.productId=parseInt(i.$form.data("product_id"));else{var n=i.$product.attr("class").split(/\s+/);e.each(n,(function(e,r){if("post-"===r.substring(0,5)){var t=parseInt(r.substring(5).replace(/[^0-9]/g,""));if(t>0)return i.productId=t,!0}})),i.productId<=0&&1===i.$product.find("a.ajax_add_to_cart[data-product_id], a.add_to_cart_button[data-product_id]").length&&(i.productId=parseInt(i.$product.find("a.ajax_add_to_cart, a.add_to_cart_button").data("product_id")))}if(i.productId<=0)return i.destroy(i),!1;i.params.refresh_on_load&&e.each(i.params.price_selector,(function(e,r){var t=!!r.hasOwnProperty("is_primary_selector")&&r.is_primary_selector,n=i.getPriceNode(i,e,t),a=i.getUnitPriceNode(i,n);t&&a.length>0&&(i.stopObserver(i,e),i.setUnitPriceLoading(i,a),setTimeout((function(){i.stopObserver(i,e);var n=i.getCurrentPriceData(i,e,r.is_total_price,t,r.quantity_selector);n?i.refreshUnitPrice(i,n,e,t):a.length>0&&i.unsetUnitPriceLoading(i,a),i.startObserver(i,e,t)}),250))}))}t.data("unitPriceObserver",i)};n.prototype.destroy=function(e){(e=e||this).cancelObservers(e),e.$form&&e.$form.off(".unit-price-observer"),e.$wrapper.removeClass("has-unit-price-observer")},n.prototype.getTextWidth=function(e){var r=e.html(),t=""+r+"";e.html(t);var i=e.find("span:first").width();return e.html(r),i},n.prototype.getPriceNode=function(e,r,t){t=void 0!==t&&t;var i=e.$wrapper.find(r+":not(.price-unit):visible").not(".variations_form .single_variation .price").first();return t&&e.isVar&&(i.length<=0||!e.replacePrice)?i=e.$wrapper.find(".woocommerce-variation-price span.price:not(.price-unit):visible:last"):t&&i.length<=0&&(i=e.$wrapper.find(".price:not(.price-unit):visible:last")),i},n.prototype.getObserverNode=function(e,r,t){var i=e.getPriceNode(e,r,t);return t&&e.isVar&&!e.replacePrice&&(i=e.$wrapper.find(".single_variation:last")),i},n.prototype.getUnitPriceNode=function(e,r){if(r.length<=0)return[];var t=r.parents(".wp-block-woocommerce-product-price[data-is-descendent-of-single-product-template]").length>0;return"SPAN"===r[0].tagName?e.$wrapper.find(".price-unit"):t?e.$wrapper.find(".wp-block-woocommerce-gzd-product-unit-price[data-is-descendent-of-single-product-template] .price-unit"):e.$wrapper.find(".price-unit:not(.wc-gzd-additional-info-placeholder, .wc-gzd-additional-info-loop)")},n.prototype.stopObserver=function(e,r){var t=e.getObserver(e,r);t&&t.disconnect()},n.prototype.startObserver=function(e,r,t){var i=e.getObserver(e,r),n=e.getObserverNode(e,r,t);return!!i&&(e.stopObserver(e,r),n.length>0&&i.observe(n[0],{childList:!0,subtree:!0,characterData:!0}),!0)},n.prototype.initObservers=function(t){0===Object.keys(t.observer).length&&e.each(t.params.price_selector,(function(i,n){var a=!!n.hasOwnProperty("is_primary_selector")&&n.is_primary_selector,o=!1;if(t.getObserverNode(t,i,a).length>0){var s=function(r,o){var s=t.getPriceNode(t,i,a);if(t.timeout&&clearTimeout(t.timeout),s.length<=0)return!1;var d=t.getUnitPriceNode(t,s),p=!1;t.stopObserver(t,i),d.length>0&&t.setUnitPriceLoading(t,d),t.timeout=setTimeout((function(){t.stopObserver(t,i);var r=t.getCurrentPriceData(t,i,n.is_total_price,a,n.quantity_selector);r&&e.active<=0&&(p=!0,t.refreshUnitPrice(t,r,i,a)),!p&&d.length>0&&t.unsetUnitPriceLoading(t,d),t.startObserver(t,i,a)}),500)};"MutationObserver"in r?o=new r.MutationObserver(s):"WebKitMutationObserver"in r?o=new r.WebKitMutationObserver(s):"MozMutationObserver"in r&&(o=new r.MozMutationObserver(s)),o&&(t.observer[i]=o,t.startObserver(t,i,a))}}))},n.prototype.getObserver=function(e,r){return!!e.observer.hasOwnProperty(r)&&e.observer[r]},n.prototype.cancelObservers=function(e){for(var r in e.observer)e.observer.hasOwnProperty(r)&&(e.observer[r].disconnect(),delete e.observer[r])},n.prototype.onResetVariation=function(e){e.data.GermanizedUnitPriceObserver.variationId=0},n.prototype.onFoundVariation=function(e,r){var t=e.data.GermanizedUnitPriceObserver;r.hasOwnProperty("variation_id")&&(t.variationId=parseInt(r.variation_id)),t.initObservers(t)},n.prototype.getCurrentPriceData=function(r,t,i,n,a){a=a&&""!==a?a:r.params.qty_selector;var o=r.getPriceNode(r,t,n);if(o.length>0){o.find(":hidden").addClass("wc-gzd-is-hidden");var s=r.getUnitPriceNode(r,o),d=o.clone();d.find(".woocommerce-price-suffix").remove(),d.find(".wc-gzd-is-hidden").remove();var p="",c=d.find(".amount:first"),u=e(r.params.wrapper+" "+a+":first"),l=1;u.length>0&&(l=parseFloat(u.val())),c.length<=0&&(c=d.find(".price").length>0?d.find(".price"):d);var v=r.getRawPrice(c,r.params.price_decimal_sep);if(d.find(".amount").length>1){var f=e(d.find(".amount")[1]);p=r.getRawPrice(f,r.params.price_decimal_sep)}if(o.find(".wc-gzd-is-hidden").removeClass("wc-gzd-is-hidden"),s.length>0&&v)return i&&(v=parseFloat(v)/l,p.length>0&&(p=parseFloat(p)/l)),{price:v,unit_price:s,sale_price:p,quantity:l}}return!1},n.prototype.getCurrentProductId=function(e){var r=e.productId;return e.variationId>0&&(r=e.variationId),parseInt(r)},n.prototype.getRawPrice=function(e,r){var t=e.length>0?e.text():"",i=!1;try{i=accounting.unformat(t,r)}catch(e){i=!1}return i},n.prototype.setUnitPriceLoading=function(e,r){var t=r.html();if(r.hasClass("wc-gzd-loading"))t=r.data("org-html");else{var i=e.getTextWidth(r),n=r.find("span").length>0?r.find("span").innerHeight():r.height();r.html(''),r.addClass("wc-gzd-loading"),r.data("org-html",t)}return t},n.prototype.unsetUnitPriceLoading=function(e,r,t){t=t||r.data("org-html"),r.html(t),r.hasClass("wc-gzd-loading")&&r.removeClass("wc-gzd-loading").show()},n.prototype.refreshUnitPrice=function(e,r,t,i){germanized.unit_price_observer_queue.add(e,e.getCurrentProductId(e),r,t,i)},e.fn.wc_germanized_unit_price_observer=function(){return e(this).data("unitPriceObserver")&&e(this).data("unitPriceObserver").destroy(),new n(this),this},e((function(){"undefined"!=typeof wc_gzd_unit_price_observer_params&&e(wc_gzd_unit_price_observer_params.wrapper).each((function(){e(this).is("body")||e(this).wc_germanized_unit_price_observer()}))}))}(jQuery,window,document),window.germanized=window.germanized||{},((window.germanized=window.germanized||{}).static=window.germanized.static||{})["unit-price-observer"]={};