{"version":3,"file":"FC_ProductImageVariant.B2Ir3I70.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/7Z72fBmwu5jHgTb4o8mq/NLZJweVd9xvcnZj0DOGK/FC_ProductImageVariant.js"],"sourcesContent":["/*\n * Framer Commerce\n * Confidential and Proprietary - All Rights Reserved\n * Unauthorized use, reproduction, distribution, or disclosure of this\n * source code or any related information is strictly prohibited.\n *\n * This software is the exclusive property of Framer Commerce (\"Company\").\n * It is considered highly confidential and proprietary information.\n *\n * Any use, copying, modification, distribution, or sharing of this software,\n * in whole or in part, without the express written permission of the Company\n * is strictly prohibited and may result in legal action.\n *\n * DISCLAIMER: This software does not provide any express or\n * implied warranties, including, but not limited to, the implied warranties\n * of merchantability and fitness for a particular purpose. In no event shall\n * Framer Commerce be liable for any direct, indirect, incidental, special,\n * exemplary, or consequential damages (including, but not limited to, procurement\n * of substitute goods or services; loss of use, data, or profits; or business\n * interruption) however caused and on any theory of liability, whether in\n * contract, strict liability, or tort (including negligence or otherwise)\n * arising in any way out of the use of this software, even if advised of\n * the possibility of such damage.\n *\n * Any unauthorized possession, use, copying, distribution, or dissemination\n * of this software will be considered a breach of confidentiality and may\n * result in legal action.\n *\n * For inquiries, contact:\n * Framer Commerce\n * Email: hello@framercommerce.com\n *\n * © 2025 Butter Supply Inc. All Rights Reserved.\n */import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useIsBrowser}from\"https://framerusercontent.com/modules/ncBs5KPMI9I5GEta13fn/zGXDjuZapa1SGy6D8P5e/IsBrowser.js\";/**\n * @framerDisableUnlink\n */export default function FC_ProductImageVariant(props){const isBrowser=useIsBrowser();const[currentImageNumber,setCurrentImageNumber]=useState(1);// Filter out empty images and create array of valid images\nconst validImages=Array.from({length:250},(_,i)=>({image:props[`image${i+1}`],imageNumber:i+1})).filter(item=>item.image);// Find current image based on image number\nconst currentImage=validImages.find(item=>item.imageNumber===currentImageNumber)?.image||validImages[0]?.image||\"\";// Handle image match events\nuseEffect(()=>{if(!isBrowser||!validImages.length)return;function handleImageMatch(e){if(e.detail&&e.detail.imageNumber){if(props.shopifyProductID&&e.detail.shopifyProductID!==`gid://shopify/Product/${props.shopifyProductID}`){return;}const imageNumber=parseInt(e.detail.imageNumber);if(!isNaN(imageNumber)&&validImages.some(item=>item.imageNumber===imageNumber)){setCurrentImageNumber(imageNumber);}}}document.addEventListener(\"variant__image__match\",handleImageMatch);return()=>{document.removeEventListener(\"variant__image__match\",handleImageMatch);};},[isBrowser,validImages]);if(!isBrowser){return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\"}});}return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",display:props.type===\"Fill\"?\"block\":\"flex\",alignItems:props.type===\"Fill\"?\"stretch\":\"center\",justifyContent:props.type===\"Fill\"?\"stretch\":\"center\",backgroundColor:props.Style?.backgroundColor||\"#f5f5f5\",padding:props.Style?.paddingPerSide?`${props.Style.paddingTop}px ${props.Style.paddingRight}px ${props.Style.paddingBottom}px ${props.Style.paddingLeft}px`:props.Style?.padding||0,borderRadius:props.Style?.radiusPerCorner?`${props.Style.radiusTopLeft}px ${props.Style.radiusTopRight}px ${props.Style.radiusBottomRight}px ${props.Style.radiusBottomLeft}px`:`${props.Style?.borderRadius||0}px`,overflow:\"hidden\",position:\"relative\"},children:currentImage?/*#__PURE__*/_jsx(\"img\",{src:currentImage,alt:\"\",style:{width:\"100%\",height:\"100%\",objectFit:props.type===\"Fill\"?\"cover\":\"contain\",borderRadius:props.Style?.radiusPerCorner?`${props.Style.radiusTopLeft}px ${props.Style.radiusTopRight}px ${props.Style.radiusBottomRight}px ${props.Style.radiusBottomLeft}px`:`${props.Style?.borderRadius||0}px`,display:\"block\",position:props.type===\"Fill\"?\"absolute\":\"relative\",top:props.type===\"Fill\"?0:\"auto\",left:props.type===\"Fill\"?0:\"auto\",minHeight:0,minWidth:0}}):// Show placeholder in canvas mode\ntypeof window!==\"undefined\"&&window.location.hostname.includes(\"framercanvas.com\")&&/*#__PURE__*/_jsxs(\"svg\",{width:\"40%\",height:\"40%\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"#9e9e9e\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",children:[/*#__PURE__*/_jsx(\"rect\",{x:\"3\",y:\"3\",width:\"18\",height:\"18\",rx:\"2\",ry:\"2\"}),/*#__PURE__*/_jsx(\"circle\",{cx:\"8.5\",cy:\"8.5\",r:\"1.5\"}),/*#__PURE__*/_jsx(\"polyline\",{points:\"21 15 16 10 5 21\"})]})});}// Generate image property controls dynamically\nconst controls={shopifyProductID:{type:ControlType.String,title:\"Product ID\",description:\"Connect to Product ID from CMS (required)\"},Style:{type:ControlType.Object,title:\"Style\",controls:{backgroundColor:{type:ControlType.Color,title:\"BG\",defaultValue:\"#FFFFFF00\"},borderRadius:{type:ControlType.FusedNumber,title:\"Radius\",defaultValue:0,toggleKey:\"radiusPerCorner\",toggleTitles:[\"All\",\"Corners\"],valueKeys:[\"radiusTopLeft\",\"radiusTopRight\",\"radiusBottomRight\",\"radiusBottomLeft\"],valueLabels:[\"TL\",\"TR\",\"BR\",\"BL\"],min:0,max:100,unit:\"px\"},padding:{type:ControlType.FusedNumber,title:\"Padding\",defaultValue:0,toggleKey:\"paddingPerSide\",toggleTitles:[\"All\",\"Sides\"],valueKeys:[\"paddingTop\",\"paddingRight\",\"paddingBottom\",\"paddingLeft\"],valueLabels:[\"T\",\"R\",\"B\",\"L\"],min:0}}},type:{type:ControlType.Enum,title:\"Type\",options:[\"Fill\",\"Fit\"],defaultValue:\"Fill\",displaySegmentedControl:true},images:{type:ControlType.Enum,title:\"Images\",options:[\"Auto\",\"Set\"],defaultValue:\"Auto\",displaySegmentedControl:true}};// Add Amount control that only shows when images mode is \"Set\"\nconst shouldShowAmount=props=>props.images===\"Set\";controls.amount={type:ControlType.Number,title:\"Amount\",defaultValue:8,min:1,max:250,step:1,displayStepper:true,hidden:props=>!shouldShowAmount(props)};for(let i=1;i<=250;i++){const shouldShow=props=>{if(props.images===\"Set\"){// In Set mode, show images up to the amount specified\nreturn i<=(props.amount||8);}else{// In Auto mode, show first image always, then only show next if previous is filled\nreturn i===1||props[`image${i-1}`];}};controls[`image${i}`]={type:ControlType.Image,title:`Image ${i}`,hidden:props=>!shouldShow(props)};}addPropertyControls(FC_ProductImageVariant,controls);// Generate default props for all 250 images\nconst defaultProps={shopifyProductID:\"\",type:\"Fill\",images:\"Auto\",amount:8,Style:{backgroundColor:\"#f5f5f5\",borderRadius:0,padding:0}};for(let i=1;i<=250;i++){defaultProps[`image${i}`]=\"\";}FC_ProductImageVariant.defaultProps=defaultProps;\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FC_ProductImageVariant\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FC_ProductImageVariant.map"],"mappings":"mQAmCG,SAAwB,EAAuB,EAAM,CAAC,IAAM,EAAU,EAAa,EAAO,CAAC,EAAmB,GAAuBA,EAAS,CAAC,EAC5I,EAAY,MAAM,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE,KAAK,CAAC,MAAM,EAAM,QAAQ,EAAE,KAAK,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,GAAM,EAAK,KAAK,EAClH,EAAa,EAAY,KAAK,GAAM,EAAK,cAAc,CAAkB,CAAC,EAAE,OAAO,EAAY,EAAE,EAAE,OAAO,GAC0iB,OAA1pB,MAAc,CAAC,GAAG,CAAC,GAAW,CAAC,EAAY,OAAO,OAAO,SAAS,EAAiB,EAAE,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,YAAY,CAAC,GAAG,EAAM,kBAAkB,EAAE,OAAO,mBAAmB,yBAAyB,EAAM,mBAAoB,OAAQ,IA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