import{l as d}from"./vendor-BGtMsOoo.js";import{A as i,B as g,C as m,E as p,g as v,L as _,F as a}from"./index-CRze-aDK.js";const{currencyCode:l}=v,f={viewItemList(e,t){i("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="productId"in e?m(e):p(e);i("select_item",{...t,items:[o]})},viewItem(e,t){var o,n;i("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;i("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 s,u;const n=p(e);n.quantity=t,i("add_to_cart",{...o,currency:l,value:(((u=(s=e.price)==null?void 0:s.actual)==null?void 0:u.amount)||0)*(t??1),items:[n]})},addItemsToCart(e,t){const o=d.sumBy(e,s=>{var u,c;return(c=(u=s==null?void 0:s.price)==null?void 0:u.actual)==null?void 0:c.amount}),n=e.filter(Boolean).map(s=>p(s));i("add_to_cart",{...t,currency:l,value:o,items:n,items_count:n.length})},removeItemsFromCart(e,t){const o=d.sumBy(e,s=>{var u;return(u=s.extendedPrice)==null?void 0:u.amount}),n=e.map(m);i("remove_from_cart",{...t,currency:l,value:o,items:n,items_count:n.length})},viewCart(e,t){i("view_cart",{...t,currency:l,value:e.total.amount,items:e.items.map(m),items_count:e.items.length})},clearCart(e,t){i("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{i("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(s){_.error(a,"beginCheckout",s)}},addShippingInfo(e,t,o){var n,s;try{i("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:(s=(n=e==null?void 0:e.coupons)==null?void 0:n[0])==null?void 0:s.code,items:e==null?void 0:e.items.map(m),items_count:e==null?void 0:e.items.length})}catch(u){_.error(a,"addShippingInfo",u)}},addPaymentInfo(e,t,o){var n,s,u,c;try{i("add_payment_info",{...t,payment_type:o,currency:(n=e==null?void 0:e.currency)==null?void 0:n.code,value:(s=e==null?void 0:e.total)==null?void 0:s.amount,coupon:(c=(u=e==null?void 0:e.coupons)==null?void 0:u[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,s,u,c,h;try{i("purchase",{...o,currency:(n=e.currency)==null?void 0:n.code,transaction_id:t,value:e.total.amount,coupon:(s=e.coupons)==null?void 0:s[0],shipping:(u=e.shippingTotal)==null?void 0:u.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,s,u;try{i("place_order",{...t,currency:(o=e.currency)==null?void 0:o.code,value:(n=e.total)==null?void 0:n.amount,coupon:(s=e.coupons)==null?void 0:s[0],shipping:e.shippingTotal.amount,tax:e.taxTotal.amount,items_count:(u=e.items)==null?void 0:u.length})}catch(c){_.error(a,"placeOrder",c)}},search(e,t=[],o=0){i("search",{search_term:e,items_count:o,visible_items:g(t.map(n=>n.code))})},viewSearchResults(e,t){var o;i("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){i("login",{...t,method:e})},signUp(e,t){i("sign_up",{...t,method:e})}};export{f as events};
//# sourceMappingURL=events-is6uTAVM.js.map
