post-robot
Advanced tools
Comparing version 4.0.6 to 4.0.7
{ | ||
"name": "post-robot", | ||
"main": "index.js", | ||
"version": "4.0.6", | ||
"version": "4.0.7", | ||
"authors": [ | ||
@@ -6,0 +6,0 @@ "Daniel Brain <dbrain@paypal.com>" |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("postRobot",[],r):"object"==typeof exports?exports.postRobot=r():e.postRobot=r()}(this,function(){return function(e){function r(t){if(n[t])return n[t].exports;var o=n[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var n={};return r.m=e,r.c=n,r.p="",r(0)}([function(e,r,n){"use strict";function t(){u.global.initialized||(i.util.listen(window,"message",a.messageListener),(0,s.openTunnelToOpener)(),(0,i.initOnReady)(),(0,i.listenForMethods)()),u.global.initialized=!0}Object.defineProperty(r,"__esModule",{value:!0}),r.Promise=void 0;var o=n(1);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(8);Object.defineProperty(r,"Promise",{enumerable:!0,get:function(){return i.Promise}});var a=n(6),u=n(15),s=n(23);t(),r["default"]=e.exports},function(e,r,n){"use strict";function t(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r["default"]=e,r}Object.defineProperty(r,"__esModule",{value:!0}),r.winutil=r.util=r.linkUrl=r.bridgeRequired=r.openBridge=r.reset=r.parent=void 0;var o=n(2);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(25);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})});var a=n(26);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})});var u=n(6);Object.defineProperty(r,"reset",{enumerable:!0,get:function(){return u.resetListeners}});var s=n(23);Object.defineProperty(r,"openBridge",{enumerable:!0,get:function(){return s.openBridge}}),Object.defineProperty(r,"bridgeRequired",{enumerable:!0,get:function(){return s.bridgeRequired}}),Object.defineProperty(r,"linkUrl",{enumerable:!0,get:function(){return s.linkUrl}});var c=n(12);Object.defineProperty(r,"util",{enumerable:!0,get:function(){return c.util}});var d=n(14),f=t(d);r.parent=(0,d.getAncestor)(),r.winutil=f},function(e,r,n){"use strict";function t(e){return c.promise.nodeify(new c.promise.Promise(function(r,n){if(!e.name)throw new Error("Expected options.name");if(!e.window)throw new Error("Expected options.window");if(u.CONFIG.MOCK_MODE)e.window=window;else if("string"==typeof e.window){var t=document.getElementById(e.window);if(!t)throw new Error("Expected options.window "+e.window+" to be a valid element id");if("iframe"!==t.tagName.toLowerCase())throw new Error("Expected options.window "+e.window+" to be an iframe");if(e.window=t.contentWindow,!e.window)throw new Error("Expected options.window")}e.domain=e.domain||"*";var o=e.name+"_"+c.util.uniqueID();if(s.listeners.response[o]=e,(0,c.isWindowClosed)(e.window))throw new Error("Target window is closed");var i=!1;return e.respond=function(e,t){return e||(i=!0),e?n(e):r(t)},c.promise.run(function(){return(0,c.isAncestor)(window,e.window)?(0,c.onWindowReady)(e.window):void 0}).then(function(){if((0,s.sendMessage)(e.window,{hash:o,type:u.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,name:e.name,data:e.data,fireAndForget:e.fireAndForget},e.domain)["catch"](n),e.fireAndForget)return r();var t=c.util.intervalTimeout(u.CONFIG.ACK_TIMEOUT,100,function(r){return e.ack||(0,c.isWindowClosed)(e.window)?t.cancel():r?void 0:n(new Error("No ack for postMessage "+e.name+" in "+u.CONFIG.ACK_TIMEOUT+"ms"))});e.timeout&&!function(){var r=c.util.intervalTimeout(e.timeout,100,function(t){return i||(0,c.isWindowClosed)(e.window)?r.cancel():t?void 0:n(new Error("Post message response timed out after "+e.timeout+" ms"))},e.timeout)}()})["catch"](n)}),e.callback)}function o(e,r,n,o,i){return i||(o||"function"!=typeof n?"function"==typeof o&&(i=o,o={}):(i=n,o={},n={})),o=o||{},o.window=e,o.name=r,o.data=n,o.callback=i,t(o)}function i(e,r,n,t){var i=(0,c.getAncestor)();return i?o(i,e,r,n,t):new c.promise.Promise(function(e,r){return r(new Error("Window does not have a parent"))})}function a(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];if(!e.window)throw new Error("Expected options.window");return{send:function(r,n,t){return o(e.window,r,n,e,t)}}}Object.defineProperty(r,"__esModule",{value:!0}),r.send=void 0,r.request=t,r.sendToParent=i,r.client=a;var u=n(3),s=n(6),c=n(8);r.send=o},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(4);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})});var o=n(5);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}Object.defineProperty(r,"__esModule",{value:!0}),r.CONFIG=void 0;var o,i=n(5),a=r.CONFIG={ALLOW_POSTMESSAGE_POPUP:!0,LOG_LEVEL:"info",BRIDGE_TIMEOUT:5e3,ACK_TIMEOUT:1e3,LOG_TO_PAGE:!1,MOCK_MODE:!1,ALLOWED_POST_MESSAGE_METHODS:(o={},t(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,!0),t(o,i.CONSTANTS.SEND_STRATEGIES.BRIDGE,!0),o)};0===window.location.href.indexOf(i.CONSTANTS.FILE_PROTOCOL)&&(a.ALLOW_POSTMESSAGE_POPUP=!0)},function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=r.CONSTANTS={POST_MESSAGE_TYPE:{REQUEST:"postrobot_message_request",RESPONSE:"postrobot_message_response",ACK:"postrobot_message_ack"},POST_MESSAGE_ACK:{SUCCESS:"success",ERROR:"error"},POST_MESSAGE_NAMES:{METHOD:"postrobot_method",READY:"postrobot_ready",OPEN_TUNNEL:"postrobot_open_tunnel"},WINDOW_TYPES:{FULLPAGE:"fullpage",POPUP:"popup",IFRAME:"iframe"},WINDOW_PROPS:{POSTROBOT:"__postRobot__"},SERIALIZATION_TYPES:{METHOD:"postrobot_method"},SEND_STRATEGIES:{POST_MESSAGE:"postrobot_post_message",BRIDGE:"postrobot_bridge"},MOCK_PROTOCOL:"mock://",FILE_PROTOCOL:"file://",BRIDGE_NAME_PREFIX:"__postrobot_bridge__",POSTROBOT_PROXY:"__postrobot_proxy__"};r.POST_MESSAGE_NAMES_LIST=Object.keys(n.POST_MESSAGE_NAMES).map(function(e){return n.POST_MESSAGE_NAMES[e]})},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(7);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})});var o=n(21);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(24);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,r,n){"use strict";function t(e){try{e=JSON.parse(e)}catch(r){return}if(e.type&&d.RECEIVE_MESSAGE_TYPES[e.type])return e}function o(e){if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!e.source)return}catch(r){return}var n=e.source,o=e.origin,i=e.data,s=t(i);if(s&&(0!==s.sourceDomain.indexOf(a.CONSTANTS.MOCK_PROTOCOL)&&0!==s.sourceDomain.indexOf(a.CONSTANTS.FILE_PROTOCOL)||(o=s.sourceDomain),-1===c.global.receivedMessages.indexOf(s.id))){c.global.receivedMessages.push(s.id);var f=void 0;if(f=-1!==a.POST_MESSAGE_NAMES_LIST.indexOf(s.name)||s.type===a.CONSTANTS.POST_MESSAGE_TYPE.ACK?"debug":"error"===s.ack?"error":"info",u.log.logLevel(f,["\n\n ","#receive",s.type.replace(/^postrobot_message_/,""),"::",s.name,"::",o,"\n\n",s]),(0,u.isWindowClosed)(n))return u.log.debug("Source window is closed - can not send "+s.type+" "+s.name);s.data&&(s.data=(0,u.deserializeMethods)(n,o,s.data)),d.RECEIVE_MESSAGE_TYPES[s.type](n,o,s)}}function i(e){try{e.source}catch(r){return}e={source:e.source||e.sourceElement,origin:e.origin||e.originalEvent.origin,data:e.data};try{(0,s.emulateIERestrictions)(e.source,window)}catch(r){return}o(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.receiveMessage=o,r.messageListener=i;var a=n(3),u=n(8),s=n(18),c=n(15),d=n(20);c.global.receivedMessages=c.global.receivedMessages||[]},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(9);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})});var o=n(12);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(13);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})});var a=n(14);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})});var u=n(16);Object.keys(u).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return u[e]}})});var s=n(11);Object.keys(s).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return s[e]}})});var c=n(17);Object.keys(c).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return c[e]}})})},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.promise=r.Promise=void 0;var t=n(10),o=n(11),i=r.Promise=t.SyncPromise,a=r.promise={Promise:i,run:function(e){return i.resolve().then(e)},nextTick:function(e){return new i(function(r,n){(0,o.nextTick)(function(){return a.run(e).then(r,n)})})},method:function(e){return function(){var r=this,n=arguments;return i.resolve().then(function(){return e.apply(r,n)})}},nodeify:function(e,r){return r?void e.then(function(e){r(null,e)},function(e){r(e)}):e},deNodeify:function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),t=1;r>t;t++)n[t-1]=arguments[t];return new i(function(r,t){try{return n.length<e.length?e.apply(void 0,n.concat([function(e,n){return e?t(e):r(n)}])):a.run(function(){return e.apply(void 0,n)}).then(r,t)}catch(o){return t(o)}})},map:function(e,r){for(var n=[],t=function(t){n.push(a.run(function(){return r(e[t])}))},o=0;o<e.length;o++)t(o);return i.all(n)}}},function(e,r){"use strict";function n(e,r,n){function t(){if(a){if(s)return n(o);if(u)return r(i)}}var o,i,a=!1,u=!1,s=!1;try{e(function(e){i=e,u=!0,t()},function(e){o=e,s=!0,t()})}catch(c){return n(c)}a=!0,t()}function t(e){d.push(e),s=s||setTimeout(o,1)}function o(){s=null;var e=d;d=[];for(var r=0;r<e.length;r++){var n=e[r];n.hasHandlers||(n.handlers.push({onError:function(e){if(!n.hasHandlers){i(e);for(var r=0;r<c.length;r++)c[r](n.value)}}}),n.dispatch())}}function i(e){setTimeout(function(){throw e},1)}function a(e){try{if(!e)return!1;if(window.Window&&e instanceof window.Window)return!1;if(window.constructor&&e instanceof window.constructor)return!1;if(f){var r=f.call(e);if("[object Window]"===r||"[object global]"===r||"[object DOMWindow]"===r)return!1}if(e&&e.then instanceof Function)return!0}catch(n){return!1}return!1}function u(){window.Promise=l}Object.defineProperty(r,"__esModule",{value:!0}),r.patchPromise=u;var s,c=[],d=[],f={}.toString,l=r.SyncPromise=function(e,r){if(this.parent=r,this.resolved=!1,this.rejected=!1,this.hasHandlers=!1,this.handlers=[],t(this),e){var o=this;n(e,function(e){return o.resolve(e)},function(e){return o.reject(e)})}};l.resolve=function(e){return a(e)?e:(new l).resolve(e)},l.reject=function(e){return(new l).reject(e)},l.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(a(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},l.prototype.reject=function(e){if(this.resolved||this.rejected)return this;if(a(e))throw new Error("Can not reject promise with another promise");return this.rejected=!0,this.value=e,this.dispatch(),this},l.prototype.dispatch=function(){var e=this;if(this.resolved||this.rejected)for(var r=function(){var r=e.handlers.shift();try{e.resolved?n=r.onSuccess?r.onSuccess(e.value):e.value:r.onError?n=r.onError(e.value):t=e.value}catch(o){t=o}if(n===e)throw new Error("Can not return a promise from the the then handler of the same promise");return r.promise?void(t?r.promise.reject(t):a(n)?n.then(function(e){r.promise.resolve(e)},function(e){r.promise.reject(e)}):r.promise.resolve(n)):"continue"};this.handlers.length;){var n,t;r()}},l.prototype.then=function(e,r){var n=new l(null,this);return this.handlers.push({promise:n,onSuccess:e,onError:r}),this.hasHandlers=!0,this.dispatch(),n},l.prototype["catch"]=function(e){return this.then(null,e)},l.prototype["finally"]=function(e){return this.then(function(r){return e(),r},function(r){throw e(),r})},l.all=function(e){for(var r=new l,n=e.length,t=[],o=0;o<e.length;o++){var i=a(e[o])?e[o]:l.resolve(e[o]);i.then(function(e){t[o]=e,n-=1,0===n&&r.resolve(t)},function(e){r.reject(e)})}return r},l.onPossiblyUnhandledException=function(e){c.push(e)}},function(e,r,n){"use strict";function t(e){a.push(e),window.postMessage(i,"*")}Object.defineProperty(r,"__esModule",{value:!0}),r.nextTick=t;var o=n(12),i="__nextTick__postRobot__"+o.util.uniqueID(),a=[];window.addEventListener("message",function(e){if(e.data===i){var r=a.shift();r.call()}})},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.util=void 0;var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=n(3),i=r.util={once:function(e){if(!e)return e;var r=!1;return function(){return r?void 0:(r=!0,e.apply(this,arguments))}},noop:function(){},safeHasProp:function(e,r){try{return!!e[r]}catch(n){return!1}},safeGetProp:function(e,r){try{return e[r]}catch(n){return}},listen:function(e,r,n){return e.addEventListener?e.addEventListener(r,n):e.attachEvent("on"+r,n),{cancel:function(){e.removeEventListener?e.removeEventListener(r,n):e.detachEvent("on"+r,n)}}},apply:function(e,r,n){return"function"==typeof e.apply?e.apply(r,n):e(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9])},find:function(e,r,n){if(!e)return n;for(var t=0;t<e.length;t++)if(r(e[t]))return e[t];return n},map:function(e,r){for(var n=[],t=0;t<e.length;t++)n.push(r(e[t]));return n},some:function(e,r){r=r||Boolean;for(var n=0;n<e.length;n++)if(r(e[n]))return!0;return!1},keys:function(e){var r=[];for(var n in e)e.hasOwnProperty(n)&&r.push(n);return r},values:function(e){var r=[];for(var n in e)e.hasOwnProperty(n)&&r.push(e[n]);return r},getByValue:function(e,r){for(var n in e)if(e.hasOwnProperty(n)&&e[n]===r)return n},uniqueID:function(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})},memoize:function(e){var r={};return function(){var n=JSON.stringify(Array.prototype.slice.call(arguments));return r.hasOwnProperty(n)||(r[n]=e.apply(this,arguments)),r[n]}},extend:function(e,r){if(!r)return e;for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n]);return e},each:function(e,r){if(Array.isArray(e))for(var n=0;n<e.length;n++)r(e[n],n);else if("object"===("undefined"==typeof e?"undefined":t(e))&&null!==e)for(var o in e)e.hasOwnProperty(o)&&r(e[o],o)},replaceObject:function(e,r){var n=arguments.length<=2||void 0===arguments[2]?1:arguments[2];if(n>=100)throw new Error("Self-referential object passed, or object contained too many layers");var o=Array.isArray(e)?[]:{};return i.each(e,function(e,a){var u=r(e,a);void 0!==u?o[a]=u:"object"===("undefined"==typeof e?"undefined":t(e))&&null!==e?o[a]=i.replaceObject(e,r,n+1):o[a]=e}),o},safeInterval:function(e,r){function n(){t=setTimeout(n,r),e.call()}var t=void 0;return t=setTimeout(n,r),{cancel:function(){clearTimeout(t)}}},intervalTimeout:function(e,r,n){var t=i.safeInterval(function(){e-=r,e=0>=e?0:e,0===e&&t.cancel(),n(e)},r);return t},getDomain:function(e){return e=e||window,e.mockDomain&&0===e.mockDomain.indexOf(o.CONSTANTS.MOCK_PROTOCOL)?e.mockDomain:e.location.protocol+"//"+e.location.host},getDomainFromUrl:function(e){var r=void 0;return e.match(/^(https?|mock|file):\/\//)?(r=e,r=r.split("/").slice(0,3).join("/")):this.getDomain()},safeGet:function(e,r){var n=void 0;try{n=e[r]}catch(t){}return n}}},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.log=void 0;var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=n(12),i=n(14),a=n(3),u=["debug","info","warn","error"];Function.prototype.bind&&window.console&&"object"===t(console.log)&&["log","info","warn","error"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call);var s=r.log={clearLogs:function(){if(window.console&&window.console.clear&&window.console.clear(),a.CONFIG.LOG_TO_PAGE){var e=document.getElementById("postRobotLogs");e&&e.parentNode.removeChild(e)}},writeToPage:function(e,r){setTimeout(function(){var n=document.getElementById("postRobotLogs");n||(n=document.createElement("div"),n.id="postRobotLogs",n.style.cssText="width: 800px; font-family: monospace; white-space: pre-wrap;",document.body.appendChild(n));var t=document.createElement("div"),i=(new Date).toString().split(" ")[4],a=o.util.map(r,function(e){if("string"==typeof e)return e;if(!e)return Object.prototype.toString.call(e);var r=void 0;try{r=JSON.stringify(e,0,2)}catch(n){r="[object]"}return"\n\n"+r+"\n\n"}).join(" "),u=i+" "+e+" "+a;t.innerHTML=u;var s={log:"#ddd",warn:"orange",error:"red",info:"blue",debug:"#aaa"}[e];t.style.cssText="margin-top: 10px; color: "+s+";",n.childNodes.length?n.insertBefore(t,n.childNodes[0]):n.appendChild(t)})},logLevel:function(e,r){try{if(u.indexOf(e)<u.indexOf(a.CONFIG.LOG_LEVEL))return;if(r=Array.prototype.slice.call(r),r.unshift(""+window.location.host+window.location.pathname),r.unshift("::"),r.unshift(""+(0,i.getWindowType)().toLowerCase()),r.unshift("[post-robot]"),a.CONFIG.LOG_TO_PAGE&&s.writeToPage(e,r),!window.console)return;if(window.console[e]||(e="log"),!window.console[e])return;window.console[e].apply(window.console,r)}catch(n){}},debug:function(){s.logLevel("debug",arguments)},info:function(){s.logLevel("info",arguments)},warn:function(){s.logLevel("warn",arguments)},error:function(){s.logLevel("error",arguments)}}},function(e,r,n){"use strict";function t(e){for(var r=P.global.domainMatches,n=Array.isArray(r),t=0,r=n?r:r[Symbol.iterator]();;){var o;if(n){if(t>=r.length)break;o=r[t++]}else{if(t=r.next(),t.done)break;o=t.value}var i=o;if(i.win===e)return i.match}var a=!1;try{T.util.getDomain(window)===T.util.getDomain(e)&&(a=!0)}catch(u){}return P.global.domainMatches.push({win:e,match:a}),N||(N=setTimeout(function(){P.global.domainMatches=[],N=null},1)),a}function o(e){if(!e)return!1;try{for(var r=["setTimeout","setInterval","postMessage","alert"],n=0;n<r.length;n++){var t=r[n];if("function"!=typeof e[t])return!1}return!(!e.document||!e.location)}catch(o){}try{for(var i=0;5>i;i++)e&&(e=e[Math.random().toString()]);return!1}catch(o){return!0}}function i(e){try{return!!(!e||e.closed||t(e)&&T.util.safeGet(e,"mockclosed"))}catch(r){}return!0}function a(e){if(e)try{return e.opener}catch(r){return}}function u(e){if(e)try{if(e.parent&&e.parent!==e)return e.parent}catch(r){return}}function s(e){var r=[];try{for(;e.parent!==e;)r.push(e.parent),e=e.parent}catch(n){}return r}function c(e,r){if(!e||!r)return!1;var n=u(r);return n?n===e:-1!==s(r).indexOf(e)}function d(e){var r=[],n=void 0;try{n=e.frames}catch(t){n=e}var o=void 0;try{o=n.length}catch(t){}if(0===o)return r;if(o)for(var i=0;o>i;i++){var a=void 0;try{a=n[i]}catch(t){continue}r.push(a)}else for(var u=0;;){var s=void 0;try{s=n[u]}catch(t){return r}if(!s)return r;if(r.push(s),u+=1,u>20)return r}return r}function f(e){for(var r=[],n=d(e),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;r.push(a);for(var u=f(a),s=Array.isArray(u),c=0,u=s?u:u[Symbol.iterator]();;){var l;if(s){if(c>=u.length)break;l=u[c++]}else{if(c=u.next(),c.done)break;l=c.value}var w=l;r.push(w)}}return r}function l(e){var r=f(e);r.push(e);for(var n=s(e),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;r.push(a);for(var u=d(a),c=Array.isArray(u),l=0,u=c?u:u[Symbol.iterator]();;){var w;if(c){if(l>=u.length)break;w=u[l++]}else{if(l=u.next(),l.done)break;w=l.value}var p=w;-1===r.indexOf(p)&&r.push(p)}}return r}function w(e){if(e){try{if(e.top)return e.top}catch(r){}if(u(e)===e)return e;try{if(c(window,e))return window.top}catch(r){}try{if(c(e,window))return window.top}catch(r){}for(var n=f(e),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;try{if(a.top)return a.top}catch(r){}if(u(a)===a)return a}}}function p(e,r){for(var n=d(e),t=Array.isArray(n),i=0,n=t?n:n[Symbol.iterator]();;){var a;if(t){if(i>=n.length)break;a=n[i++]}else{if(i=n.next(),i.done)break;a=i.value}var u=a;try{if(u.name===r&&o(u))return u}catch(s){}}try{if(o(e.frames[r]))return e.frames[r]}catch(s){}try{if(o(e[r]))return e[r]}catch(s){}}function m(e,r){var n=u(r);if(n)return n===e;for(var t=d(e),o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var s=a;if(s===r)return!0}return!1}function v(e,r){return e===a(r)}function h(e){e=e||window;var r=a(e);if(r)return r;var n=u(e);return n?n:void 0}function g(e,r){var n=h(r);if(n)return n===e;if(r===e)return!1;if(w(r)===r)return!1;for(var t=d(e),o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var u=a;if(u===r)return!0}return!1}function S(){return Boolean(a(window))}function b(){return Boolean(u(window))}function O(){return Boolean(!b()&&!S())}function E(){return S()?A.CONSTANTS.WINDOW_TYPES.POPUP:b()?A.CONSTANTS.WINDOW_TYPES.IFRAME:A.CONSTANTS.WINDOW_TYPES.FULLPAGE}function y(e,r){for(var n=e,t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}for(var a=i,u=r,s=Array.isArray(u),c=0,u=s?u:u[Symbol.iterator]();;){var d;if(s){if(c>=u.length)break;d=u[c++]}else{if(c=u.next(),c.done)break;d=c.value}var f=d;if(a===f)return!0}}}function _(e,r){var n=w(e),t=w(r);try{if(n&&t)return n===t}catch(o){}var i=l(e),u=l(r);if(y(i,u))return!0;var s=a(n),c=a(t);return s&&y(l(s),u)?!1:c&&y(l(c),i)?!1:void 0}Object.defineProperty(r,"__esModule",{value:!0}),r.isSameDomain=t,r.isWindow=o,r.isWindowClosed=i,r.getOpener=a,r.getParent=u,r.getParents=s,r.isAncestorParent=c,r.getFrames=d,r.getAllChildFrames=f,r.getAllFramesInWindow=l,r.getTop=w,r.getFrameByName=p,r.isParent=m,r.isOpener=v,r.getAncestor=h,r.isAncestor=g,r.isPopup=S,r.isIframe=b,r.isFullpage=O,r.getWindowType=E,r.isSameTopWindow=_;var T=n(12),P=n(15),A=n(3);P.global.domainMatches=P.global.domainMatches||[];var N=void 0},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.global=void 0;var t=n(3);r.global=window[t.CONSTANTS.WINDOW_PROPS.POSTROBOT]=window[t.CONSTANTS.WINDOW_PROPS.POSTROBOT]||{}},function(e,r,n){"use strict";function t(e){return"object"===("undefined"==typeof e?"undefined":s(e))&&null!==e&&e.__type__===c.CONSTANTS.SERIALIZATION_TYPES.METHOD&&e.__id__}function o(e,r,n,t){var o=d.util.uniqueID();return p.global.methods[o]={destination:e,domain:r,method:n},{__type__:c.CONSTANTS.SERIALIZATION_TYPES.METHOD,__id__:o,__name__:t}}function i(e,r,n){return d.util.replaceObject({obj:n},function(n,t){return"function"==typeof n?o(e,r,n,t):void 0}).obj}function a(e,r,n){function t(){var t=Array.prototype.slice.call(arguments);return l.log.debug("Call foreign method",n.__name__,t),(0,f.send)(e,c.CONSTANTS.POST_MESSAGE_NAMES.METHOD,{id:n.__id__,name:n.__name__,args:t},{domain:r}).then(function(e){var r=e.data;return l.log.debug("Got foreign method result",n.__name__,r.result),r.result})}return t.__name__=n.__name__,t}function u(e,r,n){return d.util.replaceObject({obj:n},function(n,o){return t(n)?a(e,r,n):void 0}).obj}Object.defineProperty(r,"__esModule",{value:!0}),r.listenForMethods=void 0;var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};r.serializeMethod=o,r.serializeMethods=i,r.deserializeMethod=a,r.deserializeMethods=u;var c=n(3),d=n(12),f=n(1),l=n(13),w=n(9),p=n(15);p.global.methods=p.global.methods||{};r.listenForMethods=d.util.once(function(){(0,f.on)(c.CONSTANTS.POST_MESSAGE_NAMES.METHOD,{window:"*",origin:"*"},function(e){var r=e.source,n=e.origin,t=e.data,o=p.global.methods[t.id];if(!o)throw new Error("Could not find method with id: "+t.id);if(o.destination!==r)throw new Error("Method window does not match");if(o.domain&&"*"!==o.domain&&n!==o.domain)throw new Error("Method domain "+o.domain+" does not match origin "+n);return l.log.debug("Call local method",t.name,t.args),w.promise.run(function(){return o.method.apply({source:r,origin:n,data:t},t.args)}).then(function(e){return{result:e,id:t.id,name:t.name}})})})},function(e,r,n){"use strict";function t(){(0,u.on)(i.CONSTANTS.POST_MESSAGE_NAMES.READY,{window:"*",domain:"*"},function(e){for(var r=e.source,n=(e.data,d.global.readyPromises),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;if(a.win===r)return void a.promise.resolve(r)}d.global.readyPromises.push({win:r,promise:(new c.SyncPromise).resolve(r)})});var e=(0,a.getAncestor)();e&&(0,u.send)(e,i.CONSTANTS.POST_MESSAGE_NAMES.READY,{},{domain:"*"})["catch"](function(e){s.log.debug(e.stack||e.toString())})}function o(e){for(var r=arguments.length<=1||void 0===arguments[1]?5e3:arguments[1],n=arguments.length<=2||void 0===arguments[2]?"Window":arguments[2],t=d.global.readyPromises,o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var u=a;if(u.win===e)return u.promise}var s=new c.SyncPromise;return d.global.readyPromises.push({win:e,promise:s}),setTimeout(function(){return s.reject(new Error(n+" did not load after "+r+"ms"))},r),s}Object.defineProperty(r,"__esModule",{value:!0}),r.initOnReady=t,r.onWindowReady=o;var i=n(3),a=n(14),u=n(1),s=n(13),c=n(10),d=n(15);d.global.readyPromises=d.global.readyPromises||[]},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(19);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})})},function(e,r,n){"use strict";function t(e,r){if(!o.CONFIG.ALLOW_POSTMESSAGE_POPUP){if((0,i.isSameDomain)(e)&&(0,i.isSameDomain)(r))return;if((0,i.isSameTopWindow)(e,r)===!1)throw new Error("Can not send and receive post messages between two different windows (disabled to emulate IE)")}}Object.defineProperty(r,"__esModule",{value:!0}),r.emulateIERestrictions=t;var o=n(3),i=n(8)},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function o(e,r){return"string"==typeof e?"*"===e||r===e:"[object RegExp]"===Object.prototype.toString.call(e)?r.match(e):Array.isArray(e)?-1!==e.indexOf(r):!1}Object.defineProperty(r,"__esModule",{value:!0}),r.RECEIVE_MESSAGE_TYPES=void 0;var i,a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},u=n(3),s=n(8),c=n(21),d=n(24);r.RECEIVE_MESSAGE_TYPES=(i={},t(i,u.CONSTANTS.POST_MESSAGE_TYPE.ACK,function(e,r,n){var t=d.listeners.response[n.hash];if(!t)throw new Error("No handler found for post message ack for message: "+n.name+" in "+window.location.href);if(!o(t.domain,r))throw new Error("Ack origin "+r+" does not match domain "+t.domain);t.ack=!0}),t(i,u.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,function(e,r,n){function t(t){return n.fireAndForget||(0,s.isWindowClosed)(e)?s.promise.Promise.resolve():(0,c.sendMessage)(e,a({target:n.originalSource,hash:n.hash,name:n.name},t),r)}var i=(0,d.getRequestListener)(n.name,e);return s.promise.Promise.all([t({type:u.CONSTANTS.POST_MESSAGE_TYPE.ACK}),s.promise.run(function(){if(!i)throw new Error("No postmessage request handler for "+n.name+" in "+window.location.href);if(!o(i.domain,r))throw new Error("Request origin "+r+" does not match domain "+i.domain);var t=n.data;return s.promise.deNodeify(i.handler,{source:e,origin:r,data:t})}).then(function(e){return t({type:u.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:u.CONSTANTS.POST_MESSAGE_ACK.SUCCESS,data:e})},function(e){return t({type:u.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:u.CONSTANTS.POST_MESSAGE_ACK.ERROR,error:e.stack?e.message+"\n"+e.stack:e.toString()})})])["catch"](function(e){return i&&i.handleError?i.handleError(e):void s.log.error(e.stack||e.toString())})}),t(i,u.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,function(e,r,n){var t=d.listeners.response[n.hash];if(!t)throw new Error("No response handler found for post message response "+n.name+" in "+window.location.href);if(!o(t.domain,r))throw new Error("Response origin "+r+" does not match domain "+t.domain);if(delete d.listeners.response[n.hash],n.ack===u.CONSTANTS.POST_MESSAGE_ACK.ERROR)return t.respond(new Error(n.error));if(n.ack===u.CONSTANTS.POST_MESSAGE_ACK.SUCCESS){var i=n.data||n.response;return t.respond(null,{source:e,origin:r,data:i})}}),i)},function(e,r,n){"use strict";function t(e,r){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],t=u.util.uniqueID(),o=(0,u.getWindowType)(),a=u.util.getDomain(window);return i({},r,n,{sourceDomain:a,id:r.id||t,windowType:o})}function o(e,r,n){return u.promise.run(function(){r=t(e,r,{data:(0,u.serializeMethods)(e,n,r.data),domain:n});var o=void 0;if(o=-1!==a.POST_MESSAGE_NAMES_LIST.indexOf(r.name)||r.type===a.CONSTANTS.POST_MESSAGE_TYPE.ACK?"debug":"error"===r.ack?"error":"info",u.log.logLevel(o,["\n\n ","#send",r.type.replace(/^postrobot_message_/,""),"::",r.name,"::",n||"*","\n\n",r]),a.CONFIG.MOCK_MODE)return delete r.target,window[a.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:u.util.getDomain(window),source:window,data:JSON.stringify(r)});if(e===window)throw new Error("Attemping to send message to self");if((0,u.isWindowClosed)(e))throw new Error("Window is closed");u.log.debug("Running send message strategies",r);var i=[];return u.promise.map(Object.keys(s.SEND_MESSAGE_STRATEGIES),function(t){return u.promise.run(function(){if(!a.CONFIG.ALLOWED_POST_MESSAGE_METHODS[t])throw new Error("Strategy disallowed: "+t);return s.SEND_MESSAGE_STRATEGIES[t](e,r,n)}).then(function(){return i.push(t+": success"),!0},function(e){return i.push(t+": "+e.message),!1})}).then(function(e){var n=u.util.some(e),t=r.type+" "+r.name+" "+(n?"success":"error")+":\n - "+i.join("\n - ")+"\n";if(u.log.debug(t),!n)throw new Error(t)})})}Object.defineProperty(r,"__esModule",{value:!0});var i=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e};r.buildMessage=t,r.sendMessage=o;var a=n(3),u=n(8),s=n(22)},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}Object.defineProperty(r,"__esModule",{value:!0}),r.SEND_MESSAGE_STRATEGIES=void 0;var o,i=n(3),a=n(8),u=n(18),s=n(23);r.SEND_MESSAGE_STRATEGIES=(o={},t(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,function(e,r,n){return(0,u.emulateIERestrictions)(window,e),n&&0===n.indexOf(i.CONSTANTS.MOCK_PROTOCOL)&&(n=e.location.protocol+"//"+e.location.host),n&&0===n.indexOf(i.CONSTANTS.FILE_PROTOCOL)&&(n="*"),e.postMessage(JSON.stringify(r,0,2),n)}),t(o,i.CONSTANTS.SEND_STRATEGIES.BRIDGE,function(e,r,n){ | ||
if((0,a.isSameDomain)(e))throw new Error("Post message through bridge disabled between same domain windows");if((0,a.isSameTopWindow)(window,e)!==!1)throw new Error("Can only use bridge to communicate between two different windows, not between frames");return(0,s.sendBridgeMessage)(e,JSON.stringify(r,0,2),n)}),o)},function(e,r,n){"use strict";function t(e){e=e||g.util.getDomainFromUrl(e);var r=e.replace(/[^a-zA-Z0-9]+/g,"_"),n=h.CONSTANTS.BRIDGE_NAME_PREFIX+"_"+r;return n}function o(){return new g.promise.Promise(function(e){return window.document&&window.document.body?e(window.document):void window.document.addEventListener("DOMContentLoaded",function(r){return e(window.document)})})}function i(e){try{var r=(0,g.getFrames)(e);if(!r||!r.length)return;for(var n=0;n<r.length;n++)try{var t=r[n];if(t&&t!==window&&(0,g.isSameDomain)(t)&&t[h.CONSTANTS.WINDOW_PROPS.POSTROBOT])return t}catch(o){continue}}catch(o){}}function a(e){var r=(arguments.length<=1||void 0===arguments[1]?h.CONFIG.BRIDGE_TIMEOUT:arguments[1],new g.promise.Promise);S.global.remoteWindows.push({win:e,sendMessagePromise:r})}function u(e,r,n){for(var t=S.global.remoteWindows,o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var u=a;if(u.win===e){var s=function(t,o,i){if(t!==e)throw new Error("Remote window does not match window");if("*"!==i&&i!==r)throw new Error("Remote domain "+i+" does not match domain "+r);n(o)};return u.sendMessagePromise.resolve(s),void(u.sendMessagePromise=g.promise.Promise.resolve(s))}}throw new Error("Window not found to register sendMessage to")}function s(e,r){for(var n=S.global.remoteWindows,t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;if(a.win===e)return a.sendMessagePromise.reject(r)}throw new Error("Window not found on which to reject sendMessage")}function c(e,r,n){var t=(0,g.isOpener)(window,e),o=(0,g.isOpener)(e,window);if(!t&&!o)throw new Error("Can only send messages to and from parent and popup windows");for(var i=S.global.remoteWindows,a=Array.isArray(i),u=0,i=a?i:i[Symbol.iterator]();;){var s;if(a){if(u>=i.length)break;s=i[u++]}else{if(u=i.next(),u.done)break;s=u.value}var c=s;if(c.win===e)return c.sendMessagePromise.then(function(t){return t(e,r,n)})}throw new Error("Window not found to send message to")}function d(e,r){for(var n=Object.keys(S.global.popupWindows),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var u=i,s=S.global.popupWindows[u];if(s.win===e){s.domain=g.util.getDomainFromUrl(r),a(e);break}}}function f(e,r){(0,b.on)(h.CONSTANTS.POST_MESSAGE_NAMES.OPEN_TUNNEL,{source:e,domain:r},function(e){var n=e.origin,t=e.data;if(n!==r)throw new Error("Domain "+r+" does not match origin "+n);if(!t.name)throw new Error("Register window expected to be passed window name");if(!t.sendMessage)throw new Error("Register window expected to be passed sendMessage method");var o=S.global.popupWindows[t.name];if(!o)throw new Error("Window with name "+t.name+" does not exist, or was not opened by this window");if(!o.domain)throw new Error("We do not have a registered domain for window "+t.name);if(o.domain!==n)throw new Error("Message origin "+n+" does not matched registered window origin "+o.domain);return u(o.win,r,t.sendMessage),{sendMessage:function(e){window&&!window.closed&&(0,O.receiveMessage)({data:e,origin:o.domain,source:o.win})}}})}function l(){var e=(0,g.getOpener)(window);if(e){a(e);var r=i(e);return r?window.name?void r[h.CONSTANTS.WINDOW_PROPS.POSTROBOT].openTunnel(e,{name:window.name,sendMessage:function(e){window&&!window.closed&&(0,O.receiveMessage)({data:e,origin:this.origin,source:this.source})}}).then(function(r){var n=r.source,t=r.origin,o=r.data;if(n!==e)throw new Error("Source does not match opener");u(n,t,o.sendMessage)})["catch"](function(r){throw s(e,r),r}):s(e,new Error("Can not register with opener: window does not have a name")):s(e,new Error("Can not register with opener: no bridge found in opener"))}}function w(e,r){g.log.debug("Opening bridge:",e,r);var n=document.createElement("iframe");return n.setAttribute("name",e),n.setAttribute("id",e),n.setAttribute("style","display: none; margin: 0; padding: 0; border: 0px none; overflow: hidden;"),n.setAttribute("frameborder","0"),n.setAttribute("border","0"),n.setAttribute("scrolling","no"),n.setAttribute("allowTransparency","true"),n.setAttribute("tabindex","-1"),n.setAttribute("hidden","true"),n.setAttribute("title",""),n.setAttribute("role","presentation"),n.src=r,n}function p(e,r){return r=r||g.util.getDomainFromUrl(e),g.util.getDomain()!==r}function m(e,r){return r=r||g.util.getDomainFromUrl(e),S.global.bridges[r]?S.global.bridges[r]:(S.global.bridges[r]=g.promise.run(function(){if(g.util.getDomain()===r)throw new Error("Can not open bridge on the same domain as current domain: "+r);var n=t(r),i=(0,g.getFrameByName)(window,n);if(i)throw new Error("Frame with name "+n+" already exists on page");var a=w(n,e);return o().then(function(n){n.body.appendChild(a);var t=a.contentWindow;return f(t,r),new g.promise.Promise(function(e,r){a.onload=e,a.onerror=r}).then(function(){return(0,g.onWindowReady)(t,h.CONFIG.BRIDGE_TIMEOUT,"Bridge "+e)}).then(function(){return t})})}),S.global.bridges[r])}Object.defineProperty(r,"__esModule",{value:!0});var v=function(){function e(e,r){var n=[],t=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(t=(a=u.next()).done)&&(n.push(a.value),!r||n.length!==r);t=!0);}catch(s){o=!0,i=s}finally{try{!t&&u["return"]&&u["return"]()}finally{if(o)throw i}}return n}return function(r,n){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return e(r,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();r.sendBridgeMessage=c,r.linkUrl=d,r.openTunnelToOpener=l,r.bridgeRequired=p,r.openBridge=m;var h=n(3),g=n(8),S=n(15),b=n(1),O=n(6);S.global.remoteWindows=S.global.remoteWindows||[],S.global.popupWindows=S.global.popupWindows||{};var E=window.open;window.open=function(e,r,n,t){var o=e;if(e&&0===e.indexOf(h.CONSTANTS.MOCK_PROTOCOL)){var i=e.split("|"),u=v(i,2);o=u[0],e=u[1]}o&&(o=g.util.getDomainFromUrl(o));var s=E.call(this,e,r,n,t);return e&&a(s),r&&(S.global.popupWindows[r]={win:s,domain:o}),s},S.global.openTunnel=function(e,r){var n=r.name,t=r.sendMessage;if(!e)throw new Error("No window found to open tunnel to");return(0,b.send)(e,h.CONSTANTS.POST_MESSAGE_NAMES.OPEN_TUNNEL,{name:n,sendMessage:function(){return t.apply(this,arguments)}},{domain:"*"})},S.global.bridges=S.global.bridges||{}},function(e,r,n){"use strict";function t(){u.global.listeners.request=[],u.global.listeners.response=[]}function o(e,r){for(var n=u.global.listeners.request,t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;if(a.name===e){if(!a.win||"*"===a.win)return a.options;if(r&&r===a.win)return a.options}}}function i(e){for(var r=void 0,n=u.global.listeners.request,t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;if(a.options===e){r=a;break}}r&&u.global.listeners.request.splice(u.global.listeners.request.indexOf(r),1)}function a(e,r,n,t){var a=o(e,r);if(a){if(!t)throw new Error("Request listener already exists for "+e);i(a)}s.request.push({name:e,win:r,options:n})}Object.defineProperty(r,"__esModule",{value:!0}),r.listeners=void 0,r.resetListeners=t,r.getRequestListener=o,r.removeRequestListener=i,r.addRequestListener=a;var u=n(15);u.global.listeners=u.global.listeners||{request:[],response:[]};var s=r.listeners=u.global.listeners},function(e,r,n){"use strict";function t(e){if(!e.name)throw new Error("Expected options.name");e.handler=e.handler||s.util.noop,e.errorHandler=e.errorHandler||function(e){throw e},e.once&&!function(){var r=e.handler;e.handler=s.util.once(function(){return(0,c.removeRequestListener)(e),r.apply(this,arguments)})}();var r=e.override||u.CONFIG.MOCK_MODE;return e.source&&(e.window=e.source),e.domain=e.domain||"*",(0,c.addRequestListener)(e.name,e.window,e,r),e.handleError=function(r){e.errorHandler(r)},e.window&&e.errorOnClose&&!function(){var r=s.util.safeInterval(function(){(0,s.isWindowClosed)(e.window)&&(r.cancel(),e.handleError(new Error("Post message target window is closed")))},50)}(),{cancel:function(){(0,c.removeRequestListener)(e)}}}function o(e,r,n,o){return"function"==typeof r&&(o=n,n=r,r={}),r=r||{},r.name=e,r.handler=n||r.handler,r.errorHandler=o||r.errorHandler,t(r)}function i(e,r,n,o){"function"==typeof r&&(o=n,n=r,r={}),r=r||{},r.name=e,r.handler=n||r.handler,r.errorHandler=o||r.errorHandler,r.once=!0;var i=new s.promise.Promise(function(e,n){r.handler=r.handler||function(r){return e(r)},r.errorHandler=r.errorHandler||n}),a=t(r);return s.util.extend(i,a),i}function a(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return{on:function(r,n,t){return o(r,e,n,t)}}}Object.defineProperty(r,"__esModule",{value:!0}),r.on=void 0,r.listen=t,r.once=i,r.listener=a;var u=n(3),s=n(8),c=n(6);r.on=o},function(e,r,n){"use strict";function t(){a.CONFIG.MOCK_MODE=!0}function o(){a.CONFIG.MOCK_MODE=!1}function i(){delete window[a.CONSTANTS.WINDOW_PROPS.POSTROBOT],window.removeEventListener("message",u.messageListener)}Object.defineProperty(r,"__esModule",{value:!0}),r.CONSTANTS=r.CONFIG=void 0,r.enableMockMode=t,r.disableMockMode=o;var a=n(3);Object.defineProperty(r,"CONFIG",{enumerable:!0,get:function(){return a.CONFIG}}),Object.defineProperty(r,"CONSTANTS",{enumerable:!0,get:function(){return a.CONSTANTS}}),r.disable=i;var u=n(6)}])}); | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("postRobot",[],r):"object"==typeof exports?exports.postRobot=r():e.postRobot=r()}(this,function(){return function(e){function r(t){if(n[t])return n[t].exports;var o=n[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var n={};return r.m=e,r.c=n,r.p="",r(0)}([function(e,r,n){"use strict";function t(){u.global.initialized||(i.util.listen(window,"message",a.messageListener),(0,s.openTunnelToOpener)(),(0,i.initOnReady)(),(0,i.listenForMethods)()),u.global.initialized=!0}Object.defineProperty(r,"__esModule",{value:!0}),r.Promise=void 0;var o=n(1);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(8);Object.defineProperty(r,"Promise",{enumerable:!0,get:function(){return i.Promise}});var a=n(6),u=n(15),s=n(23);t(),r["default"]=e.exports},function(e,r,n){"use strict";function t(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r["default"]=e,r}Object.defineProperty(r,"__esModule",{value:!0}),r.winutil=r.util=r.linkUrl=r.bridgeRequired=r.openBridge=r.reset=r.parent=void 0;var o=n(2);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(25);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})});var a=n(26);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})});var u=n(6);Object.defineProperty(r,"reset",{enumerable:!0,get:function(){return u.resetListeners}});var s=n(23);Object.defineProperty(r,"openBridge",{enumerable:!0,get:function(){return s.openBridge}}),Object.defineProperty(r,"bridgeRequired",{enumerable:!0,get:function(){return s.bridgeRequired}}),Object.defineProperty(r,"linkUrl",{enumerable:!0,get:function(){return s.linkUrl}});var c=n(12);Object.defineProperty(r,"util",{enumerable:!0,get:function(){return c.util}});var d=n(14),f=t(d);r.parent=(0,d.getAncestor)(),r.winutil=f},function(e,r,n){"use strict";function t(e){return c.promise.nodeify(new c.promise.Promise(function(r,n){if(!e.name)throw new Error("Expected options.name");if(!e.window)throw new Error("Expected options.window");if(u.CONFIG.MOCK_MODE)e.window=window;else if("string"==typeof e.window){var t=document.getElementById(e.window);if(!t)throw new Error("Expected options.window "+e.window+" to be a valid element id");if("iframe"!==t.tagName.toLowerCase())throw new Error("Expected options.window "+e.window+" to be an iframe");if(e.window=t.contentWindow,!e.window)throw new Error("Expected options.window")}e.domain=e.domain||"*";var o=e.name+"_"+c.util.uniqueID();if(s.listeners.response[o]=e,(0,c.isWindowClosed)(e.window))throw new Error("Target window is closed");var i=!1;return e.respond=function(e,t){return e||(i=!0),e?n(e):r(t)},c.promise.run(function(){if((0,c.isAncestor)(window,e.window))return(0,c.onWindowReady)(e.window)}).then(function(){if((0,s.sendMessage)(e.window,{hash:o,type:u.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,name:e.name,data:e.data,fireAndForget:e.fireAndForget},e.domain)["catch"](n),e.fireAndForget)return r();var t=c.util.intervalTimeout(u.CONFIG.ACK_TIMEOUT,100,function(r){return e.ack||(0,c.isWindowClosed)(e.window)?t.cancel():r?void 0:n(new Error("No ack for postMessage "+e.name+" in "+u.CONFIG.ACK_TIMEOUT+"ms"))});e.timeout&&!function(){var r=c.util.intervalTimeout(e.timeout,100,function(t){return i||(0,c.isWindowClosed)(e.window)?r.cancel():t?void 0:n(new Error("Post message response timed out after "+e.timeout+" ms"))},e.timeout)}()})["catch"](n)}),e.callback)}function o(e,r,n,o,i){return i||(o||"function"!=typeof n?"function"==typeof o&&(i=o,o={}):(i=n,o={},n={})),o=o||{},o.window=e,o.name=r,o.data=n,o.callback=i,t(o)}function i(e,r,n,t){var i=(0,c.getAncestor)();return i?o(i,e,r,n,t):new c.promise.Promise(function(e,r){return r(new Error("Window does not have a parent"))})}function a(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];if(!e.window)throw new Error("Expected options.window");return{send:function(r,n,t){return o(e.window,r,n,e,t)}}}Object.defineProperty(r,"__esModule",{value:!0}),r.send=void 0,r.request=t,r.sendToParent=i,r.client=a;var u=n(3),s=n(6),c=n(8);r.send=o},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(4);Object.keys(t).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})});var o=n(5);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}Object.defineProperty(r,"__esModule",{value:!0}),r.CONFIG=void 0;var o,i=n(5),a=r.CONFIG={ALLOW_POSTMESSAGE_POPUP:!0,LOG_LEVEL:"info",BRIDGE_TIMEOUT:5e3,ACK_TIMEOUT:1e3,LOG_TO_PAGE:!1,MOCK_MODE:!1,ALLOWED_POST_MESSAGE_METHODS:(o={},t(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,!0),t(o,i.CONSTANTS.SEND_STRATEGIES.BRIDGE,!0),o)};0===window.location.href.indexOf(i.CONSTANTS.FILE_PROTOCOL)&&(a.ALLOW_POSTMESSAGE_POPUP=!0)},function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=r.CONSTANTS={POST_MESSAGE_TYPE:{REQUEST:"postrobot_message_request",RESPONSE:"postrobot_message_response",ACK:"postrobot_message_ack"},POST_MESSAGE_ACK:{SUCCESS:"success",ERROR:"error"},POST_MESSAGE_NAMES:{METHOD:"postrobot_method",READY:"postrobot_ready",OPEN_TUNNEL:"postrobot_open_tunnel"},WINDOW_TYPES:{FULLPAGE:"fullpage",POPUP:"popup",IFRAME:"iframe"},WINDOW_PROPS:{POSTROBOT:"__postRobot__"},SERIALIZATION_TYPES:{METHOD:"postrobot_method"},SEND_STRATEGIES:{POST_MESSAGE:"postrobot_post_message",BRIDGE:"postrobot_bridge"},MOCK_PROTOCOL:"mock://",FILE_PROTOCOL:"file://",BRIDGE_NAME_PREFIX:"__postrobot_bridge__",POSTROBOT_PROXY:"__postrobot_proxy__"};r.POST_MESSAGE_NAMES_LIST=Object.keys(n.POST_MESSAGE_NAMES).map(function(e){return n.POST_MESSAGE_NAMES[e]})},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(7);Object.keys(t).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})});var o=n(21);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(24);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,r,n){"use strict";function t(e){try{e=JSON.parse(e)}catch(r){return}if(e&&(e=e[a.CONSTANTS.WINDOW_PROPS.POSTROBOT],e&&e.type&&d.RECEIVE_MESSAGE_TYPES[e.type]))return e}function o(e){if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!e.source)return}catch(r){return}var n=e.source,o=e.origin,i=e.data,s=t(i);if(s&&(0!==s.sourceDomain.indexOf(a.CONSTANTS.MOCK_PROTOCOL)&&0!==s.sourceDomain.indexOf(a.CONSTANTS.FILE_PROTOCOL)||(o=s.sourceDomain),c.global.receivedMessages.indexOf(s.id)===-1)){c.global.receivedMessages.push(s.id);var f=void 0;if(f=a.POST_MESSAGE_NAMES_LIST.indexOf(s.name)!==-1||s.type===a.CONSTANTS.POST_MESSAGE_TYPE.ACK?"debug":"error"===s.ack?"error":"info",u.log.logLevel(f,["\n\n\t","#receive",s.type.replace(/^postrobot_message_/,""),"::",s.name,"::",o,"\n\n",s]),(0,u.isWindowClosed)(n))return u.log.debug("Source window is closed - can not send "+s.type+" "+s.name);s.data&&(s.data=(0,u.deserializeMethods)(n,o,s.data)),d.RECEIVE_MESSAGE_TYPES[s.type](n,o,s)}}function i(e){try{e.source}catch(r){return}e={source:e.source||e.sourceElement,origin:e.origin||e.originalEvent.origin,data:e.data};try{(0,s.emulateIERestrictions)(e.source,window)}catch(r){return}o(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.receiveMessage=o,r.messageListener=i;var a=n(3),u=n(8),s=n(18),c=n(15),d=n(20);c.global.receivedMessages=c.global.receivedMessages||[]},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(9);Object.keys(t).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})});var o=n(12);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(13);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})});var a=n(14);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})});var u=n(16);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return u[e]}})});var s=n(11);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return s[e]}})});var c=n(17);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return c[e]}})})},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.promise=r.Promise=void 0;var t=n(10),o=n(11),i=r.Promise=t.SyncPromise,a=r.promise={Promise:i,run:function(e){return i.resolve().then(e)},nextTick:function(e){return new i(function(r,n){(0,o.nextTick)(function(){return a.run(e).then(r,n)})})},method:function(e){return function(){var r=this,n=arguments;return i.resolve().then(function(){return e.apply(r,n)})}},nodeify:function(e,r){return r?void e.then(function(e){r(null,e)},function(e){r(e)}):e},deNodeify:function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];return new i(function(r,t){try{return n.length<e.length?e.apply(void 0,n.concat([function(e,n){return e?t(e):r(n)}])):a.run(function(){return e.apply(void 0,n)}).then(r,t)}catch(o){return t(o)}})},map:function(e,r){for(var n=[],t=function(t){n.push(a.run(function(){return r(e[t])}))},o=0;o<e.length;o++)t(o);return i.all(n)}}},function(e,r){"use strict";function n(e,r,n){function t(){if(a){if(s)return n(o);if(u)return r(i)}}var o,i,a=!1,u=!1,s=!1;try{e(function(e){i=e,u=!0,t()},function(e){o=e,s=!0,t()})}catch(c){return n(c)}a=!0,t()}function t(e){d.push(e),s=s||setTimeout(o,1)}function o(){s=null;var e=d;d=[];for(var r=0;r<e.length;r++){var n=e[r];n.hasHandlers||(n.handlers.push({onError:function(e){if(!n.hasHandlers){i(e);for(var r=0;r<c.length;r++)c[r](n.value)}}}),n.dispatch())}}function i(e){setTimeout(function(){throw e},1)}function a(e){try{if(!e)return!1;if(window.Window&&e instanceof window.Window)return!1;if(window.constructor&&e instanceof window.constructor)return!1;if(f){var r=f.call(e);if("[object Window]"===r||"[object global]"===r||"[object DOMWindow]"===r)return!1}if(e&&e.then instanceof Function)return!0}catch(n){return!1}return!1}function u(){window.Promise=l}Object.defineProperty(r,"__esModule",{value:!0}),r.patchPromise=u;var s,c=[],d=[],f={}.toString,l=r.SyncPromise=function(e){if(this.resolved=!1,this.rejected=!1,this.hasHandlers=!1,this.handlers=[],t(this),e){var r=this;n(e,function(e){return r.resolve(e)},function(e){return r.reject(e)})}};l.resolve=function(e){return a(e)?e:(new l).resolve(e)},l.reject=function(e){return(new l).reject(e)},l.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(a(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},l.prototype.reject=function(e){if(this.resolved||this.rejected)return this;if(a(e))throw new Error("Can not reject promise with another promise");return this.rejected=!0,this.value=e,this.dispatch(),this},l.prototype.dispatch=function(){var e=this;if(this.resolved||this.rejected)for(var r=function(){var r=e.handlers.shift();try{e.resolved?n=r.onSuccess?r.onSuccess(e.value):e.value:r.onError?n=r.onError(e.value):t=e.value}catch(o){t=o}if(n===e)throw new Error("Can not return a promise from the the then handler of the same promise");return r.promise?void(t?r.promise.reject(t):a(n)?n.then(function(e){r.promise.resolve(e)},function(e){r.promise.reject(e)}):r.promise.resolve(n)):"continue"};this.handlers.length;){var n,t;r()}},l.prototype.then=function(e,r){var n=new l(null,this);return this.handlers.push({promise:n,onSuccess:e,onError:r}),this.hasHandlers=!0,this.dispatch(),n},l.prototype["catch"]=function(e){return this.then(null,e)},l.prototype["finally"]=function(e){return this.then(function(r){return e(),r},function(r){throw e(),r})},l.all=function(e){for(var r=new l,n=e.length,t=[],o=function(o){var i=a(e[o])?e[o]:l.resolve(e[o]);i.then(function(e){t[o]=e,n-=1,0===n&&r.resolve(t)},function(e){r.reject(e)})},i=0;i<e.length;i++)o(i);return r},l.onPossiblyUnhandledException=function(e){c.push(e)}},function(e,r,n){"use strict";function t(e){a.push(e),window.postMessage(i,"*")}Object.defineProperty(r,"__esModule",{value:!0}),r.nextTick=t;var o=n(12),i="__nextTick__postRobot__"+o.util.uniqueID(),a=[];window.addEventListener("message",function(e){if(e.data===i){var r=a.shift();r.call()}})},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.util=void 0;var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=n(3),i=r.util={once:function(e){if(!e)return e;var r=!1;return function(){if(!r)return r=!0,e.apply(this,arguments)}},noop:function(){},safeHasProp:function(e,r){try{return!!e[r]}catch(n){return!1}},safeGetProp:function(e,r){try{return e[r]}catch(n){return}},listen:function(e,r,n){return e.addEventListener?e.addEventListener(r,n):e.attachEvent("on"+r,n),{cancel:function(){e.removeEventListener?e.removeEventListener(r,n):e.detachEvent("on"+r,n)}}},apply:function(e,r,n){return"function"==typeof e.apply?e.apply(r,n):e(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9])},find:function(e,r,n){if(!e)return n;for(var t=0;t<e.length;t++)if(r(e[t]))return e[t];return n},map:function(e,r){for(var n=[],t=0;t<e.length;t++)n.push(r(e[t]));return n},some:function(e,r){r=r||Boolean;for(var n=0;n<e.length;n++)if(r(e[n]))return!0;return!1},keys:function(e){var r=[];for(var n in e)e.hasOwnProperty(n)&&r.push(n);return r},values:function(e){var r=[];for(var n in e)e.hasOwnProperty(n)&&r.push(e[n]);return r},getByValue:function(e,r){for(var n in e)if(e.hasOwnProperty(n)&&e[n]===r)return n},uniqueID:function(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})},memoize:function(e){var r={};return function(){var n=JSON.stringify(Array.prototype.slice.call(arguments));return r.hasOwnProperty(n)||(r[n]=e.apply(this,arguments)),r[n]}},extend:function(e,r){if(!r)return e;for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n]);return e},each:function(e,r){if(Array.isArray(e))for(var n=0;n<e.length;n++)r(e[n],n);else if("object"===("undefined"==typeof e?"undefined":t(e))&&null!==e)for(var o in e)e.hasOwnProperty(o)&&r(e[o],o)},replaceObject:function(e,r){var n=arguments.length<=2||void 0===arguments[2]?1:arguments[2];if(n>=100)throw new Error("Self-referential object passed, or object contained too many layers");var o=Array.isArray(e)?[]:{};return i.each(e,function(e,a){var u=r(e,a);void 0!==u?o[a]=u:"object"===("undefined"==typeof e?"undefined":t(e))&&null!==e?o[a]=i.replaceObject(e,r,n+1):o[a]=e}),o},safeInterval:function(e,r){function n(){t=setTimeout(n,r),e.call()}var t=void 0;return t=setTimeout(n,r),{cancel:function(){clearTimeout(t)}}},intervalTimeout:function(e,r,n){var t=i.safeInterval(function(){e-=r,e=e<=0?0:e,0===e&&t.cancel(),n(e)},r);return t},getDomain:function(e){return e=e||window,e.mockDomain&&0===e.mockDomain.indexOf(o.CONSTANTS.MOCK_PROTOCOL)?e.mockDomain:e.location.protocol+"//"+e.location.host},getDomainFromUrl:function(e){var r=void 0;return e.match(/^(https?|mock|file):\/\//)?(r=e,r=r.split("/").slice(0,3).join("/")):this.getDomain()},safeGet:function(e,r){var n=void 0;try{n=e[r]}catch(t){}return n}}},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.log=void 0;var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=n(12),i=n(14),a=n(3),u=["debug","info","warn","error"];Function.prototype.bind&&window.console&&"object"===t(console.log)&&["log","info","warn","error"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call);var s=r.log={clearLogs:function(){if(window.console&&window.console.clear&&window.console.clear(),a.CONFIG.LOG_TO_PAGE){var e=document.getElementById("postRobotLogs");e&&e.parentNode.removeChild(e)}},writeToPage:function(e,r){setTimeout(function(){var n=document.getElementById("postRobotLogs");n||(n=document.createElement("div"),n.id="postRobotLogs",n.style.cssText="width: 800px; font-family: monospace; white-space: pre-wrap;",document.body.appendChild(n));var t=document.createElement("div"),i=(new Date).toString().split(" ")[4],a=o.util.map(r,function(e){if("string"==typeof e)return e;if(!e)return Object.prototype.toString.call(e);var r=void 0;try{r=JSON.stringify(e,0,2)}catch(n){r="[object]"}return"\n\n"+r+"\n\n"}).join(" "),u=i+" "+e+" "+a;t.innerHTML=u;var s={log:"#ddd",warn:"orange",error:"red",info:"blue",debug:"#aaa"}[e];t.style.cssText="margin-top: 10px; color: "+s+";",n.childNodes.length?n.insertBefore(t,n.childNodes[0]):n.appendChild(t)})},logLevel:function(e,r){try{if(u.indexOf(e)<u.indexOf(a.CONFIG.LOG_LEVEL))return;if(r=Array.prototype.slice.call(r),r.unshift(""+window.location.host+window.location.pathname),r.unshift("::"),r.unshift(""+(0,i.getWindowType)().toLowerCase()),r.unshift("[post-robot]"),a.CONFIG.LOG_TO_PAGE&&s.writeToPage(e,r),!window.console)return;if(window.console[e]||(e="log"),!window.console[e])return;window.console[e].apply(window.console,r)}catch(n){}},debug:function(){s.logLevel("debug",arguments)},info:function(){s.logLevel("info",arguments)},warn:function(){s.logLevel("warn",arguments)},error:function(){s.logLevel("error",arguments)}}},function(e,r,n){"use strict";function t(e){for(var r=P.global.domainMatches,n=Array.isArray(r),t=0,r=n?r:r[Symbol.iterator]();;){var o;if(n){if(t>=r.length)break;o=r[t++]}else{if(t=r.next(),t.done)break;o=t.value}var i=o;if(i.win===e)return i.match}var a=!1;try{T.util.getDomain(window)===T.util.getDomain(e)&&(a=!0)}catch(u){}return P.global.domainMatches.push({win:e,match:a}),M||(M=setTimeout(function(){P.global.domainMatches=[],M=null},1)),a}function o(e){if(!e)return!1;try{for(var r=["setTimeout","setInterval","postMessage","alert"],n=0;n<r.length;n++){var t=r[n];if("function"!=typeof e[t])return!1}return!(!e.document||!e.location)}catch(o){}try{for(var i=0;i<5;i++)e&&(e=e[Math.random().toString()]);return!1}catch(o){return!0}}function i(e){try{return!!(!e||e.closed||t(e)&&T.util.safeGet(e,"mockclosed"))}catch(r){}return!0}function a(e){if(e)try{return e.opener}catch(r){return}}function u(e){if(e)try{if(e.parent&&e.parent!==e)return e.parent}catch(r){return}}function s(e){var r=[];try{for(;e.parent!==e;)r.push(e.parent),e=e.parent}catch(n){}return r}function c(e,r){if(!e||!r)return!1;var n=u(r);return n?n===e:s(r).indexOf(e)!==-1}function d(e){var r=[],n=void 0;try{n=e.frames}catch(t){n=e}var o=void 0;try{o=n.length}catch(t){}if(0===o)return r;if(o)for(var i=0;i<o;i++){var a=void 0;try{a=n[i]}catch(t){continue}r.push(a)}else for(var u=0;;){var s=void 0;try{s=n[u]}catch(t){return r}if(!s)return r;if(r.push(s),u+=1,u>20)return r}return r}function f(e){for(var r=[],n=d(e),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;r.push(a);for(var u=f(a),s=Array.isArray(u),c=0,u=s?u:u[Symbol.iterator]();;){var l;if(s){if(c>=u.length)break;l=u[c++]}else{if(c=u.next(),c.done)break;l=c.value}var w=l;r.push(w)}}return r}function l(e){var r=f(e);r.push(e);for(var n=s(e),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;r.push(a);for(var u=d(a),c=Array.isArray(u),l=0,u=c?u:u[Symbol.iterator]();;){var w;if(c){if(l>=u.length)break;w=u[l++]}else{if(l=u.next(),l.done)break;w=l.value}var p=w;r.indexOf(p)===-1&&r.push(p)}}return r}function w(e){if(e){try{if(e.top)return e.top}catch(r){}if(u(e)===e)return e;try{if(c(window,e))return window.top}catch(r){}try{if(c(e,window))return window.top}catch(r){}for(var n=f(e),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;try{if(a.top)return a.top}catch(r){}if(u(a)===a)return a}}}function p(e,r){for(var n=d(e),t=Array.isArray(n),i=0,n=t?n:n[Symbol.iterator]();;){var a;if(t){if(i>=n.length)break;a=n[i++]}else{if(i=n.next(),i.done)break;a=i.value}var u=a;try{if(u.name===r&&o(u))return u}catch(s){}}try{if(o(e.frames[r]))return e.frames[r]}catch(s){}try{if(o(e[r]))return e[r]}catch(s){}}function m(e,r){var n=u(r);if(n)return n===e;for(var t=d(e),o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var s=a;if(s===r)return!0}return!1}function v(e,r){return e===a(r)}function h(e){e=e||window;var r=a(e);if(r)return r;var n=u(e);return n?n:void 0}function S(e,r){var n=h(r);if(n)return n===e;if(r===e)return!1;if(w(r)===r)return!1;for(var t=d(e),o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var u=a;if(u===r)return!0}return!1}function g(){return Boolean(a(window))}function O(){return Boolean(u(window))}function b(){return Boolean(!O()&&!g())}function E(){return g()?A.CONSTANTS.WINDOW_TYPES.POPUP:O()?A.CONSTANTS.WINDOW_TYPES.IFRAME:A.CONSTANTS.WINDOW_TYPES.FULLPAGE}function y(e,r){for(var n=e,t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}for(var a=i,u=r,s=Array.isArray(u),c=0,u=s?u:u[Symbol.iterator]();;){var d;if(s){if(c>=u.length)break;d=u[c++]}else{if(c=u.next(),c.done)break;d=c.value}var f=d;if(a===f)return!0}}}function _(e,r){var n=w(e),t=w(r);try{if(n&&t)return n===t}catch(o){}var i=l(e),u=l(r);if(y(i,u))return!0;var s=a(n),c=a(t);return(!s||!y(l(s),u))&&((!c||!y(l(c),i))&&void 0)}Object.defineProperty(r,"__esModule",{value:!0}),r.isSameDomain=t,r.isWindow=o,r.isWindowClosed=i,r.getOpener=a,r.getParent=u,r.getParents=s,r.isAncestorParent=c,r.getFrames=d,r.getAllChildFrames=f,r.getAllFramesInWindow=l,r.getTop=w,r.getFrameByName=p,r.isParent=m,r.isOpener=v,r.getAncestor=h,r.isAncestor=S,r.isPopup=g,r.isIframe=O,r.isFullpage=b,r.getWindowType=E,r.isSameTopWindow=_;var T=n(12),P=n(15),A=n(3);P.global.domainMatches=P.global.domainMatches||[];var M=void 0},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.global=void 0;var t=n(3);r.global=window[t.CONSTANTS.WINDOW_PROPS.POSTROBOT]=window[t.CONSTANTS.WINDOW_PROPS.POSTROBOT]||{}},function(e,r,n){"use strict";function t(e){return"object"===("undefined"==typeof e?"undefined":s(e))&&null!==e&&e.__type__===c.CONSTANTS.SERIALIZATION_TYPES.METHOD&&e.__id__}function o(e,r,n,t){var o=d.util.uniqueID();return p.global.methods[o]={destination:e,domain:r,method:n},{__type__:c.CONSTANTS.SERIALIZATION_TYPES.METHOD,__id__:o,__name__:t}}function i(e,r,n){return d.util.replaceObject({obj:n},function(n,t){if("function"==typeof n)return o(e,r,n,t)}).obj}function a(e,r,n){function t(){var t=Array.prototype.slice.call(arguments);return l.log.debug("Call foreign method",n.__name__,t),(0,f.send)(e,c.CONSTANTS.POST_MESSAGE_NAMES.METHOD,{id:n.__id__,name:n.__name__,args:t},{domain:r}).then(function(e){var r=e.data;return l.log.debug("Got foreign method result",n.__name__,r.result),r.result})}return t.__name__=n.__name__,t}function u(e,r,n){return d.util.replaceObject({obj:n},function(n,o){if(t(n))return a(e,r,n)}).obj}Object.defineProperty(r,"__esModule",{value:!0}),r.listenForMethods=void 0;var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};r.serializeMethod=o,r.serializeMethods=i,r.deserializeMethod=a,r.deserializeMethods=u;var c=n(3),d=n(12),f=n(1),l=n(13),w=n(9),p=n(15);p.global.methods=p.global.methods||{};r.listenForMethods=d.util.once(function(){(0,f.on)(c.CONSTANTS.POST_MESSAGE_NAMES.METHOD,{window:"*",origin:"*"},function(e){var r=e.source,n=e.origin,t=e.data,o=p.global.methods[t.id];if(!o)throw new Error("Could not find method with id: "+t.id);if(o.destination!==r)throw new Error("Method window does not match");if(o.domain&&"*"!==o.domain&&n!==o.domain)throw new Error("Method domain "+o.domain+" does not match origin "+n);return l.log.debug("Call local method",t.name,t.args),w.promise.run(function(){return o.method.apply({source:r,origin:n,data:t},t.args)}).then(function(e){return{result:e,id:t.id,name:t.name}})})})},function(e,r,n){"use strict";function t(){(0,u.on)(i.CONSTANTS.POST_MESSAGE_NAMES.READY,{window:"*",domain:"*"},function(e){for(var r=e.source,n=(e.data,d.global.readyPromises),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;if(a.win===r)return void a.promise.resolve(r)}d.global.readyPromises.push({win:r,promise:(new c.SyncPromise).resolve(r)})});var e=(0,a.getAncestor)();e&&(0,u.send)(e,i.CONSTANTS.POST_MESSAGE_NAMES.READY,{},{domain:"*"})["catch"](function(e){s.log.debug(e.stack||e.toString())})}function o(e){for(var r=arguments.length<=1||void 0===arguments[1]?5e3:arguments[1],n=arguments.length<=2||void 0===arguments[2]?"Window":arguments[2],t=d.global.readyPromises,o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var u=a;if(u.win===e)return u.promise}var s=new c.SyncPromise;return d.global.readyPromises.push({win:e,promise:s}),setTimeout(function(){return s.reject(new Error(n+" did not load after "+r+"ms"))},r),s}Object.defineProperty(r,"__esModule",{value:!0}),r.initOnReady=t,r.onWindowReady=o;var i=n(3),a=n(14),u=n(1),s=n(13),c=n(10),d=n(15);d.global.readyPromises=d.global.readyPromises||[]},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(19);Object.keys(t).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})})},function(e,r,n){"use strict";function t(e,r){if(!o.CONFIG.ALLOW_POSTMESSAGE_POPUP){if((0,i.isSameDomain)(e)&&(0,i.isSameDomain)(r))return;if((0,i.isSameTopWindow)(e,r)===!1)throw new Error("Can not send and receive post messages between two different windows (disabled to emulate IE)")}}Object.defineProperty(r,"__esModule",{value:!0}),r.emulateIERestrictions=t;var o=n(3),i=n(8)},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function o(e,r){return"string"==typeof e?"*"===e||r===e:"[object RegExp]"===Object.prototype.toString.call(e)?r.match(e):!!Array.isArray(e)&&e.indexOf(r)!==-1}Object.defineProperty(r,"__esModule",{value:!0}),r.RECEIVE_MESSAGE_TYPES=void 0;var i,a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},u=n(3),s=n(8),c=n(21),d=n(24);r.RECEIVE_MESSAGE_TYPES=(i={},t(i,u.CONSTANTS.POST_MESSAGE_TYPE.ACK,function(e,r,n){var t=d.listeners.response[n.hash];if(!t)throw new Error("No handler found for post message ack for message: "+n.name+" in "+window.location.href);if(!o(t.domain,r))throw new Error("Ack origin "+r+" does not match domain "+t.domain);t.ack=!0}),t(i,u.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,function(e,r,n){function t(t){return n.fireAndForget||(0,s.isWindowClosed)(e)?s.promise.Promise.resolve():(0,c.sendMessage)(e,a({target:n.originalSource,hash:n.hash,name:n.name},t),r)}var i=(0,d.getRequestListener)(n.name,e);return s.promise.Promise.all([t({type:u.CONSTANTS.POST_MESSAGE_TYPE.ACK}),s.promise.run(function(){if(!i)throw new Error("No postmessage request handler for "+n.name+" in "+window.location.href);if(!o(i.domain,r))throw new Error("Request origin "+r+" does not match domain "+i.domain);var t=n.data;return s.promise.deNodeify(i.handler,{source:e,origin:r,data:t})}).then(function(e){return t({type:u.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:u.CONSTANTS.POST_MESSAGE_ACK.SUCCESS,data:e})},function(e){return t({type:u.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:u.CONSTANTS.POST_MESSAGE_ACK.ERROR,error:e.stack?e.message+"\n"+e.stack:e.toString()})})])["catch"](function(e){return i&&i.handleError?i.handleError(e):void s.log.error(e.stack||e.toString())})}),t(i,u.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,function(e,r,n){var t=d.listeners.response[n.hash];if(!t)throw new Error("No response handler found for post message response "+n.name+" in "+window.location.href);if(!o(t.domain,r))throw new Error("Response origin "+r+" does not match domain "+t.domain);if(delete d.listeners.response[n.hash],n.ack===u.CONSTANTS.POST_MESSAGE_ACK.ERROR)return t.respond(new Error(n.error));if(n.ack===u.CONSTANTS.POST_MESSAGE_ACK.SUCCESS){var i=n.data||n.response;return t.respond(null,{source:e,origin:r,data:i})}}),i)},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function o(e,r){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],t=s.util.uniqueID(),o=(0,s.getWindowType)(),i=s.util.getDomain(window);return a({},r,n,{sourceDomain:i,id:r.id||t,windowType:o})}function i(e,r,n){return s.promise.run(function(){r=o(e,r,{data:(0,s.serializeMethods)(e,n,r.data),domain:n});var i=void 0;if(i=u.POST_MESSAGE_NAMES_LIST.indexOf(r.name)!==-1||r.type===u.CONSTANTS.POST_MESSAGE_TYPE.ACK?"debug":"error"===r.ack?"error":"info",s.log.logLevel(i,["\n\n\t","#send",r.type.replace(/^postrobot_message_/,""),"::",r.name,"::",n||"*","\n\n",r]),u.CONFIG.MOCK_MODE)return delete r.target,window[u.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:s.util.getDomain(window),source:window,data:JSON.stringify(r)});if(e===window)throw new Error("Attemping to send message to self");if((0,s.isWindowClosed)(e))throw new Error("Window is closed");s.log.debug("Running send message strategies",r);var a=[],d=JSON.stringify(t({},u.CONSTANTS.WINDOW_PROPS.POSTROBOT,r),0,2);return s.promise.map(Object.keys(c.SEND_MESSAGE_STRATEGIES),function(r){return s.promise.run(function(){if(!u.CONFIG.ALLOWED_POST_MESSAGE_METHODS[r])throw new Error("Strategy disallowed: "+r);return c.SEND_MESSAGE_STRATEGIES[r](e,d,n)}).then(function(){return a.push(r+": success"),!0},function(e){return a.push(r+": "+e.message),!1})}).then(function(e){var n=s.util.some(e),t=r.type+" "+r.name+" "+(n?"success":"error")+":\n - "+a.join("\n - ")+"\n";if(s.log.debug(t),!n)throw new Error(t)})})}Object.defineProperty(r,"__esModule",{value:!0});var a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e};r.buildMessage=o,r.sendMessage=i;var u=n(3),s=n(8),c=n(22)},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{ | ||
value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}Object.defineProperty(r,"__esModule",{value:!0}),r.SEND_MESSAGE_STRATEGIES=void 0;var o,i=n(3),a=n(8),u=n(18),s=n(23);r.SEND_MESSAGE_STRATEGIES=(o={},t(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,function(e,r,n){return(0,u.emulateIERestrictions)(window,e),n&&0===n.indexOf(i.CONSTANTS.MOCK_PROTOCOL)&&(n=e.location.protocol+"//"+e.location.host),n&&0===n.indexOf(i.CONSTANTS.FILE_PROTOCOL)&&(n="*"),e.postMessage(r,n)}),t(o,i.CONSTANTS.SEND_STRATEGIES.BRIDGE,function(e,r,n){if((0,a.isSameDomain)(e))throw new Error("Post message through bridge disabled between same domain windows");if((0,a.isSameTopWindow)(window,e)!==!1)throw new Error("Can only use bridge to communicate between two different windows, not between frames");return(0,s.sendBridgeMessage)(e,r,n)}),o)},function(e,r,n){"use strict";function t(e){e=e||S.util.getDomainFromUrl(e);var r=e.replace(/[^a-zA-Z0-9]+/g,"_"),n=h.CONSTANTS.BRIDGE_NAME_PREFIX+"_"+r;return n}function o(){return new S.promise.Promise(function(e){return window.document&&window.document.body?e(window.document):void window.document.addEventListener("DOMContentLoaded",function(r){return e(window.document)})})}function i(e){try{var r=(0,S.getFrames)(e);if(!r||!r.length)return;for(var n=0;n<r.length;n++)try{var t=r[n];if(t&&t!==window&&(0,S.isSameDomain)(t)&&t[h.CONSTANTS.WINDOW_PROPS.POSTROBOT])return t}catch(o){continue}}catch(o){}}function a(e){var r=(arguments.length<=1||void 0===arguments[1]?h.CONFIG.BRIDGE_TIMEOUT:arguments[1],new S.promise.Promise);g.global.remoteWindows.push({win:e,sendMessagePromise:r})}function u(e,r,n){for(var t=g.global.remoteWindows,o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var u=a;if(u.win===e){var s=function(t,o,i){if(t!==e)throw new Error("Remote window does not match window");if("*"!==i&&i!==r)throw new Error("Remote domain "+i+" does not match domain "+r);n(o)};return u.sendMessagePromise.resolve(s),void(u.sendMessagePromise=S.promise.Promise.resolve(s))}}throw new Error("Window not found to register sendMessage to")}function s(e,r){for(var n=g.global.remoteWindows,t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;if(a.win===e)return a.sendMessagePromise.reject(r)}throw new Error("Window not found on which to reject sendMessage")}function c(e,r,n){var t=(0,S.isOpener)(window,e),o=(0,S.isOpener)(e,window);if(!t&&!o)throw new Error("Can only send messages to and from parent and popup windows");for(var i=g.global.remoteWindows,a=Array.isArray(i),u=0,i=a?i:i[Symbol.iterator]();;){var s;if(a){if(u>=i.length)break;s=i[u++]}else{if(u=i.next(),u.done)break;s=u.value}var c=s;if(c.win===e)return c.sendMessagePromise.then(function(t){return t(e,r,n)})}throw new Error("Window not found to send message to")}function d(e,r){for(var n=Object.keys(g.global.popupWindows),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var u=i,s=g.global.popupWindows[u];if(s.win===e){s.domain=S.util.getDomainFromUrl(r),a(e);break}}}function f(e,r){(0,O.on)(h.CONSTANTS.POST_MESSAGE_NAMES.OPEN_TUNNEL,{source:e,domain:r},function(e){var n=e.origin,t=e.data;if(n!==r)throw new Error("Domain "+r+" does not match origin "+n);if(!t.name)throw new Error("Register window expected to be passed window name");if(!t.sendMessage)throw new Error("Register window expected to be passed sendMessage method");var o=g.global.popupWindows[t.name];if(!o)throw new Error("Window with name "+t.name+" does not exist, or was not opened by this window");if(!o.domain)throw new Error("We do not have a registered domain for window "+t.name);if(o.domain!==n)throw new Error("Message origin "+n+" does not matched registered window origin "+o.domain);return u(o.win,r,t.sendMessage),{sendMessage:function(e){window&&!window.closed&&(0,b.receiveMessage)({data:e,origin:o.domain,source:o.win})}}})}function l(){var e=(0,S.getOpener)(window);if(e){a(e);var r=i(e);return r?window.name?void r[h.CONSTANTS.WINDOW_PROPS.POSTROBOT].openTunnel(e,{name:window.name,sendMessage:function(e){window&&!window.closed&&(0,b.receiveMessage)({data:e,origin:this.origin,source:this.source})}}).then(function(r){var n=r.source,t=r.origin,o=r.data;if(n!==e)throw new Error("Source does not match opener");u(n,t,o.sendMessage)})["catch"](function(r){throw s(e,r),r}):s(e,new Error("Can not register with opener: window does not have a name")):s(e,new Error("Can not register with opener: no bridge found in opener"))}}function w(e,r){S.log.debug("Opening bridge:",e,r);var n=document.createElement("iframe");return n.setAttribute("name",e),n.setAttribute("id",e),n.setAttribute("style","display: none; margin: 0; padding: 0; border: 0px none; overflow: hidden;"),n.setAttribute("frameborder","0"),n.setAttribute("border","0"),n.setAttribute("scrolling","no"),n.setAttribute("allowTransparency","true"),n.setAttribute("tabindex","-1"),n.setAttribute("hidden","true"),n.setAttribute("title",""),n.setAttribute("role","presentation"),n.src=r,n}function p(e,r){return r=r||S.util.getDomainFromUrl(e),S.util.getDomain()!==r}function m(e,r){return r=r||S.util.getDomainFromUrl(e),g.global.bridges[r]?g.global.bridges[r]:(g.global.bridges[r]=S.promise.run(function(){if(S.util.getDomain()===r)throw new Error("Can not open bridge on the same domain as current domain: "+r);var n=t(r),i=(0,S.getFrameByName)(window,n);if(i)throw new Error("Frame with name "+n+" already exists on page");var a=w(n,e);return o().then(function(n){n.body.appendChild(a);var t=a.contentWindow;return f(t,r),new S.promise.Promise(function(e,r){a.onload=e,a.onerror=r}).then(function(){return(0,S.onWindowReady)(t,h.CONFIG.BRIDGE_TIMEOUT,"Bridge "+e)}).then(function(){return t})})}),g.global.bridges[r])}Object.defineProperty(r,"__esModule",{value:!0});var v=function(){function e(e,r){var n=[],t=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(t=(a=u.next()).done)&&(n.push(a.value),!r||n.length!==r);t=!0);}catch(s){o=!0,i=s}finally{try{!t&&u["return"]&&u["return"]()}finally{if(o)throw i}}return n}return function(r,n){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return e(r,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();r.sendBridgeMessage=c,r.linkUrl=d,r.openTunnelToOpener=l,r.bridgeRequired=p,r.openBridge=m;var h=n(3),S=n(8),g=n(15),O=n(1),b=n(6);g.global.remoteWindows=g.global.remoteWindows||[],g.global.popupWindows=g.global.popupWindows||{};var E=window.open;window.open=function(e,r,n,t){var o=e;if(e&&0===e.indexOf(h.CONSTANTS.MOCK_PROTOCOL)){var i=e.split("|"),u=v(i,2);o=u[0],e=u[1]}o&&(o=S.util.getDomainFromUrl(o));var s=E.call(this,e,r,n,t);return e&&a(s),r&&(g.global.popupWindows[r]={win:s,domain:o}),s},g.global.openTunnel=function(e,r){var n=r.name,t=r.sendMessage;if(!e)throw new Error("No window found to open tunnel to");return(0,O.send)(e,h.CONSTANTS.POST_MESSAGE_NAMES.OPEN_TUNNEL,{name:n,sendMessage:function(){return t.apply(this,arguments)}},{domain:"*"})},g.global.bridges=g.global.bridges||{}},function(e,r,n){"use strict";function t(){u.global.listeners.request=[],u.global.listeners.response=[]}function o(e,r){for(var n=u.global.listeners.request,t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;if(a.name===e){if(!a.win||"*"===a.win)return a.options;if(r&&r===a.win)return a.options}}}function i(e){for(var r=void 0,n=u.global.listeners.request,t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;if(a.options===e){r=a;break}}r&&u.global.listeners.request.splice(u.global.listeners.request.indexOf(r),1)}function a(e,r,n,t){var a=o(e,r);if(a){if(!t)throw new Error("Request listener already exists for "+e);i(a)}s.request.push({name:e,win:r,options:n})}Object.defineProperty(r,"__esModule",{value:!0}),r.listeners=void 0,r.resetListeners=t,r.getRequestListener=o,r.removeRequestListener=i,r.addRequestListener=a;var u=n(15);u.global.listeners=u.global.listeners||{request:[],response:[]};var s=r.listeners=u.global.listeners},function(e,r,n){"use strict";function t(e){if(!e.name)throw new Error("Expected options.name");e.handler=e.handler||s.util.noop,e.errorHandler=e.errorHandler||function(e){throw e},e.once&&!function(){var r=e.handler;e.handler=s.util.once(function(){return(0,c.removeRequestListener)(e),r.apply(this,arguments)})}();var r=e.override||u.CONFIG.MOCK_MODE;return e.source&&(e.window=e.source),e.domain=e.domain||"*",(0,c.addRequestListener)(e.name,e.window,e,r),e.handleError=function(r){e.errorHandler(r)},e.window&&e.errorOnClose&&!function(){var r=s.util.safeInterval(function(){(0,s.isWindowClosed)(e.window)&&(r.cancel(),e.handleError(new Error("Post message target window is closed")))},50)}(),{cancel:function(){(0,c.removeRequestListener)(e)}}}function o(e,r,n,o){return"function"==typeof r&&(o=n,n=r,r={}),r=r||{},r.name=e,r.handler=n||r.handler,r.errorHandler=o||r.errorHandler,t(r)}function i(e,r,n,o){"function"==typeof r&&(o=n,n=r,r={}),r=r||{},r.name=e,r.handler=n||r.handler,r.errorHandler=o||r.errorHandler,r.once=!0;var i=new s.promise.Promise(function(e,n){r.handler=r.handler||function(r){return e(r)},r.errorHandler=r.errorHandler||n}),a=t(r);return s.util.extend(i,a),i}function a(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return{on:function(r,n,t){return o(r,e,n,t)}}}Object.defineProperty(r,"__esModule",{value:!0}),r.on=void 0,r.listen=t,r.once=i,r.listener=a;var u=n(3),s=n(8),c=n(6);r.on=o},function(e,r,n){"use strict";function t(){a.CONFIG.MOCK_MODE=!0}function o(){a.CONFIG.MOCK_MODE=!1}function i(){delete window[a.CONSTANTS.WINDOW_PROPS.POSTROBOT],window.removeEventListener("message",u.messageListener)}Object.defineProperty(r,"__esModule",{value:!0}),r.CONSTANTS=r.CONFIG=void 0,r.enableMockMode=t,r.disableMockMode=o;var a=n(3);Object.defineProperty(r,"CONFIG",{enumerable:!0,get:function(){return a.CONFIG}}),Object.defineProperty(r,"CONSTANTS",{enumerable:!0,get:function(){return a.CONSTANTS}}),r.disable=i;var u=n(6)}])}); |
{ | ||
"name": "post-robot", | ||
"version": "4.0.6", | ||
"version": "4.0.7", | ||
"description": "Simple postMessage based server.", | ||
@@ -5,0 +5,0 @@ "main": "dist/post-robot.min.js", |
@@ -19,2 +19,12 @@ | ||
if (!message) { | ||
return; | ||
} | ||
message = message[CONSTANTS.WINDOW_PROPS.POSTROBOT]; | ||
if (!message) { | ||
return; | ||
} | ||
if (!message.type) { | ||
@@ -21,0 +31,0 @@ return; |
@@ -65,2 +65,6 @@ | ||
let serializedMessage = JSON.stringify({ | ||
[ CONSTANTS.WINDOW_PROPS.POSTROBOT ]: message | ||
}, 0, 2); | ||
return promise.map(Object.keys(SEND_MESSAGE_STRATEGIES), strategyName => { | ||
@@ -74,3 +78,3 @@ | ||
return SEND_MESSAGE_STRATEGIES[strategyName](win, message, domain); | ||
return SEND_MESSAGE_STRATEGIES[strategyName](win, serializedMessage, domain); | ||
@@ -77,0 +81,0 @@ }).then(() => { |
@@ -21,3 +21,3 @@ | ||
return win.postMessage(JSON.stringify(message, 0, 2), domain); | ||
return win.postMessage(message, domain); | ||
}, | ||
@@ -35,4 +35,4 @@ | ||
return sendBridgeMessage(win, JSON.stringify(message, 0, 2), domain); | ||
return sendBridgeMessage(win, message, domain); | ||
} | ||
}; |
Sorry, the diff of this file is too big to display
235875
5130