var e={482:(e,t,r)=>{r.d(t,{Z:()=>u});var n=r(348);function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function o(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,l(n.key),n)}}function s(e,t,r){return(t=l(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e){var t=function(e,t){if("object"!=i(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}var u=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),s(this,"scriptsToExecute",void 0),s(this,"previousScriptEl",void 0),s(this,"scriptLoadedMap",void 0),s(this,"error",void 0),this.scriptsToExecute=t,this.previousScriptEl=void 0,this.scriptLoadedMap=new Map,this.error=void 0}return t=e,i=[{key:"replaceNodesIn",value:function(t,r,n){if(n){t.replaceChildren.apply(t,o(r));var i=new e(Array.from(t.querySelectorAll("script")));if(i.start(),i.error)throw i.error}else t.replaceChildren.apply(t,o(Array.from(r).filter((function(e){return"SCRIPT"!==e.nodeName}))))}}],(r=[{key:"start",value:function(){this.scriptsToExecute.length>0&&this.replaceScriptUntilInlineScript()}},{key:"replacePreviousScript",value:function(e){var t=this;try{var r=(0,n.M)(e);r.src&&(r.addEventListener("load",(function(){t.scriptLoadedMap.set(r.src,!0),t.replaceScriptUntilInlineScript()})),r.addEventListener("error",(function(){t.scriptLoadedMap.set(r.src,!0),t.replaceScriptUntilInlineScript()}))),e.replaceWith(r)}catch(e){this.error=e}}},{key:"replaceScriptUntilInlineScript",value:function(){for(var e;this.scriptsToExecute.length>0&&!this.error;)if((e=this.scriptsToExecute[0])&&e.parentElement){var t=!!e.src,r=!this.previousScriptEl,n=this.previousScriptEl&&(!this.previousScriptEl.src||!0===this.scriptLoadedMap.get(this.previousScriptEl.src));if(!(r||t||n))return;this.scriptsToExecute.shift(),this.replacePreviousScript(e),this.previousScriptEl=e}else this.scriptsToExecute.shift()}}])&&c(t.prototype,r),i&&c(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,i}()},348:(e,t,r)=>{function n(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function o(e){if("SCRIPT"!==e.tagName)throw new Error("Not a script element");for(var t=document.createElement("script"),r=0,n=Array.from(e.attributes);r<n.length;r++){var i=n[r],o=i.name,a=i.value;t.setAttribute(o,a)}return t.innerHTML=e.innerHTML,!e.async&&e.src&&(t.async=!1),t}function a(e){var t={domNodes:[],layoutLoading:Promise.resolve([]),linksLoading:Promise.resolve([])};if(!e)return t;var r=(new DOMParser).parseFromString(e,"text/html"),i=function(e){var t=[],r=[];return{scriptAndLinkNodes:Array.from(e.childNodes).reduce((function(e,n){var i=n instanceof HTMLLinkElement&&"stylesheet"===n.rel;return c(n),"SCRIPT"===n.nodeName||"STYLE"===n.nodeName||"META"===n.nodeName?(e.push(n),e):("IMG"===n.nodeName&&n instanceof HTMLImageElement&&r.push(new Promise((function(e,t){n.addEventListener("load",(function(){return e()})),n.addEventListener("error",(function(){return t()}))}))),i?(t.push(new Promise((function(e,t){n.addEventListener("load",(function(){return e()})),n.addEventListener("error",(function(){return t()}))}))),e.push(n),e):e)}),[]),imagesLoading:r,linkPromises:t}}(r.head),o=i.scriptAndLinkNodes,a=i.imagesLoading,s=i.linkPromises;return{domNodes:o.concat.apply(o,n(Array.from(r.body.childNodes))),layoutLoading:Promise.allSettled([].concat(n(s),n(a))),linksLoading:Promise.allSettled(s)}}r.d(t,{L:()=>a,M:()=>o});var c=function(e){var t=e instanceof HTMLImageElement||e instanceof HTMLScriptElement,r=e instanceof HTMLLinkElement;t&&e.src&&(e.src=s(e.src)),r&&e.href&&(e.href=s(e.href))},s=function(e){return e.startsWith("//")?"$https:".concat(e):e}}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n={};(()=>{r.d(n,{C:()=>l,y:()=>o});var e=r(348),t=r(482);function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function o(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n.sendCurrentUTKAsParam,o=void 0!==i&&i,a=n.isPreview,c=void 0!==a&&a,s=n.bustCache,l=void 0!==s&&s,u=new URLSearchParams(location.search),d=u.toString(),p=!!u.get("preview"),f=l||p?"&hsCacheBuster=".concat(Date.now()):"",h=c?function(e,t){var r=new URL(e).origin,n=new URLSearchParams(window.location.search),i=new URL("".concat(r,"/_hcms/preview/content-embed/").concat(t));return n.delete("preview_id"),n.delete("preview_nonce"),n.delete("injectedScripts"),n.delete("localAssets"),n.delete("scriptPath"),n.delete("staticVersion"),n.delete("cssPath"),n.delete("benderPackage"),i.search=n.toString(),i}(t,e):new URL("".concat(t,"?").concat(d).concat(f));if(o){var m=("hubspotutk",(r=document.cookie.match(RegExp("(?:^|;\\s*)"+"hubspotutk".replace(/([.*+?\^$(){}|\[\]\/\\])/g,"\\$1")+"=([^;]*)")))?r[1]:null);m&&h.searchParams.set("hsutk",m)}return fetch(h).then((function(e){if(500===e.status)throw new Error("Embed HTML Fetch failed");return e.text()}))}function a(e){return e.startsWith("/")?e.replace("/",""):e}function c(e,t,r,n){var i=n.staticVersion,o=n.branchPreviewBuild,c=function(e){return e?"//":"https://"}(r),s=function(e,t){return e?"local.hubspotqa.com":t?"b-".concat(t,".dynamic.hsappstatic.net"):"static.hsappstatic.net"}(r,o),l=function(e,t){return e?"static":t?a(t):null}(r,i);if(!l)return null;var u=a(e),d=a(t);return"".concat(c).concat(s,"/").concat(u,"/").concat(l,"/").concat(d)}function s(){var e,t,r=new URLSearchParams(window.location.search),n=r.get("benderPackage"),o=r.get("scriptPath"),a=r.get("cssPath");n&&o&&a&&(!function(e){var t="true"===e.get("deployed"),r="true"===e.get("localAssets");window.hsVars||(window.hsVars={}),window.hsVars.app_hs_base_url="https://".concat(r?"local":"app",".hubspot").concat(t?"":"qa",".com")}(r),(e=r.getAll("injectedScripts"),t=e.map((function(e){var t,r,n=e.split(",");if(n.length>=4){var o=(r=4,function(e){if(Array.isArray(e))return e}(t=n)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,a,c=[],s=!0,l=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=o.call(r)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){l=!0,i=e}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw i}}return c}}(t,r)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=c(o[0],o[1],"true"===o[2],{staticVersion:o[3]});if(!a)return Promise.resolve();var s=document.createElement("script");return s.src=a,document.head.appendChild(s),new Promise((function(e){s.onload=e}))}})),Promise.all(t)).then((function(){var e=r.get("staticVersion"),t="true"===r.get("localAssets"),i=r.get("branchPreviewBuild"),s=c(n,o,t,{staticVersion:e,branchPreviewBuild:i}),l=c(n,a,t,{staticVersion:e,branchPreviewBuild:i});if(s&&l){var u,d,p=document.createElement("link");p.rel="stylesheet",p.href=l,u=s,(d=document.createElement("script")).src=u,document.head.appendChild(d),document.head.appendChild(p)}else console.error("Injecting scripts failed due to invalid query params, please check your staticVersion, localAssets, and branchPreviewBuild params")})).catch((function(e){console.error(e),console.error("Injecting editor scripts failed with the above error")})))}function l(r,n,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},c=a.sendCurrentUTKAsParam,l=void 0!==c&&c,u=a.bustCache,d=void 0!==u&&u;return o(r,n,{sendCurrentUTKAsParam:l,isPreview:"true"===new URLSearchParams(window.location.search).get("hs_embed_preview"),bustCache:d}).then((function(r){window.__hs_script_injection_attempted||(window.__hs_script_injection_attempted=!0,s());var n=document.getElementById(i);if(n){n.style.visibility="hidden";var o=(0,e.L)(r),a=o.domNodes,c=o.linksLoading;t.Z.replaceNodesIn(n,a,!0),c.then((function(){n.style.visibility="visible"})).catch((function(e){console.log("Error loading links",e)}))}})).catch((function(e){console.error("Injecting embed HTML errored:",e)}))}})();var i=n.y,o=n.C;export{i as fetchEmbedHTML,o as injectHsEmbed};