\x20\40\x20\40
(()=>{"use strict";var t={d:(e,o)=>{for(var c in o)t.o(o,c)&&!t.o(e,c)&&Object.defineProperty(e,c,{enumerable:!0,get:o[c]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{add_to_cart:()=>w,begin_checkout:()=>f,purchase:()=>h,remove_from_cart:()=>g,search:()=>v,select_content:()=>y,view_item:()=>b,view_item_list:()=>p});const o=window.wp.i18n,c=window.wp.hooks,r=(t,e)=>{var o;const c={};t.variation&&(c.item_variant=t.variation);const r={item_id:s(t),item_name:t.name,...u(t),quantity:null!==(o=t.quantity)&&void 0!==o?o:e,price:i(t.totals?.line_total||t.prices.price,t.prices.currency_minor_unit),...c};return t?.price_after_coupon_discount<t.prices.price&&(r.discount=i(t.prices.price-t.price_after_coupon_discount,t.prices.currency_minor_unit),r.price=i(t.price_after_coupon_discount,t.prices.currency_minor_unit)),r},n=(t,e)=>({item_id:s(t),item_name:t.name,item_list_name:e,...u(t),price:i(t.prices.price,t.prices.currency_minor_unit)}),i=(t,e=2)=>parseInt(t,10)/10**e,a=(t,e,o)=>{(0,c.removeAction)(t,e),(0,c.addAction)(t,e,o)},s=t=>{const e=t.extensions?.woocommerce_google_analytics_integration?.identifier;return void 0!==e?e:"product_sku"===window.ga4w?.settings?.identifier?t.sku?t.sku:"#"+t.id:t.id},d=t=>t.coupons[0]?.code?{coupon:t.coupons[0]?.code}:{},u=t=>"categories"in t&&t.categories.length?l(t.categories):{},l=t=>Object.fromEntries(t.slice(0,5).map(((t,e)=>[m(e),t.name]))),m=t=>"item_category"+(t>0?t+1:""),_=(t,e,o)=>{var c;return null!==(c=e?.find((({id:e})=>e===t)))&&void 0!==c?c:o?.items?.find((({id:e})=>e===t))},p=({products:t,listName:e=(0,o.__)("Product List","woocommerce-google-analytics-integration")})=>0!==t.length&&{item_list_id:"engagement",item_list_name:(0,o.__)("Viewing products","woocommerce-google-analytics-integration"),items:t.map(((t,o)=>({...n(t,e),index:o+1})))},w=({product:t,quantity:e=1})=>({items:t?[r(t,e)]:[]}),g=({product:t,quantity:e=1})=>({items:t?[r(t,e)]:[]}),f=({storeCart:t})=>({currency:t.totals.currency_code,value:i(t.totals.total_price,t.totals.currency_minor_unit),...d(t),items:t.items.map(r)}),y=({product:t})=>!!t&&{content_type:"product",content_id:s(t)},v=({searchTerm:t})=>({search_term:t}),b=({product:t,listName:e=(0,o.__)("Product List","woocommerce-google-analytics-integration")})=>!!t&&{items:[n(t,e)]},h=({order:t})=>void 0!==t&&{transaction_id:t.id,affiliation:t.affiliation,currency:t.totals.currency_code,value:i(t.totals.total_price,t.totals.currency_minor_unit),tax:i(t.totals.tax_total,t.totals.currency_minor_unit),shipping:i(t.totals.shipping_total,t.totals.currency_minor_unit),items:t.items.map(r)},k="woocommerce-google-analytics",C="experimental__woocommerce_blocks";let A=!1;const S=()=>window.ga4w?.settings?.currency,q=()=>{if(window.wp?.data?.select?.("wc/store/cart")){const t=window.wp.data.select("wc/store/cart").getCartData();if(t?.items?.length>0)return t}return window.ga4w?.data?.cart},E=t=>{a(`${C}-product-render`,k,t("view_item")),a(`${C}-cart-remove-item`,k,(e=>{A=!0,t("remove_from_cart")(e)})),(t=>{document.body.addEventListener("click",(e=>{const o=e.target.closest(".wc-block-cart-item__remove-link");if(!o)return;const c=o.closest(".wc-block-cart-items__row");if(!c)return;let r=null;const n=c.querySelector(".wc-block-components-product-name"),i=n?.getAttribute("href"),a=n?.textContent?.trim();let s=null;if(i){const t=i.match(/[?&]p=(\d+)/);t&&(s=parseInt(t[1],10))}const d=q();d?.items&&(s?r=_(s,[],d):a&&(r=d.items.find((t=>t.name===a)))),r||(r=(t=>{var e,o;const c=t.querySelector(".wc-block-components-product-name"),r=c?.textContent?.trim();if(!r)return null;const n=t.querySelector(".wc-block-components-quantity-selector__input"),i=n&&parseInt(n.value,10)||1,a=t.querySelector(".wc-block-components-product-price__value ins .woocommerce-Price-amount")||t.querySelector(".wc-block-components-product-price__value .woocommerce-Price-amount")||t.querySelector(".wc-block-components-product-price__value"),s=q(),d=S(),u=null!==(e=null!==(o=s?.totals?.currency_minor_unit)&&void 0!==o?o:d?.precision)&&void 0!==e?e:2,l=a?(t=>{if(!t)return 0;const e=S();if(!e)return 0;const{decimalSeparator:o=".",thousandSeparator:c=","}=e;if(window.accounting?.unformat)return window.accounting.unformat(t,o);let r=t.replace(/[^\d.,]/g,"").trim();if(c){const t=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");r=r.replace(new RegExp(t,"g"),"")}return"."!==o&&(r=r.replace(o,".")),parseFloat(r)||0})(a.textContent):0;return{name:r,quantity:i,prices:{price:Math.round(l*10**u),currency_minor_unit:u}}})(c)),r&&setTimeout((()=>{A||t("remove_from_cart")({product:r}),A=!1}),0)}))})(t),a(`${C}-checkout-render-checkout-form`,k,(e=>{const o=e?.storeCart,c=o?.items?.length>0?o:window.ga4w?.data?.cart;c&&t("begin_checkout")({storeCart:c})})),a(`${C}-cart-add-item`,k,(({product:e})=>{t("add_to_cart")({product:e})})),a(`${C}-product-list-render`,k,t("view_item_list")),a(`${C}-product-view-link`,k,t("select_content"))};(0,c.removeAction)(`${C}-checkout-submit`,k),(0,c.removeAction)(`${C}-checkout-set-email-address`,k),(0,c.removeAction)(`${C}-checkout-set-phone-number`,k),(0,c.removeAction)(`${C}-checkout-set-billing-address`,k),(0,c.removeAction)(`${C}-cart-set-item-quantity`,k),(0,c.removeAction)(`${C}-product-search`,k),(0,c.removeAction)(`${C}-store-notice-create`,k);const $={statistics:["analytics_storage"],marketing:["ad_storage","ad_user_data","ad_personalization"]};function L(){(({tracker_function_name:t})=>{if("function"==typeof wp_has_consent){void 0===window.wp_consent_type&&(window.wp_consent_type="optin");const e={};for(const[t,o]of Object.entries($))if(""!==consent_api_get_cookie(window.consent_api.cookie_prefix+"_"+t)){const c=wp_has_consent(t)?"granted":"denied";o.forEach((t=>{e[t]=c}))}Object.keys(e).length>0&&window[t]("consent","update",e)}})(window.ga4w.settings),(({tracker_function_name:t})=>{document.addEventListener("wp_listen_for_consent_change",(e=>{const o={},c=$[Object.keys(e.detail)[0]],r="allow"===Object.values(e.detail)[0]?"granted":"denied";void 0!==c&&(c.forEach((t=>{o[t]=r})),Object.keys(o).length>0&&window[t]("consent","update",o))}))})(window.ga4w.settings);const t=function({events:t,tracker_function_name:o}){return function(c){const r=e[c];if("function"!=typeof r)throw new Error(`Event ${c} is not supported.`);return function(e){const n=r(e);t.includes(c)&&n&&window[o]("event",c,n)}}}(window.ga4w.settings);!function(t,{events:e,cart:o,products:c,product:r,added_to_cart:n,order:i}){Object.values(null!=e?e:{}).forEach((e=>{"add_to_cart"===e?t(e)({product:n}):t(e)({storeCart:o,products:c,product:r,order:i})}));const a=document.body.onadded_to_cart;document.body.onadded_to_cart=function(e,n,i,s){"function"==typeof a&&a.apply(this,arguments);const d=parseInt(s?.[0]?.dataset.product_id||s?.[0]?.value);if(Number.isNaN(d))return void console.error("Google Analytics for WooCommerce: Could not read product ID from the button given in `added_to_cart` event. Check whether WooCommerce Core events or elements are malformed by other extensions.");const u=r?.id===d?r:_(d,c,o);u&&t("add_to_cart")({product:u})};const s=()=>{document.querySelectorAll(".woocommerce-cart-form .woocommerce-cart-form__cart-item .remove[data-product_id]").forEach((t=>t.addEventListener("click",d)))};function d(e){const r=parseInt(e.target?.dataset.product_id);Number.isNaN(r)?console.error("Google Analytics for WooCommerce: Could not read product ID from the target element given to remove from cart event. Check whether WooCommerce Core events or elements are malformed by other extensions."):t("remove_from_cart")({product:_(r,c,o)})}s();const u=document.body.onupdated_wc_div;document.body.onupdated_wc_div=function(){"function"==typeof u&&u.apply(this,arguments),s()};const l=document.body.onremoved_from_cart;document.body.onremoved_from_cart=function(t,e,o,c){"function"==typeof l&&l.apply(this,arguments),d({target:c?.[0]})},document.querySelectorAll(".products .product:not(.wp-block-post)")?.forEach((e=>{const r=e.querySelector("a[data-product_id]")?.getAttribute("data-product_id");r&&e.addEventListener("click",(e=>{const n=e.target.closest(".woocommerce-loop-product__link"),i=e.target.classList.contains("button")&&e.target.hasAttribute("data-product_id"),a=e.target.classList.contains("add_to_cart_button")&&!e.target.classList.contains("product_type_variable");(n||i&&!a)&&t("select_content")({product:_(parseInt(r),c,o)})}))})),document.querySelectorAll(".products-block-post-template .product, .wc-block-product-template .product")?.forEach((e=>{const r=e.querySelector("[data-product_id]")?.getAttribute("data-product_id");r&&e.addEventListener("click",(e=>{const n=e.target,i=n.closest(".wc-block-components-product-image a"),a=n.closest(".wp-block-post-title a"),s=n.closest(".wc-block-components-product-button [data-product_id]");s&&s.classList.contains("add_to_cart_button")&&!s.classList.contains("product_type_variable")?t("add_to_cart")({product:_(parseInt(r),c,o)}):(i||s||a)&&t("select_content")({product:_(parseInt(r),c,o)})}))}))}(t,window.ga4w.data),E(t)}function x(){window.ga4w||console.warn("Google Analytics for WooCommerce: Configuration and tracking data not found after the page was fully loaded. Make sure the `woocommerce-google-analytics-integration-data` script gets eventually loaded.")}window.ga4w?L():(document.addEventListener("ga4w:ready",L),"complete"===document.readyState?x():window.addEventListener("load",x))})();