{"version":3,"file":"PPCFormPrefill.DdevZI9k.mjs","names":["React.useRef","React.useState","__esmMin","init_ssg_sandbox_shims","window","_e","de","init_jsx_runtime","c","p","init_npm_react_18_3_1","ce","addPropertyControls","init_framer_BWFVvmND","RenderTarget","ControlType","fieldValue","value","field","fields","limit","capturePrefill","now","props","PPCFormPrefill","ref","form","capture","contact","params","utm","key","UTM_KEYS","formKey","sourceId","sourcePage","nameField","emailField","passLeadDetails","companyField","phoneField","qualificationField","style","safeReturnPath","url","PPCFormReturnLink","destination","setDestination","fallback","from","savedPath","raw","data","age","label","init_PPCFormPrefill"],"sources":["https:/framerusercontent.com/modules/V3MShufqcsvXMh1Z06lg/fxQOJcIT4g5wZrPzfDZA/PPCFormPrefill.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";const UTM_KEYS=[\"utm_source\",\"utm_medium\",\"utm_campaign\",\"utm_content\",\"utm_term\"];function fieldValue(fields,field,limit){const value=field.trim()?fields.get(field):null;return typeof value===\"string\"?value.trim().slice(0,limit):\"\";}function capturePrefill(fields,props,now=Date.now()){return{version:2,createdAt:now,name:fieldValue(fields,props.nameField,200),email:fieldValue(fields,props.emailField,320),...props.passLeadDetails?{company:fieldValue(fields,props.companyField,300),phone:fieldValue(fields,props.phoneField,100),qualification:fieldValue(fields,props.qualificationField,300)}:{}};}/**\n * Native Framer owns validation, delivery and the success redirect.\n * This invisible helper adds source fields and holds prefill in this tab for 15 minutes.\n * @framerIntrinsicWidth 1\n * @framerIntrinsicHeight 1\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight fixed\n */export default function PPCFormPrefill({formKey=\"demo-request\",nameField=\"Full Name\",emailField=\"Email\",sourceId=\"\",sourcePage=\"\",passLeadDetails=false,companyField=\"Company Name\",phoneField=\"Phone\",qualificationField=\"Job Title / Role*\",style}){const ref=React.useRef(null);React.useEffect(()=>{if(RenderTarget.current()===RenderTarget.canvas)return;const form=ref.current?.closest(\"form\");if(!(form instanceof HTMLFormElement))return;const capture=()=>{if(!form.checkValidity())return;const fields=new FormData(form);const contact=capturePrefill(fields,{nameField,emailField,passLeadDetails,companyField,phoneField,qualificationField});const params=new URLSearchParams(window.location.search);const utm={};for(const key of UTM_KEYS){const value=params.get(key);if(value)utm[key]=value.slice(0,255);}try{sessionStorage.setItem(`expertly-calendly:${formKey}`,JSON.stringify({...contact,sourceId:sourceId.trim().slice(0,120),sourcePage:sourcePage.trim()||window.location.pathname,utm}));}catch{}};form.addEventListener(\"submit\",capture,true);return()=>form.removeEventListener(\"submit\",capture,true);},[formKey,nameField,emailField,sourceId,sourcePage,passLeadDetails,companyField,phoneField,qualificationField]);return /*#__PURE__*/_jsxs(\"span\",{ref:ref,\"aria-hidden\":\"true\",style:{...style,display:\"none\"},children:[sourceId&&/*#__PURE__*/_jsx(\"input\",{type:\"hidden\",name:\"Source Form\",value:sourceId,readOnly:true}),sourcePage&&/*#__PURE__*/_jsx(\"input\",{type:\"hidden\",name:\"Source Page\",value:sourcePage,readOnly:true})]});}addPropertyControls(PPCFormPrefill,{formKey:{type:ControlType.String,title:\"Flow key\",defaultValue:\"demo-request\",description:\"Match the booking page's flow key. Details stay in this browser tab for 15 minutes.\"},sourceId:{type:ControlType.String,title:\"Source form\",defaultValue:\"\",description:\"Stable identifier for this form. Included in the submission email.\"},sourcePage:{type:ControlType.String,title:\"Source page\",defaultValue:\"\",description:\"Page path for the submission email and return link.\"},nameField:{type:ControlType.String,title:\"Name field\",defaultValue:\"Full Name\"},emailField:{type:ControlType.String,title:\"Email field\",defaultValue:\"Email\"},passLeadDetails:{type:ControlType.Boolean,title:\"Pass lead details\",defaultValue:false,description:\"Also pass company, phone and role or property type to the matching Calendly questions.\"},companyField:{type:ControlType.String,title:\"Company field\",defaultValue:\"Company Name\",hidden:p=>!p.passLeadDetails,description:\"Exact native input Name. The value is kept in this tab, not added to the page URL.\"},phoneField:{type:ControlType.String,title:\"Phone field\",defaultValue:\"Phone\",hidden:p=>!p.passLeadDetails,description:\"Exact input Name. For Hospitality International use Full Phone Number, including the country prefix.\"},qualificationField:{type:ControlType.String,title:\"Role/type field\",defaultValue:\"Job Title / Role*\",hidden:p=>!p.passLeadDetails,description:\"Use Property Type for Hospitality, or the exact role input Name including its asterisk.\"}});function safeReturnPath(value){if(!value.startsWith(\"/\")||value.startsWith(\"//\")||/[\\\\\\r\\n]/.test(value))return null;try{const url=new URL(value,window.location.origin);return url.origin===window.location.origin?url.pathname+url.search+url.hash:null;}catch{return null;}}/**\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 24\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export function PPCFormReturnLink({label=\"Back to request form\",fallback=\"/\",formKey=\"demo-request\",style}){const[destination,setDestination]=React.useState(fallback);React.useEffect(()=>{const from=new URLSearchParams(window.location.search).get(\"from\")||\"\";let savedPath=\"\";try{const raw=sessionStorage.getItem(`expertly-calendly:${formKey}`);const data=raw?JSON.parse(raw):null;const age=data?Date.now()-data.createdAt:NaN;if(Number.isFinite(age)&&age>=-1e3&&age<=15*60*1e3&&typeof data.sourcePage===\"string\")savedPath=data.sourcePage;}catch{}setDestination(safeReturnPath(from)||safeReturnPath(savedPath)||safeReturnPath(fallback)||\"/\");},[fallback,formKey]);return /*#__PURE__*/_jsx(\"a\",{href:destination,style:{display:\"block\",width:\"100%\",fontFamily:'\"TWK Lausanne\", sans-serif',fontSize:14,fontWeight:300,lineHeight:1.7,textAlign:\"center\",color:\"rgb(38, 38, 38)\",textDecoration:\"none\",...style,height:\"auto\"},children:label});}addPropertyControls(PPCFormReturnLink,{label:{type:ControlType.String,title:\"Label\",defaultValue:\"Back to request form\"},fallback:{type:ControlType.String,title:\"Fallback page\",defaultValue:\"/\",description:\"Used when the visitor opens the booking page directly.\"},formKey:{type:ControlType.String,title:\"Flow key\",defaultValue:\"demo-request\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"PPCFormPrefill\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicWidth\":\"1\",\"framerIntrinsicHeight\":\"1\"}},\"PPCFormReturnLink\":{\"type\":\"reactComponent\",\"name\":\"PPCFormReturnLink\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"400\",\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicHeight\":\"24\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PPCFormPrefill.map"],"mappings":"A,qNAAyO,SAASgB,EAAW,EAAO,EAAM,EAAM,CAAC,IAAMC,EAAMC,EAAM,KAAK,EAAEC,EAAO,IAAID,CAAK,EAAE,KAAK,OAAO,OAAOD,GAAQ,SAASA,EAAM,KAAK,CAAC,CAAC,MAAM,EAAEG,CAAK,EAAE,EAAG,CAAC,SAASC,EAAe,EAAO,EAAM,EAAI,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAUC,EAAI,KAAKN,EAAWG,EAAOI,EAAM,UAAU,GAAG,EAAE,MAAMP,EAAWG,EAAOI,EAAM,WAAW,GAAG,EAAE,GAAGA,EAAM,gBAAgB,CAAC,QAAQP,EAAWG,EAAOI,EAAM,aAAa,GAAG,EAAE,MAAMP,EAAWG,EAAOI,EAAM,WAAW,GAAG,EAAE,cAAcP,EAAWG,EAAOI,EAAM,mBAAmB,GAAG,CAAC,EAAE,CAAC,CAAC,CAAE,CAOxuB,SAAwBC,EAAe,CAAC,UAAQ,eAAe,YAAU,YAAY,aAAW,QAAQ,WAAS,GAAG,aAAW,GAAG,kBAAgB,GAAM,eAAa,eAAe,aAAW,QAAQ,qBAAmB,oBAAoB,SAAO,CAAC,IAAMC,EAAIzB,EAAa,IAAI,EAA26B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