import{l as d}from"./vendor-bSWkQivH.js";import{A as s,B as g,C as m,E as p,g as v,L as _,F as a}from"./index-Dqv5IkpS.js";const{currencyCode:l}=v,f={viewItemList(e,t){s("view_item_list",{...t,items_skus:g((e??[]).map(o=>o.code)),items_count:(e==null?void 0:e.length)??0})},selectItem(e,t){const o=e&&typeof e=="object"&&"productId"in e?m(e):p(e);s("select_item",{...t,items:[o]})},viewItem(e,t){var o,n;s("view_item",{...t,currency:l,value:(n=(o=e.price)==null?void 0:o.actual)==null?void 0:n.amount,items:[p(e)]})},addItemToWishList(e,t){var o,n;s("add_to_wishlist",{...t,currency:l,value:(n=(o=e.price)==null?void 0:o.actual)==null?void 0:n.amount,items:[p(e)]})},addItemToCart(e,t,o){var u,i;const n=p(e);n.quantity=t,s("add_to_cart",{...o,currency:l,value:(((i=(u=e.price)==null?void 0:u.actual)==null?void 0:i.amount)||0)*(t??1),items:[n]})},addItemsToCart(e,t){const o=d.sumBy(e,u=>{var i,c;return(c=(i=u==null?void 0:u.price)==null?void 0:i.actual)==null?void 0:c.amount}),n=e.filter(Boolean).map(u=>p(u));s("add_to_cart",{...t,currency:l,value:o,items:n,items_count:n.length})},updateCartItem(e,t,o,n){s("update_cart_item",{...n,item_id:e,new_quantity:t,previous_quantity:o})},removeItemsFromCart(e,t){const o=d.sumBy(e,u=>{var i;return(i=u.extendedPrice)==null?void 0:i.amount}),n=e.map(m);s("remove_from_cart",{...t,currency:l,value:o,items:n,items_count:n.length})},viewCart(e,t){s("view_cart",{...t,currency:l,value:e.total.amount,items:e.items.map(m),items_count:e.items.length})},clearCart(e,t){s("clear_cart",{...t,currency:l,value:e.total.amount,items:e.items.map(m),items_count:e.items.length})},beginCheckout(e,t){var o,n;try{s("begin_checkout",{...t,currency:e.currency.code,value:e.total.amount,items:e.items.map(m),items_count:e.items.length,coupon:(n=(o=e.coupons)==null?void 0:o[0])==null?void 0:n.code})}catch(u){_.error(a,"beginCheckout",u)}},addShippingInfo(e,t,o){var n,u;try{s("add_shipping_info",{...t,shipping_tier:o,currency:e==null?void 0:e.shippingPrice.currency.code,value:e==null?void 0:e.shippingPrice.amount,coupon:(u=(n=e==null?void 0:e.coupons)==null?void 0:n[0])==null?void 0:u.code,items:e==null?void 0:e.items.map(m),items_count:e==null?void 0:e.items.length})}catch(i){_.error(a,"addShippingInfo",i)}},addPaymentInfo(e,t,o){var n,u,i,c;try{s("add_payment_info",{...t,payment_type:o,currency:(n=e==null?void 0:e.currency)==null?void 0:n.code,value:(u=e==null?void 0:e.total)==null?void 0:u.amount,coupon:(c=(i=e==null?void 0:e.coupons)==null?void 0:i[0])==null?void 0:c.code,items:e==null?void 0:e.items.map(m),items_count:e==null?void 0:e.items.length})}catch(h){_.error(a,"addPaymentInfo",h)}},purchase(e,t,o){var n,u,i,c,h;try{s("purchase",{...o,currency:(n=e.currency)==null?void 0:n.code,transaction_id:t,value:e.total.amount,coupon:(u=e.coupons)==null?void 0:u[0],shipping:(i=e.shippingTotal)==null?void 0:i.amount,tax:(c=e.taxTotal)==null?void 0:c.amount,items:e.items.map(m),items_count:(h=e==null?void 0:e.items)==null?void 0:h.length})}catch(y){_.error(a,"purchase",y)}},placeOrder(e,t){var o,n,u,i;try{s("place_order",{...t,currency:(o=e.currency)==null?void 0:o.code,value:(n=e.total)==null?void 0:n.amount,coupon:(u=e.coupons)==null?void 0:u[0],shipping:e.shippingTotal.amount,tax:e.taxTotal.amount,items_count:(i=e.items)==null?void 0:i.length})}catch(c){_.error(a,"placeOrder",c)}},search(e,t=[],o=0){s("search",{search_term:e,items_count:o,visible_items:g(t.map(n=>n.code))})},viewSearchResults(e,t){var o;s("view_search_results",{...t,search_term:e,visible_items:g(((o=t==null?void 0:t.visible_items)==null?void 0:o.map(n=>n.code))??[]),results_count:t==null?void 0:t.results_count,results_page:t==null?void 0:t.results_page})},login(e,t){s("login",{...t,method:e})},signUp(e,t){s("sign_up",{...t,method:e})}};export{f as events};
//# sourceMappingURL=events-BtDFOLp0.js.map
