{"version":3,"file":"TallyForms.Bm01nQ0Y.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/izet01HqJr9HjpAGaGFg/m8QOAvGmb2BJzhY47UbC/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 ref;// Remove initialized attribute if any, so we can reload\nconst iframeEl=iframeRef.current;if(iframeEl===null||iframeEl===void 0?void 0:(ref=iframeEl.dataset)===null||ref===void 0?void 0:ref.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\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"700\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TallyForms.map"],"mappings":"0QAII,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,OAAK,QAAM,YAAU,aAAW,CAAC,EAAY,EAAUA,EAAO,MAC5G,EAAY,EAAE,CAAC,EAAY,KAAK,aAAa,EAAM,IAAI,OAAO,EAAY,KAAK,aAAa,EAAU,IAAI,OAAO,EAAY,KAAK,yBAAyB,EAAW,IAAI,OAAO,EAAY,KAAK,mBACxM,IAAI,EAAS,GAAG,GAAG,EAAK,SAAS,aA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