{"version":3,"file":"FileUploadInput.-3EdCbnk.mjs","names":["useRef","useRef","useState","__esmMin","init_npm_react_18_3_1","init_ssg_sandbox_shims","window","te","_e","p","c","init_jsx_runtime","ce","de","RenderTarget","addPropertyControls","init_framer_CcflMUCW","ControlType","createStore","init_store_js__1_0","GoogleMapsAutocomplete","restProps","props","internalRef","parentFormRef","autocompleteElementRef","shadowInputRef","shadowDialogRef","validityHandlerRef","gmpSelectHandlerRef","gmpErrorHandlerRef","gmpChangeHandlerRef","loadStateRef","place","setPlace","usePlace","loadPlaces","script","setupAutocomplete","autocompleteElement","options","backgroundColor","border","borderRadius","colorScheme","name","overrideShadow","applyPlaceholder","overrides","applyRequired","shadowInput","applyPlaceOnly","mainText","secondaryText","text","id","\"Dg\"","\"Eg\"","init_GooglePlacesAutocomplete","FileUploadInput","fileInputRef","hiddenInputRef","selectedFile","setSelectedFile","base64Data","setBase64Data","error","setError","processing","setProcessing","convertToBase64","reader","file","handleFileChange","maxSizeBytes","maxSizeMB","errorMessage","input","style","borderWidth","successBorderColor","borderColor","buttonColor","buttonTextColor","buttonText","textColor","acceptedTypes","required","fieldName","init_FileUploadInput"],"sources":["https:/framerusercontent.com/modules/0gdmr8IfpEiisGGkxBaO/V0dJoowMowSbIEtF2RvH/GooglePlacesAutocomplete.js","https:/framerusercontent.com/modules/V4cMscE0FLJUcdMFFzCl/NfHiNTh80NkKkrjoPHF6/FileUploadInput.js"],"sourcesContent":["// Get Started: https://www.framer.com/developers\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";const usePlace=createStore({});const useLoadState=createStore();/**\n * @framerDisableUnlink\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function GoogleMapsAutocomplete(props){let{apiKey,name,overrides,colorScheme,border,borderRadius,backgroundColor,options,...restProps}=props;const internalRef=useRef(null);const parentFormRef=useRef(null);/**\n     * The created Google Places autocomplete input element (with shadow dom)\n     * https://developers.google.com/maps/documentation/javascript/place-get-started#load-places-library\n     */const autocompleteElementRef=useRef(null);const shadowInputRef=useRef(null);const shadowDialogRef=useRef(null);const validityHandlerRef=useRef(null);const gmpSelectHandlerRef=useRef(null);const gmpErrorHandlerRef=useRef(null);const gmpChangeHandlerRef=useRef(null);const loadStateRef=useRef(null);let[place,setPlace]=usePlace();// build on init\nuseEffect(()=>{/**\n         * Load the Google Maps JS API\n         * https://developers.google.com/maps/documentation/javascript/load-maps-js-api\n         */const loadPlaces=async()=>{if(!window?.google?.maps?.importLibrary){const script=document.createElement(\"script\");script.textContent=`(g=>{var h,a,k,p=\"The Google Maps JavaScript API\",c=\"google\",l=\"importLibrary\",q=\"__ib__\",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement(\"script\"));e.set(\"libraries\",[...r]+\"\");for(k in g)e.set(k.replace(/[A-Z]/g,t=>\"_\"+t[0].toLowerCase()),g[k]);e.set(\"callback\",c+\".maps.\"+q);a.src=\\`https://maps.\\${c}apis.com/maps/api/js?\\`+e;d[q]=f;a.onerror=()=>h=n(Error(p+\" could not load.\"));a.nonce=m.querySelector(\"script[nonce]\")?.nonce||\"\";m.head.append(a)}));d[l]?console.warn(p+\" only loads once. Ignoring:\",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({key:\"${props.apiKey}\",v:\"weekly\"});`;document.head.appendChild(script);}loadStateRef.current=\"loaded\";};/**\n         * Build and add the Google Autocomplete Element to the page\n         * https://developers.google.com/maps/documentation/javascript/reference/places-widget#PlaceAutocompleteElement\n         */const setupAutocomplete=async()=>{if(!internalRef.current||!window?.google)return;// Ensure places library is loaded\nawait window.google.maps.importLibrary(\"places\");const autocompleteElement=new window.google.maps.places.PlaceAutocompleteElement(options);// set refs\nautocompleteElementRef.current=autocompleteElement;shadowInputRef.current=autocompleteElement.Dg;shadowDialogRef.current=autocompleteElement.Eg;parentFormRef.current=internalRef.current.closest(\"form\");// set styles\nautocompleteElement.style.backgroundColor=backgroundColor;autocompleteElement.style.border=`${border.borderStyle} ${border.borderWidth}px ${border.borderColor}`;autocompleteElement.style[\"border-radius\"]=borderRadius;autocompleteElement.style.colorScheme=colorScheme;autocompleteElement.style.width=props.width;autocompleteElement.name=name;// mount the field\ninternalRef.current.appendChild(autocompleteElement);loadStateRef.current=\"done\";console.log(autocompleteElementRef.current,shadowDialogRef.current,shadowInputRef.current,parentFormRef.current);};/**\n         * Necessary (but hacky) overrides due to Google limitations\n         * https://stackoverflow.com/q/79556333/4481226\n         */const overrideShadow=()=>{/** Set a placeholder on the shadowDOM input */const applyPlaceholder=()=>{if(overrides?.placeholder==\"\")return;shadowInput.placeholder=overrides.placeholder;};/** Set the shadowDOM input as required */const applyRequired=()=>{if(!overrides?.required)return;shadowInput.required=overrides.required;validityHandlerRef.current=e=>{e.preventDefault();let isValid=shadowInput.reportValidity();!isValid&&e.stopImmediatePropagation();};parentFormRef.current.addEventListener(\"submit\",validityHandlerRef.current);};/** Set the shadowDOM input to require a Google place selection */const applyPlaceOnly=()=>{if(!overrides?.placeOnly)return;gmpSelectHandlerRef.current=e=>{let mainText=e.placePrediction.mainText.text;let secondaryText=e.placePrediction.secondaryText.text;let text=e.placePrediction.text.text;let id=e.placePrediction.placeId;setPlace({mainText,secondaryText,text,id});};gmpErrorHandlerRef.current=()=>{setPlace({});shadowInput.value=\"\";};gmpChangeHandlerRef.current=()=>{if(shadowInput.value!=place?.text)shadowInput.value=place?.text??\"\";};internalRef.current.addEventListener(\"gmp-select\",gmpSelectHandlerRef.current);internalRef.current.addEventListener(\"gmp-error\",gmpErrorHandlerRef.current);shadowInput.addEventListener(\"change\",gmpChangeHandlerRef.current);};// pre check\nif(!overrides||!internalRef.current||!parentFormRef.current||!autocompleteElementRef.current)return;const shadowInput=autocompleteElementRef.current[\"Dg\"];const shadowDialog=autocompleteElementRef.current[\"Eg\"];applyPlaceholder();applyRequired();applyPlaceOnly();};const effectOperations=async()=>{try{loadStateRef.current==null&&await loadPlaces();loadStateRef.current===\"loaded\"&&await setupAutocomplete();loadStateRef.current===\"done\"&&overrideShadow();}catch(e){console.error(e);}};effectOperations();return()=>{validityHandlerRef.current&&parentFormRef?.current.removeEventListener(\"submit\",validityHandlerRef.current);gmpSelectHandlerRef.current&&autocompleteElementRef?.current.removeEventListener(\"gmp-select\",gmpSelectHandlerRef.current);gmpErrorHandlerRef.current&&autocompleteElementRef?.current.removeEventListener(\"gmp-error\",gmpErrorHandlerRef.current);gmpChangeHandlerRef.current&&autocompleteElementRef?.current.removeEventListener(\"change\",gmpChangeHandlerRef.current);};},[place]);return /*#__PURE__*/_jsx(\"div\",{ref:internalRef,...restProps,children:props.children});}/** Creates an element from a string */function elementFromString(content){const template=document.createElement(\"template\");template.innerHTML=content;return template.content.firstElementChild;}GoogleMapsAutocomplete.defaultProps={showUnitSystem:false};/** https://www.framer.com/developers/property-controls */addPropertyControls(GoogleMapsAutocomplete,{apiKey:{title:\"API Key\",type:ControlType.String,placeholder:\"missing (required)\",description:\"Enable the Places API (New). [Instructions](https://developers.google.com/maps/documentation/places/web-service/get-api-key?setupProd=enable)\"},options:{type:ControlType.Object,optional:true,buttonTitle:\"enabled\",description:\"All [autocomplete properties](https://developers.google.com/maps/documentation/javascript/reference/places-widget#PlaceAutocompleteElement-Properties) (scrolling list)\",controls:{includedPrimaryTypes:{title:\"Types\",type:ControlType.Array,description:\"Up to 5 Google Place type limits\",maxCount:5,control:{type:ControlType.String,title:\"Google Place Type\",placeholder:\"ex: cultural_landmark\",description:\"A [Google place type](https://developers.google.com/maps/documentation/javascript/place-types)\"}},includedRegionCodes:{title:\"Regions\",type:ControlType.Array,description:\"Up to 15 region limits\",maxCount:15,control:{type:ControlType.String,title:\"Region\",placeholder:\"ex: PL\",maxLength:2,description:\"A [two-character region](https://www.unicode.org/cldr/charts/47/supplemental/territory_language_information.html)\"}},locationBias:{title:\"Bias\",type:ControlType.Object,optional:true,description:\"Bias results to a specified location\",controls:{lat:{type:ControlType.Number,min:-90,max:90},lng:{type:ControlType.Number,min:-180,max:180}}},locationRestriction:{title:\"Restriction\",type:ControlType.Object,optional:true,description:\"Restrict results to the specified bounds\",controls:{north:{type:ControlType.Number,min:-90,max:90},east:{type:ControlType.Number,min:-180,max:180},south:{type:ControlType.Number,min:-90,max:90},west:{type:ControlType.Number,min:-180,max:180}}},origin:{type:ControlType.Object,optional:true,description:\"The origin from which to calculate distance\",controls:{lat:{type:ControlType.Number,min:-90,max:90},lng:{type:ControlType.Number,min:-180,max:180}}},requestedLanguage:{title:\"Language\",type:ControlType.String,optional:true,placeholder:\"ex: pt-BR\",description:\"Language of the results ([view code list](https://developers.google.com/maps/faq#languagesupport))\"},requestedRegion:{title:\"Format\",type:ControlType.String,optional:true,placeholder:\"ex: uk\",description:\"Format results according to [ccTLD](https://developers.google.com/maps/documentation/javascript/reference/places-widget#PlaceAutocompleteElement.requestedRegion) region\"},unitSystem:{type:ControlType.Enum,options:[undefined,\"METRIC\",\"IMPERIAL\"]}}},colorScheme:{type:ControlType.Enum,defaultValue:\"light dark\",// displaySegmentedControl: true,\n// segmentedControlDirection: \"vertical\",\noptions:[\"light\",\"dark\",\"light dark\"],// optionTitles: [\"Option A\", \"Option B\", \"Option C\"],\ndescription:\"Style changes may require page reload\"},name:{type:ControlType.String,defaultValue:\"location\",description:\"Name of the form input (used to attach result to [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData#form))\"},backgroundColor:{type:ControlType.Color,defaultValue:\"#fff\",optional:true},borderRadius:{type:ControlType.BorderRadius,title:\"Radius\"},border:{type:ControlType.Border,defaultValue:{borderWidth:1,borderStyle:\"solid\",borderColor:\"rgba(0, 0, 0, 0.5)\"}},overrides:{title:\"Extras\",buttonTitle:\"enabled\",type:ControlType.Object,optional:true,description:\"Options to overcome [Google's limitations](https://stackoverflow.com/a/79590414/4481226).\",controls:{placeholder:{type:ControlType.String,placeholder:\"search for a location...\",description:\"Helps a user understand what this field does\"},required:{type:ControlType.Boolean,defaultValue:false,description:\"Require a place from the user\"},placeOnly:{type:ControlType.Boolean,defaultValue:false,description:\"Disallow the user from entereing a hand-typed answer\"}}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GoogleMapsAutocomplete\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"* @framerSupportedLayoutWidth any\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GooglePlacesAutocomplete.map","// // FileUploadInput: Framer file upload input that binds with Framer Form. Uploads to Cloudinary and validates file size (max 5MB).\n// import { useEffect, useRef, useState, startTransition } from \"react\"\n// import { addPropertyControls, ControlType, RenderTarget } from \"framer\"\n// interface FileUploadInputProps {\n//     acceptedTypes: string\n//     maxSizeMB: number\n//     errorMessage: string\n//     buttonText: string\n//     backgroundColor: string\n//     textColor: string\n//     buttonColor: string\n//     buttonTextColor: string\n//     borderRadius: number\n//     borderWidth: number\n//     borderColor: string\n//     successBorderColor: string\n//     cloudName: string\n//     uploadPreset: string\n//     folder: string\n//     apiKey: string\n//     publicId: string\n//     required: boolean\n//     fieldName: string\n//     style?: React.CSSProperties\n// }\n// /**\n//  * FileUploadInput\n//  *\n//  * Framer file upload input that binds with Framer Form. Uploads to Cloudinary and validates file size with 5MB max limit.\n//  *\n//  * @framerSupportedLayoutWidth any-prefer-fixed\n//  * @framerSupportedLayoutHeight any-prefer-fixed\n//  */\n// export default function FileUploadInput(props: FileUploadInputProps) {\n//     const {\n//         acceptedTypes,\n//         maxSizeMB,\n//         errorMessage,\n//         buttonText,\n//         backgroundColor,\n//         textColor,\n//         buttonColor,\n//         buttonTextColor,\n//         borderRadius,\n//         borderWidth,\n//         borderColor,\n//         successBorderColor,\n//         cloudName,\n//         uploadPreset,\n//         folder,\n//         apiKey,\n//         publicId,\n//         required,\n//         fieldName,\n//         style,\n//     } = props\n//     const fileInputRef = useRef<HTMLInputElement>(null)\n//     const hiddenInputRef = useRef<HTMLInputElement>(null)\n//     const [selectedFile, setSelectedFile] = useState<File | null>(null)\n//     const [error, setError] = useState(\"\")\n//     const [uploading, setUploading] = useState(false)\n//     const [uploadedUrl, setUploadedUrl] = useState(\"\")\n//     const uploadToCloudinary = async (file: File) => {\n//         if (!cloudName || !uploadPreset) {\n//             startTransition(() => {\n//                 setError(\"Cloudinary configuration missing\")\n//             })\n//             return\n//         }\n//         startTransition(() => {\n//             setUploading(true)\n//             setError(\"\")\n//         })\n//         try {\n//             const formData = new FormData()\n//             formData.append(\"file\", file)\n//             formData.append(\"upload_preset\", uploadPreset)\n//             if (folder) {\n//                 formData.append(\"folder\", folder)\n//             }\n//             if (apiKey) {\n//                 formData.append(\"api_key\", apiKey)\n//             }\n//             if (publicId) {\n//                 formData.append(\"public_id\", publicId)\n//             }\n//             const response = await fetch(\n//                 `https://api.cloudinary.com/v1_1/${cloudName}/upload`,\n//                 {\n//                     method: \"POST\",\n//                     body: formData,\n//                 }\n//             )\n//             if (!response.ok) {\n//                 throw new Error(\"Upload failed\")\n//             }\n//             const data = await response.json()\n//             startTransition(() => {\n//                 setUploadedUrl(data.secure_url)\n//                 setUploading(false)\n//             })\n//         } catch (err) {\n//             startTransition(() => {\n//                 setError(\"Upload failed. Please try again.\")\n//                 setUploading(false)\n//                 setSelectedFile(null)\n//                 setUploadedUrl(\"\")\n//             })\n//             if (fileInputRef.current) {\n//                 fileInputRef.current.value = \"\"\n//             }\n//         }\n//     }\n//     const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n//         const file = e.target.files?.[0]\n//         if (!file) {\n//             startTransition(() => {\n//                 setSelectedFile(null)\n//                 setError(\"\")\n//                 setUploadedUrl(\"\")\n//             })\n//             return\n//         }\n//         const maxSizeBytes = maxSizeMB * 1024 * 1024\n//         if (file.size > maxSizeBytes) {\n//             startTransition(() => {\n//                 setSelectedFile(null)\n//                 setError(\n//                     errorMessage || `File size must be less than ${maxSizeMB}MB`\n//                 )\n//                 setUploadedUrl(\"\")\n//             })\n//             if (fileInputRef.current) {\n//                 fileInputRef.current.value = \"\"\n//             }\n//             return\n//         }\n//         startTransition(() => {\n//             setSelectedFile(file)\n//             setError(\"\")\n//         })\n//         // Upload immediately\n//         uploadToCloudinary(file)\n//     }\n//     const handleButtonClick = () => {\n//         fileInputRef.current?.click()\n//     }\n//     // Trigger input + change events for Framer Form validation\n//     useEffect(() => {\n//         if (!hiddenInputRef.current) return\n//         const input = hiddenInputRef.current\n//         const event = new Event(\"input\", { bubbles: true })\n//         const change = new Event(\"change\", { bubbles: true })\n//         input.value = uploadedUrl\n//         input.dispatchEvent(event)\n//         input.dispatchEvent(change)\n//     }, [uploadedUrl])\n//     if (RenderTarget.current() === RenderTarget.thumbnail) return null\n//     if (!cloudName || !uploadPreset) {\n//         return (\n//             <div style={{ color: \"#c00\", fontSize: 13 }}>\n//                 ⚠️ Invalid Cloudinary configuration. Add Cloud Name and Upload\n//                 Preset in Property Controls.\n//             </div>\n//         )\n//     }\n//     return (\n//         <div\n//             style={{\n//                 width: \"100%\",\n//                 display: \"flex\",\n//                 flexDirection: \"column\",\n//                 ...style,\n//             }}\n//         >\n//             <div\n//                 style={{\n//                     display: \"flex\",\n//                     alignItems: \"center\",\n//                     gap: 12,\n//                     padding: \"10px 12px\",\n//                     backgroundColor,\n//                     borderRadius,\n//                     border: `${borderWidth}px solid ${error ? \"#c00\" : uploadedUrl ? successBorderColor : borderColor}`,\n//                     minHeight: 44,\n//                 }}\n//             >\n//                 <button\n//                     type=\"button\"\n//                     onClick={handleButtonClick}\n//                     disabled={uploading}\n//                     style={{\n//                         padding: \"8px 16px\",\n//                         backgroundColor: uploading ? \"#999\" : buttonColor,\n//                         color: buttonTextColor,\n//                         border: \"none\",\n//                         borderRadius: borderRadius - 2,\n//                         fontSize: 14,\n//                         fontWeight: 500,\n//                         cursor: uploading ? \"not-allowed\" : \"pointer\",\n//                         whiteSpace: \"nowrap\",\n//                     }}\n//                 >\n//                     {buttonText}\n//                 </button>\n//                 <span\n//                     style={{\n//                         fontSize: 14,\n//                         color: selectedFile ? textColor : \"#999\",\n//                         overflow: \"hidden\",\n//                         textOverflow: \"ellipsis\",\n//                         whiteSpace: \"nowrap\",\n//                     }}\n//                 >\n//                     {uploading\n//                         ? `Uploading ${selectedFile?.name || \"\"}...`\n//                         : selectedFile\n//                           ? selectedFile.name\n//                           : \"No file chosen\"}\n//                 </span>\n//                 <input\n//                     ref={fileInputRef}\n//                     type=\"file\"\n//                     accept={acceptedTypes}\n//                     onChange={handleFileChange}\n//                     disabled={uploading}\n//                     style={{\n//                         display: \"none\",\n//                     }}\n//                 />\n//             </div>\n//             {selectedFile && !uploading && uploadedUrl && (\n//                 <span style={{ fontSize: 12, color: \"#22CC66\", marginTop: 8 }}>\n//                     ✓ Uploaded successfully (\n//                     {(selectedFile.size / 1024 / 1024).toFixed(2)} MB)\n//                 </span>\n//             )}\n//             {error && (\n//                 <span style={{ color: \"#c00\", fontSize: 13 }}>{error}</span>\n//             )}\n//             {/* Hidden input for Framer form validation (not readOnly, so required works) */}\n//             <input\n//                 ref={hiddenInputRef}\n//                 type=\"text\"\n//                 name={fieldName}\n//                 value={uploadedUrl}\n//                 required={required}\n//                 style={{\n//                     opacity: 0,\n//                     height: 0,\n//                     width: 0,\n//                     position: \"absolute\",\n//                     pointerEvents: \"none\",\n//                 }}\n//                 tabIndex={-1}\n//                 aria-hidden=\"true\"\n//                 autoComplete=\"off\"\n//             />\n//         </div>\n//     )\n// }\n// addPropertyControls(FileUploadInput, {\n//     fieldName: {\n//         type: ControlType.String,\n//         title: \"Field Name\",\n//         defaultValue: \"file\",\n//         placeholder: \"e.g., resume, portfolio\",\n//     },\n//     required: {\n//         type: ControlType.Boolean,\n//         title: \"Required\",\n//         defaultValue: true,\n//         enabledTitle: \"Yes\",\n//         disabledTitle: \"No\",\n//     },\n//     cloudName: {\n//         type: ControlType.String,\n//         title: \"Cloud Name\",\n//         placeholder: \"dvre9ske8\",\n//         defaultValue: \"dvre9ske8\",\n//     },\n//     uploadPreset: {\n//         type: ControlType.String,\n//         title: \"Upload Preset\",\n//         placeholder: \"ml_default\",\n//         defaultValue: \"ml_default\",\n//     },\n//     folder: {\n//         type: ControlType.String,\n//         title: \"Folder\",\n//         placeholder: \"dev\",\n//         defaultValue: \"dev\",\n//     },\n//     apiKey: {\n//         type: ControlType.String,\n//         title: \"API Key\",\n//         placeholder: \"223257751961888\",\n//         defaultValue: \"223257751961888\",\n//     },\n//     publicId: {\n//         type: ControlType.String,\n//         title: \"Public ID (PID)\",\n//         placeholder: \"8774ae99-5bec-48f8-9814-115fe5fcc2ed\",\n//         defaultValue: \"8774ae99-5bec-48f8-9814-115fe5fcc2ed\",\n//     },\n//     acceptedTypes: {\n//         type: ControlType.String,\n//         title: \"Accepted Types\",\n//         defaultValue: \"image/*,.pdf,.doc,.docx\",\n//         placeholder: \"e.g., image/*,.pdf\",\n//     },\n//     maxSizeMB: {\n//         type: ControlType.Number,\n//         title: \"Max Size (MB)\",\n//         defaultValue: 5,\n//         min: 1,\n//         max: 50,\n//         step: 1,\n//     },\n//     errorMessage: {\n//         type: ControlType.String,\n//         title: \"Error Message\",\n//         defaultValue: \"File size must be less than 5MB\",\n//     },\n//     buttonText: {\n//         type: ControlType.String,\n//         title: \"Button Text\",\n//         defaultValue: \"Choose File\",\n//     },\n//     backgroundColor: {\n//         type: ControlType.Color,\n//         title: \"Background\",\n//         defaultValue: \"#FFFFFF\",\n//     },\n//     textColor: {\n//         type: ControlType.Color,\n//         title: \"Text Color\",\n//         defaultValue: \"#000000\",\n//     },\n//     buttonColor: {\n//         type: ControlType.Color,\n//         title: \"Button Color\",\n//         defaultValue: \"#0099FF\",\n//     },\n//     buttonTextColor: {\n//         type: ControlType.Color,\n//         title: \"Button Text\",\n//         defaultValue: \"#FFFFFF\",\n//     },\n//     borderColor: {\n//         type: ControlType.Color,\n//         title: \"Border Color\",\n//         defaultValue: \"#DDDDDD\",\n//     },\n//     successBorderColor: {\n//         type: ControlType.Color,\n//         title: \"Success Border\",\n//         defaultValue: \"#22CC66\",\n//     },\n//     borderRadius: {\n//         type: ControlType.Number,\n//         title: \"Border Radius\",\n//         defaultValue: 8,\n//         min: 0,\n//         max: 32,\n//         step: 1,\n//     },\n//     borderWidth: {\n//         type: ControlType.Number,\n//         title: \"Border Width\",\n//         defaultValue: 1,\n//         min: 0,\n//         max: 10,\n//         step: 1,\n//     },\n// })\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";export default function FileUploadInput(props){const{acceptedTypes,maxSizeMB,errorMessage,buttonText,backgroundColor,textColor,buttonColor,buttonTextColor,borderRadius,borderWidth,borderColor,successBorderColor,fieldName,required,style}=props;const fileInputRef=useRef(null);const hiddenInputRef=useRef(null);const[selectedFile,setSelectedFile]=useState(null);const[base64Data,setBase64Data]=useState(\"\");const[error,setError]=useState(\"\");const[processing,setProcessing]=useState(false);// Helper to convert file to Base64\nconst convertToBase64=file=>{setProcessing(true);const reader=new FileReader;console.log(\"reader\",reader.result);reader.onload=()=>{startTransition(()=>{setBase64Data(reader.result);setProcessing(false);});};reader.onerror=()=>{setError(\"Error reading file\");setProcessing(false);};reader.readAsDataURL(file);};const handleFileChange=e=>{const file=e.target.files?.[0];console.log(\"file\",file);if(!file){setBase64Data(\"\");setSelectedFile(null);return;}const maxSizeBytes=maxSizeMB*1024*1024;if(file.size>maxSizeBytes){setError(errorMessage||`File too large (max ${maxSizeMB}MB)`);setSelectedFile(null);setBase64Data(\"\");if(fileInputRef.current)fileInputRef.current.value=\"\";return;}setError(\"\");setSelectedFile(file);convertToBase64(file);};// Sync Base64 string with Framer Form's hidden input\nuseEffect(()=>{if(!hiddenInputRef.current)return;const input=hiddenInputRef.current;input.value=base64Data;input.dispatchEvent(new Event(\"input\",{bubbles:true}));input.dispatchEvent(new Event(\"change\",{bubbles:true}));},[base64Data]);if(RenderTarget.current()===RenderTarget.thumbnail)return null;return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",display:\"flex\",flexDirection:\"column\",...style},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"center\",gap:12,padding:\"10px 12px\",backgroundColor,borderRadius,border:`${borderWidth}px solid ${error?\"#c00\":base64Data?successBorderColor:borderColor}`,minHeight:44},children:[/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:()=>fileInputRef.current?.click(),style:{padding:\"8px 16px\",backgroundColor:processing?\"#999\":buttonColor,color:buttonTextColor,border:\"none\",borderRadius:borderRadius-2,cursor:\"pointer\"},children:processing?\"Reading...\":buttonText}),/*#__PURE__*/_jsx(\"span\",{style:{fontSize:14,color:selectedFile?textColor:\"#999\",overflow:\"hidden\",textOverflow:\"ellipsis\"},children:selectedFile?selectedFile.name:\"No file chosen\"}),/*#__PURE__*/_jsx(\"input\",{ref:fileInputRef,type:\"file\",accept:acceptedTypes,onChange:handleFileChange,style:{display:\"none\"}})]}),error&&/*#__PURE__*/_jsx(\"span\",{style:{color:\"#c00\",fontSize:13,marginTop:4},children:error}),base64Data&&!processing&&/*#__PURE__*/_jsx(\"span\",{style:{color:successBorderColor,fontSize:12,marginTop:4},children:\"✓ File ready for submission\"}),/*#__PURE__*/_jsx(\"input\",{ref:hiddenInputRef,type:required?\"text\":\"hidden\",name:fieldName,required:required,value:base64Data,style:{opacity:0,height:0,width:0,position:\"absolute\",pointerEvents:\"none\"},tabIndex:-1,\"aria-hidden\":\"true\",autoComplete:\"off\"})]});}addPropertyControls(FileUploadInput,{fieldName:{type:ControlType.String,title:\"Field Name\",defaultValue:\"file_base64\"},required:{type:ControlType.Boolean,title:\"Required\",defaultValue:true},acceptedTypes:{type:ControlType.String,title:\"Accepted Types\",defaultValue:\"image/*,.pdf\"},maxSizeMB:{type:ControlType.Number,title:\"Max Size (MB)\",defaultValue:2},buttonText:{type:ControlType.String,title:\"Button Text\",defaultValue:\"Choose File\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},buttonColor:{type:ControlType.Color,title:\"Button Color\",defaultValue:\"#0099FF\"},buttonTextColor:{type:ControlType.Color,title:\"Button Text\",defaultValue:\"#FFFFFF\"},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#DDDDDD\"},successBorderColor:{type:ControlType.Color,title:\"Success Border\",defaultValue:\"#22CC66\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8},borderWidth:{type:ControlType.Number,title:\"Border Width\",defaultValue:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FileUploadInput\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FileUploadInput.map"],"mappings":"A,oRAKG,SAAwBoB,EAAuB,EAAM,CAAC,GAAG,CAAC,SAAO,OAAK,YAAU,cAAY,SAAO,eAAa,kBAAgB,UAAQ,GAAGC,GAAWC,EAAYC,EAAYvB,EAAO,IAAI,EAAQwB,EAAcxB,EAAO,IAAI,EAGhNyB,EAAuBzB,EAAO,IAAI,EAAQ0B,EAAe1B,EAAO,IAAI,EAAQ2B,EAAgB3B,EAAO,IAAI,EAAQ4B,EAAmB5B,EAAO,IAAI,EAAQ6B,EAAoB7B,EAAO,IAAI,EAAQ8B,EAAmB9B,EAAO,IAAI,EAAQ+B,EAAoB/B,EAAO,IAAI,EAAQgC,EAAahC,EAAO,IAAI,EAAK,CAACiC,EAAMC,GAAUC,EAAS,EAe0pB,OAdv+BvB,MAAc,CAGH,IAAMwB,EAAW,SAAS,CAAC,GAAG,CAAC9B,GAAQ,QAAQ,MAAM,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