{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/jNVNc45FmRe5Gc0wsMUR/WgsEZTjqCgK0IcjD5Zn3/TallyForms.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const WIDGET_URL=\"https://tally.so/widgets/embed.js\";/**\n * @framerIntrinsicWidth 700\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight any\n */export default function TallyForms(props){const{form,title,alignLeft,background}=props;const iframeRef=useRef(null);// Use the options to build the URL query params\nconst queryParams=[];queryParams.push(`hideTitle=${title?\"0\":\"1\"}`);queryParams.push(`alignLeft=${alignLeft?\"1\":\"0\"}`);queryParams.push(`transparentBackground=${background?\"0\":\"1\"}`);queryParams.push(\"dynamicHeight=1\");// The iframe URL\nlet embedUrl=\"\";if(form.includes(\"tally.so/\")){// Tally link with form ID\nconst matches=form.match(/\\/(?:r|embed|popup|forms)\\/([a-zA-Z0-9]+)/);if(matches!==null){const formId=matches[1];embedUrl=`https://tally.so/embed/${formId}`;}}else if(form.startsWith(\"http\")&&form.includes(\".\")){// Custom domain\nembedUrl=form;queryParams.push(\"embed=1\");}// If we still don't have URL, we assume the form is the form ID itself\nif(!embedUrl){embedUrl=`https://tally.so/embed/${form}`;}// Append query params\nembedUrl=`${embedUrl}?${queryParams.join(\"&\")}`;const prefillForm=()=>{try{// Get values from URL parameters first\nconst urlParams=new URLSearchParams(window.location.search);let height=urlParams.get(\"height\");let weight=urlParams.get(\"weight\");const mpId=urlParams.get(\"mp_id\")// NEW: Get mp_id from URL\n;// If not in URL, try sessionStorage\nif(!height||!weight){height=sessionStorage.getItem(\"luminaHeight\");weight=sessionStorage.getItem(\"luminaWeight\");}// If still not found, try localStorage\nif(!height||!weight){height=localStorage.getItem(\"luminaHeight\");weight=localStorage.getItem(\"luminaWeight\");}console.log(\"Retrieved values to prefill:\",{height,weight,mpId})// NEW: Log mpId\n;const iframe=iframeRef.current;if(!iframe?.contentWindow){console.log(\"No iframe found\");return;}// Function to fill the form\nconst fillForm=()=>{try{const iframeDoc=iframe.contentDocument||iframe.contentWindow?.document;if(!iframeDoc)return false;// NEW: Add mp_id hidden field ==============================\nlet mpIdInput=iframeDoc.querySelector('input[name=\"mp_id\"]');if(!mpIdInput){mpIdInput=document.createElement(\"input\");mpIdInput.type=\"hidden\";mpIdInput.name=\"mp_id\";iframeDoc.body.appendChild(mpIdInput);console.log(\"Created mp_id hidden field\");}mpIdInput.value=mpId||\"\";// ==========================================================\n// Existing height/weight logic\nconst heightInput=iframeDoc.querySelector('input[placeholder*=\"altura\"], input[name*=\"altura\"]');const weightInput=iframeDoc.querySelector('input[placeholder*=\"peso\"], input[name*=\"peso\"]');if(!heightInput||!weightInput){console.log(\"Inputs not found:\",{heightFound:!!heightInput,weightFound:!!weightInput,mpIdFound:!!mpIdInput});return false;}// Set values with delay\nsetTimeout(()=>{if(height)heightInput.value=height;if(weight)weightInput.value=weight;// Trigger events\nconst events=[\"input\",\"change\",\"keyup\",\"keydown\",\"keypress\",\"focus\",\"blur\"];events.forEach(eventType=>{const event=new Event(eventType,{bubbles:true,cancelable:true,composed:true});heightInput.dispatchEvent(event);weightInput.dispatchEvent(event);});// Add data attributes\nheightInput.setAttribute(\"data-value-set\",height||\"\");weightInput.setAttribute(\"data-value-set\",weight||\"\");},100);console.log(\"Form filled successfully\",{height,weight,mpId});// Clear storage\nsessionStorage.removeItem(\"luminaHeight\");sessionStorage.removeItem(\"luminaWeight\");localStorage.removeItem(\"luminaHeight\");localStorage.removeItem(\"luminaWeight\");return true;}catch(error){console.error(\"Error filling form:\",error);return false;}};// Existing attempt logic\nlet attempts=0;const maxAttempts=20;const attemptInterval=setInterval(()=>{attempts++;console.log(`Attempt ${attempts} to fill form`);if(fillForm()||attempts>=maxAttempts){clearInterval(attemptInterval);}},1e3);setTimeout(()=>clearInterval(attemptInterval),2e4);}catch(error){console.error(\"Error in prefillForm:\",error);}};const loadWidgetScript=()=>{const scriptEl=document.createElement(\"script\");scriptEl.src=WIDGET_URL;scriptEl.onload=()=>{loadEmbeds();prefillForm();};scriptEl.onerror=loadEmbeds;document.body.appendChild(scriptEl);};const loadEmbeds=()=>{const iframeEl=iframeRef.current;if(iframeEl?.dataset?.tallyEmbedWidgetInitialized){iframeEl.removeAttribute(\"data-tally-embed-widget-initialized\");iframeEl.removeAttribute(\"src\");}// @ts-ignore\nif(typeof Tally!==\"undefined\"){// @ts-ignore\nTally.loadEmbeds();}else{document.querySelectorAll(\"iframe[data-tally-src]:not([src])\").forEach(e=>{e.src=e.dataset.tallySrc;});}};useEffect(()=>{// @ts-ignore\nif(typeof Tally!==\"undefined\"){loadEmbeds();prefillForm();}else if(document.querySelector(`script[src=\"${WIDGET_URL}\"]`)==null){loadWidgetScript();}// Also try prefilling when iframe loads\nconst iframe=iframeRef.current;if(iframe){iframe.addEventListener(\"load\",()=>{setTimeout(prefillForm,1e3);});}},[embedUrl]);return /*#__PURE__*/_jsx(\"iframe\",{ref:iframeRef,\"data-tally-src\":embedUrl,\"data-hj-allow-iframe\":\"\",allow:\"cross-origin-isolated\",crossorigin:\"anonymous\",width:\"100%\",height:\"auto\",frameBorder:0,marginHeight:0,marginWidth:0,title:\"Tally form\"});}addPropertyControls(TallyForms,{form:{type:ControlType.String,title:\"Form\",defaultValue:\"tally.so/r/3EKXW4\",description:\"Create a form in [Tally](https://tally.so?ref=framer) and copy the form link\"},title:{type:ControlType.Boolean,title:\"Title\",enabledTitle:\"Show\",disabledTitle:\"Hide\",defaultValue:false},alignLeft:{type:ControlType.Boolean,title:\"Align\",enabledTitle:\"Left\",disabledTitle:\"Center\",defaultValue:true},background:{type:ControlType.Boolean,title:\"Background\",enabledTitle:\"Show\",disabledTitle:\"Hide\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TallyForms\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\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,MAAM,wBAAwB,YAAY,YAAY,MAAM,OAAO,OAAO,OAAO,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC,CAAE,CAAC0B,EAAoBnC,EAAW,CAAC,KAAK,CAAC,KAAKoC,EAAY,OAAO,MAAM,OAAO,aAAa,oBAAoB,YAAY,8EAA8E,EAAE,MAAM,CAAC,KAAKA,EAAY,QAAQ,MAAM,QAAQ,aAAa,OAAO,cAAc,OAAO,aAAa,EAAK,EAAE,UAAU,CAAC,KAAKA,EAAY,QAAQ,MAAM,QAAQ,aAAa,OAAO,cAAc,SAAS,aAAa,EAAI,EAAE,WAAW,CAAC,KAAKA,EAAY,QAAQ,MAAM,aAAa,aAAa,OAAO,cAAc,OAAO,aAAa,EAAK,CAAC,CAAC",
  "names": ["init_ssg_sandbox_shims", "WIDGET_URL", "TallyForms", "props", "form", "title", "alignLeft", "background", "iframeRef", "pe", "queryParams", "embedUrl", "matches", "prefillForm", "urlParams", "height", "weight", "mpId", "iframe", "fillForm", "iframeDoc", "mpIdInput", "heightInput", "weightInput", "eventType", "event", "error", "attempts", "maxAttempts", "attemptInterval", "loadWidgetScript", "scriptEl", "loadEmbeds", "iframeEl", "e", "ue", "p", "addPropertyControls", "ControlType"]
}
