{"version":3,"file":"ProductStockLabel.BeD5_lKd.mjs","names":["useMemo"],"sources":["https:/framerusercontent.com/modules/toUvGHV1GWvSMGANwbhf/U4OZbeNMpOPF68KmBgiF/ProductStockLabel.js"],"sourcesContent":["// Create new Framer code component Product Stock Label in ProductStockLabel.tsx.\n// This replaces an external Inventory Label on CMS product cards, not product detail selected-variant labels.\n// Needs JSON parsing/aggregation unavailable natively. Expose shopifyData string (CMS-bound), label string default Out of stock,\n// color default rgb(204,72,43), font extended Font default 500 14px line height 1em zero letter spacing.\n// Parse Shopify JSON format {variants:[{availableForSale:boolean,...}]}. Render label ONLY if nonempty variants array and\n// EVERY variant availableForSale === false. Any true OR unknown availability, invalid JSON or no variants => return null.\n// Support optionally variants.nodes or edges[].node only if useful, primary input flat variants. Do not fetch or mutate Shopify data;\n// derive from supplied CMS data. Root semantic span noninteractive, style prop correctly merged, intrinsic auto dimensions,\n// no margin or padding, nowrap matching inline price row. Stable canvas/SSR behavior based on data.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo}from\"react\";function checkVariantAvailability(shopifyData){if(typeof shopifyData!==\"string\"||shopifyData.trim().length===0){return{status:\"invalid_json\",totalVariants:0,trueCount:0,falseCount:0,unknownCount:0};}let parsed;try{parsed=JSON.parse(shopifyData);}catch{return{status:\"invalid_json\",totalVariants:0,trueCount:0,falseCount:0,unknownCount:0};}const variantsSource=parsed?.variants;let variants=[];if(Array.isArray(variantsSource)){variants=variantsSource;}else if(Array.isArray(variantsSource?.nodes)){variants=variantsSource.nodes;}else if(Array.isArray(variantsSource?.edges)){variants=variantsSource.edges.map(edge=>edge?.node).filter(node=>node!==undefined&&node!==null);}if(!Array.isArray(variants)||variants.length===0){return{status:\"empty_variants\",totalVariants:0,trueCount:0,falseCount:0,unknownCount:0};}let trueCount=0;let falseCount=0;let unknownCount=0;for(const variant of variants){const value=variant?.availableForSale;if(value===true)trueCount+=1;else if(value===false)falseCount+=1;else unknownCount+=1;}const totalVariants=variants.length;if(unknownCount>0){return{status:\"unknown_values\",totalVariants,trueCount,falseCount,unknownCount};}if(trueCount===totalVariants){return{status:\"all_true\",totalVariants,trueCount,falseCount,unknownCount};}if(falseCount===totalVariants){return{status:\"all_false\",totalVariants,trueCount,falseCount,unknownCount};}return{status:\"mixed\",totalVariants,trueCount,falseCount,unknownCount};}/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function ProductStockLabel(props){const{shopifyData,label,color,font,style}=props;const availability=useMemo(()=>checkVariantAvailability(shopifyData),[shopifyData]);if(availability.status!==\"all_false\")return null;return /*#__PURE__*/_jsx(\"span\",{style:{position:\"relative\",display:\"inline-block\",width:\"max-content\",minWidth:\"max-content\",whiteSpace:\"nowrap\",margin:0,padding:0,color,fontFamily:font?.fontFamily,fontSize:font?.fontSize,fontStyle:font?.fontStyle,fontWeight:font?.fontWeight,letterSpacing:font?.letterSpacing,lineHeight:font?.lineHeight,textAlign:font?.textAlign,...style},children:label});}addPropertyControls(ProductStockLabel,{shopifyData:{type:ControlType.String,title:\"Shopify Data\",defaultValue:\"\",displayTextArea:true},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Out of stock\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"rgb(204,72,43)\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"14px\",variant:\"Medium\",letterSpacing:\"0em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ProductStockLabel\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ProductStockLabel.map"],"mappings":"2KAS0H,SAAS,EAAyB,EAAY,CAAC,GAAG,OAAO,GAAc,UAAU,EAAY,KA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