{"version":3,"file":"TallyForms.CJ81Kveb.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/FunZRtCencOiSs69yafJ/WWr3bp1mGXZbQiTIKWMs/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 loadWidgetScript=()=>{const scriptEl=document.createElement(\"script\");scriptEl.src=WIDGET_URL;scriptEl.onload=loadEmbeds;scriptEl.onerror=loadEmbeds;document.body.appendChild(scriptEl);};const loadEmbeds=()=>{var _iframeEl_dataset;// Remove initialized attribute if any, so we can reload\nconst iframeEl=iframeRef.current;if(iframeEl===null||iframeEl===void 0?void 0:(_iframeEl_dataset=iframeEl.dataset)===null||_iframeEl_dataset===void 0?void 0:_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(function(e){e.src=e.dataset.tallySrc;});}};useEffect(()=>{// @ts-ignore\nif(typeof Tally!==\"undefined\"){loadEmbeds();}else if(document.querySelector(`script[src=\"${WIDGET_URL}\"]`)==null){loadWidgetScript();}},[embedUrl]);return /*#__PURE__*/_jsx(\"iframe\",{ref:iframeRef,\"data-tally-src\":embedUrl,width:\"100%\",height:\"100%\",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\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"700\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TallyForms.map"],"mappings":"iLAIG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,OAAK,QAAM,YAAU,cAAY,EAAY,EAAUA,EAAO,KAAK,CAChH,EAAY,EAAE,CAAC,EAAY,KAAK,aAAa,EAAM,IAAI,MAAM,CAAC,EAAY,KAAK,aAAa,EAAU,IAAI,MAAM,CAAC,EAAY,KAAK,yBAAyB,EAAW,IAAI,MAAM,CAAC,EAAY,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