(()=>{"use strict";const e=window.wp.i18n,t="woocommerce-google-analytics",o="experimental__woocommerce_blocks",c=window.wp.hooks,r=(e,t)=>({id:s(e),name:e.name,quantity:t,category:m(e),price:n(e.prices.price,e.prices.currency_minor_unit)}),i=(e,t)=>({id:s(e),name:e.name,list_name:t,category:m(e),price:n(e.prices.price,e.prices.currency_minor_unit)}),n=(e,t=2)=>(parseInt(e,10)/10**t).toString(),a=(e,t,o)=>{(0,c.removeAction)(e,t),(0,c.addAction)(e,t,o)},s=e=>e.sku?e.sku:"#"+e.id,m=e=>"categories"in e&&e.categories.length?e.categories[0].name:"";let u=-1;const p=e=>({storeCart:t})=>{u!==e&&(t.hasOwnProperty("cartTotals")||(t={cartCoupons:t.coupons,cartItems:t.items,cartTotals:t.totals}),g(0===e?"begin_checkout":"checkout_progress",{items:t.cartItems.map((e=>r(e,e.quantity))),coupon:t.cartCoupons[0]?.code||"",currency:t.cartTotals.currency_code,value:n(t.cartTotals.total_price,t.cartTotals.currency_minor_unit),checkout_step:e}),u=e)},_=({step:e,option:t,value:o})=>()=>{g("set_checkout_option",{checkout_step:e,checkout_option:t,value:o}),u=e},g=(e,t)=>{if("function"!=typeof gtag)throw new Error("Function gtag not implemented.");window.gtag("event",e,t)};a(`${o}-checkout-render-checkout-form`,t,(({...e})=>p(0)(e))),a(`${o}-checkout-set-email-address`,t,(({...e})=>p(1)(e))),a(`${o}-checkout-set-shipping-address`,t,(({...e})=>p(2)(e))),a(`${o}-checkout-set-billing-address`,t,(({...e})=>p(3)(e))),a(`${o}-checkout-set-phone-number`,t,(({step:e,...t})=>{p("shipping"===e?2:3)(t)})),a(`${o}-checkout-set-selected-shipping-rate`,t,(({shippingRateId:t})=>{_({step:4,option:(0,e.__)("Shipping Method","woo-gutenberg-products-block"),value:t})()})),a(`${o}-checkout-set-active-payment-method`,t,(({paymentMethodSlug:t})=>{_({step:5,option:(0,e.__)("Payment Method","woo-gutenberg-products-block"),value:t})()})),a(`${o}-product-list-render`,t,(({products:t,listName:o=(0,e.__)("Product List","woocommerce-google-analytics-integration")})=>{g("view_item_list",{event_category:"engagement",event_label:(0,e.__)("Viewing products","woocommerce-google-analytics-integration"),items:t.map(((e,t)=>({...i(e,o),list_position:t+1})))})})),a(`${o}-cart-add-item`,t,(({product:t,quantity:o=1})=>{g("add_to_cart",{event_category:"ecommerce",event_label:(0,e.__)("Add to Cart","woocommerce-google-analytics-integration"),items:[r(t,o)]})})),a(`${o}-cart-set-item-quantity`,t,(({product:t,quantity:o=1})=>{g("change_cart_quantity",{event_category:"ecommerce",event_label:(0,e.__)("Change Cart Item Quantity","woocommerce-google-analytics-integration"),items:[r(t,o)]})})),a(`${o}-cart-remove-item`,t,(({product:t,quantity:o=1})=>{g("remove_from_cart",{event_category:"ecommerce",event_label:(0,e.__)("Remove Cart Item","woocommerce-google-analytics-integration"),items:[r(t,o)]})})),a(`${o}-checkout-submit`,t,(()=>{g("add_payment_info")})),a(`${o}-product-view-link`,t,(({product:t,listName:o=(0,e.__)("Product List","woocommerce-google-analytics-integration")})=>{g("select_content",{content_type:"product",items:[i(t,o)]})})),a(`${o}-product-search`,t,(({searchTerm:e})=>{g("search",{search_term:e})})),a(`${o}-product-render`,t,(({product:t,listName:o=(0,e.__)("Product List","woocommerce-google-analytics-integration")})=>{t&&g("view_item",{items:[i(t,o)]})})),a(`${o}-store-notice-create`,t,(({status:e,content:t})=>{"error"===e&&g("exception",{description:t,fatal:!1})}))})();