{"version":3,"file":"Shopify_ProductAddToCart.CKiddW8L.mjs","names":[],"sources":["https:/framerusercontent.com/modules/sLbkDuXdCdpfHR6EbULm/ASRHjqKAeEZLYknSWrxf/Shopify_ProductAddToCart.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";import{cn,textProperties,ProductBaseControls,ConfigControls}from\"https://framerusercontent.com/modules/7dEgbg7qo3lsQk361YtS/GcbE9R3HahoLzirI2AwT/_utils.js\";import{useProduct}from\"https://framerusercontent.com/modules/xEahqZEsyG5uoZky61jQ/20W3GuDrfjSYfjii0us3/_useProduct.js\";import{useCart}from\"https://framerusercontent.com/modules/kEMMGb5hqGCVwEpqX70U/CTQr4PQF56Lu06nEcZTz/_useCart.js\";import ComponentWrapper from\"https://framerusercontent.com/modules/hQlZBgGeLDev5WuUJA4d/bjHQA4uLvjbgjrDSUO16/ComponentWrapper.js\";/**\n * @framerDisableUnlink\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function Shopify_ProductAddToCart(props){var _props_productID;const{product,selectedProduct}=useProduct((_props_productID=props.productID)!==null&&_props_productID!==void 0?_props_productID:null,props.config);const{addToCart,actionLoading,cartError}=useCart(props.config);const handleAddToCart=async()=>{const attributes=[];const productElements=document.querySelectorAll('[name^=\"product-\"]');productElements.forEach(element=>{const key=element.getAttribute(\"name\").replace(\"product-\",\"\");const value=element.value;if(value&&value!==\"\"){attributes.push({key,value});}});if(selectedProduct===null||selectedProduct===void 0?void 0:selectedProduct.selectedOption){addToCart(selectedProduct.selectedOption,selectedProduct.quantity,attributes);}else{addToCart(product===null||product===void 0?void 0:product.variants.nodes[0].id,1);}};return /*#__PURE__*/_jsxs(ComponentWrapper,{style:cn(styles.wrapper),productID:props.productID||\"EMPTY\",config:props.config,children:[/*#__PURE__*/_jsx(motion.button,{onClick:handleAddToCart,disabled:actionLoading,style:cn(styles.container,props.styles,actionLoading&&styles.loading),whileHover:{...cn(props.hoverStyle),transition:{duration:.25}},children:/*#__PURE__*/_jsx(\"span\",{children:props.label})}),cartError&&/*#__PURE__*/_jsx(motion.span,{style:cn(props.errorStyle),children:cartError})]});}Shopify_ProductAddToCart.displayName=\"Product Add To Cart\";addPropertyControls(Shopify_ProductAddToCart,{...ConfigControls,...ProductBaseControls,label:{title:\"Label\",type:ControlType.String,defaultValue:\"Add to cart\"},styles:{buttonTitle:\"Style\",type:ControlType.Object,controls:{...textProperties(16,\"#000\"),backgroundColor:{title:\"Background color\",type:ControlType.Color,optional:true},border:{type:ControlType.Border,defaultValue:{borderColor:\"#000\"}},borderRadius:{type:ControlType.BorderRadius,defaultValue:\"6px\"},padding:{type:ControlType.Padding,defaultValue:\"10px 32px 10px 32px\"}}},hoverStyle:{title:\"Hover\",buttonTitle:\"Style\",type:ControlType.Object,controls:{color:{type:ControlType.Color,defaultValue:\"#fff\",optional:true},backgroundColor:{type:ControlType.Color,defaultValue:\"#000\",optional:true},border:{type:ControlType.Border,defaultValue:{borderColor:\"#fff\"}}}},errorStyle:{title:\"Error Style\",type:ControlType.Object,controls:textProperties(14,\"#bb0000\")}});const styles={wrapper:{display:\"flex\",flexDirection:\"column\",gap:8},container:{display:\"flex\",flexDirection:\"row\",alignItems:\"center\",justifyContent:\"center\",cursor:\"pointer\",flex:1,fontFamily:\"inherit\"},loading:{opacity:.6,cursor:\"wait\"}};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Shopify_ProductAddToCart\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"* @framerSupportedLayoutWidth any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Shopify_ProductAddToCart.map"],"mappings":"8XAIG,SAAwB,EAAyB,EAAM,CAAsB,GAAK,CAAC,UAAQ,mBAA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