{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/Z98jpVJkost5xTkHL38i/x4DtskAtAJuLKtbKmWCl/Demo_Form.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{forwardRef,useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// Import for Property Controls\nexport function withCustomId(Component){return /*#__PURE__*/forwardRef((props,ref)=>{// We'll use a useEffect to apply the ID once the component is mounted\n// and its ref is available.\nReact.useEffect(()=>{if(ref&&ref.current&&props.id){const element=ref.current;element.id=props.id;// console.log(`Set ID \"${props.id}\" on element:`, element); // For debugging\n}},[props.id,ref])// Re-run if ID or ref changes\n;// Pass all original props and the ref to the wrapped component\nreturn /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}// Add Property Controls so you can set the ID from the Framer canvas\naddPropertyControls(withCustomId,{id:{type:ControlType.String,title:\"Custom ID\",defaultValue:\"takeDemo\",placeholder:\"e.g., myContactForm\",displayTextArea:false}});export function withFormSubmitLogic(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[formErrors,setFormErrors]=useState({});const[submissionAttempted,setSubmissionAttempted]=useState(false);// Get the ID passed from the `withCustomId` override\n// Assuming your form component receives `id` as a prop because `withCustomId`\n// is applied to it, and passes it down.\nconst formId=props.id||\"takeDemo\"// Use the ID from props or a default\n;const getForm=()=>{// Prefer getting by the assigned ID\nconst formById=document.getElementById(formId);if(formById)return formById;// Fallback: If no ID or ID not found, try getting the first form\nif(document.forms.length>0){console.warn(`Form with ID \"${formId}\" not found. Falling back to document.forms[0]. Please ensure the form has the correct ID assigned via 'withCustomId' override.`);return document.forms[0];}return null;};// ... (rest of your validateForm and handleTap functions) ...\nconst validateForm=form=>{const errors={};let isValid=true;const formData=new FormData(form);// Access inputs by their 'name' attribute\nconst name=formData.get(\"name\");if(!name||typeof name===\"string\"&&name.trim()===\"\"){isValid=false;errors.name=\"Name is required.\";}const email=formData.get(\"email\");const emailRegex=/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;if(!email||typeof email===\"string\"&&!emailRegex.test(email.trim())){isValid=false;errors.email=\"Please enter a valid email address.\";}const phone_number=formData.get(\"phone_number\");if(!phone_number||typeof phone_number===\"string\"&&phone_number.trim()===\"\"){isValid=false;errors.phone_number=\"Phone Number is required.\";}const company_name=formData.get(\"company_name\");if(!company_name||typeof company_name===\"string\"&&company_name.trim()===\"\"){isValid=false;errors.company_name=\"Company Name is required.\";}return{isValid,errors};};const handleTap=()=>{setSubmissionAttempted(true);try{const form=getForm();if(!form){console.error(\"Framer Form not found! Please ensure it has a custom ID and is correctly applied.\");// alert(\"Form not found. Please contact support.\")\nreturn;}const{isValid,errors}=validateForm(form);setFormErrors(errors);if(!isValid){console.warn(\"Form validation failed:\",errors);let errorMessages=Object.values(errors).join(\"\\n\");if(errorMessages){// alert(\"Please correct the following errors:\\n\" +errorMessages)\n}else{// alert(\"There were validation errors. Please check the form.\")\n}// Optional: Add visual error classes directly here if you can't rely on useEffect for some reason\nObject.keys(errors).forEach(fieldName=>{const input=form.elements.namedItem(fieldName);if(input){input.classList.add(\"input-error\");}});return;}// Remove error classes on successful validation\nObject.keys(formErrors).forEach(fieldName=>{const input=form.elements.namedItem(fieldName);if(input){input.classList.remove(\"input-error\");}});const formData=new FormData(form);let data={};for(const pair of formData.entries()){data[pair[0]]=pair[1];}localStorage.setItem(\"demoFormData\",JSON.stringify(data));console.log(\"Form data saved:\",data);window.location.href=\"/demo-agents\";}catch(error){console.error(\"Error during form submission or validation:\",error);// alert(\"An unexpected error occurred. Please try again.\")\n}};// This useEffect will run when formErrors change, useful for dynamic error displays\nuseEffect(()=>{const form=getForm();if(!form)return;// Apply/remove 'input-error' class based on formErrors state\nArray.from(form.elements).forEach(element=>{const input=element;if(input.name&&formErrors[input.name]){input.classList.add(\"input-error\");}else if(input.name){input.classList.remove(\"input-error\");}});// You could also attempt to insert/update error message text next to inputs here,\n// but that's more complex as it involves creating/finding DOM elements dynamically.\n},[formErrors,submissionAttempted])// Also re-run on submission attempt to clear errors initially\n;return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onClick:handleTap});});}export function withAccessControl(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const localStoragePresent=localStorage.getItem(\"demoFormData\");if(!localStoragePresent){window.location.href=\"/demo\";return null;}return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}export function withPhoneNumber(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const formData=localStorage.getItem(\"demoFormData\");let phone_number=\"\";if(formData){let jsonFormData=JSON.parse(formData);phone_number=jsonFormData.phone_number;console.log(formData);console.log(phone_number);props[\"value\"]=phone_number;}return /*#__PURE__*/_jsx(Component,{ref:ref,...props,defaultValue:phone_number,value:phone_number});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withAccessControl\":{\"type\":\"reactHoc\",\"name\":\"withAccessControl\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCustomId\":{\"type\":\"reactHoc\",\"name\":\"withCustomId\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withPhoneNumber\":{\"type\":\"reactHoc\",\"name\":\"withPhoneNumber\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFormSubmitLogic\":{\"type\":\"reactHoc\",\"name\":\"withFormSubmitLogic\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Demo_Form.map"],
  "mappings": "uHACO,SAASA,EAAaC,EAAU,CAAC,OAAoBC,EAAW,CAACC,EAAMC,KAExEC,EAAU,IAAI,CAAC,GAAGD,GAAKA,EAAI,SAASD,EAAM,GAAG,CAAC,IAAMG,EAAQF,EAAI,QAAQE,EAAQ,GAAGH,EAAM,EAC/F,CAAC,EAAE,CAACA,EAAM,GAAGC,CAAG,CAAC,EAEG,EAAKH,EAAU,CAAC,IAAIG,EAAI,GAAGD,CAAK,CAAC,EAAG,CAAE,CAC1DI,EAAoBP,EAAa,CAAC,GAAG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AAIG,EAAI,GAAGD,EAAM,QAAQwB,CAAS,CAAC,CAAE,CAAC,CAAE,CAAQ,SAASQ,EAAkBlC,EAAU,CAAC,OAAoBC,EAAW,CAACC,EAAMC,IAAiC,aAAa,QAAQ,cAAc,EAAyF,EAAKH,EAAU,CAAC,IAAIG,EAAI,GAAGD,CAAK,CAAC,GAA/F8B,EAAO,SAAS,KAAK,QAAe,KAA8D,CAAE,CAAQ,SAASG,EAAgBnC,EAAU,CAAC,OAAoBC,EAAW,CAACC,EAAMC,IAAM,CAAC,IAAMkB,EAAS,aAAa,QAAQ,cAAc,EAAMG,EAAa,GAAG,OAAGH,IAAgDG,EAArB,KAAK,MAAMH,CAAQ,EAA4B,aAAa,QAAQ,IAAIA,CAAQ,EAAE,QAAQ,IAAIG,CAAY,EAAEtB,EAAM,MAASsB,GAAkC,EAAKxB,EAAU,CAAC,IAAIG,EAAI,GAAGD,EAAM,aAAasB,EAAa,MAAMA,CAAY,CAAC,CAAE,CAAC,CAAE",
  "names": ["withCustomId", "Component", "Y", "props", "ref", "ue", "element", "addPropertyControls", "ControlType", "withFormSubmitLogic", "formErrors", "setFormErrors", "ye", "submissionAttempted", "setSubmissionAttempted", "formId", "getForm", "formById", "validateForm", "form", "errors", "isValid", "formData", "name", "email", "phone_number", "company_name", "handleTap", "errorMessages", "fieldName", "input", "data", "pair", "window", "error", "withAccessControl", "withPhoneNumber"]
}
