(()=>{var t={};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),((o,n)=>{if(!o)return;const{currency:e,products:i,purchase:l,add_to_cart:a,eventsToTrack:r}=(null===(n=t.g._googlesitekit)||void 0===n?void 0:n.wcdata)||{},c=null==r?void 0:r.includes("add_to_cart"),d=null==r?void 0:r.includes("purchase");if(a&&c){var u,s;const{price:o}=a,n=f(o,e,a);null===(u=t.g._googlesitekit)||void 0===u||null===(s=u.gtagEvent)||void 0===s||s.call(u,"add_to_cart",n)}if(l&&d){var g,_,p;const{id:o,totals:n,items:e,user_data:i}=l,a=f(n.total_price,n.currency_code,e,o,n.shipping_total,n.tax_total);null!==(g=t.g._googlesitekit)&&void 0!==g&&g.gtagUserData&&i&&(a.user_data=i),null===(_=t.g._googlesitekit)||void 0===_||null===(p=_.gtagEvent)||void 0===p||p.call(_,"purchase",a)}const v=o("body");function f(t,o,n){let e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;const a={value:m(t),currency:o,items:[]};if(e&&(a.transaction_id=e),"number"==typeof i&&(a.shipping=i),"number"==typeof l&&(a.tax=l),n&&n.length)for(const t of n)a.items.push(h(t));else n&&n.id&&(a.items=[h(n)]);return a}function h(t){const{id:o,name:n,price:e,variation:i,quantity:l,categories:a}=t,r={item_id:o,item_name:n,price:m(e)};if(l&&(r.quantity=l),i&&(r.item_variant=i),a&&null!=a&&a.length){let t=1;for(const o of a)r[t>1?"item_category".concat(t):"item_category"]=o.name,t++}return r}function m(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return parseInt(t,10)/10**o}c&&(v.on("added_to_cart",(o,n,l,a)=>{var r,c;if(null==a||!a.jquery)return;const d=parseInt(a.data("product_id"),10);if(!d)return;const u=(null==i?void 0:i.find(t=>(null==t?void 0:t.id)===d))||{},{price:s}=u,g=f(s,e,u);null===(r=t.g._googlesitekit)||void 0===r||null===(c=r.gtagEvent)||void 0===c||c.call(r,"add_to_cart",g)}),o(".products-block-post-template .product, .wc-block-product-template .product").each(function(){const n=o(this),l=parseInt(n.find("[data-product_id]").attr("data-product_id"),10);l&&n.on("click",n=>{var a,r;const c=o(n.target).closest(".wc-block-components-product-button [data-product_id]");if(!c.length||!c.hasClass("add_to_cart_button")||c.hasClass("product_type_variable"))return;const d=(null==i?void 0:i.find(t=>(null==t?void 0:t.id)===l))||{},{price:u}=d,s=f(u,e,d);null===(a=t.g._googlesitekit)||void 0===a||null===(r=a.gtagEvent)||void 0===r||r.call(a,"add_to_cart",s)})}))})(t.g.jQuery)})();