{"version":3,"sources":["webpack://@verndale/toolkit/./src/js/modules/marketo-modal.js"],"names":["Module","Component","modal","modalCloseX","accountId","formId","formContainer","button","submitButton","script","form","svgElem"],"mappings":"kJAEA,MAAMA,UAAeC,WAAU,CAC7B,eAAgB,CACd,KAAK,IAAM,CACT,IAAK,KAAK,EACZ,EAEA,KAAK,iBAAiB,CACxB,CAEA,kBAAmB,CACjB,MAAMC,EAAQ,SAAS,cAAc,gBAAgB,EAC/CC,EAAc,SAAS,cAAc,uBAAuB,EAC5DC,EAAYF,EAAM,aAAa,iBAAiB,EAChDG,EAASH,EAAM,aAAa,cAAc,EAC1CI,EAAgB,SAAS,cAAc,gCAAgC,EAG7EH,EAAY,iBAAiB,QAAS,IAAM,CAExCD,EAAM,UAAU,OAAO,yBAAyB,EAGzB,SAAS,iBAAiB,gCAAgC,EAClE,QAAQK,GAAU,CAC7BA,EAAO,UAAU,OAAO,eAAe,CAC3C,CAAC,CACL,CAAC,EAGD,MAAMC,EAAeN,EAAM,cAAc,qDAAqD,EAgB9F,GAfIM,GACAA,EAAa,iBAAiB,QAAS,IAAM,CAElB,SAAS,iBAAiB,gCAAgC,EAClE,QAAQD,GAAU,CAC7BA,EAAO,UAAU,OAAO,eAAe,CAC3C,CAAC,CACL,CAAC,EAILD,EAAc,UAAY,sBAAsBD,wCAI5C,OAAO,WAAe,IACxB,KAAK,gBAAgBD,EAAWC,CAAM,MAEjC,CACL,MAAMI,EAAS,SAAS,cAAc,QAAQ,EAC9CA,EAAO,IAAM,+CACbA,EAAO,OAAS,IAAM,KAAK,gBAAgBL,EAAWC,CAAM,EAC5D,SAAS,KAAK,YAAYI,CAAM,CAClC,CACF,CAEA,gBAAgBL,EAAWC,EAAQ,CAC7B,OAAO,WAAe,KAK1B,WAAW,SAAS,oBAAqBD,EAAWC,EAASK,GAAS,CAEpE,MAAMC,EAAU;AAAA;AAAA;AAAA,gBAIVH,EAAeE,EAAK,YAAY,EAAE,KAAK,uBAAuB,EAEhEF,EAAa,OAAS,GACxBA,EAAa,OAAOG,CAAO,CAE/B,CAAC,CACH,CACF,CAEA,UAAeX,C","file":"scripts/347.15cd98a4.js","sourcesContent":["import { Component } from '@verndale/core';\n\nclass Module extends Component {\n setupDefaults() {\n this.dom = {\n $el: this.el\n };\n\n this.openMarketoModal();\n }\n\n openMarketoModal() {\n const modal = document.querySelector('.marketo-modal');\n const modalCloseX = document.querySelector('.marketo-modal__close');\n const accountId = modal.getAttribute('data-account-id');\n const formId = modal.getAttribute('data-form-id');\n const formContainer = document.querySelector('.marketo-modal-form__container');\n\n // when the Marketo modal's close button is clicked\n modalCloseX.addEventListener(\"click\", () => {\n // hide the Marketo modal\n modal.classList.remove('marketo-modal__expanded');\n\n // return the Marketo button to its normal state\n const marketoButtons = document.querySelectorAll('[data-module=\"marketo-button\"]');\n marketoButtons.forEach(button => {\n button.classList.remove('btn--disabled');\n });\n });\n\n // when the Marketo form's submit button is clicked and the form is submitted\n const submitButton = modal.querySelector('.marketo-modal__expanded form button[type=\"submit\"]');\n if (submitButton) {\n submitButton.addEventListener(\"click\", () => {\n // return all Marketo buttons to their normal state\n const marketoButtons = document.querySelectorAll('[data-module=\"marketo-button\"]');\n marketoButtons.forEach(button => {\n button.classList.remove('btn--disabled');\n });\n });\n }\n\n // create the markup for the Marketo form and insert it into the handlebars container\n formContainer.innerHTML = `
`;\n\n // check that the MktoForms2 instance is available prior to loading the Marketo form data.\n // if it is, load the Marketo form data\n if (typeof MktoForms2 !== 'undefined') {\n this.loadMarketoForm(accountId, formId);\n // if it is not, load the MktoForms2 script dynamically, and then load the Marketo form data\n } else {\n const script = document.createElement('script');\n script.src = \"//info.amwell.com/js/forms2/js/forms2.min.js\";\n script.onload = () => this.loadMarketoForm(accountId, formId);\n document.head.appendChild(script);\n }\n }\n\n loadMarketoForm(accountId, formId) {\n if (typeof MktoForms2 === \"undefined\") {\n return;\n }\n\n // eslint-disable-next-line no-undef\n MktoForms2.loadForm(\"//info.amwell.com\", accountId, formId, (form) => {\n // add right-facing chevron svg into the form's button\n const svgElem = `\n `;\n const submitButton = form.getFormElem().find('button[type=\"submit\"]');\n\n if (submitButton.length > 0) {\n submitButton.append(svgElem);\n }\n });\n }\n}\n\nexport default Module;\n"],"sourceRoot":""}