{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/xEahqZEsyG5uoZky61jQ/0fKThaOrafAWucwKdjoT/_useProduct.js", "ssg:https://framerusercontent.com/modules/XUMZkHzkb6JRq7hdD46W/ZNjEBvlFU5A2kT222b25/Shopify_ProductPrice.js"],
  "sourcesContent": ["import{useState,useEffect,useMemo}from\"react\";import{useAtom}from\"jotai\";import{useShopify}from\"https://framerusercontent.com/modules/tdCHCV0pSkxlDaX5GkOX/X3Q52ZLiO6DTT1Sb5gV1/_useShopify.js\";import{priceCode}from\"https://framerusercontent.com/modules/7dEgbg7qo3lsQk361YtS/NrF60tPHZRRgADqpoRFr/_utils.js\";import{selectedProductsAtom}from\"https://framerusercontent.com/modules/yZBbIevRfN36MGDPpltx/4PeFfcQIwdCvASoUnlqk/_atoms.js\";import{DefaultProduct}from\"https://framerusercontent.com/modules/fWwtzMT2tYXMW4IKB8On/wpKBMEEfYUg1FgLTPRiM/_test_data.js\";const DefaultSelectedOption={quantity:1,quantityAvailable:null,selectedOption:null,sellingPlan:null};export function useProduct(productID,config,addToSelected){const[selectedProducts,setSelectedProducts]=useAtom(selectedProductsAtom);const{products}=useShopify(config);const[product,setProduct]=useState((config===null||config===void 0?void 0:config.testMode)?DefaultProduct:null);const selected=(product===null||product===void 0?void 0:product.id)?selectedProducts[product.id]:null;// get price and compare price\nconst getPrice=(camparePrice,price)=>{const comparePriceValue=camparePrice&&camparePrice.amount!==\"0.0\"?priceCode(camparePrice,config):null;const priceValue=priceCode(price,config);return{camparePrice:comparePriceValue!==priceValue?comparePriceValue:null,price:priceValue};};const changeQuantity=quantity=>{if(!product)return;setSelectedProducts(state=>({...state,[product.id]:{...DefaultSelectedOption,...state[product.id],quantity}}));};const selectVariant=(item,sellingPlan)=>{if(!product)return;setSelectedProducts(state=>({...state,[product.id]:{...DefaultSelectedOption,...state[product.id],sellingPlan,quantityAvailable:item.quantityAvailable,selectedOption:item.id}}));};// set first variant as default selected when addToSelected is true\nuseEffect(()=>{if(product&&addToSelected){const defaultVariant=product.variants.nodes[0];setSelectedProducts(state=>({...state,[product.id]:{...DefaultSelectedOption,quantityAvailable:defaultVariant.quantityAvailable,selectedOption:defaultVariant.id}}));return()=>{setSelectedProducts(state=>({...state,[product.id]:null}));};}},[product,addToSelected]);// set product when productID found\nuseEffect(()=>{const foundProduct=products.find(item=>item.id===productID);if(foundProduct){setProduct((config===null||config===void 0?void 0:config.testMode)?DefaultProduct:foundProduct);}},[products,productID,config===null||config===void 0?void 0:config.testMode]);// return result with two mode: when variant selected and when not selected\nconst result=useMemo(()=>{if(!product)return{product:null,availableForSale:null,multiplePrice:null,price:null,stock:null,selectedVariant:null,selectedProduct:null};const selectedVariant=product.variants.nodes.find(item=>item.id===(selected===null||selected===void 0?void 0:selected.selectedOption));if(selectedVariant){var _selectedVariant_sellingPlanAllocations;const selectedSellingPlan=selectedVariant===null||selectedVariant===void 0?void 0:(_selectedVariant_sellingPlanAllocations=selectedVariant.sellingPlanAllocations)===null||_selectedVariant_sellingPlanAllocations===void 0?void 0:_selectedVariant_sellingPlanAllocations.nodes.find(item=>item.sellingPlan.id===(selected===null||selected===void 0?void 0:selected.sellingPlan));const{compareAtPriceV2,availableForSale,priceV2,quantityAvailable}=selectedVariant;var _selectedSellingPlan_checkoutChargeAmount;const price=(_selectedSellingPlan_checkoutChargeAmount=selectedSellingPlan===null||selectedSellingPlan===void 0?void 0:selectedSellingPlan.checkoutChargeAmount)!==null&&_selectedSellingPlan_checkoutChargeAmount!==void 0?_selectedSellingPlan_checkoutChargeAmount:priceV2;return{product,price:getPrice(compareAtPriceV2,price),multiplePrice:false,availableForSale,stock:quantityAvailable,selectedVariant,selectedProduct:selected};}const{compareAtPriceRange,priceRange,availableForSale,totalInventory}=product!==null&&product!==void 0?product:{};const multiplePrice=priceRange.minVariantPrice.amount!==priceRange.maxVariantPrice.amount;return{product,price:getPrice(compareAtPriceRange.minVariantPrice,priceRange.minVariantPrice),multiplePrice,availableForSale,stock:totalInventory,selectedVariant:null,selectedProduct:selected};},[product,selected,config===null||config===void 0?void 0:config.languageIsoCode,config===null||config===void 0?void 0:config.countryIsoCode]);return{...result,changeQuantity,selectVariant};}\nexport const __FramerMetadata__ = {\"exports\":{\"useProduct\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}", "import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{cn,ProductBaseControls,ConfigControls,textProperties}from\"https://framerusercontent.com/modules/eAejHXy6apg0StNmpKvK/4uA71TWP0uSyqhDERFA6/_framer_utils.js\";import{useProduct}from\"https://framerusercontent.com/modules/xEahqZEsyG5uoZky61jQ/0fKThaOrafAWucwKdjoT/_useProduct.js\";import ComponentWrapper from\"https://framerusercontent.com/modules/hQlZBgGeLDev5WuUJA4d/W5z3USVGl6mIjAon3RMp/ComponentWrapper.js\";/**\n * @framerDisableUnlink\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function Shopify_ProductPrice(props){var _props_productID;const{product,price,multiplePrice,availableForSale}=useProduct((_props_productID=props.productID)!==null&&_props_productID!==void 0?_props_productID:null,props.config);return /*#__PURE__*/_jsx(ComponentWrapper,{style:styles.container,productID:props.productID||\"EMPTY\",hidden:!product,config:props.config,children:()=>/*#__PURE__*/_jsxs(_Fragment,{children:[price.camparePrice&&/*#__PURE__*/_jsxs(\"span\",{style:cn(styles.comparePrice,props.comparePriceStyle),children:[price.camparePrice,\" \"]}),/*#__PURE__*/_jsxs(\"span\",{style:cn(props.priceStyle),children:[multiplePrice?props.startFromTitle:\"\",\" \",price.price]}),!availableForSale&&props.soldOutTitle&&/*#__PURE__*/_jsx(\"span\",{style:cn(props.soldOutStyle),children:props.soldOutTitle})]})});}Shopify_ProductPrice.displayName=\"Product Price\";addPropertyControls(Shopify_ProductPrice,{...ConfigControls,...ProductBaseControls,startFromTitle:{title:\"Start from Label\",type:ControlType.String,defaultValue:\"Start from\"},soldOutTitle:{title:\"Sold out Label\",type:ControlType.String,defaultValue:\"Sold out\"},priceStyle:{title:\"Price\",buttonTitle:\"Style\",type:ControlType.Object,controls:textProperties(18,\"rgba(18, 18, 18, 1)\")},comparePriceStyle:{title:\"Compare Price\",buttonTitle:\"Style\",type:ControlType.Object,controls:{hidden:{type:ControlType.Boolean,defaultValue:false},...textProperties(16,\"rgba(18, 18, 18, 0.75)\")}},soldOutStyle:{title:\"Sold Out\",buttonTitle:\"Style\",type:ControlType.Object,controls:{hidden:{type:ControlType.Boolean,defaultValue:false},...textProperties(14,\"#fff\"),backgroundColor:{type:ControlType.Color,defaultValue:\"#000000\"},border:{type:ControlType.Border,defaultValue:{borderWidth:0}},padding:{type:ControlType.Padding,defaultValue:\"2px 8px 2px 8px\"},borderRadius:{type:ControlType.BorderRadius,defaultValue:\"20px\"}}}});const styles={container:{display:\"flex\",flexDirection:\"row\",flexWrap:\"wrap\",gap:8,alignItems:\"center\"},comparePrice:{textDecoration:\"line-through\"}};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Shopify_ProductPrice\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"* @framerSupportedLayoutWidth auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],
  "mappings": "oOAAuiB,IAAMA,EAAsB,CAAC,SAAS,EAAE,kBAAkB,KAAK,eAAe,KAAK,YAAY,IAAI,EAAS,SAASC,EAAWC,EAAUC,EAAOC,EAAc,CAAC,GAAK,CAACC,EAAiBC,CAAmB,EAAEC,EAAQC,CAAoB,EAAO,CAAC,SAAAC,CAAQ,EAAEC,EAAWP,CAAM,EAAO,CAACQ,EAAQC,CAAU,EAAEC,EAAgDV,GAAO,SAAUW,EAAe,IAAI,EAAQC,EAAkDJ,GAAQ,GAAIN,EAAiBM,EAAQ,EAA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AAY,OAAO,SAAS,CAAC,OAAO,CAAC,KAAKA,EAAY,QAAQ,aAAa,EAAK,EAAE,GAAGC,EAAe,GAAG,MAAM,EAAE,gBAAgB,CAAC,KAAKD,EAAY,MAAM,aAAa,SAAS,EAAE,OAAO,CAAC,KAAKA,EAAY,OAAO,aAAa,CAAC,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAKA,EAAY,QAAQ,aAAa,iBAAiB,EAAE,aAAa,CAAC,KAAKA,EAAY,aAAa,aAAa,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,IAAMP,EAAO,CAAC,UAAU,CAAC,QAAQ,OAAO,cAAc,MAAM,SAAS,OAAO,IAAI,EAAE,WAAW,QAAQ,EAAE,aAAa,CAAC,eAAe,cAAc,CAAC",
  "names": ["DefaultSelectedOption", "useProduct", "productID", "config", "addToSelected", "selectedProducts", "setSelectedProducts", "useAtom", "selectedProductsAtom", "products", "useShopify", "product", "setProduct", "ye", "DefaultProduct", "selected", "getPrice", "camparePrice", "price", "comparePriceValue", "priceCode", "priceValue", "changeQuantity", "quantity", "state", "selectVariant", "item", "sellingPlan", "ue", "defaultVariant", "foundProduct", "se", "selectedVariant", "_selectedVariant_sellingPlanAllocations", "selectedSellingPlan", "compareAtPriceV2", "availableForSale", "priceV2", "quantityAvailable", "_selectedSellingPlan_checkoutChargeAmount", "compareAtPriceRange", "priceRange", "totalInventory", "multiplePrice", "Shopify_ProductPrice", "props", "_props_productID", "product", "price", "multiplePrice", "availableForSale", "useProduct", "p", "ComponentWrapper", "styles", "u", "l", "cn", "addPropertyControls", "ConfigControls", "ProductBaseControls", "ControlType", "textProperties"]
}
