{"version":3,"file":"Autocomplete.Dzz925An.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/GVm59KJbvir8hRTzQiTf/HABFVyI3VQdXWkOluNw6/Autocomplete.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// Helper function to dynamically load scripts\nconst loadScript=(src,callback)=>{if(typeof window===\"undefined\")return;// Ensure it's running in the browser\n// Check if script is already loaded\nif(document.querySelector(`script[src=\"${src}\"]`)){callback===null||callback===void 0?void 0:callback()// Call the callback if the script is already loaded\n;return;}const script=document.createElement(\"script\");script.src=src;script.onload=callback;script.async=true// Ensure scripts load asynchronously\n;document.head.appendChild(script);};// Helper function to dynamically inject styles\nconst injectStyles=()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;// Ensure it's running in the browser\nif(!document.querySelector(\"#autocomplete-styles\")){const style=document.createElement(\"style\");style.id=\"autocomplete-styles\";style.innerHTML=`\n            .field_autocomplete {\n                --framer-input-background: none !important;\n                --framer-input-border: none !important;\n                --framer-input-padding: 0 !important;\n                flex: 0 0 auto !important;\n                height: auto !important;\n                position: relative !important;\n                width: 100% !important;\n            }\n            .field_autocomplete select {\n                width: 100% !important;\n                height: auto !important;\n                padding: 10px !important;\n                box-sizing: border-box !important;\n                border: none !important;\n                border-radius: 10px !important;\n            }\n            .select2-container .select2-search--inline {\n                float: none;\n            }\n        `;document.head.appendChild(style);}};// Autocomplete Component\nexport function Autocomplete(props){const{googleMapsAPI,googleMapsAPIKey,targetFieldName}=props;const googleMapsScriptLoadedRef=useRef(false);useEffect(()=>{// Inject styles only in the browser environment\nif(typeof window!==\"undefined\"&&typeof document!==\"undefined\"){injectStyles();}// Ensure the script only loads in the browser environment\nif(typeof window!==\"undefined\"&&typeof document!==\"undefined\"&&googleMapsAPI&&googleMapsAPIKey&&!googleMapsScriptLoadedRef.current){const scriptSrc=`https://maps.googleapis.com/maps/api/js?key=${googleMapsAPIKey}&libraries=places`;loadScript(scriptSrc,()=>{googleMapsScriptLoadedRef.current=true;initializeGoogleMapsAutocomplete();});}},[googleMapsAPI,googleMapsAPIKey,targetFieldName]);// Initialize Google Maps Autocomplete\nconst initializeGoogleMapsAutocomplete=()=>{if(typeof window!==\"undefined\"&&typeof document!==\"undefined\"&&window.google&&googleMapsAPIKey&&targetFieldName){console.log(\"Initializing Google Maps autocomplete for\",targetFieldName);const inputFields=document.querySelectorAll(`input[name=\"${targetFieldName}\"]`);inputFields.forEach(inputField=>{const autocomplete=new google.maps.places.Autocomplete(inputField);autocomplete.addListener(\"place_changed\",()=>{const place=autocomplete.getPlace();console.log(\"Selected place:\",place);});});}else{console.error(\"Google Maps is not loaded, target field name is missing, or the code is not running in the browser.\");}};// Placeholder for rendering or debugging\nconst isEditor=typeof window!==\"undefined\"&&window.location.href.includes(\"framer.com\");const hiddenStyle=isEditor?{}:{display:\"none\",padding:20};return /*#__PURE__*/_jsx(\"div\",{style:hiddenStyle,children:/*#__PURE__*/_jsx(\"h1\",{children:\"Autocomplete Configuration\"})});}// Define property controls for the component\naddPropertyControls(Autocomplete,{googleMapsAPI:{type:ControlType.Boolean,title:\"Source: GoogleMaps API\",defaultValue:false},googleMapsAPIKey:{type:ControlType.String,title:\"GoogleMaps API Key\",hidden:props=>!props.googleMapsAPI},targetFieldName:{type:ControlType.String,title:\"Target Field Name\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"Autocomplete\":{\"type\":\"reactComponent\",\"name\":\"Autocomplete\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Autocomplete.map"],"mappings":"2LA6BA,SAAgB,EAAa,EAAM,CAAC,GAAK,CAAC,gBAAc,mBAAiB,mBAAiB,EAAY,EAA0BA,EAAO,GAAM,CAAC,MAAc,CAClJ,IAAS,QAAa,OAAO,SAAW,KAAa,GAAc,CACnE,IAAS,QAAa,OAAO,SAAW,KA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