!function(){"use strict";function t(i){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(i)}function i(t,i){for(var s=0;s<i.length;s++){var n=i[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,e(n.key),n)}}function e(i){var e=function(i){if("object"!=t(i)||!i)return i;var e=i[Symbol.toPrimitive];if(void 0!==e){var s=e.call(i,"string");if("object"!=t(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}(i);return"symbol"==t(e)?e:e+""}var s=function(){function t(i){if(function(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this,t),"core:logout-iframe"===i)this.populateData(),0===Object.keys(this.sps).length&&this.btncontinue.click(),this.btnall.addEventListener("click",this.initLogout.bind(this)),window.addEventListener("message",this.clearAssociation.bind(this),!1);else if("IFrameLogoutHandler"===i){var e=document.querySelector('i[id="data"]'),s={spId:e.getAttribute("data-spid")};e.hasAttribute("data-error")&&(s.error=e.getAttribute("data-error")),window.parent.postMessage(JSON.stringify(s),t.getOrigin())}}return e=t,n=[{key:"getOrigin",value:function(){var t=window.location.origin;return t||(t=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"")),t}}],(s=[{key:"clearAssociation",value:function(i){if(i.origin===t.getOrigin()){var e=JSON.parse(i.data);void 0===e.error?this.completed(e.spId):this.failed(e.spId,e.error),0===Object.keys(this.sps).length&&0===this.nfailed&&this.btncontinue.click()}}},{key:"completed",value:function(t){void 0!==this.sps[t]&&(this.sps[t].icon.classList.remove("fa-spin"),this.sps[t].icon.classList.remove("fa-circle-o-notch"),this.sps[t].icon.classList.add("fa-check-circle"),this.sps[t].element.style.display="none",delete this.sps[t],this.finish())}},{key:"failed",value:function(t,i){void 0!==this.sps[t]&&(this.sps[t].element.classList.add("error"),this.sps[t].icon.classList.remove("fa-spin","fa-circle-o-notch"),this.sps[t].icon.classList.add("fa-exclamation-circle"),this.errmsg.classList.remove("hidden"),this.errfrm.classList.remove("hidden"),delete this.sps[t],this.nfailed++,this.finish())}},{key:"finish",value:function(){Object.keys(this.sps).length>0||(void 0!==this.timeout&&clearTimeout(this.timeout),this.nfailed>0?(this.errmsg.classList.remove("hidden"),this.errfrm.classList.remove("hidden"),this.actions.classList.add("hidden")):this.btncontinue.click())}},{key:"initLogout",value:function(t){t.preventDefault(),this.btnall.disabled=!0,this.btncancel.disabled=!0,Object.keys(this.sps).forEach(function(t){this.sps[t].status="inprogress",this.sps[t].startTime=(new Date).getTime(),this.sps[t].iframe.setAttribute("src",this.sps[t].iframe.getAttribute("data-url")),this.sps[t].icon.classList.add("fa-spin")}.bind(this)),this.initTimeout()}},{key:"initTimeout",value:function(){var t=10;for(var i in this.sps)if(void 0!==i&&this.sps.hasOwnProperty(i)&&"inprogress"===this.sps[i].status){var e=((new Date).getTime()-this.sps[i].startTime)/1e3;this.sps[i].timeout<=e?this.failed(i,"Timed out",window.document):this.sps[i].timeout-e<t&&(t=this.sps[i].timeout-e)}Object.keys(this.sps).length>0?this.timeout=setTimeout(this.initTimeout.bind(this),1e3*t):this.finish()}},{key:"populateData",value:function(){this.sps={},this.btnall=document.querySelector('button[id="btn-all"]'),this.btncancel=document.querySelector('button[id="btn-cancel"]'),this.btncontinue=document.querySelector('button[id="btn-continue"]'),this.actions=document.querySelector('div[id="original-actions"]'),this.errmsg=document.querySelector('div[id="error-message"]'),this.errfrm=document.querySelector('form[id="error-form"]'),this.nfailed=0;var t=this;document.querySelectorAll('li[id^="sp-"]').forEach(function(i,e,s){var n=i.getAttribute("data-id"),o=document.querySelector('iframe[id="iframe-'+n+'"]'),r=i.getAttribute("data-status");switch(r){case"failed":t.nfailed++;case"completed":return}t.sps[n]={status:r,timeout:i.getAttribute("data-timeout"),element:i,iframe:o,icon:document.querySelector('i[id="icon-'+n+'"]')}})}}])&&i(e.prototype,s),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,s,n}();ready(function(){new s(document.body.id)})}();
//# sourceMappingURL=logout.js.map