'use client';
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useMemo as l}from"react";import{useCartData as i,useCartUI as r,useFormatMoney as n,getGlobalColorStateStyle as s,filterHoverVariables as a,cls as p,getGlobalColorStateClass as g}from"@gem-sdk/core";let Cart=({setting:c,styles:o,builderAttrs:d,builderProps:m,className:h,style:u})=>{let{data:f}=i(),{openCart:v}=r(),x=n(f?.totalPrice??0,!1),w=l(()=>f?.lineItems.reduce((e,t)=>e+t.quantity,0)??0,[f?.lineItems]),b=s("c",o?.iconColor),_=c?.enableHoverEffect?b:a(b);return e("div",{...d,"data-id":m?.uid,"aria-hidden":!0,style:u,className:p("gp-relative gp-inline-block",m?.uid,h),onClick:v,children:t("div",{className:"gp-flex gp-cursor-pointer gp-items-center gp-gap-4",children:[t("div",{className:p("gp-relative",g("text",o?.iconColor)),style:_,children:[c?.svgIcon?e("span",{className:"gp-flex gp-h-8 gp-w-8 gp-items-center gp-justify-center [&_>_svg]:gp-h-8 [&_>_svg]:gp-w-8",dangerouslySetInnerHTML:{__html:c.svgIcon}}):e("span",{className:"gp-flex gp-h-8 gp-w-8 gp-items-center gp-justify-center [&_>_svg]:gp-h-8 [&_>_svg]:gp-w-8",children:e("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"})})}),e("span",{className:"gp-absolute -gp-right-2 -gp-top-1 gp-inline-flex gp-aspect-square gp-w-5 gp-animate-bounce gp-items-center gp-justify-center gp-rounded-full gp-bg-g-brand gp-text-xs gp-font-semibold gp-text-white",children:w})]}),!c?.iconOnly&&t("div",{className:"gp-flex gp-flex-col",children:[e("span",{className:"gp-font-semibold",children:c?.label}),e("div",{children:t("span",{"aria-label":"Total item","data-testid":"cart-total",children:[w," items - ",x]})})]})]})})};export{Cart as default};
