'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),React=require("react"),core=require("@gem-sdk/core");const Cart=({setting:e,styles:t,builderAttrs:s,builderProps:r,className:i,style:l})=>{let{data:n}=core.useCartData(),{openCart:a}=core.useCartUI(),o=core.useFormatMoney(n?.totalPrice??0,!1),c=React.useMemo(()=>n?.lineItems.reduce((e,t)=>e+t.quantity,0)??0,[n?.lineItems]),g=core.getGlobalColorStateStyle("c",t?.iconColor),p=e?.enableHoverEffect?g:core.filterHoverVariables(g);return jsxRuntime.jsx("div",{...s,"data-id":r?.uid,"aria-hidden":!0,style:l,className:core.cls("gp-relative gp-inline-block",r?.uid,i),onClick:a,children:jsxRuntime.jsxs("div",{className:"gp-flex gp-cursor-pointer gp-items-center gp-gap-4",children:[jsxRuntime.jsxs("div",{className:core.cls("gp-relative",core.getGlobalColorStateClass("text",t?.iconColor)),style:p,children:[e?.svgIcon?jsxRuntime.jsx("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:e.svgIcon}}):jsxRuntime.jsx("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:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("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"})})}),jsxRuntime.jsx("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:c})]}),!e?.iconOnly&&jsxRuntime.jsxs("div",{className:"gp-flex gp-flex-col",children:[jsxRuntime.jsx("span",{className:"gp-font-semibold",children:e?.label}),jsxRuntime.jsx("div",{children:jsxRuntime.jsxs("span",{"aria-label":"Total item","data-testid":"cart-total",children:[c," items - ",o]})})]})]})})};exports.default=Cart;
