{"version":3,"file":"AutoFetchCountry_2.BUVGAcVi.mjs","names":["__legacyOverrideHOC_DataObserverContext","_jsx","__esmMin","init_npm_react_18_3_1","oe","ce","window","c","init_jsx_runtime","init_ssg_sandbox_shims","DataObserverContext","init_framer_D6uXRwWs","autofillCountry","response","country","data","res","fullCountryCode","countryData","inputField","error","autofillCountryEnhanced","isMounted","locationResponse","countryResponse","root","suffixes","nativeInputValueSetter","withautofillCountry","C","props","withautofillCountryEnhanced","init_AutoFetchCountry_2"],"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":"A,yLACA,SAAgBY,GAAiB,CASjC,OATkCP,MAAc,CAChD,MAAM,kCAAkC,CAAC,CAAC,KAAK,GAAUQ,EAAS,KAAK,CAAC,CAAC,CAAC,KAAK,GAAM,CAAC,IAAMC,EAAQC,EAAK,QAEzG,MAAM,wCAAwCD,GAAS,CAAC,CAAC,KAAK,GAAKE,EAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAa,CAGjG,IAAMC,EAAgB,GAH8FC,EAAY,EAAE,CAAC,IAAI,OACpHA,EAAY,EAAE,CAAC,IAAI,SAAS,KAGzCC,EAAW,SAAS,cAAc,qBAAqB,EAC1DA,IAAY,EAAW,MAAMF,EAAiB,CAAC,CAAC,CAAC,MAAM,GAAO,CAAC,QAAQ,MAAM,+BAA+BG,CAAK,CAAE,CAAC,CAAE,CAAC,CAAC,CAAC,MAAM,GAAO,CAAC,QAAQ,MAAM,0BAA0BA,CAAK,CAAE,CAAC,CAAE,EAAE,CAAC,CAAC,EAC1L,CAAC,CAAE,CACT,SAAgBC,GAAyB,CASxC,OATyChB,MAAc,CAAC,IAAIiB,EAAU,GAQvE,OADkM,SAPrF,CAAC,GAAG,CACjH,IAAMC,EAAiB,MAAM,MAAM,kCAAkC,EAAE,GAAG,CAACA,EAAiB,GAAG,MAAU,MAAM,0BAA0B,EAAmD,IAAMT,GAAQ,MAAtCS,EAAiB,KAAK,EAAA,CAA6B,QAAQ,GAAG,CAACT,GAAS,CAACQ,EAAU,OACvP,IAAME,EAAgB,MAAM,MAAM,wCAAwCV,GAAS,EAAE,GAAG,CAACU,EAAgB,GAAG,MAAU,MAAM,8BAA8B,EAAE,IAAMN,EAAY,MAAMM,EAAgB,KAAK,EACzM,GAAG,CAACN,EAAY,EAAE,EAAE,KAAK,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