{"version":3,"file":"AutoFetchCountry_2.fl4e_cTo.mjs","names":["__legacyOverrideHOC_DataObserverContext","_jsx"],"sources":["https:/framerusercontent.com/modules/IOhZHSbvXZj2pdQCLWVb/8YJ6qYEtRoiCgPbanG0H/AutoFetchCountry_2.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";// Original version\nexport function autofillCountry(){useEffect(()=>{// Fetch the visitor's country using the provided API\nfetch(\"https://api.fetch.tools/location\").then(response=>response.json()).then(data=>{const country=data.country// For example, \"PK\"\n;// Now, get the country calling code using a service\nfetch(`https://restcountries.com/v3.1/alpha/${country}`).then(res=>res.json()).then(countryData=>{const countryCode=countryData[0].idd.root// For example, \"+\" for PK\n;const callingCode=countryData[0].idd.suffixes[0]// This will be the code, like 92\n;// Combine to form the full country calling code\nconst fullCountryCode=`${countryCode}${callingCode}`;// Select the input field by its name attribute\nconst inputField=document.querySelector('input[name=\"Phone\"]');// If the input field exists, set its value to the detected country code\nif(inputField){inputField.value=fullCountryCode;}}).catch(error=>{console.error(\"Error fetching country code:\",error);});}).catch(error=>{console.error(\"Error fetching country:\",error);});},[]);// Return an empty object as no additional props are being overridden\nreturn{};}// Enhanced version with improvements\nexport function autofillCountryEnhanced(){useEffect(()=>{let isMounted=true;const autofillPhoneCode=async()=>{try{// Fetch the visitor's country\nconst locationResponse=await fetch(\"https://api.fetch.tools/location\");if(!locationResponse.ok)throw new Error(\"Failed to fetch location\");const locationData=await locationResponse.json();const country=locationData.country;if(!country||!isMounted)return;// Get the country calling code\nconst countryResponse=await fetch(`https://restcountries.com/v3.1/alpha/${country}`);if(!countryResponse.ok)throw new Error(\"Failed to fetch country data\");const countryData=await countryResponse.json();// Validate the response structure\nif(!countryData[0]?.idd?.root||!countryData[0]?.idd?.suffixes?.[0]){console.warn(\"Invalid country data structure\");return;}const{root,suffixes}=countryData[0].idd;const fullCountryCode=`${root}${suffixes[0]}`;if(!isMounted)return;// Find the input field\nconst inputField=document.querySelector('input[name=\"Phone\"]');if(inputField){// Set the value\ninputField.value=fullCountryCode;// Trigger React events properly\nconst nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,\"value\")?.set;if(nativeInputValueSetter){nativeInputValueSetter.call(inputField,fullCountryCode);}// Dispatch input and change events\ninputField.dispatchEvent(new Event(\"input\",{bubbles:true}));inputField.dispatchEvent(new Event(\"change\",{bubbles:true}));}}catch(error){console.error(\"Error autofilling country code:\",error);}};autofillPhoneCode();// Cleanup function\nreturn()=>{isMounted=false;};},[])// Empty dependency array - runs once on mount\n;return{};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withautofillCountry(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...autofillCountry(props)});};}withautofillCountry.displayName=\"autofillCountry\";export function withautofillCountryEnhanced(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...autofillCountryEnhanced(props)});};}withautofillCountryEnhanced.displayName=\"autofillCountryEnhanced\";\nexport const __FramerMetadata__ = {\"exports\":{\"withautofillCountryEnhanced\":{\"type\":\"reactHoc\",\"name\":\"withautofillCountryEnhanced\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"autofillCountryEnhanced\":{\"type\":\"override\",\"name\":\"autofillCountryEnhanced\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"autofillCountry\":{\"type\":\"override\",\"name\":\"autofillCountry\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withautofillCountry\":{\"type\":\"reactHoc\",\"name\":\"withautofillCountry\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AutoFetchCountry_2.map"],"mappings":"iSACA,SAAgB,GAAiB,CASjC,OATkC,MAAc,CAChD,MAAM,mCAAmC,CAAC,KAAK,GAAU,EAAS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