{"version":3,"file":"embed.js","sources":["../../embed-code/src/main.js","../../embed-code/node_modules/iframe-resizer/js/iframeResizer.min.js"],"sourcesContent":["import iFrameResize from 'iframe-resizer/js/iframeResizer.min';\n\n(() => {\n const { url, form, type } = document.currentScript.dataset;\n const embedId = `connect-embed-${form}`;\n\n // A dynamic form question has position absolute which is a challenge for the iframeResize plugin\n // Thus we opted to not have the iframeResize plugin to do its magic for dynamic forms.\n // Static forms are okidoki\n const allowResize = type !== 'dynamic';\n\n const frame = document.createElement('iframe');\n frame.src = url;\n frame.id = embedId;\n frame.style.border = 0;\n frame.style.width = '100%';\n document.currentScript.parentNode.insertBefore(frame, null);\n\n function handleIframeMessage({ message = {} }) {\n switch (message.event) {\n case 'form:redirect-to':\n window.location.href = message.payload.url;\n break;\n case 'form:reset':\n // TODO scroll TO\n break;\n case 'form:loaded':\n if (!allowResize) {\n frame.style.height = '100vh';\n }\n break;\n default:\n // TODO do nothing\n }\n }\n\n iFrameResize({\n log: false,\n autoResize: allowResize,\n checkOrigin: [RMP_CONNECT_EMBED.IFRAME_WHITELIST_DOMAINS], // eslint-disable-line\n onMessage: handleIframeMessage,\n }, `#${embedId}`);\n})();\n\n// child.on('form:loaded')\n// child.on('form:change-height')\n// child.on('form:reset-scroll')\n// child.on('form:redirect-to')\n","/*! iFrame Resizer (iframeSizer.min.js ) - v4.3.1 - 2021-01-11\n * Desc: Force cross domain iframes to size to content.\n * Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame.\n * Copyright: (c) 2021 David J. Bradshaw - dave@bradshaw.net\n * License: MIT\n */\n\n!function(l){if(\"undefined\"!=typeof window){var e,m=0,g=!1,o=!1,x=\"message\".length,M=\"[iFrameSizer]\",I=M.length,k=null,r=window.requestAnimationFrame,h={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},F={},i=null,p={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:\"bodyOffset\",id:\"iFrameResizer\",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:\"parent\",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:\"scroll\",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){N(\"onMessage function not defined\")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}},z={};window.jQuery&&((e=window.jQuery).fn?e.fn.iFrameResize||(e.fn.iFrameResize=function(i){return this.filter(\"iframe\").each(function(e,n){d(n,i)}).end()}):E(\"\",\"Unable to bind to jQuery, it is not fully loaded.\")),\"function\"==typeof define&&define.amd?define([],v):\"object\"==typeof module&&\"object\"==typeof module.exports&&(module.exports=v()),window.iFrameResize=window.iFrameResize||v()}function w(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function O(e,n,i){e.addEventListener(n,i,!1)}function R(e,n,i){e.removeEventListener(n,i,!1)}function a(e){return M+\"[\"+function(e){var n=\"Host page: \"+e;return window.top!==window.self&&(n=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+\": \"+e:\"Nested host page: \"+e),n}(e)+\"]\"}function t(e){return F[e]?F[e].log:g}function T(e,n){s(\"log\",e,n,t(e))}function E(e,n){s(\"info\",e,n,t(e))}function N(e,n){s(\"warn\",e,n,!0)}function s(e,n,i,t){!0===t&&\"object\"==typeof window.console&&console[e](a(n),i)}function n(n){function e(){i(\"Height\"),i(\"Width\"),L(function(){A(y),H(v),c(\"onResized\",y)},y,\"init\")}function i(e){var n=Number(F[v][\"max\"+e]),i=Number(F[v][\"min\"+e]),t=e.toLowerCase(),o=Number(y[t]);T(v,\"Checking \"+t+\" is in range \"+i+\"-\"+n),oF[c][\"max\"+e])throw new Error(\"Value for min\"+e+\" can not be greater than max\"+e)}c in F&&\"iFrameResizer\"in i?N(c,\"Ignored iFrame, already setup.\"):(d=(d=e)||{},F[c]={firstRun:!0,iframe:i,remoteHost:i.src&&i.src.split(\"/\").slice(0,3).join(\"/\")},function(e){if(\"object\"!=typeof e)throw new TypeError(\"Options is not an object\")}(d),Object.keys(d).forEach(n,d),function(e){for(var n in p)Object.prototype.hasOwnProperty.call(p,n)&&(F[c][n]=Object.prototype.hasOwnProperty.call(e,n)?e[n]:p[n])}(d),F[c]&&(F[c].targetOrigin=!0===F[c].checkOrigin?function(e){return\"\"===e||null!==e.match(/^(about:blank|javascript:|file:\\/\\/)/)?\"*\":e}(F[c].remoteHost):\"*\"),function(){switch(T(c,\"IFrame scrolling \"+(F[c]&&F[c].scrolling?\"enabled\":\"disabled\")+\" for \"+c),i.style.overflow=!1===(F[c]&&F[c].scrolling)?\"hidden\":\"auto\",F[c]&&F[c].scrolling){case\"omit\":break;case!0:i.scrolling=\"yes\";break;case!1:i.scrolling=\"no\";break;default:i.scrolling=F[c]?F[c].scrolling:\"no\"}}(),f(\"Height\"),f(\"Width\"),u(\"maxHeight\"),u(\"minHeight\"),u(\"maxWidth\"),u(\"minWidth\"),\"number\"!=typeof(F[c]&&F[c].bodyMargin)&&\"0\"!==(F[c]&&F[c].bodyMargin)||(F[c].bodyMarginV1=F[c].bodyMargin,F[c].bodyMargin=F[c].bodyMargin+\"px\"),r=q(c),(s=w())&&(a=s,i.parentNode&&new a(function(e){e.forEach(function(e){Array.prototype.slice.call(e.removedNodes).forEach(function(e){e===i&&C(i)})})}).observe(i.parentNode,{childList:!0})),O(i,\"load\",function(){B(\"iFrame.onload\",r,i,l,!0),function(){var e=F[c]&&F[c].firstRun,n=F[c]&&F[c].heightCalculationMethod in h;!e&&n&&P({iframe:i,height:0,width:0,type:\"init\"})}()}),B(\"init\",r,i,l,!0),F[c]&&(F[c].iframe.iFrameResizer={close:C.bind(null,F[c].iframe),removeListeners:b.bind(null,F[c].iframe),resize:B.bind(null,\"Window resize\",\"resize\",F[c].iframe),moveToAnchor:function(e){B(\"Move to anchor\",\"moveToAnchor:\"+e,F[c].iframe,c)},sendMessage:function(e){B(\"Send Message\",\"message:\"+(e=JSON.stringify(e)),F[c].iframe,c)}}))}function c(e,n){null===i&&(i=setTimeout(function(){i=null,e()},n))}function u(){\"hidden\"!==document.visibilityState&&(T(\"document\",\"Trigger event: Visiblity change\"),c(function(){f(\"Tab Visable\",\"resize\")},16))}function f(n,i){Object.keys(F).forEach(function(e){!function(e){return F[e]&&\"parent\"===F[e].resizeFrom&&F[e].autoResize&&!F[e].firstRun}(e)||B(n,i,F[e].iframe,e)})}function y(){O(window,\"message\",n),O(window,\"resize\",function(){!function(e){T(\"window\",\"Trigger event: \"+e),c(function(){f(\"Window \"+e,\"resize\")},16)}(\"resize\")}),O(document,\"visibilitychange\",u),O(document,\"-webkit-visibilitychange\",u)}function v(){function i(e,n){n&&(function(){if(!n.tagName)throw new TypeError(\"Object is not a valid DOM element\");if(\"IFRAME\"!==n.tagName.toUpperCase())throw new TypeError(\"Expected