{"version":3,"file":"Create_PriceFrom.Cg2PIOW3.mjs","names":["useState","priceFromText","salePriceFromText"],"sources":["https:/framerusercontent.com/modules/gj53OHS8Kkjda7Vpd49J/123RC5kdhgigXjuUeGBq/Create_PriceFrom.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{getStarMapJewelrySku}from\"https://framerusercontent.com/modules/KYsdNQQbOOPfSKUhrJi1/dGQMzt7E45c5ph0pOn44/utils_JewelrySku.js\";import{store_ProductPropsStore}from\"https://framerusercontent.com/modules/XlGHH84z4WYiDTmjfihj/NJtSNNOqg1gvpC3QcbSd/store_ProductPropsStore.js\";import{store_ProductPrices}from\"https://framerusercontent.com/modules/sntb8dU0GIjuRMyT5z3F/l8SNYDLAxhtHuWMwKNqY/store_ProductPrices.js\";import{getPriceText,getSalePriceText}from\"https://framerusercontent.com/modules/P71mmonnzSYySBCAYaxg/bU03Gvw8Leriy2XTOyOE/utils_ProductPrices.js\";import{getTnsProps}from\"https://framerusercontent.com/modules/f5MemFRu7KXGzetUeQ0m/a4ha00CLdU13htGtCGMT/utils_TnsProps.js\";const showDiscountedPrice=false;export default function Create_PriceFrom({jewelryOverrideSku,updatedStyle}){const[priceFromText,setPriceFromText]=useState(\"\");const[salePriceFromText,setSalePriceFromText]=useState(\"\");const[pricesObj,setPricesObj]=store_ProductPrices();const[store,setStore]=store_ProductPropsStore();useEffect(()=>{if(!pricesObj||!pricesObj.pricing||!pricesObj.countryCode||pricesObj.countryCode===\"\"){return;}const{pricing}=pricesObj;const isJewelry=store.productFormat===\"Jewelry\";const isZodiac=isJewelry&&store.jewelryType===\"Zodiac\";const isCanvas=!isJewelry&&store.printFormat===\"Canvas\";const isPrint=!isJewelry;let discountPercent=0;if(showDiscountedPrice){if(isCanvas){discountPercent=0;}else if(isZodiac){discountPercent=25;}else if(isJewelry){discountPercent=20;}else if(isPrint){discountPercent=15;}}/**\n         * If we have an override SKU for jewelry, use that not props\n         */if(jewelryOverrideSku){let priceFromText=\"\";let salePriceFromText=\"\";let price=Object.values(pricing.jewelry.NIGHT_SKY).find(x=>x.sku===jewelryOverrideSku);if(!price){price=Object.values(pricing.jewelry.MOMENTS).find(x=>x.sku===jewelryOverrideSku);}if(price?.customer){if(price.customer.gross>0){priceFromText=getPriceText(price);salePriceFromText=getSalePriceText(price,discountPercent);}}setPriceFromText(priceFromText);setSalePriceFromText(salePriceFromText);return;}// ////////////\n// GET PRICE \"FROM\"...\nlet priceFrom=\"\";let salePriceFrom=\"\";let lowestPrice=-1;if(store.productFormat===\"Jewelry\"){if(pricing.jewelry&&pricing.jewelry.NIGHT_SKY){const priceObj=pricing.jewelry.NIGHT_SKY;// Format, Piece, Material and Bezel Mount are locked in... but we can iterate on jewelrySize\n// and jewelryChain\nlet availableSizes=[\"25mm\",\"20mm\",\"15mm\"];let jewelryChains=[\"Black Cord\",\"Sterling Silver\",\"18k Gold Vermeil\",\"9k Solid Gold\",\"No Mount\"];// We can filter out some options here:\nif(store.jewelryPiece===\"Locket\"){availableSizes=[\"25mm\",\"20mm\"];jewelryChains=[\"Sterling Silver\",\"18k Gold Vermeil\"];}Object.values(availableSizes).forEach(size=>{Object.values(jewelryChains).forEach(chain=>{const tnsSku=getStarMapJewelrySku(store.productFormat,store.jewelryPiece,store.jewelryMaterial,size,store.jewelryBezelMount,chain);let price=Object.values(pricing.jewelry.NIGHT_SKY).find(x=>x.sku===tnsSku);if(!price){price=Object.values(pricing.jewelry.MOMENTS).find(x=>x.sku===tnsSku);}if(price?.customer){if(lowestPrice===-1||price.customer.gross>0&&price.customer.gross<lowestPrice){lowestPrice=price.customer.gross;priceFrom=getPriceText(price);salePriceFrom=getSalePriceText(price,discountPercent);}}});});}}else if(store.productFormat===\"Print\"){let availableSizesLayouts=[{printLayout:\"Square\",printSize:\"12x12\"},{printLayout:\"Square\",printSize:\"16x16\"},// don't bother with largest\n// { printLayout: \"Square\", printSize: \"20x20\" },\n{printLayout:\"Portrait\",printSize:\"12x16\"},{printLayout:\"Portrait\",printSize:\"18x24\"}];Object.values(availableSizesLayouts).forEach(item=>{const tnsProps=getTnsProps({...store,printLayout:item.printLayout,printSize:item.printSize,printFrame:\"None\"});const{orientation,productFormat}=tnsProps;if(pricing[orientation]&&pricing[orientation][tnsProps.sizeId]){const itemPrice=pricing[orientation][tnsProps.sizeId];if(itemPrice&&itemPrice[productFormat]){const price=itemPrice[productFormat];if(price?.customer){if(lowestPrice===-1||price.customer.gross>0&&price.customer.gross<lowestPrice){lowestPrice=price.customer.gross;priceFrom=getPriceText(price);salePriceFrom=getSalePriceText(price,discountPercent);}}}}});}if(lowestPrice>-1&&priceFrom){setPriceFromText(priceFrom);setSalePriceFromText(salePriceFrom);}},[pricesObj,store,pricesObj.pricing,pricesObj.countryCode,jewelryOverrideSku]);if(showDiscountedPrice&&salePriceFromText){return /*#__PURE__*/_jsxs(\"p\",{style:updatedStyle?updatedStyleText:styleText,children:[\"From \",/*#__PURE__*/_jsx(\"span\",{style:strikeThroughPrice,children:priceFromText}),\"\\xa0\",salePriceFromText]});}else{return /*#__PURE__*/_jsxs(\"p\",{style:updatedStyle?updatedStyleText:styleText,children:[\"From \",priceFromText]});}}// /////////////////////////////////////////////////////////////////\n// STYLES\n// /////////////\nCreate_PriceFrom.defaultProps={jewelryOverrideSku:\"\",updatedStyle:false};addPropertyControls(Create_PriceFrom,{jewelryOverrideSku:{type:ControlType.String,defaultValue:\"\"},updatedStyle:{type:ControlType.Boolean,defaultValue:false}});// /////////////////////////////////////////////////////////////////\n// STYLES\n// /////////////\nconst styleText={width:\"auto\",height:\"auto\",boxSizing:\"border-box\",outline:\"none\",flex:\"none\",display:\"inline\",// display: \"flex\",\n// flexDirection: \"column\",\n// justifyContent: \"flex-start\",\n// flexShrink: 0,\nfontFamily:'\"Inter\", \"Inter Placeholder\", sans-serif',fontSize:\"14px\",fontWeight:400,// color: \"rgb(10, 14, 21)\",\ncolor:\"#121824\",textAlign:\"left\",userSelect:\"none\",whiteSpace:\"pre\",WebkitFontSmoothing:\"inherit\",margin:\"0px\",padding:\"0px\",letterSpacing:\"0px\",textDecoration:\"none\",lineHeight:\"1.4em\"};const strikeThroughPrice={textDecoration:\"line-through\",color:\"#838B93\"};const updatedStyleText={...styleText,fontFamily:'Inter, \"Inter Placeholder\", sans-serif',fontWeight:600,fontSize:\"14px\",lineHeight:\"16.8px\"};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Create_PriceFrom\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"yaAA81B,SAAwB,EAAiB,CAAC,qBAAmB,gBAAc,CAAC,GAAK,CAAC,EAAc,GAAkBA,EAAS,GAAG,CAAM,CAAC,EAAkB,GAAsBA,EAAS,GAAG,CAAM,CAAC,EAAU,GAAc,GAAqB,CAAM,CAAC,EAAM,GAAU,GAAyB,CASb,OATc,MAAc,CAAC,GAAG,CAAC,GAAW,CAAC,EAAU,SAAS,CAAC,EAAU,aAAa,EAAU,cAAc,GAAI,OAAQ,GAAK,CAAC,WAAS,EAAgB,EAAU,EAAM,gBAAgB,UAE9xC,GAFuzC,GAAW,EAAM,YAAsC,CAAC,GAAW,EAAM,YAE73C,EAAmB,CAAC,IAAIC,EAAc,GAAOC,EAAkB,GAAO,EAAM,OAAO,OAAO,EAAQ,QAAQ,UAAU,CAAC,KAAK,GAAG,EAAE,MAAM,EAAmB,CAAC,AAAW,IAAM,OAAO,OAAO,EAAQ,QAAQ,QAAQ,CAAC,KAAK,GAAG,EAAE,MAAM,EAAmB,CAAK,GAAO,UAAa,EAAM,SAAS,MAAM,IAAG,EAAc,EAAa,EAAM,CAAC,EAAkB,EAAiB,EAAM,EAAgB,EAAG,EAAiBD,EAAc,CAAC,EAAqBC,EAAkB,CAAC,OAEzd,IAAI,EAAU,GAAO,EAAc,GAAO,EAAY,GAAG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