{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/WHAwRhDFm10rIiCunTFc/YqZhTTiPfPmB6oLdww2d/WithApr.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import React,{useEffect,useState}from\"react\";const DEFAULT_APR=\"xx.x\";function containsAprPlaceholder(children){if(typeof children===\"string\"){return children.includes(\"{apr}\");}if(Array.isArray(children)){return children.some(child=>containsAprPlaceholder(child));}if(children&&typeof children===\"object\"){const element=children;if(element.props&&element.props.children){return containsAprPlaceholder(element.props.children);}}return false;}function replaceAprInChildren(children,apr,defaultApr=DEFAULT_APR){if(typeof children===\"string\"){return children.replace(/{apr}/g,apr||defaultApr);}if(Array.isArray(children)){return children.map(child=>replaceAprInChildren(child,apr,defaultApr));}if(children&&typeof children===\"object\"){const element=children;if(element.props&&element.props.children){const updatedChildren=replaceAprInChildren(element.props.children,apr,defaultApr);return /*#__PURE__*/React.cloneElement(element,{...element.props,children:updatedChildren});}return element;}return children;}export async function getFinanceConstants(){const isProd=window.location.hostname===\"www.oodlecarfinance.com\";try{const response=await fetch(`https://${!isProd?\"staging.\":\"\"}webeng.oodlefinance.com/finance-constants-service/finance-constants`,{method:\"GET\",headers:{\"Content-Type\":\"application/json\"}});const result=await response.json();return result===null||result===void 0?void 0:result.LOAN_DEFAULTS;}catch{return DEFAULT_APR;}}export function withApr(Component){return props=>{const[apr,setApr]=useState(DEFAULT_APR);useEffect(()=>{async function fetchApr(){if(containsAprPlaceholder(props.children)){const financeConstants=await getFinanceConstants();const fetchedApr=(financeConstants===null||financeConstants===void 0?void 0:financeConstants.APR)||DEFAULT_APR;setApr(fetchedApr);}}fetchApr();},[props.children]);const updatedChildren=replaceAprInChildren(props.children,apr);return /*#__PURE__*/_jsx(Component,{...props,children:updatedChildren});};}\nexport const __FramerMetadata__ = {\"exports\":{\"getFinanceConstants\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withApr\":{\"type\":\"reactHoc\",\"name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M,CAAC,OAAOb,CAAY,CAAC,CAAQ,SAASc,EAAQC,EAAU,CAAC,OAAOC,GAAO,CAAC,GAAK,CAACV,EAAIW,CAAM,EAAEC,EAASlB,CAAW,EAAEmB,EAAU,IAAI,CAAC,eAAeC,GAAU,CAAC,GAAGnB,EAAuBe,EAAM,QAAQ,EAAE,CAAC,IAAMK,EAAiB,MAAMX,EAAoB,EAAQY,EAAsED,GAAiB,KAAMrB,EAAYiB,EAAOK,CAAU,CAAE,CAAC,CAACF,EAAS,CAAE,EAAE,CAACJ,EAAM,QAAQ,CAAC,EAAE,IAAMR,EAAgBH,EAAqBW,EAAM,SAASV,CAAG,EAAE,OAAoBiB,EAAKR,EAAU,CAAC,GAAGC,EAAM,SAASR,CAAe,CAAC,CAAE,CAAE",
  "names": ["DEFAULT_APR", "containsAprPlaceholder", "children", "child", "element", "replaceAprInChildren", "apr", "defaultApr", "updatedChildren", "e", "getFinanceConstants", "isProd", "window", "result", "withApr", "Component", "props", "setApr", "ye", "ue", "fetchApr", "financeConstants", "fetchedApr", "p"]
}
