{"version":3,"file":"withRealPrice.ByppXJrM.mjs","names":[],"sources":["https:/framerusercontent.com/modules/nROLN2ppOfdXfpzkYLGX/tIQgOZ1pJFvNeNQPiSGe/withRealPrice.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{useAnimate}from\"framer-motion\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";const useStore=createStore({});var ProductTypes;(function(ProductTypes){ProductTypes[ProductTypes[\"mediation\"]=50]=\"mediation\";ProductTypes[ProductTypes[\"diyPaperwork\"]=63]=\"diyPaperwork\";ProductTypes[ProductTypes[\"weFileForYou\"]=67]=\"weFileForYou\";ProductTypes[ProductTypes[\"assistedDivorce\"]=92]=\"assistedDivorce\";ProductTypes[ProductTypes[\"fullyGuidedDivorce\"]=93]=\"fullyGuidedDivorce\";})(ProductTypes||(ProductTypes={}));const fetchStatuses={};const fetchPriceFromAPI=async params=>{const fetchKey=JSON.stringify(params);if(fetchStatuses[fetchKey]){return null;}fetchStatuses[fetchKey]=true;const baseUrl=window.location.hostname.includes(\"divorce.com\")?\"https://divorce.com\":\"https://staging.completecase.com:8190\";const url=new URL(\"/api/v2/product-prices/\",baseUrl);url.search=new URLSearchParams(params).toString();const response=await fetch(url.toString());const data=await response.json();fetchStatuses[fetchKey]=false;return data;};const getPriceString=(price,affirm)=>affirm?`4 payments of $${Number(price/4).toLocaleString(\"en-US\")}/mo`:`$${Number(price).toLocaleString(\"en-US\")}`;const withRealPriceFactory=(Component,productType,affirm)=>props=>{const[store,setStore]=useStore();const[scope,animate]=useAnimate();const price=store[productType]||0;useEffect(()=>{const getAndSetPrice=async()=>{const params={product_types:productType};const data=await fetchPriceFromAPI(params);data&&setStore({...store,[productType]:data[productType]});};!price&&getAndSetPrice();},[]);useEffect(()=>{price&&animate(scope.current,{opacity:1},{duration:.1});},[price]);const newPrors=price?{...props,text:getPriceString(price,affirm)}:{...props,initial:{opacity:0}};return /*#__PURE__*/_jsx(Component,{...newPrors,ref:scope});};export function withMediationRealPrice(Component){return withRealPriceFactory(Component,50,false);}export function withDiyPaperworkRealPrice(Component){return withRealPriceFactory(Component,63,false);}export function withWeFileForYouRealPrice(Component){return withRealPriceFactory(Component,67,false);}export function withAssistedDivorceRealPrice(Component){return withRealPriceFactory(Component,92,false);}export function withFullyGuidedDivorceRealPrice(Component){return withRealPriceFactory(Component,93,false);}export function withDiyPaperworkAffirmRealPrice(Component){return withRealPriceFactory(Component,63,true);}export function withWeFileForYouAffirmRealPrice(Component){return withRealPriceFactory(Component,67,true);}export function withAssistedDivorceAffirmRealPrice(Component){return withRealPriceFactory(Component,92,true);}export function withFullyGuidedDivorceAffirmRealPrice(Component){return withRealPriceFactory(Component,93,true);}\nexport const __FramerMetadata__ = {\"exports\":{\"withFullyGuidedDivorceAffirmRealPrice\":{\"type\":\"reactHoc\",\"name\":\"withFullyGuidedDivorceAffirmRealPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withWeFileForYouRealPrice\":{\"type\":\"reactHoc\",\"name\":\"withWeFileForYouRealPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDiyPaperworkRealPrice\":{\"type\":\"reactHoc\",\"name\":\"withDiyPaperworkRealPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withWeFileForYouAffirmRealPrice\":{\"type\":\"reactHoc\",\"name\":\"withWeFileForYouAffirmRealPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFullyGuidedDivorceRealPrice\":{\"type\":\"reactHoc\",\"name\":\"withFullyGuidedDivorceRealPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAssistedDivorceAffirmRealPrice\":{\"type\":\"reactHoc\",\"name\":\"withAssistedDivorceAffirmRealPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withMediationRealPrice\":{\"type\":\"reactHoc\",\"name\":\"withMediationRealPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDiyPaperworkAffirmRealPrice\":{\"type\":\"reactHoc\",\"name\":\"withDiyPaperworkAffirmRealPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAssistedDivorceRealPrice\":{\"type\":\"reactHoc\",\"name\":\"withAssistedDivorceRealPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./withRealPrice.map"],"mappings":"kOAAg3D,SAAgB,EAAuB,EAAU,CAAC,OAAO,EAAqB,EAAU,GAAG,GAAM,CAAE,SAAgB,EAA0B,EAAU,CAAC,OAAO,EAAqB,EAAU,GAAG,GAAM,CAAE,SAAgB,EAA0B,EAAU,CAAC,OAAO,EAAqB,EAAU,GAAG,GAAM,CAAE,SAAgB,EAA6B,EAAU,CAAC,OAAO,EAAqB,EAAU,GAAG,GAAM,CAAE,SAAgB,EAAgC,EAAU,CAAC,OAAO,EAAqB,EAAU,GAAG,GAAM,CAAE,SAAgB,EAAgC,EAAU,CAAC,OAAO,EAAqB,EAAU,GAAG,GAAK,CAAE,SAAgB,EAAgC,EAAU,CAAC,OAAO,EAAqB,EAAU,GAAG,GAAK,CAAE,SAAgB,EAAmC,EAAU,CAAC,OAAO,EAAqB,EAAU,GAAG,GAAK,CAAE,SAAgB,EAAsC,EAAU,CAAC,OAAO,EAAqB,EAAU,GAAG,GAAK,kCAA5vF,IAA6B,IAAsC,IAAqE,CAAM,EAAS,EAAY,EAAE,CAAC,EAAmB,SAAS,EAAa,CAAC,EAAa,EAAa,UAAa,IAAI,YAAY,EAAa,EAAa,aAAgB,IAAI,eAAe,EAAa,EAAa,aAAgB,IAAI,eAAe,EAAa,EAAa,gBAAmB,IAAI,kBAAkB,EAAa,EAAa,mBAAsB,IAAI,uBAAwB,AAAe,IAAa,EAAE,CAAE,CAAO,EAAc,EAAE,CAAO,EAAkB,KAAM,IAAQ,CAAC,IAAM,EAAS,KAAK,UAAU,EAAO,CAAC,GAAG,EAAc,GAAW,OAAO,KAAM,EAAc,GAAU,GAAK,IAAM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