!function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={exports:{},id:r,loaded:!1};return e[r].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){return e+"-"+t}function o(){return window.location.href.indexOf("localhost")>-1}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=document.createElement("script"),r=t.skipBabelPolyFill,a=["async","charset","crossorigin","integrity","language","nonce","onload","referrerpolicy","src","type"];return a.forEach(function(t){var a=e.getAttribute(t);if("src"===t){if(a){if(r&&n.src.indexOf("babel-polyfill.js")!==-1)return;return void(n[t]=a+"?_="+Date.now())}n.innerHTML=e.innerHTML.replace(".config({",'.config({urlArgs: "_=" + Date.now(),')}a&&(n[t]=a)}),document.getElementsByTagName("head")[0].appendChild(n),n}function d(e,t){if(!Array.isArray(e))return!1;if(0===e.length)return!1;var n=[].slice.call(e||[]),r=n.pop();return r=s(r,t),r.onload?d(n,t):void(r.onload=function(){d(n,t)})}function c(){var e=[].slice.call(document.getElementsByTagName("script")||[]),t="(http|https)://(.)*/spa/widgets/loader/([0-9]+).([0-9]+).([0-9]+)/index.js",n=e.reverse().filter(function(e){return e.src&&e.src.match(t)});if(n&&n.length){var r=n[0].src.split("/");return r[r.length-1]="loading.gif",r.join("/")}return console.error("Widget loader script does not exist"),!1}function u(e,t){var n=i(e,t);return g[n]}function l(e,t){var n=i(e,t);return delete g[n]}function p(){var e="[data-sparta-event-dispatcher]",t=document.querySelector(e);if(!t){var n=document.createElement("div");return n.setAttribute("data-sparta-event-dispatcher",!0),h=c(),n}return t}function f(){if(document.currentScript)return document.currentScript;var e=document.getElementsByTagName("script");return e[e.length-1]}var v=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},n=new CustomEvent(e,{detail:t});this.dispatcherElement.dispatchEvent(n)}},{key:"sub",value:function(e,t){this.dispatcherElement.addEventListener(e,t)}},{key:"unsub",value:function(e,t){this.dispatcherElement.removeEventListener(e,t)}},{key:"once",value:function(e,t){var n=this,r=function r(a){n.dispatcherElement.removeEventListener(e,r),t(a)};this.dispatcherElement.addEventListener(e,r)}},{key:"canRefreshWidget",value:function(e,t,n){var r=[].slice.call(document.querySelectorAll('[data-sparta-container="'+e+'"][data-version="'+t+'"]')||[]);return n&&r.length>0}},{key:"load",value:function(e){var t=e.name,n=e.version,a=e.container,i=e.path,o=e.spinner,s=e.options,d=void 0===s?{}:s,c=e.language,p=void 0===c?"en":c,f=e.enableWidgetRefresh,v=void 0===f||f,h=e.enableWidgetCache,g=void 0!==h&&h;if(g||l(t,n),!t||!n||!a)return console.error("invalid config object passed to widget loader"),!1;var w=[],y=[];return"[object Array]"===Object.prototype.toString.call(a)?(window.sparta.widgetLoader[t]=r({},n,{}),w=a):w.push(a),w.forEach(function(e){var t=document.getElementById(e);return t?(y.push(t),!0):(console.error("widget container destination does not exist"),!1)}),this.canRefreshWidget(t,n,v)?this.pub(m.REFRESH_WIDGET,{name:t,version:n,container:y}):(u(t,n)||this.generateStyleSheet(y,o),this.widgetXHR(y,i,t,n,d,p)),!0}},{key:"generateStyleSheet",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e.forEach(function(e){var n=document.createElement("style"),r="\n #"+e.id+" > [data-sparta-container].sparta-widget-loading,\n #"+e.id+" > [data-sparta-container].sparta-widget-loading > .sparta-widget {\n visibility: hidden;\n height: 100%;\n width: 100%;\n }\n ";t&&(r+="\n #"+e.id+".sparta-widget-loading {\n height: 100%;\n background-image: url('"+h+"');\n background-repeat: no-repeat;\n background-position: center center;\n }\n "),n.type="text/css",n.id=e.id+"-sparta-widget-style-sheet",n.stylesSheet?n.styleSheet.cssText=r:n.appendChild(document.createTextNode(r)),document.head.appendChild(n),e.classList.add("sparta-widget-loading")})}},{key:"widgetXHR",value:function(e,t,n,r,a,c){function l(t,i){e.forEach(function(e){e.innerHTML=t});var o=e[e.length-1];o.style.height="auto",o.style.backgroundImage="";var c=[].slice.call(o.querySelectorAll("script")||[]),u=function(e){return e.forEach(function(e){return e.parentNode.removeChild(e)})};if(o.querySelector("[data-sparta-widget]").setAttribute("data-sparta-options",JSON.stringify(a)),i){var l=[],p=[].slice.call(o.querySelectorAll('[data-component="module"]')||[]);p.forEach(function(e){if(e.dataset.module.indexOf("module")!==-1){var t=e.dataset;l.push(window.sparta.require[n][r].require("modules/"+t.moduleRef+"/"+t.version+"/js/"+t.module))}});var f=window.sparta.require[n][r].require("global/sparta-bootstrap-utility"),v=window.sparta.require[n][r].require("modules/"+n+"/"+r+"/js/"+n);l.push(v),f.default.init(l,{name:n,version:r})}else window.navigator.userAgent.match(/(MSIE|Trident)/)?d(c.reverse(),a):c.forEach(s),u(c)}var p=u(n,r);if(p)return void l(p,!0);var f=new XMLHttpRequest;w||o()||(f.withCredentials=!0);var v=c&&"en"!==c.toLowerCase()?c.toLowerCase()+"/":"",h=t+"/spa/widgets/"+n+"/"+r+"/"+v+"index.html?_="+Date.now(),y=this;f.open("GET",h),f.onreadystatechange=function(){var a=this;if(4===this.readyState)if(200!==this.status)console.error("unable to load widget:",h,this.status),e.forEach(function(e){e.innerHTML="unable to load widget",y.pub(m.ERROR_LOADING_WIDGET,{widget:{name:n,version:r,path:t,container:e},xhrReq:a})});else{var o=i(n,r);g[o]=this.responseText,l(this.responseText,!1)}},f.send()}}]),e}(),E=new y,b=E.getNamespace();window.sparta=window.sparta||{},window.sparta[b]=window.sparta[b]||{},!b||window.sparta&&window.sparta[b].widgetLoader||(window.sparta[b].widgetLoader=E,document.dispatchEvent(new CustomEvent(b+".spartaLoaderLoaded")))},function(e,t){try{var n=new window.CustomEvent("test");if(n.preventDefault(),n.defaultPrevented!==!0)throw new Error("Could not prevent default")}catch(e){var r=function(e,t){var n,r;return t=t||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent"),n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),r=n.preventDefault,n.preventDefault=function(){r.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(e){this.defaultPrevented=!0}},n};r.prototype=window.Event.prototype,window.CustomEvent=r}}]); //# sourceMappingURL=index.js.map