{"version":3,"file":"HighLevelForm.Ccha4QeF.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/sQijgWB7T0XhPdUu7WUk/IF1TqKApP8rECNYSe1V3/HighLevelForm.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * HighLevel (GoHighLevel / LeadConnector) embedded form or survey.\n * Renders the LeadConnector iframe and loads the resize script (form_embed.js),\n * which handles multi-step survey resizing and submit behavior.\n *\n * v1.1.0 (Sep 17 2026) — passes ad attribution into the embed.\n *\n * WHY. GoHighLevel's \"Add to Google Ads\" workflow action can only upload a\n * conversion when the contact carries a click ID: gclid, gbraid or wbraid.\n * This embed is served from leadconnectorhq.com, and a cross-origin iframe\n * cannot read the parent page's URL. So the gclid sitting in\n * smarthomelending.com/apply?gclid=... never reaches the submission, every\n * upload is rejected as \"Skipped\", and paid leads look organic.\n *\n * Adding the parameters to this iframe's own address closes that gap. It is\n * done here, where the src is built, rather than by hunting for the frame in\n * the DOM afterwards — nothing to match, nothing to mistake for another embed.\n *\n * ORDERING MATTERS. The src is applied in an effect rather than during render\n * because the attribution lives in sessionStorage, which does not exist during\n * server rendering; computing it inline would make the server and client\n * disagree on the src and hand React a hydration mismatch. The effect runs on\n * mount, milliseconds in and long before anyone can type, and runs exactly once\n * — reassigning src reloads the frame, which would wipe a half-finished survey.\n *\n * GHL SIDE. Each parameter needs a hidden custom field on the form or survey\n * whose Query Key matches the name EXACTLY, case-sensitive. `GCLID` will not\n * match `gclid`; the value is accepted and silently discarded.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicWidth 500\n * @framerIntrinsicHeight 847\n */// Written by GetMyRateFunnel's getAttribution() on every page of the site.\nconst ATTRIBUTION_KEY=\"shl_attribution\";// gbraid and wbraid matter as much as gclid: Google sends those INSTEAD of\n// gclid on iOS and app-campaign traffic, and GHL accepts any of the three.\nconst ATTRIBUTION_PARAMS=[\"gclid\",\"gbraid\",\"wbraid\",\"fbclid\",\"utm_source\",\"utm_medium\",\"utm_campaign\",\"utm_term\",\"utm_content\"];function collectAttribution(){const out={};if(typeof window===\"undefined\")return out;try{const stored=JSON.parse(window.sessionStorage.getItem(ATTRIBUTION_KEY)||\"{}\");if(stored&&typeof stored===\"object\"){ATTRIBUTION_PARAMS.forEach(k=>{if(stored[k])out[k]=String(stored[k]);});}}catch(e){}// The live URL wins over storage — it is the fresher click. Matched\n// case-insensitively, because casing drifts between ad platforms.\ntry{const q=new URLSearchParams(window.location.search);const lower={};q.forEach((v,k)=>{const lk=k.toLowerCase();if(v&&!(lk in lower))lower[lk]=v;});ATTRIBUTION_PARAMS.forEach(k=>{if(lower[k])out[k]=lower[k];});}catch(e){}return out;}export default function HighLevelForm(props){const{embedType,formId,surveyId,embedName,height,borderRadius,passAttribution}=props;const baseUrl=(props.baseUrl||\"https://get.smarthomelending.com\").replace(/\\/$/,\"\");const scriptUrl=props.scriptUrl||`${baseUrl}/js/form_embed.js`;const isSurvey=embedType===\"survey\";const widgetId=isSurvey?surveyId:formId;const src=isSurvey?`${baseUrl}/widget/survey/${widgetId}`:`${baseUrl}/widget/form/${widgetId}`;const frameRef=useRef(null);const appliedRef=useRef(false);// Runs before the script effect below, so the frame is carrying its\n// attribution by the time form_embed.js starts managing it.\nuseEffect(()=>{if(!passAttribution)return;if(appliedRef.current)return;const el=frameRef.current;if(!el)return;let url;try{url=new URL(el.src||src,window.location.href);}catch(e){return;}const att=collectAttribution();let added=0;ATTRIBUTION_PARAMS.forEach(k=>{// Never overwrite a value the URL already carries.\nif(att[k]&&!url.searchParams.has(k)){url.searchParams.set(k,att[k]);added++;}});// Mark as done even when nothing was added, so a re-render can never\n// reassign src a second time and reload a survey mid-answer.\nappliedRef.current=true;if(!added)return;el.src=url.toString();},[passAttribution,src]);useEffect(()=>{// Load the LeadConnector embed script once (handles resize + submit).\nconst existing=document.querySelector(`script[src=\"${scriptUrl}\"]`);if(existing)return;const script=document.createElement(\"script\");script.src=scriptUrl;script.async=true;document.body.appendChild(script);},[scriptUrl]);if(isSurvey){// Multi-step survey: form_embed.js controls the height. scrolling disabled.\nreturn /*#__PURE__*/_jsx(\"iframe\",{ref:frameRef,src:src,title:\"survey\",id:widgetId,scrolling:\"no\",\"data-cookie-consent\":\"true\",\"data-cookie-consent-provider\":\"auto\",style:{display:\"block\",width:\"100%\",minHeight:height,border:\"none\",borderRadius:borderRadius,background:\"transparent\"}});}// Single-page form.\nreturn /*#__PURE__*/_jsx(\"iframe\",{ref:frameRef,src:src,title:embedName,id:`inline-${widgetId}`,\"data-layout\":\"{'id':'INLINE'}\",\"data-trigger-type\":\"alwaysShow\",\"data-activation-type\":\"alwaysActivated\",\"data-deactivation-type\":\"neverDeactivate\",\"data-form-name\":embedName,\"data-height\":height,\"data-layout-iframe-id\":`inline-${widgetId}`,\"data-form-id\":widgetId,style:{width:\"100%\",height:\"100%\",minHeight:height,border:\"none\",borderRadius:borderRadius,background:\"transparent\"}});}// Declared as a typed const rather than inline. Assigning an object literal\n// straight onto the function (`HighLevelForm.defaultProps = {...}`) is an\n// expando property, and TypeScript widens literal types on those — embedType\n// becomes `string`, which then fails the \"form\" | \"survey\" union that\n// addPropertyControls checks against. An `as const` on the value does not\n// survive that widening; annotating the const does.\nconst DEFAULT_PROPS={embedType:\"survey\",formId:\"4JNPQupE8Y3WyDaiwy3s\",surveyId:\"65Xcbz7FZWznWpwU3zy0\",embedName:\"Website Apply Now Survey\",baseUrl:\"https://get.smarthomelending.com\",scriptUrl:\"\",height:847,borderRadius:24,passAttribution:true};HighLevelForm.defaultProps=DEFAULT_PROPS;addPropertyControls(HighLevelForm,{embedType:{type:ControlType.Enum,title:\"Type\",options:[\"survey\",\"form\"],optionTitles:[\"Survey\",\"Form\"],defaultValue:\"survey\"},surveyId:{type:ControlType.String,title:\"Survey ID\",defaultValue:\"65Xcbz7FZWznWpwU3zy0\",hidden:props=>props.embedType!==\"survey\"},formId:{type:ControlType.String,title:\"Form ID\",defaultValue:\"4JNPQupE8Y3WyDaiwy3s\",hidden:props=>props.embedType!==\"form\"},embedName:{type:ControlType.String,title:\"Name\",defaultValue:\"Website Apply Now Survey\"},baseUrl:{type:ControlType.String,title:\"Embed Host\",defaultValue:\"https://get.smarthomelending.com\"},scriptUrl:{type:ControlType.String,title:\"Script URL\",defaultValue:\"\",description:\"Blank = {Embed Host}/js/form_embed.js\"},passAttribution:{type:ControlType.Boolean,title:\"Pass Ad Data\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\",description:\"Sends gclid/gbraid/wbraid + UTMs into the embed. Needs matching hidden fields in GHL.\"},height:{type:ControlType.Number,title:\"Min Height\",defaultValue:847,min:200,max:2e3,unit:\"px\",step:1},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:24,min:0,max:100,unit:\"px\",step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HighLevelForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HighLevelForm.map"],"mappings":"+LAoCgI,SAAS,GAAoB,CAAC,IAAM,EAAI,CAAC,EAAE,GAAU,IAAS,OAAY,OAAO,EAAI,GAAG,CAAC,IAAM,EAAO,KAAK,MAAM,EAAO,eAAe,QAAQ,CAAe,GAAG,IAAI,EAAK,GAAQ,OAAO,GAAS,UAAU,EAAmB,QAAQ,GAAG,CAAI,EAAO,KAAG,EAAI,GAAG,OAAO,EAAO,EAAE,EAAE,CAAC,CAAG,MAAS,CAAC,CAE/Z,GAAG,CAAC,IAAM,EAAE,IAAI,gBAAgB,EAAO,SAAS,MAAM,EAAQ,EAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,IAAM,EAAG,EAAE,YAAY,EAAK,GAAG,EAAE,KAAM,KAAO,EAAM,GAAI,EAAE,CAAC,E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