{"version":3,"file":"Autocomplete.fLvYOxKd.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,EAAK,EAAE,MAAc,CAE5J,GADU,IAAS,QAAa,OAAO,SAAW,KAAa,EAAa,EAClE,IAAS,QAAa,OAAO,S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