{"version":3,"file":"CartQuickAdd.CbcFvRtT.mjs","names":["useState","startTransition","_Fragment"],"sources":["https:/framerusercontent.com/modules/JgPHNZuUlYIKwTqeFAi3/WJ71HfJelTX67P2mdxnI/CartQuickAdd.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{motion,AnimatePresence}from\"framer-motion\";const STORE_KEY=\"cavara-cart-v1\";function readStore(){const empty={lines:[],open:false,shop:\"\",token:\"\"};if(typeof window===\"undefined\")return empty;const scope=window;if(!scope.__cavaraCart){let saved=null;try{saved=JSON.parse(window.localStorage.getItem(STORE_KEY)??\"null\");}catch(error){saved=null;}scope.__cavaraCart={...empty,lines:saved?.lines??[]};}return scope.__cavaraCart;}function commitStore(){if(typeof window===\"undefined\")return;const store=readStore();try{window.localStorage.setItem(STORE_KEY,JSON.stringify({lines:store.lines}));}catch(error){// storage can be unavailable in private mode — cart still works in memory\n}window.dispatchEvent(new CustomEvent(\"cavara-cart\"));}/** CMS image fields arrive as an object; plain URL controls arrive as a string. */function resolveImageSrc(value){if(!value)return\"\";if(typeof value===\"string\")return value;return typeof value.src===\"string\"?value.src:\"\";}/**\n * Quick Add\n *\n * Quantity stepper plus an animated add-to-cart button. Writes into the shared\n * Cavara cart store that Cart Pill and Cart Drawer read from.\n *\n * @framerIntrinsicWidth 558\n * @framerIntrinsicHeight 41\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function QuickAdd(props){const{variantId,title,image,priceLabel,unitPrice,label,addedLabel,accent,onAccent,outline,maxQty,font,style}=props;const imageSrc=resolveImageSrc(image);const[qty,setQty]=useState(1);const[added,setAdded]=useState(false);const isStatic=useIsStaticRenderer();useEffect(()=>{if(!added)return;const timer=window.setTimeout(()=>startTransition(()=>setAdded(false)),1400);return()=>window.clearTimeout(timer);},[added]);function step(delta){startTransition(()=>setQty(value=>Math.min(maxQty,Math.max(1,value+delta))));}function addToCart(){if(isStatic)return;const store=readStore();const existing=store.lines.find(line=>line.variantId===variantId&&line.title===title);if(existing){existing.qty=Math.min(99,existing.qty+qty);// carts saved before the lot image was wired up carry no artwork —\n// repair them the next time the same lot is added\nif(!existing.image&&imageSrc)existing.image=imageSrc;}else{store.lines=[...store.lines,{variantId,title,image:imageSrc,unitPrice,priceLabel,qty}];}store.open=true;commitStore();startTransition(()=>{setAdded(true);setQty(1);});}const stepperButton={width:34,height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",background:\"transparent\",border:\"none\",padding:0,cursor:\"pointer\",color:accent,fontSize:15,lineHeight:1,fontFamily:\"inherit\"};return /*#__PURE__*/_jsxs(\"div\",{style:{...style,position:\"relative\",display:\"flex\",alignItems:\"center\",gap:10,width:\"100%\",minWidth:\"max-content\",...font},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"center\",height:38,borderRadius:999,border:`1px solid ${outline}`,flex:\"0 0 auto\",overflow:\"hidden\"},children:[/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:()=>step(-1),style:stepperButton,\"aria-label\":\"Decrease quantity\",children:\"−\"}),/*#__PURE__*/_jsx(\"div\",{style:{width:30,textAlign:\"center\",color:accent,fontVariantNumeric:\"tabular-nums\",userSelect:\"none\"},children:/*#__PURE__*/_jsx(AnimatePresence,{mode:\"popLayout\",initial:false,children:/*#__PURE__*/_jsx(motion.span,{initial:{y:8,opacity:0},animate:{y:0,opacity:1},exit:{y:-8,opacity:0},transition:{type:\"spring\",stiffness:520,damping:34},style:{display:\"block\"},children:qty},qty)})}),/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:()=>step(1),style:stepperButton,\"aria-label\":\"Increase quantity\",children:\"+\"})]}),/*#__PURE__*/_jsxs(motion.button,{type:\"button\",onClick:addToCart,\"aria-label\":`${label} ${title}`,initial:false,whileHover:isStatic?undefined:{scale:1.012},whileTap:isStatic?undefined:{scale:.975},transition:{type:\"spring\",stiffness:460,damping:30},style:{position:\"relative\",flex:\"1 1 auto\",height:41,borderRadius:999,border:\"none\",background:accent,cursor:\"pointer\",overflow:\"hidden\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",fontFamily:\"inherit\",...font,color:onAccent},children:[/*#__PURE__*/_jsx(motion.span,{\"aria-hidden\":true,initial:{x:\"-120%\"},animate:added?{x:\"120%\"}:{x:\"-120%\"},transition:{duration:.9,ease:[.22,1,.36,1]},style:{position:\"absolute\",inset:0,background:`linear-gradient(100deg, transparent 0%, ${onAccent}33 45%, transparent 90%)`,pointerEvents:\"none\"}}),/*#__PURE__*/_jsx(AnimatePresence,{mode:\"popLayout\",initial:false,children:/*#__PURE__*/_jsx(motion.span,{initial:{y:14,opacity:0},animate:{y:0,opacity:1},exit:{y:-14,opacity:0},transition:{type:\"spring\",stiffness:480,damping:32},style:{display:\"flex\",alignItems:\"center\",gap:8,whiteSpace:\"nowrap\"},children:added?/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"svg\",{width:\"13\",height:\"13\",viewBox:\"0 0 24 24\",fill:\"none\",\"aria-hidden\":true,children:/*#__PURE__*/_jsx(\"path\",{d:\"M4 12.5l5 5L20 6.5\",stroke:onAccent,strokeWidth:\"2.2\",strokeLinecap:\"round\",strokeLinejoin:\"round\"})}),addedLabel]}):`${label} — ${priceLabel}`},added?\"added\":\"idle\")})]})]});}addPropertyControls(QuickAdd,{variantId:{type:ControlType.String,title:\"Variant ID\",defaultValue:\"\",placeholder:\"gid://shopify/ProductVariant/…\",description:\"Shopify variant ID for this lot.\"},title:{type:ControlType.String,title:\"Title\",defaultValue:\"Ethiopia \\xb7 Guji Highlands\"},image:{type:ControlType.Image,title:\"Image\"},priceLabel:{type:ControlType.String,title:\"Price Label\",defaultValue:\"$34\"},unitPrice:{type:ControlType.Number,title:\"Unit Price\",defaultValue:34,min:0,max:1e4,step:1},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Add to cart\"},addedLabel:{type:ControlType.String,title:\"Added Label\",defaultValue:\"Added to cart\"},accent:{type:ControlType.Color,title:\"Accent\",defaultValue:\"#241813\"},onAccent:{type:ControlType.Color,title:\"On Accent\",defaultValue:\"#F8F4EB\"},outline:{type:ControlType.Color,title:\"Outline\",defaultValue:\"rgba(36, 24, 19, 0.22)\"},maxQty:{type:ControlType.Number,title:\"Max Qty\",defaultValue:20,min:1,max:99,step:1},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{variant:\"Medium\",fontSize:\"14px\",letterSpacing:\"0em\",lineHeight:\"1.2em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"QuickAdd\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"41\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"558\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CartQuickAdd.map"],"mappings":"oRAAgS,SAAS,GAAW,CAAC,IAAM,EAAM,CAAC,MAAM,CAAC,EAAE,KAAK,GAAM,KAAK,GAAG,MAAM,EAAE,EAAE,GAAU,IAAS,OAAY,OAAO,EAAM,IAAM,EAAM,EAAO,GAAG,CAAC,EAAM,aAAa,CAAC,IAAI,EAAM,KAAK,GAAG,CAAC,EAAM,KAAK,MAAM,EAAO,aAAa,QAAQ,CAAS,GAAG,MAAM,CAAE,MAAa,CAAC,EAAM,IAAK,CAAC,EAAM,aAAa,CAAC,GAAG,EAAM,MAAM,GAAO,OAAO,CAAC,CAAC,CAAE,CAAC,OAAO,EAAM,YAAa,CAAC,SAAS,GAAa,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,EAAM,EAAU,EAAE,GAAG,CAAC,EAAO,aAAa,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