{"version":3,"file":"Marketo_Form_Embed.DTHCuXPA.mjs","names":["useState","_Fragment","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","window","init_jsx_runtime","c","p","ce","_e","addPropertyControls","ControlType","init_framer_BWFVvmND","SettingsMessage","init_Utils_QTIc","MarketoForm","props","isEmbedValid","setIsEmbedValid","formId","setFormId","script","setScript","isLoading","setIsLoading","embed","style","link","value","id","embedFirstLine","isValidEmbed","newScript","handleError","message","error","form","email","values","l","customCSS","init_Marketo_Form_Embed"],"sources":["https:/framerusercontent.com/modules/c9FbF6gWas7sJWzmNUfz/bAedGggxcI358Ds3lN8y/Marketo_Form_Embed.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useEffect}from\"react\";import{SettingsMessage}from\"https://framer.com/m/Utils-QTIc.js@PVRWqcAS5FromVQ03eYl\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerIntrinsicWidth 600\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicHeight 300\n */export default function MarketoForm(props){const{embed,style}=props;const[isEmbedValid,setIsEmbedValid]=useState(false);const[formId,setFormId]=useState(null);const[script,setScript]=useState(null);const[isLoading,setIsLoading]=useState(true);if(!embed||embed.length===0){return /*#__PURE__*/_jsx(SettingsMessage,{title:\"Marketo Embed Component\",description:\"Enter the Marketo Embed Code here\",containerStyle:style});}useEffect(()=>{setIsLoading(true);const embedRegex=/MktoForms2\\.loadForm\\(\"(.+?)\", \"(.+?)\", (\\d+)(?:, .+?)?\\);/;const embedMatch=embed.match(embedRegex);const[,link,value,id]=embedMatch||[];setFormId(`mktoForm_${id}`);const embedFirstLine=`<script src=\"${link}/js/forms2/js/forms2.min.js\"></script>`;const isValidEmbed=embed.startsWith(embedFirstLine)&&value&&id&&link;setIsEmbedValid(isValidEmbed);if(isValidEmbed){const newScript=document.createElement(\"script\");newScript.src=`${link}/js/forms2/js/forms2.min.js`;newScript.async=true;const handleError=(error,message)=>{setIsEmbedValid(false);setIsLoading(false);console.error(message,error);};const handleScriptLoad=()=>{try{if(window.MktoForms2){window.MktoForms2.loadForm(link,value,id,function(form){form.onSuccess(function(values,followUpUrl){if(window.dreamdata&&window.dreamdata.initialized){const email=values.Email||values.email;window.dreamdata.identify(null,{email:email});window.dreamdata.track(\"Marketo Form Submitted\");}return true;});});}}catch(error){handleError(error,\"Error loading form:\");}};newScript.onload=handleScriptLoad;document.body.appendChild(newScript);setScript(newScript);try{document.body.appendChild(newScript);setScript(newScript);}catch(error){handleError(error,\"Error appending script:\");}}setIsLoading(false);return()=>{if(script){try{document.body.removeChild(script);}catch(error){setIsEmbedValid(false);console.error(\"Error removing script:\",error);}}};},[embed]);return /*#__PURE__*/_jsx(_Fragment,{children:isLoading?/*#__PURE__*/_jsx(_Fragment,{}):isEmbedValid?/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:customCSS}),/*#__PURE__*/_jsx(\"form\",{id:formId})]}):/*#__PURE__*/_jsx(SettingsMessage,{title:\"Your embed code is incorrect!\",description:\"Update the Marketo embed form in the component property.\",containerStyle:style,icon:\"🚨\"})});}const customCSS=`\n    .mktoLabel {\n        width: auto !important;\n        float: none !important;\n        display: block !important;\n    }\n`;MarketoForm.displayName=\"Marketo Form\";addPropertyControls(MarketoForm,{embed:{title:\"Embed Code\",type:ControlType.String,displayTextArea:true,description:\"[Where to find my Marketo embed form](https://experienceleague.adobe.com/en/docs/marketo/using/product-docs/demand-generation/forms/form-actions/embed-a-form-on-your-website).\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"MarketoForm\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"600\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"*\",\"framerIntrinsicHeight\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