{"version":3,"file":"NewPriceSummary.DkYMSIFY.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/ZFkkqk7Adq5w6QSwVCoL/gu7sblHQBXEhimygoDSp/NewPriceSummary.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{Frame}from\"framer\";export function NewPriceSummary(){const getSelectedClassesFromStorage=()=>{try{const stored=sessionStorage.getItem(\"selectedClasses\");return stored?JSON.parse(stored):[];}catch(error){console.error(\"Error reading from sessionStorage:\",error);return[];}};const[selectedClasses,setSelectedClasses]=useState(()=>getSelectedClassesFromStorage());const[discountCode,setDiscountCode]=useState(\"\");const[appliedDiscount,setAppliedDiscount]=useState(null);const[isMobile,setIsMobile]=useState(false);// Add new state variables for currency and total price\nconst[currency,setCurrency]=useState(()=>{try{const storedCurrency=sessionStorage.getItem(\"currency\");if(!storedCurrency)return\"USD\";const parsed=JSON.parse(storedCurrency);if([\"USD\",\"EUR\",\"TRY\"].includes(parsed)){return parsed;}return\"USD\";}catch(error){console.error(\"Error reading currency from sessionStorage:\",error);return\"USD\";}});const[totalPrice,setTotalPrice]=useState(()=>{try{const price=sessionStorage.getItem(\"totalPriceUSD\");if(!price)return 0;const parsedPrice=JSON.parse(price);return typeof parsedPrice===\"number\"?parsedPrice:0;}catch(error){console.error(\"Error reading estimated total price from sessionStorage:\",error);return 0;}});// Currency conversion rates\nconst conversionRates={USD:1,EUR:.95,TRY:45};// Function to convert price from USD to selected currency\nconst convertPrice=priceInUSD=>{const rate=conversionRates[currency]||1;return(priceInUSD*rate).toFixed(2);};// Get the currency symbol\nconst getCurrencySymbol=curr=>{switch(curr){case\"EUR\":return\"€\";case\"TRY\":return\"₺\";case\"USD\":default:return\"$\";}};useEffect(()=>{const checkMobile=()=>{setIsMobile(true);};checkMobile();window.addEventListener(\"resize\",checkMobile);return()=>window.removeEventListener(\"resize\",checkMobile);},[]);// Effect to listen for currency and price changes from the first component\nuseEffect(()=>{const handleCurrencyChange=event=>{const{currency:newCurrency}=event.detail;if([\"USD\",\"EUR\",\"TRY\"].includes(newCurrency)){setCurrency(newCurrency);}};const handlePriceChange=event=>{const{totalPrice:newTotalPrice}=event.detail;setTotalPrice(newTotalPrice);};// Listen for the custom currency and price change events\nwindow.addEventListener(\"currencyChange\",handleCurrencyChange);window.addEventListener(\"priceChange\",handlePriceChange);return()=>{window.removeEventListener(\"currencyChange\",handleCurrencyChange);window.removeEventListener(\"priceChange\",handlePriceChange);};},[]);// Effect to check price updates (keep the existing polling for price updates)\nuseEffect(()=>{const checkUpdates=()=>{// Check price\nconst storedPrice=sessionStorage.getItem(\"totalPriceUSD\");try{if(!storedPrice){// If price is removed from storage, reset to 0\nsetTotalPrice(0);}else{const parsedPrice=JSON.parse(storedPrice);setTotalPrice(parsedPrice);}}catch(error){console.error(\"Error parsing price:\",error);setTotalPrice(0);}// Check currency (fallback in case event doesn't fire)\nconst storedCurrency=sessionStorage.getItem(\"currency\");if(storedCurrency){try{const parsedCurrency=JSON.parse(storedCurrency);if([\"USD\",\"EUR\",\"TRY\"].includes(parsedCurrency)){setCurrency(parsedCurrency);}}catch(error){console.error(\"Error parsing currency:\",error);}}};const intervalId=setInterval(checkUpdates,300);checkUpdates()// Initial check\n;return()=>clearInterval(intervalId);},[]);// Example static pricing\nconst discountValue=appliedDiscount?.type===\"percent\"?totalPrice*appliedDiscount.value/100:0;// Calculate tax (rounded to 2 decimal places)\nconst taxAmount=Math.round(totalPrice*.2*100)/100;// Calculate final price (total + tax - discount)\nconst estimatedPrice=totalPrice+taxAmount-discountValue;// Store the final price in sessionStorage\nuseEffect(()=>{try{sessionStorage.setItem(\"paidPrice\",JSON.stringify(estimatedPrice));}catch(error){console.error(\"Error writing to sessionStorage:\",error);}},[estimatedPrice]);const applyDiscount=()=>{if(discountCode===\"ISBANKASI15\"){setAppliedDiscount({code:\"ISBANKASI15\",type:\"percent\",value:15});}setDiscountCode(\"\");};const removeDiscount=()=>setAppliedDiscount(null);return /*#__PURE__*/_jsx(Frame,{width:\"100%\",height:\"100%\",backdropFilter:\"blur(5px)\",style:{maxWidth:\"100%\",margin:\"0 auto\",padding:\"0px\",borderRadius:isMobile?\"8px\":\"30px\",border:isMobile?\"1px solid #EAEDF0\":\"1px solid #e0e0e0\",boxSizing:\"border-box\",display:\"flex\",flexDirection:isMobile?\"column\":\"row\",justifyContent:\"space-between\",alignItems:\"flex-start\",position:\"relative\",overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"div\",{style:{width:isMobile?\"100%\":\"30%\",position:isMobile?\"static\":\"sticky\",top:0,background:\"#ffffff\",overflow:\"auto\",padding:isMobile?\"10px\":\"20px\",boxSizing:\"border-box\"},children:/*#__PURE__*/_jsxs(\"div\",{style:{fontFamily:\"Geist, sans-serif\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{marginBottom:\"20px\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{fontSize:\"12px\",fontWeight:500,color:\"#637381\",marginBottom:\"12px\",letterSpacing:\"-0.05em\"},children:\"Discounts\"}),/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"center\",border:\"1px solid #f0e6fa\",borderRadius:\"8px\",padding:\"8px 12px\",marginBottom:\"10px\"},children:[/*#__PURE__*/_jsx(\"input\",{type:\"text\",placeholder:\"Enter Discount code\",value:discountCode,onChange:e=>setDiscountCode(e.target.value),style:{flex:1,border:\"none\",outline:\"none\",fontSize:\"14px\",color:\"#8c7aa9\",background:\"transparent\"}}),/*#__PURE__*/_jsx(\"button\",{onClick:applyDiscount,style:{background:\"transparent\",border:\"none\",cursor:\"pointer\",color:\"#8c7aa9\",fontSize:\"16px\"},children:\"➤\"})]}),appliedDiscount&&/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",justifyContent:\"space-between\",alignItems:\"center\",color:\"#7a4ca0\",fontSize:\"14px\",marginBottom:\"10px\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{cursor:\"pointer\",marginRight:\"8px\"},onClick:removeDiscount,children:\"✕\"}),/*#__PURE__*/_jsxs(\"span\",{children:[appliedDiscount.code,\" (\",appliedDiscount.value,\"%)\"]}),/*#__PURE__*/_jsxs(\"span\",{children:[\"- \",getCurrencySymbol(currency),convertPrice(discountValue)]})]})]}),/*#__PURE__*/_jsx(\"hr\",{style:{border:\"0.5px solid #eee\",margin:\"16px 0\"}}),/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",justifyContent:\"space-between\",marginBottom:\"8px\",fontSize:\"14px\",color:\"#4d4d4d\"},children:[/*#__PURE__*/_jsx(\"span\",{children:\"Service Fee\"}),/*#__PURE__*/_jsxs(\"span\",{children:[getCurrencySymbol(currency),convertPrice(totalPrice)]})]}),/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",justifyContent:\"space-between\",marginBottom:\"8px\",fontSize:\"14px\",color:\"#4d4d4d\"},children:[/*#__PURE__*/_jsx(\"span\",{children:\"Tax (20%)\"}),/*#__PURE__*/_jsxs(\"span\",{children:[getCurrencySymbol(currency),convertPrice(Math.round(totalPrice*.2*100)/100)]})]}),/*#__PURE__*/_jsx(\"hr\",{style:{border:\"0.5px solid #eee\",margin:\"16px 0\"}}),/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",justifyContent:\"space-between\",fontWeight:600,fontSize:\"16px\",color:\"#212b36\"},children:[/*#__PURE__*/_jsx(\"span\",{children:\"Estimated Price\"}),/*#__PURE__*/_jsxs(\"span\",{children:[getCurrencySymbol(currency),convertPrice(estimatedPrice)]})]})]})})});}\nexport const __FramerMetadata__ = {\"exports\":{\"NewPriceSummary\":{\"type\":\"reactComponent\",\"name\":\"NewPriceSummary\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NewPriceSummary.map"],"mappings":"0RAAyH,SAAgB,GAAiB,CAAC,IAAM,MAAkC,CAAC,GAAG,CAAC,IAAM,EAAO,eAAe,Q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