var __awaiter=this&&this.__awaiter||function(t,e,n,s){return new(n||(n=Promise))(function(i,o){function a(t){try{c(s.next(t))}catch(t){o(t)}}function r(t){try{c(s.throw(t))}catch(t){o(t)}}function c(t){t.done?i(t.value):new n(function(e){e(t.value)}).then(a,r)}c((s=s.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var n,s,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function r(o){return function(r){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,s&&(i=2&o[0]?s.return:o[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,o[1])).done)return i;switch(s=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,s=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],s=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,r])}}};Ema.loadBundle("chunk-9b6fe1d5.js",["exports","./chunk-0652d382.js","./chunk-bcc9d06a.js"],function(t,e,n){window;var s=Symbol(),i=Symbol(),o=function(){function t(t){if(this.state={},this.baseUrl="",this.loading=!0,this.authenticated=!1,this.errorMessage="",t!==i)throw new Error("Cannot construct singleton");this.base=n.BaseService.instance,this.permissions=n.PermissionsService.instance,this.translation=this.base.translation,this.config=this.base.config,this.user=new n.User("visitor")}return t.prototype.init=function(){return __awaiter(this,void 0,void 0,function(){var t,s,i,o,a=this;return __generator(this,function(r){switch(r.label){case 0:return[4,this.base.initApp(this.baseUrl+"/assets/config.json",!0,"_emaApp")];case 1:return r.sent(),[4,this.permissions.loadRules(this.baseUrl+"/assets/permissions.json",!0,"rules")];case 2:return r.sent(),this.base.translation.use(this.config.get("language")),this.data={},t=this.data,[4,n.Util.fetchJson(this.baseUrl+"/assets/collection-manifest.json")];case 3:return t.manifest=r.sent(),s=this.data,[4,n.Util.fetchJson(this.baseUrl+"/assets/data/mock-data.json")];case 4:return s.mockData=r.sent(),i=this.data,[4,n.Util.fetchJson(this.baseUrl+"/assets/data/mock-dwp.json")];case 5:return i.dwpData=r.sent(),o=this.data,[4,n.Util.fetchJson(this.baseUrl+"/assets/data/apiSwagger.json")];case 6:return o.swaggerData=r.sent(),this.collectionManifest=this.data.manifest,this.parseComponents(),this.initHistory(),this.initSketchListeners(),window.document.location.hostname.match("localhost")&&(this.config.set("dev",!0),n.DomUtil.addClass(document.getElementsByTagName("body")[0],"dev")),this.state.initialized=!0,e.timer(200).subscribe(function(){a.initLoginForm()}),[2]}})})},t.prototype.initLoginForm=function(){this.loginForm=document.getElementById("app-login-form"),e.fromEvent(this.loginForm,"formSubmit").subscribe(function(t){console.log("app-login-form",t.detail)})},t.prototype.initSketchListeners=function(){var t=this;e.fromEvent(document,"sketch-artboard-init").subscribe(function(t){console.log("sketch init: ",t.detail.selector)}),e.fromEvent(document,"sketch-artboard-update").subscribe(function(t){console.log("sketch update: ",t.detail.selector)}),e.fromEvent(document,"svgElementClick").subscribe(function(e){var n=e.detail.id;n.match("btn-logo")&&t.showFlashMessage("Called from sketch: id="+n,"primary",2e3),n.match("icon-sketch"),console.log("svg: id = ",e.detail.id)})},t.prototype.initHistory=function(){"undefined"!=typeof window&&window},t.prototype.parseComponents=function(){var t=this,e=n.Util.copy(this.data.manifest.components),s=[];e.map(function(e){var n=e.tag,i=!1;t.config.get("componentsIgnorePatterns").forEach(function(t){n.match(t)&&(i=!0)}),i||s.push(e)}),this.components=s},t.prototype.showFlashMessage=function(t,e,n){void 0===n&&(n=2e3),document.querySelector("ema-flash-message").show(t,e,n)},Object.defineProperty(t,"instance",{get:function(){return this[s]||(this[s]=new t(i)),this[s]},enumerable:!0,configurable:!0}),t}();t.AppService=o});