post-robot
Advanced tools
Comparing version 10.0.19 to 10.0.20
@@ -190,6 +190,2 @@ "use strict"; | ||
if (name) { | ||
if (details.name && details.name !== name) { | ||
throw new Error(`Different window already linked for name ${name}: ${details.name}`); | ||
} | ||
details.name = name; | ||
@@ -196,0 +192,0 @@ popupWindowsByName.set(name, details); |
@@ -28,2 +28,22 @@ "use strict"; | ||
function resolveHelloPromise(win, { | ||
domain | ||
}) { | ||
const helloPromises = (0, _global.windowStore)('helloPromises'); | ||
const existingPromise = helloPromises.get(win); | ||
if (existingPromise) { | ||
existingPromise.resolve({ | ||
domain | ||
}); | ||
} | ||
const newPromise = _src2.ZalgoPromise.resolve({ | ||
domain | ||
}); | ||
helloPromises.set(win, newPromise); | ||
return newPromise; | ||
} | ||
function listenForHello({ | ||
@@ -38,4 +58,3 @@ on | ||
}) => { | ||
getHelloPromise(source).resolve({ | ||
win: source, | ||
resolveHelloPromise(source, { | ||
domain: origin | ||
@@ -63,4 +82,3 @@ }); | ||
}) => { | ||
getHelloPromise(win).resolve({ | ||
win, | ||
resolveHelloPromise(win, { | ||
domain: origin | ||
@@ -67,0 +85,0 @@ }); |
@@ -38,23 +38,20 @@ "use strict"; | ||
function normalizeDomain(win, domain, childTimeout, { | ||
function normalizeDomain(win, targetDomain, actualDomain, { | ||
send | ||
}) { | ||
if (typeof targetDomain === 'string') { | ||
return _src.ZalgoPromise.resolve(targetDomain); | ||
} | ||
return _src.ZalgoPromise.try(() => { | ||
if ((0, _src2.isAncestor)(window, win)) { | ||
return (0, _lib.awaitWindowHello)(win, childTimeout); | ||
} else if ((0, _src3.isRegex)(domain)) { | ||
// $FlowFixMe | ||
return (0, _lib.sayHello)(win, { | ||
send | ||
}); | ||
} else { | ||
return { | ||
domain | ||
}; | ||
} // $FlowFixMe | ||
return actualDomain || (0, _lib.sayHello)(win, { | ||
send | ||
}).then(({ | ||
domain | ||
}) => domain); | ||
}).then(normalizedDomain => { | ||
if (!(0, _src2.matchDomain)(targetDomain, targetDomain)) { | ||
throw new Error(`Domain ${(0, _src3.stringify)(targetDomain)} does not match ${(0, _src3.stringify)(targetDomain)}`); | ||
} | ||
}).then(({ | ||
domain: normalizedDomain | ||
}) => { | ||
// $FlowFixMe | ||
return normalizedDomain; | ||
@@ -73,10 +70,13 @@ }); | ||
validateOptions(name, win, domain); | ||
return normalizeDomain(win, domain, childTimeout, { | ||
if ((0, _src2.isAncestor)(window, win)) { | ||
return (0, _lib.awaitWindowHello)(win, childTimeout); | ||
} | ||
}).then(({ | ||
domain: actualDomain | ||
} = {}) => { | ||
return normalizeDomain(win, domain, actualDomain, { | ||
send | ||
}); | ||
}).then(targetDomain => { | ||
if (!(0, _src2.matchDomain)(domain, targetDomain)) { | ||
throw new Error(`Domain ${(0, _src3.stringify)(domain)} does not match ${(0, _src3.stringify)(targetDomain)}`); | ||
} | ||
domain = targetDomain; | ||
@@ -83,0 +83,0 @@ const logName = name === _conf.MESSAGE_NAME.METHOD && data && typeof data.name === 'string' ? `${data.name}()` : name; |
@@ -1,2 +0,2 @@ | ||
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("postRobot",[],e):"object"==typeof exports?exports.postRobot=e():n.postRobot=e()}("undefined"!=typeof self?self:this,(function(){return function(n){var e={};function r(t){if(e[t])return e[t].exports;var o=e[t]={i:t,l:!1,exports:{}};return n[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=n,r.c=e,r.d=function(n,e,t){r.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:t})},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,e){if(1&e&&(n=r(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)r.d(t,o,function(e){return n[e]}.bind(null,o));return t},r.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(e,"a",e),e},r.o=function(n,e){return{}.hasOwnProperty.call(n,e)},r.p="",r(r.s=0)}([function(n,e,r){"use strict";function t(n){return"[object RegExp]"==={}.toString.call(n)}r.r(e);var o={MOCK:"mock:",FILE:"file:",ABOUT:"about:"},i="*",a={IFRAME:"iframe",POPUP:"popup"},u="Call was rejected by callee.\r\n";function s(n){return void 0===n&&(n=window),n.location.protocol===o.ABOUT}function c(n){if(void 0===n&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function f(n){if(void 0===n&&(n=window),n&&!c(n))try{return n.opener}catch(n){}}function d(n){try{return!0}catch(n){}return!1}function w(n){var e=(n=n||window).location;if(!e)throw new Error("Can not read window location");var r=e.protocol;if(!r)throw new Error("Can not read window protocol");if(r===o.FILE)return o.FILE+"//";if(r===o.ABOUT){var t=c(n);return t&&d()?w(t):o.ABOUT+"//"}var i=e.host;if(!i)throw new Error("Can not read window host");return r+"//"+i}function h(n){var e=w(n=n||window);return e&&n.mockDomain&&0===n.mockDomain.indexOf(o.MOCK)?n.mockDomain:e}function l(n){if(!function(n){try{if(n===window)return!0}catch(n){}try{var e=Object.getOwnPropertyDescriptor(n,"location");if(e&&!1===e.enumerable)return!1}catch(n){}try{if(s(n)&&d())return!0}catch(n){}try{if(w(n)===w(window))return!0}catch(n){}return!1}(n))return!1;try{if(n===window)return!0;if(s(n)&&d())return!0;if(h(window)===h(n))return!0}catch(n){}return!1}function m(n){if(!l(n))throw new Error("Expected window to be same domain");return n}function v(n,e){if(!n||!e)return!1;var r=c(e);return r?r===n:-1!==function(n){var e=[];try{for(;n.parent!==n;)e.push(n.parent),n=n.parent}catch(n){}return e}(e).indexOf(n)}function p(n){var e,r,t=[];try{e=n.frames}catch(r){e=n}try{r=e.length}catch(n){}if(0===r)return t;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=e[o]}catch(n){continue}t.push(i)}return t}for(var a=0;a<100;a++){var u=void 0;try{u=e[a]}catch(n){return t}if(!u)return t;t.push(u)}return t}function g(n){for(var e=[],r=0,t=p(n);r<t.length;r++){var o=t[r];e.push(o);for(var i=0,a=g(o);i<a.length;i++)e.push(a[i])}return e}function y(n){if(n){try{if(n.top)return n.top}catch(n){}if(c(n)===n)return n;try{if(v(window,n)&&window.top)return window.top}catch(n){}try{if(v(n,window)&&window.top)return window.top}catch(n){}for(var e=0,r=g(n);e<r.length;e++){var t=r[e];try{if(t.top)return t.top}catch(n){}if(c(t)===t)return t}}}function _(n){var e=y(n);if(!e)throw new Error("Can not determine top window");return[].concat(g(e),[e])}var E=[],O=[];function b(n,e){void 0===e&&(e=!0);try{if(n===window)return!1}catch(n){return!0}try{if(!n)return!0}catch(n){return!0}try{if(n.closed)return!0}catch(n){return!n||n.message!==u}if(e&&l(n))try{if(n.mockclosed)return!0}catch(n){}try{if(!n.parent||!n.top)return!0}catch(n){}var r=function(n,e){for(var r=0;r<n.length;r++)try{if(n[r]===e)return r}catch(n){}return-1}(E,n);if(-1!==r){var t=O[r];if(t&&function(n){if(!n.contentWindow)return!0;if(!n.parentNode)return!0;var e=n.ownerDocument;return!(!e||!e.documentElement||e.documentElement.contains(n))}(t))return!0}return!1}function W(n){return(n=n||window).navigator.mockUserAgent||n.navigator.userAgent}function S(n,e){for(var r=p(n),t=0;t<r.length;t++){var o=r[t];try{if(l(o)&&o.name===e&&-1!==r.indexOf(o))return o}catch(n){}}try{if(-1!==r.indexOf(n.frames[e]))return n.frames[e]}catch(n){}try{if(-1!==r.indexOf(n[e]))return n[e]}catch(n){}}function x(n,e){return n===f(e)}function A(n){return void 0===n&&(n=window),f(n=n||window)||c(n)||void 0}function R(n,e){for(var r=0;r<n.length;r++)for(var t=n[r],o=0;o<e.length;o++)if(t===e[o])return!0;return!1}function N(n,e){var r=y(n)||n,t=y(e)||e;try{if(r&&t)return r===t}catch(n){}var o=_(n),i=_(e);if(R(o,i))return!0;var a=f(r),u=f(t);return!(a&&R(_(a),i)||(u&&R(_(u),o),1))}function P(n,e){if("string"==typeof n){if("string"==typeof e)return n===i||e===n;if(t(e))return!1;if(Array.isArray(e))return!1}return t(n)?t(e)?n.toString()===e.toString():!Array.isArray(e)&&Boolean(e.match(n)):!!Array.isArray(n)&&(Array.isArray(e)?JSON.stringify(n)===JSON.stringify(e):!t(e)&&n.some((function(n){return P(n,e)})))}function I(n){return n.match(/^(https?|mock|file):\/\//)?n.split("/").slice(0,3).join("/"):h()}function M(n){try{if(n===window)return!0}catch(n){if(n&&n.message===u)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===u)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===u)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===u)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===u)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===u)return!0}try{if(n&&"__unlikely_value__"===n.__cross_domain_utils_window_check__)return!1}catch(n){return!0}return!1}function k(n){try{n.close()}catch(n){}}function j(n){try{if(!n)return!1;if("undefined"!=typeof Promise&&n instanceof Promise)return!0;if("undefined"!=typeof window&&"function"==typeof window.Window&&n instanceof window.Window)return!1;if("undefined"!=typeof window&&"function"==typeof window.constructor&&n instanceof window.constructor)return!1;var e={}.toString;if(e){var r=e.call(n);if("[object Window]"===r||"[object global]"===r||"[object DOMWindow]"===r)return!1}if("function"==typeof n.then)return!0}catch(n){return!1}return!1}var D,T=[],C=[],L=0;function B(){if(!L&&D){var n=D;D=null,n.resolve()}}function F(){L+=1}function z(){L-=1,B()}var U=function(){function n(n){var e=this;if(this.resolved=void 0,this.rejected=void 0,this.errorHandled=void 0,this.value=void 0,this.error=void 0,this.handlers=void 0,this.dispatching=void 0,this.stack=void 0,this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],n){var r,t,o=!1,i=!1,a=!1;F();try{n((function(n){a?e.resolve(n):(o=!0,r=n)}),(function(n){a?e.reject(n):(i=!0,t=n)}))}catch(n){return z(),void this.reject(n)}z(),a=!0,o?this.resolve(r):i&&this.reject(t)}}var e=n.prototype;return e.resolve=function(n){if(this.resolved||this.rejected)return this;if(j(n))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=n,this.dispatch(),this},e.reject=function(n){var e=this;if(this.resolved||this.rejected)return this;if(j(n))throw new Error("Can not reject promise with another promise");if(!n){var r=n&&"function"==typeof n.toString?n.toString():{}.toString.call(n);n=new Error("Expected reject to be called with Error, got "+r)}return this.rejected=!0,this.error=n,this.errorHandled||setTimeout((function(){e.errorHandled||function(n,e){if(-1===T.indexOf(n)){T.push(n),setTimeout((function(){throw n}),1);for(var r=0;r<C.length;r++)C[r](n,e)}}(n,e)}),1),this.dispatch(),this},e.asyncReject=function(n){return this.errorHandled=!0,this.reject(n),this},e.dispatch=function(){var e=this,r=this.resolved,t=this.rejected,o=this.handlers;if(!this.dispatching&&(r||t)){this.dispatching=!0,F();for(var i=function(i){var a=o[i],u=a.onSuccess,s=a.onError,c=a.promise,f=void 0;if(r)try{f=u?u(e.value):e.value}catch(n){return c.reject(n),"continue"}else if(t){if(!s)return c.reject(e.error),"continue";try{f=s(e.error)}catch(n){return c.reject(n),"continue"}}f instanceof n&&(f.resolved||f.rejected)?(f.resolved?c.resolve(f.value):c.reject(f.error),f.errorHandled=!0):j(f)?f instanceof n&&(f.resolved||f.rejected)?f.resolved?c.resolve(f.value):c.reject(f.error):f.then((function(n){c.resolve(n)}),(function(n){c.reject(n)})):c.resolve(f)},a=0;a<o.length;a++)i(a);o.length=0,this.dispatching=!1,z()}},e.then=function(e,r){if(e&&"function"!=typeof e&&!e.call)throw new Error("Promise.then expected a function for success handler");if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.then expected a function for error handler");var t=new n;return this.handlers.push({promise:t,onSuccess:e,onError:r}),this.errorHandled=!0,this.dispatch(),t},e.catch=function(n){return this.then(void 0,n)},e.finally=function(e){if(e&&"function"!=typeof e&&!e.call)throw new Error("Promise.finally expected a function");return this.then((function(r){return n.try(e).then((function(){return r}))}),(function(r){return n.try(e).then((function(){throw r}))}))},e.timeout=function(n,e){var r=this;if(this.resolved||this.rejected)return this;var t=setTimeout((function(){r.resolved||r.rejected||r.reject(e||new Error("Promise timed out after "+n+"ms"))}),n);return this.then((function(n){return clearTimeout(t),n}))},e.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},n.resolve=function(e){return e instanceof n?e:j(e)?new n((function(n,r){return e.then(n,r)})):(new n).resolve(e)},n.reject=function(e){return(new n).reject(e)},n.asyncReject=function(e){return(new n).asyncReject(e)},n.all=function(e){var r=new n,t=e.length,o=[];if(!t)return r.resolve(o),r;for(var i=function(i){var a=e[i];if(a instanceof n){if(a.resolved)return o[i]=a.value,t-=1,"continue"}else if(!j(a))return o[i]=a,t-=1,"continue";n.resolve(a).then((function(n){o[i]=n,0==(t-=1)&&r.resolve(o)}),(function(n){r.reject(n)}))},a=0;a<e.length;a++)i(a);return 0===t&&r.resolve(o),r},n.hash=function(e){var r={};return n.all(Object.keys(e).map((function(t){return n.resolve(e[t]).then((function(n){r[t]=n}))}))).then((function(){return r}))},n.map=function(e,r){return n.all(e.map(r))},n.onPossiblyUnhandledException=function(n){return function(n){return C.push(n),{cancel:function(){C.splice(C.indexOf(n),1)}}}(n)},n.try=function(e,r,t){if(e&&"function"!=typeof e&&!e.call)throw new Error("Promise.try expected a function");var o;F();try{o=e.apply(r,t||[])}catch(e){return z(),n.reject(e)}return z(),n.resolve(o)},n.delay=function(e){return new n((function(n){setTimeout(n,e)}))},n.isPromise=function(e){return!!(e&&e instanceof n)||j(e)},n.flush=function(){return e=D=D||new n,B(),e;var e},n}();function H(){return(H=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)({}).hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n}).apply(this,arguments)}function q(n,e){for(var r=0;r<n.length;r++)try{if(n[r]===e)return r}catch(n){}return-1}var G,J=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__",function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var n=new WeakMap,e={};return Object.freeze(e),n.set(e,"__testvalue__"),"__testvalue__"===n.get(e)}catch(n){return!1}}())try{this.weakmap=new WeakMap}catch(n){}this.keys=[],this.values=[]}var e=n.prototype;return e._cleanupClosedWindows=function(){for(var n=this.weakmap,e=this.keys,r=0;r<e.length;r++){var t=e[r];if(M(t)&&b(t)){if(n)try{n.delete(t)}catch(n){}e.splice(r,1),this.values.splice(r,1),r-=1}}},e.isSafeToReadWrite=function(n){return!M(n)},e.set=function(n,e){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.set(n,e)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var t=this.name,o=n[t];return void(o&&o[0]===n?o[1]=e:Object.defineProperty(n,t,{value:[n,e],writable:!0}))}catch(n){}this._cleanupClosedWindows();var i=this.keys,a=this.values,u=q(i,n);-1===u?(i.push(n),a.push(e)):a[u]=e},e.get=function(n){if(!n)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{if(e.has(n))return e.get(n)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var r=n[this.name];return r&&r[0]===n?r[1]:void 0}catch(n){}this._cleanupClosedWindows();var t=q(this.keys,n);if(-1!==t)return this.values[t]},e.delete=function(n){if(!n)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{e.delete(n)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var r=n[this.name];r&&r[0]===n&&(r[0]=r[1]=void 0)}catch(n){}this._cleanupClosedWindows();var t=this.keys,o=q(t,n);-1!==o&&(t.splice(o,1),this.values.splice(o,1))},e.has=function(n){if(!n)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{if(e.has(n))return!0}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var r=n[this.name];return!(!r||r[0]!==n)}catch(n){}return this._cleanupClosedWindows(),-1!==q(this.keys,n)},e.getOrSet=function(n,e){if(this.has(n))return this.get(n);var r=e();return this.set(n,r),r},n}();function X(){var n="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,(function(){return n.charAt(Math.floor(Math.random()*n.length))}))+"_"+function(n){if("function"==typeof btoa)return btoa(encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(function(n,e){return String.fromCharCode(parseInt(e,16))})));if("undefined"!=typeof Buffer)return Buffer.from(n,"utf8").toString("base64");throw new Error("Can not find window.btoa or Buffer")}((new Date).toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}function Y(n){var e={};function r(){for(var r=this,t=arguments,o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var u=function(n){try{return JSON.stringify([].slice.call(n),(function(n,e){return"function"==typeof e?"memoize["+function(n){if(G=G||new J,null==n||"object"!=typeof n&&"function"!=typeof n)throw new Error("Invalid object");var e=G.get(n);return e||(e=typeof n+":"+X(),G.set(n,e)),e}(e)+"]":e}))}catch(n){throw new Error("Arguments not serializable -- can not be used to memoize")}}(i);return e.hasOwnProperty(u)?e[u]:(e[u]=U.try((function(){return n.apply(r,t)})).finally((function(){delete e[u]})),e[u])}return r.reset=function(){e={}},r}function Z(){}function K(n,e){if(void 0===e&&(e=1),e>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+{}.toString.call(n)+">";if("string"==typeof n)return n;if(n instanceof Error){var r=n&&n.stack,t=n&&n.message;if(r&&t)return-1!==r.indexOf(t)?r:t+"\n"+r;if(r)return r;if(t)return t}return n&&n.toString&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}catch(n){return"Error while stringifying error: "+K(n,e+1)}}function Q(n){return"string"==typeof n?n:n&&n.toString&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}function V(n){return"[object RegExp]"==={}.toString.call(n)}function $(n,e,r){if(n.hasOwnProperty(e))return n[e];var t=r();return n[e]=t,t}Object.create(Error.prototype);var nn={METHOD:"postrobot_method",HELLO:"postrobot_hello",OPEN_TUNNEL:"postrobot_open_tunnel"},en="__postrobot_bridge__",rn="*",tn={CROSS_DOMAIN_ZALGO_PROMISE:"cross_domain_zalgo_promise",CROSS_DOMAIN_FUNCTION:"cross_domain_function",CROSS_DOMAIN_WINDOW:"cross_domain_window"};function on(n){return void 0===n&&(n=window),n!==window?n.__post_robot_10_0_19__:n.__post_robot_10_0_19__=n.__post_robot_10_0_19__||{}}var an=function(){return{}};function un(n,e){return void 0===n&&(n="store"),void 0===e&&(e=an),$(on(),n,(function(){var n=e();return{has:function(e){return n.hasOwnProperty(e)},get:function(e,r){return n.hasOwnProperty(e)?n[e]:r},set:function(e,r){return n[e]=r,r},del:function(e){delete n[e]},getOrSet:function(e,r){return $(n,e,r)},reset:function(){n=e()},keys:function(){return Object.keys(n)}}}))}var sn=function(){};function cn(){var n=on();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new sn,n.WINDOW_WILDCARD}function fn(n,e){return void 0===n&&(n="store"),void 0===e&&(e=an),un("windowStore").getOrSet(n,(function(){var r=new J,t=function(n){return r.getOrSet(n,e)};return{has:function(e){return t(e).hasOwnProperty(n)},get:function(e,r){var o=t(e);return o.hasOwnProperty(n)?o[n]:r},set:function(e,r){return t(e)[n]=r,r},del:function(e){delete t(e)[n]},getOrSet:function(e,r){return $(t(e),n,r)}}}))}function dn(){return un("instance").getOrSet("instanceID",X)}function wn(n){return fn("helloPromises").getOrSet(n,(function(){return new U}))}function hn(n,e){return(0,e.send)(n,nn.HELLO,{instanceID:dn()},{domain:rn,timeout:-1}).then((function(e){var r=e.origin,t=e.data.instanceID;return wn(n).resolve({win:n,domain:r}),{win:n,domain:r,instanceID:t}}))}function ln(n,e){var r=e.send;return fn("windowInstanceIDPromises").getOrSet(n,(function(){return hn(n,{send:r}).then((function(n){return n.instanceID}))}))}function mn(n,e,r){void 0===e&&(e=5e3),void 0===r&&(r="Window");var t=wn(n);return-1!==e&&(t=t.timeout(e,new Error(r+" did not load after "+e+"ms"))),t}function vn(n){fn("knownWindows").set(n,!0)}var pn,gn={FUNCTION:"function",ERROR:"error",PROMISE:"promise",REGEX:"regex",DATE:"date",ARRAY:"array",OBJECT:"object",STRING:"string",NUMBER:"number",BOOLEAN:"boolean",NULL:"null",UNDEFINED:"undefined"};function yn(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function _n(n){return void 0===n?gn.UNDEFINED:null===n?gn.NULL:Array.isArray(n)?gn.ARRAY:"function"==typeof n?gn.FUNCTION:"object"==typeof n?n instanceof Error?gn.ERROR:"function"==typeof n.then?gn.PROMISE:"[object RegExp]"==={}.toString.call(n)?gn.REGEX:"[object Date]"==={}.toString.call(n)?gn.DATE:gn.OBJECT:"string"==typeof n?gn.STRING:"number"==typeof n?gn.NUMBER:"boolean"==typeof n?gn.BOOLEAN:void 0}function En(n,e){return{__type__:n,__val__:e}}var On,bn=((pn={})[gn.FUNCTION]=function(){},pn[gn.ERROR]=function(n){return En(gn.ERROR,{message:n.message,stack:n.stack,code:n.code})},pn[gn.PROMISE]=function(){},pn[gn.REGEX]=function(n){return En(gn.REGEX,n.source)},pn[gn.DATE]=function(n){return En(gn.DATE,n.toJSON())},pn[gn.ARRAY]=function(n){return n},pn[gn.OBJECT]=function(n){return n},pn[gn.STRING]=function(n){return n},pn[gn.NUMBER]=function(n){return n},pn[gn.BOOLEAN]=function(n){return n},pn[gn.NULL]=function(n){return n},pn),Wn={},Sn=((On={})[gn.FUNCTION]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},On[gn.ERROR]=function(n){var e=n.stack,r=n.code,t=new Error(n.message);return t.code=r,t.stack=e+"\n\n"+t.stack,t},On[gn.PROMISE]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},On[gn.REGEX]=function(n){return new RegExp(n)},On[gn.DATE]=function(n){return new Date(n)},On[gn.ARRAY]=function(n){return n},On[gn.OBJECT]=function(n){return n},On[gn.STRING]=function(n){return n},On[gn.NUMBER]=function(n){return n},On[gn.BOOLEAN]=function(n){return n},On[gn.NULL]=function(n){return n},On),xn={};function An(){return!!W(window).match(/MSIE|trident|edge\/12|edge\/13/i)}function Rn(n){return!N(window,n)}function Nn(n,e){if(n){if(h()!==I(n))return!0}else if(e&&!l(e))return!0;return!1}function Pn(n){var e=n.win,r=n.domain;return!(!An()||r&&!Nn(r,e)||e&&!Rn(e))}function In(n){var e=(n=n||I(n)).replace(/[^a-zA-Z0-9]+/g,"_");return en+"_"+e}function Mn(){return Boolean(window.name&&window.name===In(h()))}var kn=new U((function(n){if(window.document&&window.document.body)return n(window.document.body);var e=setInterval((function(){if(window.document&&window.document.body)return clearInterval(e),n(window.document.body)}),10)}));function jn(n){fn("remoteWindowPromises").getOrSet(n,(function(){return new U}))}function Dn(n){var e=fn("remoteWindowPromises").get(n);if(!e)throw new Error("Remote window promise not found");return e}function Tn(n,e,r){Dn(n).resolve((function(t,o,i){if(t!==n)throw new Error("Remote window does not match window");if(!P(o,e))throw new Error("Remote domain "+o+" does not match domain "+e);r.fireAndForget(i)}))}function Cn(n,e){Dn(n).reject(e).catch(Z)}function Ln(n){for(var e=n.win,r=n.name,t=n.domain,o=un("popupWindowsByName"),i=fn("popupWindowsByWin"),a=0,u=o.keys();a<u.length;a++){var s=u[a],c=o.get(s);c&&!b(c.win)||o.del(s)}var f=i.getOrSet(e,(function(){return r?o.getOrSet(r,(function(){return{win:e,name:r}})):{win:e}}));if(f.win&&f.win!==e)throw new Error("Different window already linked for window: "+(r||"undefined"));if(r){if(f.name&&f.name!==r)throw new Error("Different window already linked for name "+r+": "+f.name);f.name=r,o.set(r,f)}return t&&(f.domain=t,jn(e)),i.set(e,f),f}function Bn(n){var e,r=n.on,t=n.send,i=n.receiveMessage;e=window.open,window.open=function(n,r,t,i){var a=e.call(this,function(n){if(0!==I(n).indexOf(o.MOCK))return n;throw new Error("Mock urls not supported out of test mode")}(n),r,t,i);return a?(Ln({win:a,name:r,domain:n?I(n):null}),a):a},function(n){var e=n.on,r=n.send,t=n.receiveMessage,o=un("popupWindowsByName");e(nn.OPEN_TUNNEL,(function(n){var i=n.source,a=n.origin,u=n.data,s=un("bridges").get(a);if(!s)throw new Error("Can not find bridge promise for domain "+a);return s.then((function(n){if(i!==n)throw new Error("Message source does not matched registered bridge for domain "+a);if(!u.name)throw new Error("Register window expected to be passed window name");if(!u.sendMessage)throw new Error("Register window expected to be passed sendMessage method");if(!o.has(u.name))throw new Error("Window with name "+u.name+" does not exist, or was not opened by this window");if(!o.get(u.name).domain)throw new Error("We do not have a registered domain for window "+u.name);if(o.get(u.name).domain!==a)throw new Error("Message origin "+a+" does not matched registered window origin "+o.get(u.name).domain);return Tn(o.get(u.name).win,a,u.sendMessage),{sendMessage:function(n){if(window&&!window.closed){var i=o.get(u.name);if(i)try{t({data:n,origin:i.domain,source:i.win},{on:e,send:r})}catch(n){U.reject(n)}}}}}))}))}({on:r,send:t,receiveMessage:i}),function(n){var e=n.send;on(window).openTunnelToParent=function(n){var r=n.name,t=n.source,o=n.canary,i=n.sendMessage,a=un("tunnelWindows"),u=c(window);if(!u)throw new Error("No parent window found to open tunnel to");var s=function(n){var e=n.name,r=n.source,t=n.canary,o=n.sendMessage;!function(){for(var n=un("tunnelWindows"),e=0,r=n.keys();e<r.length;e++){var t=r[e];b(n[t].source)&&n.del(t)}}();var i=X();return un("tunnelWindows").set(i,{name:e,source:r,canary:t,sendMessage:o}),i}({name:r,source:t,canary:o,sendMessage:i});return e(u,nn.OPEN_TUNNEL,{name:r,sendMessage:function(){var n=a.get(s);if(n&&n.source&&!b(n.source)){try{n.canary()}catch(n){return}n.sendMessage.apply(this,arguments)}}},{domain:rn})}}({on:r,send:t}),function(n){var e=n.on,r=n.send,t=n.receiveMessage;U.try((function(){var n,o=f(window);if(o&&Pn({win:o}))return jn(o),(n=o,fn("remoteBridgeAwaiters").getOrSet(n,(function(){return U.try((function(){var e=S(n,In(h()));if(e)return l(e)&&on(m(e))?e:new U((function(n){var r,t;r=setInterval((function(){if(e&&l(e)&&on(m(e)))return clearInterval(r),clearTimeout(t),n(e)}),100),t=setTimeout((function(){return clearInterval(r),n()}),2e3)}))}))}))).then((function(n){return n?window.name?on(m(n)).openTunnelToParent({name:window.name,source:window,canary:function(){},sendMessage:function(n){if(window&&!window.closed)try{t({data:n,origin:this.origin,source:this.source},{on:e,send:r})}catch(n){U.reject(n)}}}).then((function(n){var e=n.source,r=n.origin,t=n.data;if(e!==o)throw new Error("Source does not match opener");Tn(e,r,t.sendMessage)})).catch((function(n){throw Cn(o,n),n})):Cn(o,new Error("Can not register with opener: window does not have a name")):Cn(o,new Error("Can not register with opener: no bridge found in opener"))}))}))}({on:r,send:t,receiveMessage:i})}function Fn(){for(var n=un("idToProxyWindow"),e=0,r=n.keys();e<r.length;e++){var t=r[e];n.get(t).shouldClean()&&n.del(t)}}var zn=function(){function n(n){var e=n.send,r=n.win,t=n.serializedWindow;this.id=void 0,this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.name=void 0,this.actualWindowPromise=new U,this.serializedWindow=t||function(n,e){var r,t=e.send;return{id:X(),getType:function(){return n.then((function(n){return f(n)?a.POPUP:a.IFRAME}))},getInstanceID:Y((function(){return n.then((function(n){return ln(n,{send:t})}))})),close:function(){return n.then(k)},getName:function(){return n.then((function(n){if(!b(n))return r}))},focus:function(){return n.then((function(n){n.focus()}))},isClosed:function(){return n.then((function(n){return b(n)}))},setLocation:function(e){return n.then((function(n){if(l(n))try{if(n.location&&"function"==typeof n.location.replace)return void n.location.replace(e)}catch(n){}n.location=e}))},setName:function(e){return n.then((function(n){Ln({win:n,name:e});var t=m(n);t.name=e,t.frameElement&&t.frameElement.setAttribute("name",e),r=e}))}}}(this.actualWindowPromise,{send:e}),un("idToProxyWindow").set(this.getID(),this),r&&this.setWindow(r)}var e=n.prototype;return e.getID=function(){return this.serializedWindow.id},e.getType=function(){return this.serializedWindow.getType()},e.isPopup=function(){return this.getType()===a.POPUP},e.setLocation=function(n){var e=this;return this.serializedWindow.setLocation(n).then((function(){return e}))},e.getName=function(){return this.serializedWindow.getName()},e.setName=function(n){var e=this;return this.serializedWindow.setName(n).then((function(){return e}))},e.close=function(){var n=this;return this.serializedWindow.close().then((function(){return n}))},e.focus=function(){var n=this;return U.all([this.isPopup()&&this.getName().then((function(n){n&&window.open("",n)})),this.serializedWindow.focus()]).then((function(){return n}))},e.isClosed=function(){return this.serializedWindow.isClosed()},e.getWindow=function(){return this.actualWindow},e.setWindow=function(n){this.actualWindow=n,this.actualWindowPromise.resolve(this.actualWindow),fn("winToProxyWindow").set(n,this)},e.awaitWindow=function(){return this.actualWindowPromise},e.matchWindow=function(n,e){var r=this,t=e.send;return U.try((function(){return r.actualWindow?n===r.actualWindow:U.hash({proxyInstanceID:r.getInstanceID(),knownWindowInstanceID:ln(n,{send:t})}).then((function(e){var t=e.proxyInstanceID===e.knownWindowInstanceID;return t&&r.setWindow(n),t}))}))},e.unwrap=function(){return this.actualWindow||this},e.getInstanceID=function(){return this.serializedWindow.getInstanceID()},e.shouldClean=function(){return Boolean(this.actualWindow&&b(this.actualWindow))},e.serialize=function(){return this.serializedWindow},n.unwrap=function(e){return n.isProxyWindow(e)?e.unwrap():e},n.serialize=function(e,r){var t=r.send;return Fn(),n.toProxyWindow(e,{send:t}).serialize()},n.deserialize=function(e,r){var t=r.send;return Fn(),un("idToProxyWindow").get(e.id)||new n({serializedWindow:e,send:t})},n.isProxyWindow=function(n){return Boolean(n&&!M(n)&&n.isProxyWindow)},n.toProxyWindow=function(e,r){var t=r.send;if(Fn(),n.isProxyWindow(e))return e;var o=e;return fn("winToProxyWindow").get(o)||new n({win:o,send:t})},n}();function Un(n,e,r,t,o){var i=fn("methodStore"),a=un("proxyWindowMethods");zn.isProxyWindow(t)?a.set(n,{val:e,name:r,domain:o,source:t}):(a.del(n),i.getOrSet(t,(function(){return{}}))[n]={domain:o,name:r,val:e,source:t})}function Hn(n,e){var r=fn("methodStore"),t=un("proxyWindowMethods");return r.getOrSet(n,(function(){return{}}))[e]||t.get(e)}function qn(n,e,r,t,o){!function(n){var e=n.on,r=n.send;un("builtinListeners").getOrSet("functionCalls",(function(){return e(nn.METHOD,{domain:rn},(function(n){var e=n.source,t=n.origin,o=n.data,i=o.id,a=o.name,u=Hn(e,i);if(!u)throw new Error("Could not find method '"+o.name+"' with id: "+o.id+" in "+h(window));var s=u.source,c=u.domain,f=u.val;return U.try((function(){if(!P(c,t))throw new Error("Method '"+o.name+"' domain "+JSON.stringify(V(u.domain)?u.domain.source:u.domain)+" does not match origin "+t+" in "+h(window));if(zn.isProxyWindow(s))return s.matchWindow(e,{send:r}).then((function(n){if(!n)throw new Error("Method call '"+o.name+"' failed - proxy window does not match source in "+h(window))}))})).then((function(){return f.apply({source:e,origin:t},o.args)}),(function(n){return U.try((function(){if(f.onError)return f.onError(n)})).then((function(){throw n.stack&&(n.stack="Remote call to "+a+"()\n\n"+n.stack),n}))})).then((function(n){return{result:n,id:i,name:a}}))}))}))}({on:o.on,send:o.send});var i=r.__id__||X();n=zn.unwrap(n);var a=r.__name__||r.name||t;return zn.isProxyWindow(n)?(Un(i,r,a,n,e),n.awaitWindow().then((function(n){Un(i,r,a,n,e)}))):Un(i,r,a,n,e),En(tn.CROSS_DOMAIN_FUNCTION,{id:i,name:a})}function Gn(n,e,r,t){var o,i=t.on,a=t.send;return function(n,e){void 0===e&&(e=Wn);var r=JSON.stringify(n,(function(n){var r=this[n];if(yn(this))return r;var t=_n(r);if(!t)return r;var o=e[t]||bn[t];return o?o(r,n):r}));return void 0===r?gn.UNDEFINED:r}(r,((o={})[gn.PROMISE]=function(r,t){return function(n,e,r,t,o){return En(tn.CROSS_DOMAIN_ZALGO_PROMISE,{then:qn(n,e,(function(n,e){return r.then(n,e)}),t,{on:o.on,send:o.send})})}(n,e,r,t,{on:i,send:a})},o[gn.FUNCTION]=function(r,t){return qn(n,e,r,t,{on:i,send:a})},o[gn.OBJECT]=function(n){return M(n)||zn.isProxyWindow(n)?En(tn.CROSS_DOMAIN_WINDOW,zn.serialize(n,{send:a})):n},o))}function Jn(n,e,r,t){var o,i=t.on,a=t.send;return function(n,e){if(void 0===e&&(e=xn),n!==gn.UNDEFINED)return JSON.parse(n,(function(n,r){if(yn(this))return r;var t,o;if(yn(r)?(t=r.__type__,o=r.__val__):(t=_n(r),o=r),!t)return o;var i=e[t]||Sn[t];return i?i(o,n):o}))}(r,((o={})[tn.CROSS_DOMAIN_ZALGO_PROMISE]=function(n){return function(n,e,r){return new U(r.then)}(0,0,n)},o[tn.CROSS_DOMAIN_FUNCTION]=function(r){return function(n,e,r,t){var o=r.id,i=r.name,a=t.send,u=function(r){function t(){var u=arguments;return zn.toProxyWindow(n,{send:a}).awaitWindow().then((function(n){var s=Hn(n,o);if(s&&s.val!==t)return s.val.apply({source:window,origin:h()},u);var c={domain:e,fireAndForget:r.fireAndForget},f=[].slice.call(u);return a(n,nn.METHOD,{id:o,name:i,args:f},c).then((function(n){if(!r.fireAndForget)return n.data.result}))})).catch((function(n){throw n}))}return void 0===r&&(r={}),t.__name__=i,t.__origin__=e,t.__source__=n,t.__id__=o,t.origin=e,t},s=u();return s.fireAndForget=u({fireAndForget:!0}),s}(n,e,r,{on:i,send:a})},o[tn.CROSS_DOMAIN_WINDOW]=function(n){return zn.deserialize(n,{send:a})},o))}var Xn={};function Yn(n,e,r,t){var o,i=t.on,a=t.send;if(b(n))throw new Error("Window is closed");for(var u=Gn(n,e,((o={}).__post_robot_10_0_19__=H({id:X(),origin:h(window)},r),o),{on:i,send:a}),s=Object.keys(Xn),c=[],f=0;f<s.length;f++){var d=s[f];try{Xn[d](n,u,e)}catch(n){c.push(n)}}if(c.length===s.length)throw new Error("All post-robot messaging strategies failed:\n\n"+c.map(K).join("\n\n"))}Xn.postrobot_post_message=function(n,e,r){(Array.isArray(r)?r:"string"==typeof r?[r]:[rn]).map((function(n){return 0===n.indexOf(o.FILE)?rn:n})).forEach((function(r){n.postMessage(e,r)}))},Xn.postrobot_bridge=function(n,e,r){if(An()||Mn()){if(l(n))throw new Error("Post message through bridge disabled between same domain windows");if(!1!==N(window,n))throw new Error("Can only use bridge to communicate between two different windows, not between frames");!function(n,e,r){var t=x(window,n),o=x(n,window);if(!t&&!o)throw new Error("Can only send messages to and from parent and popup windows");Dn(n).then((function(t){return t(n,e,r)}))}(n,r,e)}},Xn.postrobot_global=function(n,e){if(W(window).match(/MSIE|rv:11|trident|edge\/12|edge\/13/i)){if(!l(n))throw new Error("Post message through global disabled between different domain windows");if(!1!==N(window,n))throw new Error("Can only use global to communicate between two different windows, not between frames");var r=on(n);if(!r)throw new Error("Can not find postRobot global on foreign window");r.receiveMessage({source:window,origin:h(),data:e})}};var Zn,Kn="__domain_regex__";function Qn(n){return un("responseListeners").get(n)}function Vn(n){un("responseListeners").del(n)}function $n(n){return un("erroredResponseListeners").has(n)}function ne(n){var e=n.name,r=n.win,t=n.domain,o=fn("requestListeners");if(r===rn&&(r=null),t===rn&&(t=null),!e)throw new Error("Name required to get request listener");for(var i=0,a=[r,cn()];i<a.length;i++){var u=a[i];if(u){var s=o.get(u);if(s){var c=s[e];if(c){if(t&&"string"==typeof t){if(c[t])return c[t];if(c[Kn])for(var f=0,d=c[Kn];f<d.length;f++){var w=d[f],h=w.listener;if(P(w.regex,t))return h}}if(c[rn])return c[rn]}}}}}var ee=((Zn={}).postrobot_message_request=function(n,e,r,t){var o=t.on,i=t.send,a=ne({name:r.name,win:n,domain:e});function u(t,a,u){void 0===u&&(u={}),r.fireAndForget||b(n)||Yn(n,e,H({type:t,ack:a,hash:r.hash,name:r.name},u),{on:o,send:i})}return U.all([u("postrobot_message_ack"),U.try((function(){if(!a)throw new Error("No handler found for post message: "+r.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!P(a.domain,e))throw new Error("Request origin "+e+" does not match domain "+a.domain.toString());return a.handler({source:n,origin:e,data:r.data})})).then((function(n){return u("postrobot_message_response","success",{data:n})}),(function(n){return u("postrobot_message_response","error",{error:n})}))]).then(Z).catch((function(n){if(a&&a.handleError)return a.handleError(n);throw n}))},Zn.postrobot_message_ack=function(n,e,r){if(!$n(r.hash)){var t=Qn(r.hash);if(!t)throw new Error("No handler found for post message ack for message: "+r.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!P(t.domain,e))throw new Error("Ack origin "+e+" does not match domain "+t.domain.toString());if(n!==t.win)throw new Error("Ack source does not match registered window");t.ack=!0}},Zn.postrobot_message_response=function(n,e,r){if(!$n(r.hash)){var o,i=Qn(r.hash);if(!i)throw new Error("No handler found for post message response for message: "+r.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!P(i.domain,e))throw new Error("Response origin "+e+" does not match domain "+(o=i.domain,Array.isArray(o)?"("+o.join(" | ")+")":t(o)?"RegExp("+o.toString():o.toString()));if(n!==i.win)throw new Error("Response source does not match registered window");Vn(r.hash),"error"===r.ack?i.promise.reject(r.error):"success"===r.ack&&i.promise.resolve({source:n,origin:e,data:r.data})}},Zn);function re(n,e){var r=e.on,t=e.send,i=un("receivedMessages");if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!n.source)return}catch(n){return}var a=n.source,u=n.origin,s=function(n,e,r,t){var o,i=t.on,a=t.send;try{o=Jn(e,r,n,{on:i,send:a})}catch(n){return}if(o&&"object"==typeof o&&null!==o&&(o=o.__post_robot_10_0_19__)&&"object"==typeof o&&null!==o&&o.type&&"string"==typeof o.type&&ee[o.type])return o}(n.data,a,u,{on:r,send:t});s&&(vn(a),i.has(s.id)||(i.set(s.id,!0),b(a)&&!s.fireAndForget||(0===s.origin.indexOf(o.FILE)&&(u=o.FILE+"//"),ee[s.type](a,u,s,{on:r,send:t}))))}function te(n,e,r){if(!n)throw new Error("Expected name");if("function"==typeof e&&(r=e,e={}),!r)throw new Error("Expected handler");(e=e||{}).name=n,e.handler=r||e.handler;var t=e.window,o=e.domain,i=function n(e,r){var t=e.name,o=e.win,i=e.domain,a=fn("requestListeners");if(!t||"string"!=typeof t)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var u=[],s=0,c=o;s<c.length;s++)u.push(n({name:t,domain:i,win:c[s]},r));return{cancel:function(){for(var n=0;n<u.length;n++)u[n].cancel()}}}if(Array.isArray(i)){for(var f=[],d=0,w=i;d<w.length;d++)f.push(n({name:t,win:o,domain:w[d]},r));return{cancel:function(){for(var n=0;n<f.length;n++)f[n].cancel()}}}var h=ne({name:t,win:o,domain:i});if(o&&o!==rn||(o=cn()),i=i||rn,h)throw o&&i?new Error("Request listener already exists for "+t+" on domain "+i.toString()+" for "+(o===cn()?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+t+" for "+(o===cn()?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+t+" on domain "+i.toString()):new Error("Request listener already exists for "+t);var l,m,v=a.getOrSet(o,(function(){return{}})),p=$(v,t,(function(){return{}})),g=i.toString();return V(i)?(l=$(p,Kn,(function(){return[]}))).push(m={regex:i,listener:r}):p[g]=r,{cancel:function(){delete p[g],m&&(l.splice(l.indexOf(m,1)),l.length||delete p[Kn]),Object.keys(p).length||delete v[t],o&&!Object.keys(v).length&&a.del(o)}}}({name:n,win:t,domain:o},{handler:e.handler,handleError:e.errorHandler||function(n){throw n},window:t,domain:o||rn,name:n});return{cancel:function(){i.cancel()}}}function oe(n,e,r){"function"==typeof(e=e||{})&&(r=e,e={});var t,o=new U;return e.errorHandler=function(n){t.cancel(),o.reject(n)},t=te(n,e,(function(n){if(t.cancel(),o.resolve(n),r)return r(n)})),o.cancel=t.cancel,o}var ie,ae=function n(e,r,t,o){var i=(o=o||{}).domain||rn,a=o.timeout||-1,u=o.timeout||5e3,s=o.fireAndForget||!1;return U.try((function(){return function(n,e,r){if(!n)throw new Error("Expected name");if(r&&"string"!=typeof r&&!Array.isArray(r)&&!V(r))throw new TypeError("Expected domain to be a string, array, or regex");if(b(e))throw new Error("Target window is closed")}(r,e,i),function(n,e,r,t){var o=t.send;return U.try((function(){return function(n,e){var r=A(e);if(r)return r===n;if(e===n)return!1;if(y(e)===e)return!1;for(var t=0,o=p(n);t<o.length;t++)if(o[t]===e)return!0;return!1}(window,n)?mn(n,r):V(e)?hn(n,{send:o}):{domain:e}})).then((function(n){return n.domain}))}(e,i,u,{send:n})})).then((function(o){if(!P(i,o))throw new Error("Domain "+Q(i)+" does not match "+Q(o));i=o;var u,c,f=r===nn.METHOD&&t&&"string"==typeof t.name?t.name+"()":r,d=new U,w=r+"_"+X();if(!s){var l={name:r,win:e,domain:i,promise:d};!function(n,e){un("responseListeners").set(n,e)}(w,l);var m=fn("requestPromises").getOrSet(e,(function(){return[]}));m.push(d),d.catch((function(){!function(n){un("erroredResponseListeners").set(n,!0)}(w),Vn(w)}));var v=function(n){return fn("knownWindows").get(n,!1)}(e)?1e4:2e3,p=a,g=v,y=p,_=(u=function(){return b(e)?d.reject(new Error("Window closed for "+r+" before "+(l.ack?"response":"ack"))):l.cancelled?d.reject(new Error("Response listener was cancelled for "+r)):(g=Math.max(g-500,0),-1!==y&&(y=Math.max(y-500,0)),l.ack||0!==g?0===y?d.reject(new Error("No response for postMessage "+f+" in "+h()+" in "+p+"ms")):void 0:d.reject(new Error("No ack for postMessage "+f+" in "+h()+" in "+v+"ms")))},500,function n(){c=setTimeout((function(){u(),n()}),500)}(),{cancel:function(){clearTimeout(c)}});d.finally((function(){_.cancel(),m.splice(m.indexOf(d,1))})).catch(Z)}return Yn(e,i,{type:"postrobot_message_request",hash:w,name:r,data:t,fireAndForget:s},{on:te,send:n}),s?d.resolve():d}))};function ue(n,e,r){return Gn(n,e,r,{on:te,send:ae})}function se(n,e,r){return Jn(n,e,r,{on:te,send:ae})}function ce(n){return new zn({send:ae,win:n})}function fe(n){return zn.toProxyWindow(n,{send:ae})}function de(){var n,e,r;on().initialized||(on().initialized=!0,function(n){var e=n.on,r=n.send,t=on();t.receiveMessage=t.receiveMessage||function(n){return re(n,{on:e,send:r})}}({on:te,send:ae}),e=(n={on:te,send:ae}).on,r=n.send,un().getOrSet("postMessageListener",(function(){return(n=window).addEventListener("message",t=function(n){!function(n,e){var r=e.on,t=e.send,i=n.source||n.sourceElement,a=n.origin||n.originalEvent&&n.originalEvent.origin,u=n.data;if("null"===a&&(a=o.FILE+"//"),i){if(!a)throw new Error("Post message did not have origin domain");re({source:i,origin:a,data:u},{on:r,send:t})}}(n,{on:e,send:r})}),{cancel:function(){n.removeEventListener("message",t)}};var n,t})),Bn({on:te,send:ae,receiveMessage:re}),function(n){var e=n.on,r=n.send;un("builtinListeners").getOrSet("helloListener",(function(){var n=e(nn.HELLO,{domain:rn},(function(n){var e=n.source,r=n.origin;return wn(e).resolve({win:e,domain:r}),{instanceID:dn()}})),t=A();return t&&hn(t,{send:r}).catch(Z),n}))}({on:te,send:ae}))}function we(){var n;!function(){for(var n=un("responseListeners"),e=0,r=n.keys();e<r.length;e++){var t=r[e],o=n.get(t);o&&(o.cancelled=!0),n.del(t)}}(),(n=un().get("postMessageListener"))&&n.cancel(),delete window.__post_robot_10_0_19__}function he(n){for(var e=0,r=fn("requestPromises").get(n,[]);e<r.length;e++)r[e].reject(new Error("Window cleaned up before response")).catch(Z)}r.d(e,"bridge",(function(){return ie})),r.d(e,"Promise",(function(){return U})),r.d(e,"TYPES",(function(){return!0})),r.d(e,"ProxyWindow",(function(){return zn})),r.d(e,"setup",(function(){return de})),r.d(e,"destroy",(function(){return we})),r.d(e,"serializeMessage",(function(){return ue})),r.d(e,"deserializeMessage",(function(){return se})),r.d(e,"createProxyWindow",(function(){return ce})),r.d(e,"toProxyWindow",(function(){return fe})),r.d(e,"on",(function(){return te})),r.d(e,"once",(function(){return oe})),r.d(e,"send",(function(){return ae})),r.d(e,"markWindowKnown",(function(){return vn})),r.d(e,"cleanUpWindow",(function(){return he})),ie={setupBridge:Bn,openBridge:function(n,e){var r=un("bridges"),t=un("bridgeFrames");return e=e||I(n),r.getOrSet(e,(function(){return U.try((function(){if(h()===e)throw new Error("Can not open bridge on the same domain as current domain: "+e);var r=In(e);if(S(window,r))throw new Error("Frame with name "+r+" already exists on page");var o=function(n,e){var r=document.createElement("iframe");return r.setAttribute("name",n),r.setAttribute("id",n),r.setAttribute("style","display: none; margin: 0; padding: 0; border: 0px none; overflow: hidden;"),r.setAttribute("frameborder","0"),r.setAttribute("border","0"),r.setAttribute("scrolling","no"),r.setAttribute("allowTransparency","true"),r.setAttribute("tabindex","-1"),r.setAttribute("hidden","true"),r.setAttribute("title",""),r.setAttribute("role","presentation"),r.src=e,r}(r,n);return t.set(e,o),kn.then((function(e){e.appendChild(o);var r=o.contentWindow;return new U((function(n,e){o.addEventListener("load",n),o.addEventListener("error",e)})).then((function(){return mn(r,5e3,"Bridge "+n)})).then((function(){return r}))}))}))}))},linkWindow:Ln,linkUrl:function(n,e){Ln({win:n,domain:I(e)})},isBridge:Mn,needsBridge:Pn,needsBridgeForBrowser:An,hasBridge:function(n,e){return un("bridges").has(e||I(n))},needsBridgeForWin:Rn,needsBridgeForDomain:Nn,destroyBridges:function(){for(var n=un("bridges"),e=un("bridgeFrames"),r=0,t=e.keys();r<t.length;r++){var o=e.get(t[r]);o&&o.parentNode&&o.parentNode.removeChild(o)}e.reset(),n.reset()}},de()}])})); | ||
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("postRobot",[],e):"object"==typeof exports?exports.postRobot=e():n.postRobot=e()}("undefined"!=typeof self?self:this,(function(){return function(n){var e={};function r(t){if(e[t])return e[t].exports;var o=e[t]={i:t,l:!1,exports:{}};return n[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=n,r.c=e,r.d=function(n,e,t){r.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:t})},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,e){if(1&e&&(n=r(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)r.d(t,o,function(e){return n[e]}.bind(null,o));return t},r.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(e,"a",e),e},r.o=function(n,e){return{}.hasOwnProperty.call(n,e)},r.p="",r(r.s=0)}([function(n,e,r){"use strict";function t(n){return"[object RegExp]"==={}.toString.call(n)}r.r(e);var o={MOCK:"mock:",FILE:"file:",ABOUT:"about:"},i="*",a={IFRAME:"iframe",POPUP:"popup"},u="Call was rejected by callee.\r\n";function s(n){return void 0===n&&(n=window),n.location.protocol===o.ABOUT}function c(n){if(void 0===n&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function f(n){if(void 0===n&&(n=window),n&&!c(n))try{return n.opener}catch(n){}}function d(n){try{return!0}catch(n){}return!1}function w(n){var e=(n=n||window).location;if(!e)throw new Error("Can not read window location");var r=e.protocol;if(!r)throw new Error("Can not read window protocol");if(r===o.FILE)return o.FILE+"//";if(r===o.ABOUT){var t=c(n);return t&&d()?w(t):o.ABOUT+"//"}var i=e.host;if(!i)throw new Error("Can not read window host");return r+"//"+i}function h(n){var e=w(n=n||window);return e&&n.mockDomain&&0===n.mockDomain.indexOf(o.MOCK)?n.mockDomain:e}function l(n){if(!function(n){try{if(n===window)return!0}catch(n){}try{var e=Object.getOwnPropertyDescriptor(n,"location");if(e&&!1===e.enumerable)return!1}catch(n){}try{if(s(n)&&d())return!0}catch(n){}try{if(w(n)===w(window))return!0}catch(n){}return!1}(n))return!1;try{if(n===window)return!0;if(s(n)&&d())return!0;if(h(window)===h(n))return!0}catch(n){}return!1}function m(n){if(!l(n))throw new Error("Expected window to be same domain");return n}function v(n,e){if(!n||!e)return!1;var r=c(e);return r?r===n:-1!==function(n){var e=[];try{for(;n.parent!==n;)e.push(n.parent),n=n.parent}catch(n){}return e}(e).indexOf(n)}function p(n){var e,r,t=[];try{e=n.frames}catch(r){e=n}try{r=e.length}catch(n){}if(0===r)return t;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=e[o]}catch(n){continue}t.push(i)}return t}for(var a=0;a<100;a++){var u=void 0;try{u=e[a]}catch(n){return t}if(!u)return t;t.push(u)}return t}function g(n){for(var e=[],r=0,t=p(n);r<t.length;r++){var o=t[r];e.push(o);for(var i=0,a=g(o);i<a.length;i++)e.push(a[i])}return e}function y(n){if(n){try{if(n.top)return n.top}catch(n){}if(c(n)===n)return n;try{if(v(window,n)&&window.top)return window.top}catch(n){}try{if(v(n,window)&&window.top)return window.top}catch(n){}for(var e=0,r=g(n);e<r.length;e++){var t=r[e];try{if(t.top)return t.top}catch(n){}if(c(t)===t)return t}}}function _(n){var e=y(n);if(!e)throw new Error("Can not determine top window");return[].concat(g(e),[e])}var E=[],O=[];function b(n,e){void 0===e&&(e=!0);try{if(n===window)return!1}catch(n){return!0}try{if(!n)return!0}catch(n){return!0}try{if(n.closed)return!0}catch(n){return!n||n.message!==u}if(e&&l(n))try{if(n.mockclosed)return!0}catch(n){}try{if(!n.parent||!n.top)return!0}catch(n){}var r=function(n,e){for(var r=0;r<n.length;r++)try{if(n[r]===e)return r}catch(n){}return-1}(E,n);if(-1!==r){var t=O[r];if(t&&function(n){if(!n.contentWindow)return!0;if(!n.parentNode)return!0;var e=n.ownerDocument;return!(!e||!e.documentElement||e.documentElement.contains(n))}(t))return!0}return!1}function W(n){return(n=n||window).navigator.mockUserAgent||n.navigator.userAgent}function S(n,e){for(var r=p(n),t=0;t<r.length;t++){var o=r[t];try{if(l(o)&&o.name===e&&-1!==r.indexOf(o))return o}catch(n){}}try{if(-1!==r.indexOf(n.frames[e]))return n.frames[e]}catch(n){}try{if(-1!==r.indexOf(n[e]))return n[e]}catch(n){}}function x(n,e){return n===f(e)}function N(n){return void 0===n&&(n=window),f(n=n||window)||c(n)||void 0}function A(n,e){for(var r=0;r<n.length;r++)for(var t=n[r],o=0;o<e.length;o++)if(t===e[o])return!0;return!1}function R(n,e){var r=y(n)||n,t=y(e)||e;try{if(r&&t)return r===t}catch(n){}var o=_(n),i=_(e);if(A(o,i))return!0;var a=f(r),u=f(t);return!(a&&A(_(a),i)||(u&&A(_(u),o),1))}function P(n,e){if("string"==typeof n){if("string"==typeof e)return n===i||e===n;if(t(e))return!1;if(Array.isArray(e))return!1}return t(n)?t(e)?n.toString()===e.toString():!Array.isArray(e)&&Boolean(e.match(n)):!!Array.isArray(n)&&(Array.isArray(e)?JSON.stringify(n)===JSON.stringify(e):!t(e)&&n.some((function(n){return P(n,e)})))}function I(n){return n.match(/^(https?|mock|file):\/\//)?n.split("/").slice(0,3).join("/"):h()}function M(n){try{if(n===window)return!0}catch(n){if(n&&n.message===u)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===u)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===u)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===u)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===u)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===u)return!0}try{if(n&&"__unlikely_value__"===n.__cross_domain_utils_window_check__)return!1}catch(n){return!0}return!1}function k(n){try{n.close()}catch(n){}}function j(n){try{if(!n)return!1;if("undefined"!=typeof Promise&&n instanceof Promise)return!0;if("undefined"!=typeof window&&"function"==typeof window.Window&&n instanceof window.Window)return!1;if("undefined"!=typeof window&&"function"==typeof window.constructor&&n instanceof window.constructor)return!1;var e={}.toString;if(e){var r=e.call(n);if("[object Window]"===r||"[object global]"===r||"[object DOMWindow]"===r)return!1}if("function"==typeof n.then)return!0}catch(n){return!1}return!1}var T,D=[],C=[],L=0;function B(){if(!L&&T){var n=T;T=null,n.resolve()}}function F(){L+=1}function z(){L-=1,B()}var U=function(){function n(n){var e=this;if(this.resolved=void 0,this.rejected=void 0,this.errorHandled=void 0,this.value=void 0,this.error=void 0,this.handlers=void 0,this.dispatching=void 0,this.stack=void 0,this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],n){var r,t,o=!1,i=!1,a=!1;F();try{n((function(n){a?e.resolve(n):(o=!0,r=n)}),(function(n){a?e.reject(n):(i=!0,t=n)}))}catch(n){return z(),void this.reject(n)}z(),a=!0,o?this.resolve(r):i&&this.reject(t)}}var e=n.prototype;return e.resolve=function(n){if(this.resolved||this.rejected)return this;if(j(n))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=n,this.dispatch(),this},e.reject=function(n){var e=this;if(this.resolved||this.rejected)return this;if(j(n))throw new Error("Can not reject promise with another promise");if(!n){var r=n&&"function"==typeof n.toString?n.toString():{}.toString.call(n);n=new Error("Expected reject to be called with Error, got "+r)}return this.rejected=!0,this.error=n,this.errorHandled||setTimeout((function(){e.errorHandled||function(n,e){if(-1===D.indexOf(n)){D.push(n),setTimeout((function(){throw n}),1);for(var r=0;r<C.length;r++)C[r](n,e)}}(n,e)}),1),this.dispatch(),this},e.asyncReject=function(n){return this.errorHandled=!0,this.reject(n),this},e.dispatch=function(){var e=this.resolved,r=this.rejected,t=this.handlers;if(!this.dispatching&&(e||r)){this.dispatching=!0,F();for(var o=function(n,e){return n.then((function(n){e.resolve(n)}),(function(n){e.reject(n)}))},i=0;i<t.length;i++){var a=t[i],u=a.onSuccess,s=a.onError,c=a.promise,f=void 0;if(e)try{f=u?u(this.value):this.value}catch(n){c.reject(n);continue}else if(r){if(!s){c.reject(this.error);continue}try{f=s(this.error)}catch(n){c.reject(n);continue}}f instanceof n&&(f.resolved||f.rejected)?(f.resolved?c.resolve(f.value):c.reject(f.error),f.errorHandled=!0):j(f)?f instanceof n&&(f.resolved||f.rejected)?f.resolved?c.resolve(f.value):c.reject(f.error):o(f,c):c.resolve(f)}t.length=0,this.dispatching=!1,z()}},e.then=function(e,r){if(e&&"function"!=typeof e&&!e.call)throw new Error("Promise.then expected a function for success handler");if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.then expected a function for error handler");var t=new n;return this.handlers.push({promise:t,onSuccess:e,onError:r}),this.errorHandled=!0,this.dispatch(),t},e.catch=function(n){return this.then(void 0,n)},e.finally=function(e){if(e&&"function"!=typeof e&&!e.call)throw new Error("Promise.finally expected a function");return this.then((function(r){return n.try(e).then((function(){return r}))}),(function(r){return n.try(e).then((function(){throw r}))}))},e.timeout=function(n,e){var r=this;if(this.resolved||this.rejected)return this;var t=setTimeout((function(){r.resolved||r.rejected||r.reject(e||new Error("Promise timed out after "+n+"ms"))}),n);return this.then((function(n){return clearTimeout(t),n}))},e.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},n.resolve=function(e){return e instanceof n?e:j(e)?new n((function(n,r){return e.then(n,r)})):(new n).resolve(e)},n.reject=function(e){return(new n).reject(e)},n.asyncReject=function(e){return(new n).asyncReject(e)},n.all=function(e){var r=new n,t=e.length,o=[];if(!t)return r.resolve(o),r;for(var i=function(n,e,i){return e.then((function(e){o[n]=e,0==(t-=1)&&r.resolve(o)}),(function(n){i.reject(n)}))},a=0;a<e.length;a++){var u=e[a];if(u instanceof n){if(u.resolved){o[a]=u.value,t-=1;continue}}else if(!j(u)){o[a]=u,t-=1;continue}i(a,n.resolve(u),r)}return 0===t&&r.resolve(o),r},n.hash=function(e){var r={};return n.all(Object.keys(e).map((function(t){return n.resolve(e[t]).then((function(n){r[t]=n}))}))).then((function(){return r}))},n.map=function(e,r){return n.all(e.map(r))},n.onPossiblyUnhandledException=function(n){return function(n){return C.push(n),{cancel:function(){C.splice(C.indexOf(n),1)}}}(n)},n.try=function(e,r,t){if(e&&"function"!=typeof e&&!e.call)throw new Error("Promise.try expected a function");var o;F();try{o=e.apply(r,t||[])}catch(e){return z(),n.reject(e)}return z(),n.resolve(o)},n.delay=function(e){return new n((function(n){setTimeout(n,e)}))},n.isPromise=function(e){return!!(e&&e instanceof n)||j(e)},n.flush=function(){return e=T=T||new n,B(),e;var e},n}();function H(){return(H=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)({}).hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n}).apply(this,arguments)}function q(n,e){for(var r=0;r<n.length;r++)try{if(n[r]===e)return r}catch(n){}return-1}var G,J=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__",function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var n=new WeakMap,e={};return Object.freeze(e),n.set(e,"__testvalue__"),"__testvalue__"===n.get(e)}catch(n){return!1}}())try{this.weakmap=new WeakMap}catch(n){}this.keys=[],this.values=[]}var e=n.prototype;return e._cleanupClosedWindows=function(){for(var n=this.weakmap,e=this.keys,r=0;r<e.length;r++){var t=e[r];if(M(t)&&b(t)){if(n)try{n.delete(t)}catch(n){}e.splice(r,1),this.values.splice(r,1),r-=1}}},e.isSafeToReadWrite=function(n){return!M(n)},e.set=function(n,e){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.set(n,e)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var t=this.name,o=n[t];return void(o&&o[0]===n?o[1]=e:Object.defineProperty(n,t,{value:[n,e],writable:!0}))}catch(n){}this._cleanupClosedWindows();var i=this.keys,a=this.values,u=q(i,n);-1===u?(i.push(n),a.push(e)):a[u]=e},e.get=function(n){if(!n)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{if(e.has(n))return e.get(n)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var r=n[this.name];return r&&r[0]===n?r[1]:void 0}catch(n){}this._cleanupClosedWindows();var t=q(this.keys,n);if(-1!==t)return this.values[t]},e.delete=function(n){if(!n)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{e.delete(n)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var r=n[this.name];r&&r[0]===n&&(r[0]=r[1]=void 0)}catch(n){}this._cleanupClosedWindows();var t=this.keys,o=q(t,n);-1!==o&&(t.splice(o,1),this.values.splice(o,1))},e.has=function(n){if(!n)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{if(e.has(n))return!0}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var r=n[this.name];return!(!r||r[0]!==n)}catch(n){}return this._cleanupClosedWindows(),-1!==q(this.keys,n)},e.getOrSet=function(n,e){if(this.has(n))return this.get(n);var r=e();return this.set(n,r),r},n}();function X(){var n="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,(function(){return n.charAt(Math.floor(Math.random()*n.length))}))+"_"+function(n){if("function"==typeof btoa)return btoa(encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(function(n,e){return String.fromCharCode(parseInt(e,16))})));if("undefined"!=typeof Buffer)return Buffer.from(n,"utf8").toString("base64");throw new Error("Can not find window.btoa or Buffer")}((new Date).toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}function Y(n){var e,r={};function t(){for(var e=this,t=arguments,o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var u=function(n){try{return JSON.stringify([].slice.call(n),(function(n,e){return"function"==typeof e?"memoize["+function(n){if(G=G||new J,null==n||"object"!=typeof n&&"function"!=typeof n)throw new Error("Invalid object");var e=G.get(n);return e||(e=typeof n+":"+X(),G.set(n,e)),e}(e)+"]":e}))}catch(n){throw new Error("Arguments not serializable -- can not be used to memoize")}}(i);return r.hasOwnProperty(u)?r[u]:(r[u]=U.try((function(){return n.apply(e,t)})).finally((function(){delete r[u]})),r[u])}return t.reset=function(){r={}},function(n,e){try{delete n.name,n.name=e}catch(n){}return n.__name__=n.displayName=e,n}(t,((e=n).name||e.__name__||e.displayName||"anonymous")+"::promiseMemoized")}function Z(){}function K(n,e){if(void 0===e&&(e=1),e>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+{}.toString.call(n)+">";if("string"==typeof n)return n;if(n instanceof Error){var r=n&&n.stack,t=n&&n.message;if(r&&t)return-1!==r.indexOf(t)?r:t+"\n"+r;if(r)return r;if(t)return t}return n&&n.toString&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}catch(n){return"Error while stringifying error: "+K(n,e+1)}}function Q(n){return"string"==typeof n?n:n&&n.toString&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}function V(n){return"[object RegExp]"==={}.toString.call(n)}function $(n,e,r){if(n.hasOwnProperty(e))return n[e];var t=r();return n[e]=t,t}Object.create(Error.prototype);var nn={METHOD:"postrobot_method",HELLO:"postrobot_hello",OPEN_TUNNEL:"postrobot_open_tunnel"},en="__postrobot_bridge__",rn="*",tn={CROSS_DOMAIN_ZALGO_PROMISE:"cross_domain_zalgo_promise",CROSS_DOMAIN_FUNCTION:"cross_domain_function",CROSS_DOMAIN_WINDOW:"cross_domain_window"};function on(n){return void 0===n&&(n=window),n!==window?n.__post_robot_10_0_20__:n.__post_robot_10_0_20__=n.__post_robot_10_0_20__||{}}var an=function(){return{}};function un(n,e){return void 0===n&&(n="store"),void 0===e&&(e=an),$(on(),n,(function(){var n=e();return{has:function(e){return n.hasOwnProperty(e)},get:function(e,r){return n.hasOwnProperty(e)?n[e]:r},set:function(e,r){return n[e]=r,r},del:function(e){delete n[e]},getOrSet:function(e,r){return $(n,e,r)},reset:function(){n=e()},keys:function(){return Object.keys(n)}}}))}var sn=function(){};function cn(){var n=on();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new sn,n.WINDOW_WILDCARD}function fn(n,e){return void 0===n&&(n="store"),void 0===e&&(e=an),un("windowStore").getOrSet(n,(function(){var r=new J,t=function(n){return r.getOrSet(n,e)};return{has:function(e){return t(e).hasOwnProperty(n)},get:function(e,r){var o=t(e);return o.hasOwnProperty(n)?o[n]:r},set:function(e,r){return t(e)[n]=r,r},del:function(e){delete t(e)[n]},getOrSet:function(e,r){return $(t(e),n,r)}}}))}function dn(){return un("instance").getOrSet("instanceID",X)}function wn(n,e){var r=e.domain,t=fn("helloPromises"),o=t.get(n);o&&o.resolve({domain:r});var i=U.resolve({domain:r});return t.set(n,i),i}function hn(n,e){return(0,e.send)(n,nn.HELLO,{instanceID:dn()},{domain:rn,timeout:-1}).then((function(e){var r=e.origin,t=e.data.instanceID;return wn(n,{domain:r}),{win:n,domain:r,instanceID:t}}))}function ln(n,e){var r=e.send;return fn("windowInstanceIDPromises").getOrSet(n,(function(){return hn(n,{send:r}).then((function(n){return n.instanceID}))}))}function mn(n,e,r){void 0===e&&(e=5e3),void 0===r&&(r="Window");var t=function(n){return fn("helloPromises").getOrSet(n,(function(){return new U}))}(n);return-1!==e&&(t=t.timeout(e,new Error(r+" did not load after "+e+"ms"))),t}function vn(n){fn("knownWindows").set(n,!0)}var pn,gn={FUNCTION:"function",ERROR:"error",PROMISE:"promise",REGEX:"regex",DATE:"date",ARRAY:"array",OBJECT:"object",STRING:"string",NUMBER:"number",BOOLEAN:"boolean",NULL:"null",UNDEFINED:"undefined"};function yn(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function _n(n){return void 0===n?gn.UNDEFINED:null===n?gn.NULL:Array.isArray(n)?gn.ARRAY:"function"==typeof n?gn.FUNCTION:"object"==typeof n?n instanceof Error?gn.ERROR:"function"==typeof n.then?gn.PROMISE:"[object RegExp]"==={}.toString.call(n)?gn.REGEX:"[object Date]"==={}.toString.call(n)?gn.DATE:gn.OBJECT:"string"==typeof n?gn.STRING:"number"==typeof n?gn.NUMBER:"boolean"==typeof n?gn.BOOLEAN:void 0}function En(n,e){return{__type__:n,__val__:e}}var On,bn=((pn={})[gn.FUNCTION]=function(){},pn[gn.ERROR]=function(n){return En(gn.ERROR,{message:n.message,stack:n.stack,code:n.code})},pn[gn.PROMISE]=function(){},pn[gn.REGEX]=function(n){return En(gn.REGEX,n.source)},pn[gn.DATE]=function(n){return En(gn.DATE,n.toJSON())},pn[gn.ARRAY]=function(n){return n},pn[gn.OBJECT]=function(n){return n},pn[gn.STRING]=function(n){return n},pn[gn.NUMBER]=function(n){return n},pn[gn.BOOLEAN]=function(n){return n},pn[gn.NULL]=function(n){return n},pn),Wn={},Sn=((On={})[gn.FUNCTION]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},On[gn.ERROR]=function(n){var e=n.stack,r=n.code,t=new Error(n.message);return t.code=r,t.stack=e+"\n\n"+t.stack,t},On[gn.PROMISE]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},On[gn.REGEX]=function(n){return new RegExp(n)},On[gn.DATE]=function(n){return new Date(n)},On[gn.ARRAY]=function(n){return n},On[gn.OBJECT]=function(n){return n},On[gn.STRING]=function(n){return n},On[gn.NUMBER]=function(n){return n},On[gn.BOOLEAN]=function(n){return n},On[gn.NULL]=function(n){return n},On),xn={};function Nn(){return!!W(window).match(/MSIE|trident|edge\/12|edge\/13/i)}function An(n){return!R(window,n)}function Rn(n,e){if(n){if(h()!==I(n))return!0}else if(e&&!l(e))return!0;return!1}function Pn(n){var e=n.win,r=n.domain;return!(!Nn()||r&&!Rn(r,e)||e&&!An(e))}function In(n){var e=(n=n||I(n)).replace(/[^a-zA-Z0-9]+/g,"_");return en+"_"+e}function Mn(){return Boolean(window.name&&window.name===In(h()))}var kn=new U((function(n){if(window.document&&window.document.body)return n(window.document.body);var e=setInterval((function(){if(window.document&&window.document.body)return clearInterval(e),n(window.document.body)}),10)}));function jn(n){fn("remoteWindowPromises").getOrSet(n,(function(){return new U}))}function Tn(n){var e=fn("remoteWindowPromises").get(n);if(!e)throw new Error("Remote window promise not found");return e}function Dn(n,e,r){Tn(n).resolve((function(t,o,i){if(t!==n)throw new Error("Remote window does not match window");if(!P(o,e))throw new Error("Remote domain "+o+" does not match domain "+e);r.fireAndForget(i)}))}function Cn(n,e){Tn(n).reject(e).catch(Z)}function Ln(n){for(var e=n.win,r=n.name,t=n.domain,o=un("popupWindowsByName"),i=fn("popupWindowsByWin"),a=0,u=o.keys();a<u.length;a++){var s=u[a],c=o.get(s);c&&!b(c.win)||o.del(s)}var f=i.getOrSet(e,(function(){return r?o.getOrSet(r,(function(){return{win:e,name:r}})):{win:e}}));if(f.win&&f.win!==e)throw new Error("Different window already linked for window: "+(r||"undefined"));return r&&(f.name=r,o.set(r,f)),t&&(f.domain=t,jn(e)),i.set(e,f),f}function Bn(n){var e,r=n.on,t=n.send,i=n.receiveMessage;e=window.open,window.open=function(n,r,t,i){var a=e.call(this,function(n){if(0!==I(n).indexOf(o.MOCK))return n;throw new Error("Mock urls not supported out of test mode")}(n),r,t,i);return a?(Ln({win:a,name:r,domain:n?I(n):null}),a):a},function(n){var e=n.on,r=n.send,t=n.receiveMessage,o=un("popupWindowsByName");e(nn.OPEN_TUNNEL,(function(n){var i=n.source,a=n.origin,u=n.data,s=un("bridges").get(a);if(!s)throw new Error("Can not find bridge promise for domain "+a);return s.then((function(n){if(i!==n)throw new Error("Message source does not matched registered bridge for domain "+a);if(!u.name)throw new Error("Register window expected to be passed window name");if(!u.sendMessage)throw new Error("Register window expected to be passed sendMessage method");if(!o.has(u.name))throw new Error("Window with name "+u.name+" does not exist, or was not opened by this window");if(!o.get(u.name).domain)throw new Error("We do not have a registered domain for window "+u.name);if(o.get(u.name).domain!==a)throw new Error("Message origin "+a+" does not matched registered window origin "+o.get(u.name).domain);return Dn(o.get(u.name).win,a,u.sendMessage),{sendMessage:function(n){if(window&&!window.closed){var i=o.get(u.name);if(i)try{t({data:n,origin:i.domain,source:i.win},{on:e,send:r})}catch(n){U.reject(n)}}}}}))}))}({on:r,send:t,receiveMessage:i}),function(n){var e=n.send;on(window).openTunnelToParent=function(n){var r=n.name,t=n.source,o=n.canary,i=n.sendMessage,a=un("tunnelWindows"),u=c(window);if(!u)throw new Error("No parent window found to open tunnel to");var s=function(n){var e=n.name,r=n.source,t=n.canary,o=n.sendMessage;!function(){for(var n=un("tunnelWindows"),e=0,r=n.keys();e<r.length;e++){var t=r[e];b(n[t].source)&&n.del(t)}}();var i=X();return un("tunnelWindows").set(i,{name:e,source:r,canary:t,sendMessage:o}),i}({name:r,source:t,canary:o,sendMessage:i});return e(u,nn.OPEN_TUNNEL,{name:r,sendMessage:function(){var n=a.get(s);if(n&&n.source&&!b(n.source)){try{n.canary()}catch(n){return}n.sendMessage.apply(this,arguments)}}},{domain:rn})}}({on:r,send:t}),function(n){var e=n.on,r=n.send,t=n.receiveMessage;U.try((function(){var n,o=f(window);if(o&&Pn({win:o}))return jn(o),(n=o,fn("remoteBridgeAwaiters").getOrSet(n,(function(){return U.try((function(){var e=S(n,In(h()));if(e)return l(e)&&on(m(e))?e:new U((function(n){var r,t;r=setInterval((function(){if(e&&l(e)&&on(m(e)))return clearInterval(r),clearTimeout(t),n(e)}),100),t=setTimeout((function(){return clearInterval(r),n()}),2e3)}))}))}))).then((function(n){return n?window.name?on(m(n)).openTunnelToParent({name:window.name,source:window,canary:function(){},sendMessage:function(n){if(window&&!window.closed)try{t({data:n,origin:this.origin,source:this.source},{on:e,send:r})}catch(n){U.reject(n)}}}).then((function(n){var e=n.source,r=n.origin,t=n.data;if(e!==o)throw new Error("Source does not match opener");Dn(e,r,t.sendMessage)})).catch((function(n){throw Cn(o,n),n})):Cn(o,new Error("Can not register with opener: window does not have a name")):Cn(o,new Error("Can not register with opener: no bridge found in opener"))}))}))}({on:r,send:t,receiveMessage:i})}function Fn(){for(var n=un("idToProxyWindow"),e=0,r=n.keys();e<r.length;e++){var t=r[e];n.get(t).shouldClean()&&n.del(t)}}var zn=function(){function n(n){var e=n.send,r=n.win,t=n.serializedWindow;this.id=void 0,this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.name=void 0,this.actualWindowPromise=new U,this.serializedWindow=t||function(n,e){var r,t=e.send;return{id:X(),getType:function(){return n.then((function(n){return f(n)?a.POPUP:a.IFRAME}))},getInstanceID:Y((function(){return n.then((function(n){return ln(n,{send:t})}))})),close:function(){return n.then(k)},getName:function(){return n.then((function(n){if(!b(n))return r}))},focus:function(){return n.then((function(n){n.focus()}))},isClosed:function(){return n.then((function(n){return b(n)}))},setLocation:function(e){return n.then((function(n){if(l(n))try{if(n.location&&"function"==typeof n.location.replace)return void n.location.replace(e)}catch(n){}n.location=e}))},setName:function(e){return n.then((function(n){Ln({win:n,name:e});var t=m(n);t.name=e,t.frameElement&&t.frameElement.setAttribute("name",e),r=e}))}}}(this.actualWindowPromise,{send:e}),un("idToProxyWindow").set(this.getID(),this),r&&this.setWindow(r)}var e=n.prototype;return e.getID=function(){return this.serializedWindow.id},e.getType=function(){return this.serializedWindow.getType()},e.isPopup=function(){return this.getType()===a.POPUP},e.setLocation=function(n){var e=this;return this.serializedWindow.setLocation(n).then((function(){return e}))},e.getName=function(){return this.serializedWindow.getName()},e.setName=function(n){var e=this;return this.serializedWindow.setName(n).then((function(){return e}))},e.close=function(){var n=this;return this.serializedWindow.close().then((function(){return n}))},e.focus=function(){var n=this;return U.all([this.isPopup()&&this.getName().then((function(n){n&&window.open("",n)})),this.serializedWindow.focus()]).then((function(){return n}))},e.isClosed=function(){return this.serializedWindow.isClosed()},e.getWindow=function(){return this.actualWindow},e.setWindow=function(n){this.actualWindow=n,this.actualWindowPromise.resolve(this.actualWindow),fn("winToProxyWindow").set(n,this)},e.awaitWindow=function(){return this.actualWindowPromise},e.matchWindow=function(n,e){var r=this,t=e.send;return U.try((function(){return r.actualWindow?n===r.actualWindow:U.hash({proxyInstanceID:r.getInstanceID(),knownWindowInstanceID:ln(n,{send:t})}).then((function(e){var t=e.proxyInstanceID===e.knownWindowInstanceID;return t&&r.setWindow(n),t}))}))},e.unwrap=function(){return this.actualWindow||this},e.getInstanceID=function(){return this.serializedWindow.getInstanceID()},e.shouldClean=function(){return Boolean(this.actualWindow&&b(this.actualWindow))},e.serialize=function(){return this.serializedWindow},n.unwrap=function(e){return n.isProxyWindow(e)?e.unwrap():e},n.serialize=function(e,r){var t=r.send;return Fn(),n.toProxyWindow(e,{send:t}).serialize()},n.deserialize=function(e,r){var t=r.send;return Fn(),un("idToProxyWindow").get(e.id)||new n({serializedWindow:e,send:t})},n.isProxyWindow=function(n){return Boolean(n&&!M(n)&&n.isProxyWindow)},n.toProxyWindow=function(e,r){var t=r.send;if(Fn(),n.isProxyWindow(e))return e;var o=e;return fn("winToProxyWindow").get(o)||new n({win:o,send:t})},n}();function Un(n,e,r,t,o){var i=fn("methodStore"),a=un("proxyWindowMethods");zn.isProxyWindow(t)?a.set(n,{val:e,name:r,domain:o,source:t}):(a.del(n),i.getOrSet(t,(function(){return{}}))[n]={domain:o,name:r,val:e,source:t})}function Hn(n,e){var r=fn("methodStore"),t=un("proxyWindowMethods");return r.getOrSet(n,(function(){return{}}))[e]||t.get(e)}function qn(n,e,r,t,o){!function(n){var e=n.on,r=n.send;un("builtinListeners").getOrSet("functionCalls",(function(){return e(nn.METHOD,{domain:rn},(function(n){var e=n.source,t=n.origin,o=n.data,i=o.id,a=o.name,u=Hn(e,i);if(!u)throw new Error("Could not find method '"+o.name+"' with id: "+o.id+" in "+h(window));var s=u.source,c=u.domain,f=u.val;return U.try((function(){if(!P(c,t))throw new Error("Method '"+o.name+"' domain "+JSON.stringify(V(u.domain)?u.domain.source:u.domain)+" does not match origin "+t+" in "+h(window));if(zn.isProxyWindow(s))return s.matchWindow(e,{send:r}).then((function(n){if(!n)throw new Error("Method call '"+o.name+"' failed - proxy window does not match source in "+h(window))}))})).then((function(){return f.apply({source:e,origin:t},o.args)}),(function(n){return U.try((function(){if(f.onError)return f.onError(n)})).then((function(){throw n.stack&&(n.stack="Remote call to "+a+"()\n\n"+n.stack),n}))})).then((function(n){return{result:n,id:i,name:a}}))}))}))}({on:o.on,send:o.send});var i=r.__id__||X();n=zn.unwrap(n);var a=r.__name__||r.name||t;return zn.isProxyWindow(n)?(Un(i,r,a,n,e),n.awaitWindow().then((function(n){Un(i,r,a,n,e)}))):Un(i,r,a,n,e),En(tn.CROSS_DOMAIN_FUNCTION,{id:i,name:a})}function Gn(n,e,r,t){var o,i=t.on,a=t.send;return function(n,e){void 0===e&&(e=Wn);var r=JSON.stringify(n,(function(n){var r=this[n];if(yn(this))return r;var t=_n(r);if(!t)return r;var o=e[t]||bn[t];return o?o(r,n):r}));return void 0===r?gn.UNDEFINED:r}(r,((o={})[gn.PROMISE]=function(r,t){return function(n,e,r,t,o){return En(tn.CROSS_DOMAIN_ZALGO_PROMISE,{then:qn(n,e,(function(n,e){return r.then(n,e)}),t,{on:o.on,send:o.send})})}(n,e,r,t,{on:i,send:a})},o[gn.FUNCTION]=function(r,t){return qn(n,e,r,t,{on:i,send:a})},o[gn.OBJECT]=function(n){return M(n)||zn.isProxyWindow(n)?En(tn.CROSS_DOMAIN_WINDOW,zn.serialize(n,{send:a})):n},o))}function Jn(n,e,r,t){var o,i=t.on,a=t.send;return function(n,e){if(void 0===e&&(e=xn),n!==gn.UNDEFINED)return JSON.parse(n,(function(n,r){if(yn(this))return r;var t,o;if(yn(r)?(t=r.__type__,o=r.__val__):(t=_n(r),o=r),!t)return o;var i=e[t]||Sn[t];return i?i(o,n):o}))}(r,((o={})[tn.CROSS_DOMAIN_ZALGO_PROMISE]=function(n){return function(n,e,r){return new U(r.then)}(0,0,n)},o[tn.CROSS_DOMAIN_FUNCTION]=function(r){return function(n,e,r,t){var o=r.id,i=r.name,a=t.send,u=function(r){function t(){var u=arguments;return zn.toProxyWindow(n,{send:a}).awaitWindow().then((function(n){var s=Hn(n,o);if(s&&s.val!==t)return s.val.apply({source:window,origin:h()},u);var c={domain:e,fireAndForget:r.fireAndForget},f=[].slice.call(u);return a(n,nn.METHOD,{id:o,name:i,args:f},c).then((function(n){if(!r.fireAndForget)return n.data.result}))})).catch((function(n){throw n}))}return void 0===r&&(r={}),t.__name__=i,t.__origin__=e,t.__source__=n,t.__id__=o,t.origin=e,t},s=u();return s.fireAndForget=u({fireAndForget:!0}),s}(n,e,r,{on:i,send:a})},o[tn.CROSS_DOMAIN_WINDOW]=function(n){return zn.deserialize(n,{send:a})},o))}var Xn={};function Yn(n,e,r,t){var o,i=t.on,a=t.send;if(b(n))throw new Error("Window is closed");for(var u=Gn(n,e,((o={}).__post_robot_10_0_20__=H({id:X(),origin:h(window)},r),o),{on:i,send:a}),s=Object.keys(Xn),c=[],f=0;f<s.length;f++){var d=s[f];try{Xn[d](n,u,e)}catch(n){c.push(n)}}if(c.length===s.length)throw new Error("All post-robot messaging strategies failed:\n\n"+c.map(K).join("\n\n"))}Xn.postrobot_post_message=function(n,e,r){(Array.isArray(r)?r:"string"==typeof r?[r]:[rn]).map((function(n){return 0===n.indexOf(o.FILE)?rn:n})).forEach((function(r){n.postMessage(e,r)}))},Xn.postrobot_bridge=function(n,e,r){if(Nn()||Mn()){if(l(n))throw new Error("Post message through bridge disabled between same domain windows");if(!1!==R(window,n))throw new Error("Can only use bridge to communicate between two different windows, not between frames");!function(n,e,r){var t=x(window,n),o=x(n,window);if(!t&&!o)throw new Error("Can only send messages to and from parent and popup windows");Tn(n).then((function(t){return t(n,e,r)}))}(n,r,e)}},Xn.postrobot_global=function(n,e){if(W(window).match(/MSIE|rv:11|trident|edge\/12|edge\/13/i)){if(!l(n))throw new Error("Post message through global disabled between different domain windows");if(!1!==R(window,n))throw new Error("Can only use global to communicate between two different windows, not between frames");var r=on(n);if(!r)throw new Error("Can not find postRobot global on foreign window");r.receiveMessage({source:window,origin:h(),data:e})}};var Zn,Kn="__domain_regex__";function Qn(n){return un("responseListeners").get(n)}function Vn(n){un("responseListeners").del(n)}function $n(n){return un("erroredResponseListeners").has(n)}function ne(n){var e=n.name,r=n.win,t=n.domain,o=fn("requestListeners");if(r===rn&&(r=null),t===rn&&(t=null),!e)throw new Error("Name required to get request listener");for(var i=0,a=[r,cn()];i<a.length;i++){var u=a[i];if(u){var s=o.get(u);if(s){var c=s[e];if(c){if(t&&"string"==typeof t){if(c[t])return c[t];if(c[Kn])for(var f=0,d=c[Kn];f<d.length;f++){var w=d[f],h=w.listener;if(P(w.regex,t))return h}}if(c[rn])return c[rn]}}}}}var ee=((Zn={}).postrobot_message_request=function(n,e,r,t){var o=t.on,i=t.send,a=ne({name:r.name,win:n,domain:e});function u(t,a,u){void 0===u&&(u={}),r.fireAndForget||b(n)||Yn(n,e,H({type:t,ack:a,hash:r.hash,name:r.name},u),{on:o,send:i})}return U.all([u("postrobot_message_ack"),U.try((function(){if(!a)throw new Error("No handler found for post message: "+r.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!P(a.domain,e))throw new Error("Request origin "+e+" does not match domain "+a.domain.toString());return a.handler({source:n,origin:e,data:r.data})})).then((function(n){return u("postrobot_message_response","success",{data:n})}),(function(n){return u("postrobot_message_response","error",{error:n})}))]).then(Z).catch((function(n){if(a&&a.handleError)return a.handleError(n);throw n}))},Zn.postrobot_message_ack=function(n,e,r){if(!$n(r.hash)){var t=Qn(r.hash);if(!t)throw new Error("No handler found for post message ack for message: "+r.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!P(t.domain,e))throw new Error("Ack origin "+e+" does not match domain "+t.domain.toString());if(n!==t.win)throw new Error("Ack source does not match registered window");t.ack=!0}},Zn.postrobot_message_response=function(n,e,r){if(!$n(r.hash)){var o,i=Qn(r.hash);if(!i)throw new Error("No handler found for post message response for message: "+r.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!P(i.domain,e))throw new Error("Response origin "+e+" does not match domain "+(o=i.domain,Array.isArray(o)?"("+o.join(" | ")+")":t(o)?"RegExp("+o.toString():o.toString()));if(n!==i.win)throw new Error("Response source does not match registered window");Vn(r.hash),"error"===r.ack?i.promise.reject(r.error):"success"===r.ack&&i.promise.resolve({source:n,origin:e,data:r.data})}},Zn);function re(n,e){var r=e.on,t=e.send,i=un("receivedMessages");if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!n.source)return}catch(n){return}var a=n.source,u=n.origin,s=function(n,e,r,t){var o,i=t.on,a=t.send;try{o=Jn(e,r,n,{on:i,send:a})}catch(n){return}if(o&&"object"==typeof o&&null!==o&&(o=o.__post_robot_10_0_20__)&&"object"==typeof o&&null!==o&&o.type&&"string"==typeof o.type&&ee[o.type])return o}(n.data,a,u,{on:r,send:t});s&&(vn(a),i.has(s.id)||(i.set(s.id,!0),b(a)&&!s.fireAndForget||(0===s.origin.indexOf(o.FILE)&&(u=o.FILE+"//"),ee[s.type](a,u,s,{on:r,send:t}))))}function te(n,e,r){if(!n)throw new Error("Expected name");if("function"==typeof e&&(r=e,e={}),!r)throw new Error("Expected handler");(e=e||{}).name=n,e.handler=r||e.handler;var t=e.window,o=e.domain,i=function n(e,r){var t=e.name,o=e.win,i=e.domain,a=fn("requestListeners");if(!t||"string"!=typeof t)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var u=[],s=0,c=o;s<c.length;s++)u.push(n({name:t,domain:i,win:c[s]},r));return{cancel:function(){for(var n=0;n<u.length;n++)u[n].cancel()}}}if(Array.isArray(i)){for(var f=[],d=0,w=i;d<w.length;d++)f.push(n({name:t,win:o,domain:w[d]},r));return{cancel:function(){for(var n=0;n<f.length;n++)f[n].cancel()}}}var h=ne({name:t,win:o,domain:i});if(o&&o!==rn||(o=cn()),i=i||rn,h)throw o&&i?new Error("Request listener already exists for "+t+" on domain "+i.toString()+" for "+(o===cn()?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+t+" for "+(o===cn()?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+t+" on domain "+i.toString()):new Error("Request listener already exists for "+t);var l,m,v=a.getOrSet(o,(function(){return{}})),p=$(v,t,(function(){return{}})),g=i.toString();return V(i)?(l=$(p,Kn,(function(){return[]}))).push(m={regex:i,listener:r}):p[g]=r,{cancel:function(){delete p[g],m&&(l.splice(l.indexOf(m,1)),l.length||delete p[Kn]),Object.keys(p).length||delete v[t],o&&!Object.keys(v).length&&a.del(o)}}}({name:n,win:t,domain:o},{handler:e.handler,handleError:e.errorHandler||function(n){throw n},window:t,domain:o||rn,name:n});return{cancel:function(){i.cancel()}}}function oe(n,e,r){"function"==typeof(e=e||{})&&(r=e,e={});var t,o=new U;return e.errorHandler=function(n){t.cancel(),o.reject(n)},t=te(n,e,(function(n){if(t.cancel(),o.resolve(n),r)return r(n)})),o.cancel=t.cancel,o}var ie,ae=function n(e,r,t,o){var i=(o=o||{}).domain||rn,a=o.timeout||-1,u=o.timeout||5e3,s=o.fireAndForget||!1;return U.try((function(){if(function(n,e,r){if(!n)throw new Error("Expected name");if(r&&"string"!=typeof r&&!Array.isArray(r)&&!V(r))throw new TypeError("Expected domain to be a string, array, or regex");if(b(e))throw new Error("Target window is closed")}(r,e,i),function(n,e){var r=N(e);if(r)return r===n;if(e===n)return!1;if(y(e)===e)return!1;for(var t=0,o=p(n);t<o.length;t++)if(o[t]===e)return!0;return!1}(window,e))return mn(e,u)})).then((function(r){return function(n,e,r,t){var o=t.send;return"string"==typeof e?U.resolve(e):U.try((function(){return r||hn(n,{send:o}).then((function(n){return n.domain}))})).then((function(n){if(!P(e,e))throw new Error("Domain "+Q(e)+" does not match "+Q(e));return n}))}(e,i,(void 0===r?{}:r).domain,{send:n})})).then((function(o){i=o;var u,c,f=r===nn.METHOD&&t&&"string"==typeof t.name?t.name+"()":r,d=new U,w=r+"_"+X();if(!s){var l={name:r,win:e,domain:i,promise:d};!function(n,e){un("responseListeners").set(n,e)}(w,l);var m=fn("requestPromises").getOrSet(e,(function(){return[]}));m.push(d),d.catch((function(){!function(n){un("erroredResponseListeners").set(n,!0)}(w),Vn(w)}));var v=function(n){return fn("knownWindows").get(n,!1)}(e)?1e4:2e3,p=a,g=v,y=p,_=(u=function(){return b(e)?d.reject(new Error("Window closed for "+r+" before "+(l.ack?"response":"ack"))):l.cancelled?d.reject(new Error("Response listener was cancelled for "+r)):(g=Math.max(g-500,0),-1!==y&&(y=Math.max(y-500,0)),l.ack||0!==g?0===y?d.reject(new Error("No response for postMessage "+f+" in "+h()+" in "+p+"ms")):void 0:d.reject(new Error("No ack for postMessage "+f+" in "+h()+" in "+v+"ms")))},500,function n(){c=setTimeout((function(){u(),n()}),500)}(),{cancel:function(){clearTimeout(c)}});d.finally((function(){_.cancel(),m.splice(m.indexOf(d,1))})).catch(Z)}return Yn(e,i,{type:"postrobot_message_request",hash:w,name:r,data:t,fireAndForget:s},{on:te,send:n}),s?d.resolve():d}))};function ue(n,e,r){return Gn(n,e,r,{on:te,send:ae})}function se(n,e,r){return Jn(n,e,r,{on:te,send:ae})}function ce(n){return new zn({send:ae,win:n})}function fe(n){return zn.toProxyWindow(n,{send:ae})}function de(){var n,e,r;on().initialized||(on().initialized=!0,function(n){var e=n.on,r=n.send,t=on();t.receiveMessage=t.receiveMessage||function(n){return re(n,{on:e,send:r})}}({on:te,send:ae}),e=(n={on:te,send:ae}).on,r=n.send,un().getOrSet("postMessageListener",(function(){return(n=window).addEventListener("message",t=function(n){!function(n,e){var r=e.on,t=e.send,i=n.source||n.sourceElement,a=n.origin||n.originalEvent&&n.originalEvent.origin,u=n.data;if("null"===a&&(a=o.FILE+"//"),i){if(!a)throw new Error("Post message did not have origin domain");re({source:i,origin:a,data:u},{on:r,send:t})}}(n,{on:e,send:r})}),{cancel:function(){n.removeEventListener("message",t)}};var n,t})),Bn({on:te,send:ae,receiveMessage:re}),function(n){var e=n.on,r=n.send;un("builtinListeners").getOrSet("helloListener",(function(){var n=e(nn.HELLO,{domain:rn},(function(n){return wn(n.source,{domain:n.origin}),{instanceID:dn()}})),t=N();return t&&hn(t,{send:r}).catch(Z),n}))}({on:te,send:ae}))}function we(){var n;!function(){for(var n=un("responseListeners"),e=0,r=n.keys();e<r.length;e++){var t=r[e],o=n.get(t);o&&(o.cancelled=!0),n.del(t)}}(),(n=un().get("postMessageListener"))&&n.cancel(),delete window.__post_robot_10_0_20__}function he(n){for(var e=0,r=fn("requestPromises").get(n,[]);e<r.length;e++)r[e].reject(new Error("Window cleaned up before response")).catch(Z)}r.d(e,"bridge",(function(){return ie})),r.d(e,"Promise",(function(){return U})),r.d(e,"TYPES",(function(){return!0})),r.d(e,"ProxyWindow",(function(){return zn})),r.d(e,"setup",(function(){return de})),r.d(e,"destroy",(function(){return we})),r.d(e,"serializeMessage",(function(){return ue})),r.d(e,"deserializeMessage",(function(){return se})),r.d(e,"createProxyWindow",(function(){return ce})),r.d(e,"toProxyWindow",(function(){return fe})),r.d(e,"on",(function(){return te})),r.d(e,"once",(function(){return oe})),r.d(e,"send",(function(){return ae})),r.d(e,"markWindowKnown",(function(){return vn})),r.d(e,"cleanUpWindow",(function(){return he})),ie={setupBridge:Bn,openBridge:function(n,e){var r=un("bridges"),t=un("bridgeFrames");return e=e||I(n),r.getOrSet(e,(function(){return U.try((function(){if(h()===e)throw new Error("Can not open bridge on the same domain as current domain: "+e);var r=In(e);if(S(window,r))throw new Error("Frame with name "+r+" already exists on page");var o=function(n,e){var r=document.createElement("iframe");return r.setAttribute("name",n),r.setAttribute("id",n),r.setAttribute("style","display: none; margin: 0; padding: 0; border: 0px none; overflow: hidden;"),r.setAttribute("frameborder","0"),r.setAttribute("border","0"),r.setAttribute("scrolling","no"),r.setAttribute("allowTransparency","true"),r.setAttribute("tabindex","-1"),r.setAttribute("hidden","true"),r.setAttribute("title",""),r.setAttribute("role","presentation"),r.src=e,r}(r,n);return t.set(e,o),kn.then((function(e){e.appendChild(o);var r=o.contentWindow;return new U((function(n,e){o.addEventListener("load",n),o.addEventListener("error",e)})).then((function(){return mn(r,5e3,"Bridge "+n)})).then((function(){return r}))}))}))}))},linkWindow:Ln,linkUrl:function(n,e){Ln({win:n,domain:I(e)})},isBridge:Mn,needsBridge:Pn,needsBridgeForBrowser:Nn,hasBridge:function(n,e){return un("bridges").has(e||I(n))},needsBridgeForWin:An,needsBridgeForDomain:Rn,destroyBridges:function(){for(var n=un("bridges"),e=un("bridgeFrames"),r=0,t=e.keys();r<t.length;r++){var o=e.get(t[r]);o&&o.parentNode&&o.parentNode.removeChild(o)}e.reset(),n.reset()}},de()}])})); | ||
//# sourceMappingURL=post-robot.ie.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("postRobot",[],e):"object"==typeof exports?exports.postRobot=e():n.postRobot=e()}("undefined"!=typeof self?self:this,(function(){return function(n){var e={};function r(t){if(e[t])return e[t].exports;var o=e[t]={i:t,l:!1,exports:{}};return n[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=n,r.c=e,r.d=function(n,e,t){r.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:t})},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,e){if(1&e&&(n=r(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)r.d(t,o,function(e){return n[e]}.bind(null,o));return t},r.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(e,"a",e),e},r.o=function(n,e){return{}.hasOwnProperty.call(n,e)},r.p="",r(r.s=0)}([function(n,e,r){"use strict";function t(n){return"[object RegExp]"==={}.toString.call(n)}r.r(e);var o={MOCK:"mock:",FILE:"file:",ABOUT:"about:"},i="*",u={IFRAME:"iframe",POPUP:"popup"},a="Call was rejected by callee.\r\n";function c(n){return void 0===n&&(n=window),n.location.protocol===o.ABOUT}function s(n){if(void 0===n&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function f(n){if(void 0===n&&(n=window),n&&!s(n))try{return n.opener}catch(n){}}function d(n){try{return!0}catch(n){}return!1}function l(n){var e=(n=n||window).location;if(!e)throw new Error("Can not read window location");var r=e.protocol;if(!r)throw new Error("Can not read window protocol");if(r===o.FILE)return o.FILE+"//";if(r===o.ABOUT){var t=s(n);return t&&d()?l(t):o.ABOUT+"//"}var i=e.host;if(!i)throw new Error("Can not read window host");return r+"//"+i}function h(n){var e=l(n=n||window);return e&&n.mockDomain&&0===n.mockDomain.indexOf(o.MOCK)?n.mockDomain:e}function w(n){if(!function(n){try{if(n===window)return!0}catch(n){}try{var e=Object.getOwnPropertyDescriptor(n,"location");if(e&&!1===e.enumerable)return!1}catch(n){}try{if(c(n)&&d())return!0}catch(n){}try{if(l(n)===l(window))return!0}catch(n){}return!1}(n))return!1;try{if(n===window)return!0;if(c(n)&&d())return!0;if(h(window)===h(n))return!0}catch(n){}return!1}function p(n,e){if(!n||!e)return!1;var r=s(e);return r?r===n:-1!==function(n){var e=[];try{for(;n.parent!==n;)e.push(n.parent),n=n.parent}catch(n){}return e}(e).indexOf(n)}function v(n){var e,r,t=[];try{e=n.frames}catch(r){e=n}try{r=e.length}catch(n){}if(0===r)return t;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=e[o]}catch(n){continue}t.push(i)}return t}for(var u=0;u<100;u++){var a=void 0;try{a=e[u]}catch(n){return t}if(!a)return t;t.push(a)}return t}var m=[],y=[];function g(n,e){void 0===e&&(e=!0);try{if(n===window)return!1}catch(n){return!0}try{if(!n)return!0}catch(n){return!0}try{if(n.closed)return!0}catch(n){return!n||n.message!==a}if(e&&w(n))try{if(n.mockclosed)return!0}catch(n){}try{if(!n.parent||!n.top)return!0}catch(n){}var r=function(n,e){for(var r=0;r<n.length;r++)try{if(n[r]===e)return r}catch(n){}return-1}(m,n);if(-1!==r){var t=y[r];if(t&&function(n){if(!n.contentWindow)return!0;if(!n.parentNode)return!0;var e=n.ownerDocument;return!(!e||!e.documentElement||e.documentElement.contains(n))}(t))return!0}return!1}function _(n){return void 0===n&&(n=window),f(n=n||window)||s(n)||void 0}function E(n,e){if("string"==typeof n){if("string"==typeof e)return n===i||e===n;if(t(e))return!1;if(Array.isArray(e))return!1}return t(n)?t(e)?n.toString()===e.toString():!Array.isArray(e)&&Boolean(e.match(n)):!!Array.isArray(n)&&(Array.isArray(e)?JSON.stringify(n)===JSON.stringify(e):!t(e)&&n.some((function(n){return E(n,e)})))}function O(n){try{if(n===window)return!0}catch(n){if(n&&n.message===a)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===a)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===a)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===a)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===a)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===a)return!0}try{if(n&&"__unlikely_value__"===n.__cross_domain_utils_window_check__)return!1}catch(n){return!0}return!1}function W(n){try{n.close()}catch(n){}}function S(n){try{if(!n)return!1;if("undefined"!=typeof Promise&&n instanceof Promise)return!0;if("undefined"!=typeof window&&"function"==typeof window.Window&&n instanceof window.Window)return!1;if("undefined"!=typeof window&&"function"==typeof window.constructor&&n instanceof window.constructor)return!1;var e={}.toString;if(e){var r=e.call(n);if("[object Window]"===r||"[object global]"===r||"[object DOMWindow]"===r)return!1}if("function"==typeof n.then)return!0}catch(n){return!1}return!1}var b,R=[],x=[],I=0;function P(){if(!I&&b){var n=b;b=null,n.resolve()}}function N(){I+=1}function j(){I-=1,P()}var A=function(){function n(n){var e=this;if(this.resolved=void 0,this.rejected=void 0,this.errorHandled=void 0,this.value=void 0,this.error=void 0,this.handlers=void 0,this.dispatching=void 0,this.stack=void 0,this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],n){var r,t,o=!1,i=!1,u=!1;N();try{n((function(n){u?e.resolve(n):(o=!0,r=n)}),(function(n){u?e.reject(n):(i=!0,t=n)}))}catch(n){return j(),void this.reject(n)}j(),u=!0,o?this.resolve(r):i&&this.reject(t)}}var e=n.prototype;return e.resolve=function(n){if(this.resolved||this.rejected)return this;if(S(n))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=n,this.dispatch(),this},e.reject=function(n){var e=this;if(this.resolved||this.rejected)return this;if(S(n))throw new Error("Can not reject promise with another promise");if(!n){var r=n&&"function"==typeof n.toString?n.toString():{}.toString.call(n);n=new Error("Expected reject to be called with Error, got "+r)}return this.rejected=!0,this.error=n,this.errorHandled||setTimeout((function(){e.errorHandled||function(n,e){if(-1===R.indexOf(n)){R.push(n),setTimeout((function(){throw n}),1);for(var r=0;r<x.length;r++)x[r](n,e)}}(n,e)}),1),this.dispatch(),this},e.asyncReject=function(n){return this.errorHandled=!0,this.reject(n),this},e.dispatch=function(){var e=this,r=this.resolved,t=this.rejected,o=this.handlers;if(!this.dispatching&&(r||t)){this.dispatching=!0,N();for(var i=function(i){var u=o[i],a=u.onSuccess,c=u.onError,s=u.promise,f=void 0;if(r)try{f=a?a(e.value):e.value}catch(n){return s.reject(n),"continue"}else if(t){if(!c)return s.reject(e.error),"continue";try{f=c(e.error)}catch(n){return s.reject(n),"continue"}}f instanceof n&&(f.resolved||f.rejected)?(f.resolved?s.resolve(f.value):s.reject(f.error),f.errorHandled=!0):S(f)?f instanceof n&&(f.resolved||f.rejected)?f.resolved?s.resolve(f.value):s.reject(f.error):f.then((function(n){s.resolve(n)}),(function(n){s.reject(n)})):s.resolve(f)},u=0;u<o.length;u++)i(u);o.length=0,this.dispatching=!1,j()}},e.then=function(e,r){if(e&&"function"!=typeof e&&!e.call)throw new Error("Promise.then expected a function for success handler");if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.then expected a function for error handler");var t=new n;return this.handlers.push({promise:t,onSuccess:e,onError:r}),this.errorHandled=!0,this.dispatch(),t},e.catch=function(n){return this.then(void 0,n)},e.finally=function(e){if(e&&"function"!=typeof e&&!e.call)throw new Error("Promise.finally expected a function");return this.then((function(r){return n.try(e).then((function(){return r}))}),(function(r){return n.try(e).then((function(){throw r}))}))},e.timeout=function(n,e){var r=this;if(this.resolved||this.rejected)return this;var t=setTimeout((function(){r.resolved||r.rejected||r.reject(e||new Error("Promise timed out after "+n+"ms"))}),n);return this.then((function(n){return clearTimeout(t),n}))},e.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},n.resolve=function(e){return e instanceof n?e:S(e)?new n((function(n,r){return e.then(n,r)})):(new n).resolve(e)},n.reject=function(e){return(new n).reject(e)},n.asyncReject=function(e){return(new n).asyncReject(e)},n.all=function(e){var r=new n,t=e.length,o=[];if(!t)return r.resolve(o),r;for(var i=function(i){var u=e[i];if(u instanceof n){if(u.resolved)return o[i]=u.value,t-=1,"continue"}else if(!S(u))return o[i]=u,t-=1,"continue";n.resolve(u).then((function(n){o[i]=n,0==(t-=1)&&r.resolve(o)}),(function(n){r.reject(n)}))},u=0;u<e.length;u++)i(u);return 0===t&&r.resolve(o),r},n.hash=function(e){var r={};return n.all(Object.keys(e).map((function(t){return n.resolve(e[t]).then((function(n){r[t]=n}))}))).then((function(){return r}))},n.map=function(e,r){return n.all(e.map(r))},n.onPossiblyUnhandledException=function(n){return function(n){return x.push(n),{cancel:function(){x.splice(x.indexOf(n),1)}}}(n)},n.try=function(e,r,t){if(e&&"function"!=typeof e&&!e.call)throw new Error("Promise.try expected a function");var o;N();try{o=e.apply(r,t||[])}catch(e){return j(),n.reject(e)}return j(),n.resolve(o)},n.delay=function(e){return new n((function(n){setTimeout(n,e)}))},n.isPromise=function(e){return!!(e&&e instanceof n)||S(e)},n.flush=function(){return e=b=b||new n,P(),e;var e},n}();function k(){return(k=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)({}).hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n}).apply(this,arguments)}function D(n,e){for(var r=0;r<n.length;r++)try{if(n[r]===e)return r}catch(n){}return-1}var M,T=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__",function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var n=new WeakMap,e={};return Object.freeze(e),n.set(e,"__testvalue__"),"__testvalue__"===n.get(e)}catch(n){return!1}}())try{this.weakmap=new WeakMap}catch(n){}this.keys=[],this.values=[]}var e=n.prototype;return e._cleanupClosedWindows=function(){for(var n=this.weakmap,e=this.keys,r=0;r<e.length;r++){var t=e[r];if(O(t)&&g(t)){if(n)try{n.delete(t)}catch(n){}e.splice(r,1),this.values.splice(r,1),r-=1}}},e.isSafeToReadWrite=function(n){return!O(n)},e.set=function(n,e){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.set(n,e)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var t=this.name,o=n[t];return void(o&&o[0]===n?o[1]=e:Object.defineProperty(n,t,{value:[n,e],writable:!0}))}catch(n){}this._cleanupClosedWindows();var i=this.keys,u=this.values,a=D(i,n);-1===a?(i.push(n),u.push(e)):u[a]=e},e.get=function(n){if(!n)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{if(e.has(n))return e.get(n)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var r=n[this.name];return r&&r[0]===n?r[1]:void 0}catch(n){}this._cleanupClosedWindows();var t=D(this.keys,n);if(-1!==t)return this.values[t]},e.delete=function(n){if(!n)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{e.delete(n)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var r=n[this.name];r&&r[0]===n&&(r[0]=r[1]=void 0)}catch(n){}this._cleanupClosedWindows();var t=this.keys,o=D(t,n);-1!==o&&(t.splice(o,1),this.values.splice(o,1))},e.has=function(n){if(!n)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{if(e.has(n))return!0}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var r=n[this.name];return!(!r||r[0]!==n)}catch(n){}return this._cleanupClosedWindows(),-1!==D(this.keys,n)},e.getOrSet=function(n,e){if(this.has(n))return this.get(n);var r=e();return this.set(n,r),r},n}();function C(){var n="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,(function(){return n.charAt(Math.floor(Math.random()*n.length))}))+"_"+function(n){if("function"==typeof btoa)return btoa(encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(function(n,e){return String.fromCharCode(parseInt(e,16))})));if("undefined"!=typeof Buffer)return Buffer.from(n,"utf8").toString("base64");throw new Error("Can not find window.btoa or Buffer")}((new Date).toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}function L(n){var e={};function r(){for(var r=this,t=arguments,o=arguments.length,i=new Array(o),u=0;u<o;u++)i[u]=arguments[u];var a=function(n){try{return JSON.stringify([].slice.call(n),(function(n,e){return"function"==typeof e?"memoize["+function(n){if(M=M||new T,null==n||"object"!=typeof n&&"function"!=typeof n)throw new Error("Invalid object");var e=M.get(n);return e||(e=typeof n+":"+C(),M.set(n,e)),e}(e)+"]":e}))}catch(n){throw new Error("Arguments not serializable -- can not be used to memoize")}}(i);return e.hasOwnProperty(a)?e[a]:(e[a]=A.try((function(){return n.apply(r,t)})).finally((function(){delete e[a]})),e[a])}return r.reset=function(){e={}},r}function z(){}function F(n,e){if(void 0===e&&(e=1),e>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+{}.toString.call(n)+">";if("string"==typeof n)return n;if(n instanceof Error){var r=n&&n.stack,t=n&&n.message;if(r&&t)return-1!==r.indexOf(t)?r:t+"\n"+r;if(r)return r;if(t)return t}return n&&n.toString&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}catch(n){return"Error while stringifying error: "+F(n,e+1)}}function U(n){return"string"==typeof n?n:n&&n.toString&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}function B(n){return"[object RegExp]"==={}.toString.call(n)}function H(n,e,r){if(n.hasOwnProperty(e))return n[e];var t=r();return n[e]=t,t}Object.create(Error.prototype);var q={METHOD:"postrobot_method",HELLO:"postrobot_hello",OPEN_TUNNEL:"postrobot_open_tunnel"},G="*",J={CROSS_DOMAIN_ZALGO_PROMISE:"cross_domain_zalgo_promise",CROSS_DOMAIN_FUNCTION:"cross_domain_function",CROSS_DOMAIN_WINDOW:"cross_domain_window"};function X(n){return void 0===n&&(n=window),n!==window?n.__post_robot_10_0_19__:n.__post_robot_10_0_19__=n.__post_robot_10_0_19__||{}}var Y=function(){return{}};function Z(n,e){return void 0===n&&(n="store"),void 0===e&&(e=Y),H(X(),n,(function(){var n=e();return{has:function(e){return n.hasOwnProperty(e)},get:function(e,r){return n.hasOwnProperty(e)?n[e]:r},set:function(e,r){return n[e]=r,r},del:function(e){delete n[e]},getOrSet:function(e,r){return H(n,e,r)},reset:function(){n=e()},keys:function(){return Object.keys(n)}}}))}var K=function(){};function Q(){var n=X();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new K,n.WINDOW_WILDCARD}function V(n,e){return void 0===n&&(n="store"),void 0===e&&(e=Y),Z("windowStore").getOrSet(n,(function(){var r=new T,t=function(n){return r.getOrSet(n,e)};return{has:function(e){return t(e).hasOwnProperty(n)},get:function(e,r){var o=t(e);return o.hasOwnProperty(n)?o[n]:r},set:function(e,r){return t(e)[n]=r,r},del:function(e){delete t(e)[n]},getOrSet:function(e,r){return H(t(e),n,r)}}}))}function $(){return Z("instance").getOrSet("instanceID",C)}function nn(n){return V("helloPromises").getOrSet(n,(function(){return new A}))}function en(n,e){return(0,e.send)(n,q.HELLO,{instanceID:$()},{domain:G,timeout:-1}).then((function(e){var r=e.origin,t=e.data.instanceID;return nn(n).resolve({win:n,domain:r}),{win:n,domain:r,instanceID:t}}))}function rn(n,e){var r=e.send;return V("windowInstanceIDPromises").getOrSet(n,(function(){return en(n,{send:r}).then((function(n){return n.instanceID}))}))}function tn(n){V("knownWindows").set(n,!0)}var on,un={FUNCTION:"function",ERROR:"error",PROMISE:"promise",REGEX:"regex",DATE:"date",ARRAY:"array",OBJECT:"object",STRING:"string",NUMBER:"number",BOOLEAN:"boolean",NULL:"null",UNDEFINED:"undefined"};function an(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function cn(n){return void 0===n?un.UNDEFINED:null===n?un.NULL:Array.isArray(n)?un.ARRAY:"function"==typeof n?un.FUNCTION:"object"==typeof n?n instanceof Error?un.ERROR:"function"==typeof n.then?un.PROMISE:"[object RegExp]"==={}.toString.call(n)?un.REGEX:"[object Date]"==={}.toString.call(n)?un.DATE:un.OBJECT:"string"==typeof n?un.STRING:"number"==typeof n?un.NUMBER:"boolean"==typeof n?un.BOOLEAN:void 0}function sn(n,e){return{__type__:n,__val__:e}}var fn,dn=((on={})[un.FUNCTION]=function(){},on[un.ERROR]=function(n){return sn(un.ERROR,{message:n.message,stack:n.stack,code:n.code})},on[un.PROMISE]=function(){},on[un.REGEX]=function(n){return sn(un.REGEX,n.source)},on[un.DATE]=function(n){return sn(un.DATE,n.toJSON())},on[un.ARRAY]=function(n){return n},on[un.OBJECT]=function(n){return n},on[un.STRING]=function(n){return n},on[un.NUMBER]=function(n){return n},on[un.BOOLEAN]=function(n){return n},on[un.NULL]=function(n){return n},on),ln={},hn=((fn={})[un.FUNCTION]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},fn[un.ERROR]=function(n){var e=n.stack,r=n.code,t=new Error(n.message);return t.code=r,t.stack=e+"\n\n"+t.stack,t},fn[un.PROMISE]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},fn[un.REGEX]=function(n){return new RegExp(n)},fn[un.DATE]=function(n){return new Date(n)},fn[un.ARRAY]=function(n){return n},fn[un.OBJECT]=function(n){return n},fn[un.STRING]=function(n){return n},fn[un.NUMBER]=function(n){return n},fn[un.BOOLEAN]=function(n){return n},fn[un.NULL]=function(n){return n},fn),wn={};function pn(){for(var n=Z("idToProxyWindow"),e=0,r=n.keys();e<r.length;e++){var t=r[e];n.get(t).shouldClean()&&n.del(t)}}new A((function(n){if(window.document&&window.document.body)return n(window.document.body);var e=setInterval((function(){if(window.document&&window.document.body)return clearInterval(e),n(window.document.body)}),10)}));var vn=function(){function n(n){var e=n.send,r=n.win,t=n.serializedWindow;this.id=void 0,this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.name=void 0,this.actualWindowPromise=new A,this.serializedWindow=t||function(n,e){var r,t=e.send;return{id:C(),getType:function(){return n.then((function(n){return f(n)?u.POPUP:u.IFRAME}))},getInstanceID:L((function(){return n.then((function(n){return rn(n,{send:t})}))})),close:function(){return n.then(W)},getName:function(){return n.then((function(n){if(!g(n))return r}))},focus:function(){return n.then((function(n){n.focus()}))},isClosed:function(){return n.then((function(n){return g(n)}))},setLocation:function(e){return n.then((function(n){if(w(n))try{if(n.location&&"function"==typeof n.location.replace)return void n.location.replace(e)}catch(n){}n.location=e}))},setName:function(e){return n.then((function(n){var t=function(n){if(!w(n))throw new Error("Expected window to be same domain");return n}(n);t.name=e,t.frameElement&&t.frameElement.setAttribute("name",e),r=e}))}}}(this.actualWindowPromise,{send:e}),Z("idToProxyWindow").set(this.getID(),this),r&&this.setWindow(r)}var e=n.prototype;return e.getID=function(){return this.serializedWindow.id},e.getType=function(){return this.serializedWindow.getType()},e.isPopup=function(){return this.getType()===u.POPUP},e.setLocation=function(n){var e=this;return this.serializedWindow.setLocation(n).then((function(){return e}))},e.getName=function(){return this.serializedWindow.getName()},e.setName=function(n){var e=this;return this.serializedWindow.setName(n).then((function(){return e}))},e.close=function(){var n=this;return this.serializedWindow.close().then((function(){return n}))},e.focus=function(){var n=this;return A.all([this.isPopup()&&this.getName().then((function(n){n&&window.open("",n)})),this.serializedWindow.focus()]).then((function(){return n}))},e.isClosed=function(){return this.serializedWindow.isClosed()},e.getWindow=function(){return this.actualWindow},e.setWindow=function(n){this.actualWindow=n,this.actualWindowPromise.resolve(this.actualWindow),V("winToProxyWindow").set(n,this)},e.awaitWindow=function(){return this.actualWindowPromise},e.matchWindow=function(n,e){var r=this,t=e.send;return A.try((function(){return r.actualWindow?n===r.actualWindow:A.hash({proxyInstanceID:r.getInstanceID(),knownWindowInstanceID:rn(n,{send:t})}).then((function(e){var t=e.proxyInstanceID===e.knownWindowInstanceID;return t&&r.setWindow(n),t}))}))},e.unwrap=function(){return this.actualWindow||this},e.getInstanceID=function(){return this.serializedWindow.getInstanceID()},e.shouldClean=function(){return Boolean(this.actualWindow&&g(this.actualWindow))},e.serialize=function(){return this.serializedWindow},n.unwrap=function(e){return n.isProxyWindow(e)?e.unwrap():e},n.serialize=function(e,r){var t=r.send;return pn(),n.toProxyWindow(e,{send:t}).serialize()},n.deserialize=function(e,r){var t=r.send;return pn(),Z("idToProxyWindow").get(e.id)||new n({serializedWindow:e,send:t})},n.isProxyWindow=function(n){return Boolean(n&&!O(n)&&n.isProxyWindow)},n.toProxyWindow=function(e,r){var t=r.send;if(pn(),n.isProxyWindow(e))return e;var o=e;return V("winToProxyWindow").get(o)||new n({win:o,send:t})},n}();function mn(n,e,r,t,o){var i=V("methodStore"),u=Z("proxyWindowMethods");vn.isProxyWindow(t)?u.set(n,{val:e,name:r,domain:o,source:t}):(u.del(n),i.getOrSet(t,(function(){return{}}))[n]={domain:o,name:r,val:e,source:t})}function yn(n,e){var r=V("methodStore"),t=Z("proxyWindowMethods");return r.getOrSet(n,(function(){return{}}))[e]||t.get(e)}function gn(n,e,r,t,o){!function(n){var e=n.on,r=n.send;Z("builtinListeners").getOrSet("functionCalls",(function(){return e(q.METHOD,{domain:G},(function(n){var e=n.source,t=n.origin,o=n.data,i=o.id,u=o.name,a=yn(e,i);if(!a)throw new Error("Could not find method '"+o.name+"' with id: "+o.id+" in "+h(window));var c=a.source,s=a.domain,f=a.val;return A.try((function(){if(!E(s,t))throw new Error("Method '"+o.name+"' domain "+JSON.stringify(B(a.domain)?a.domain.source:a.domain)+" does not match origin "+t+" in "+h(window));if(vn.isProxyWindow(c))return c.matchWindow(e,{send:r}).then((function(n){if(!n)throw new Error("Method call '"+o.name+"' failed - proxy window does not match source in "+h(window))}))})).then((function(){return f.apply({source:e,origin:t},o.args)}),(function(n){return A.try((function(){if(f.onError)return f.onError(n)})).then((function(){throw n.stack&&(n.stack="Remote call to "+u+"()\n\n"+n.stack),n}))})).then((function(n){return{result:n,id:i,name:u}}))}))}))}({on:o.on,send:o.send});var i=r.__id__||C();n=vn.unwrap(n);var u=r.__name__||r.name||t;return vn.isProxyWindow(n)?(mn(i,r,u,n,e),n.awaitWindow().then((function(n){mn(i,r,u,n,e)}))):mn(i,r,u,n,e),sn(J.CROSS_DOMAIN_FUNCTION,{id:i,name:u})}function _n(n,e,r,t){var o,i=t.on,u=t.send;return function(n,e){void 0===e&&(e=ln);var r=JSON.stringify(n,(function(n){var r=this[n];if(an(this))return r;var t=cn(r);if(!t)return r;var o=e[t]||dn[t];return o?o(r,n):r}));return void 0===r?un.UNDEFINED:r}(r,((o={})[un.PROMISE]=function(r,t){return function(n,e,r,t,o){return sn(J.CROSS_DOMAIN_ZALGO_PROMISE,{then:gn(n,e,(function(n,e){return r.then(n,e)}),t,{on:o.on,send:o.send})})}(n,e,r,t,{on:i,send:u})},o[un.FUNCTION]=function(r,t){return gn(n,e,r,t,{on:i,send:u})},o[un.OBJECT]=function(n){return O(n)||vn.isProxyWindow(n)?sn(J.CROSS_DOMAIN_WINDOW,vn.serialize(n,{send:u})):n},o))}function En(n,e,r,t){var o,i=t.on,u=t.send;return function(n,e){if(void 0===e&&(e=wn),n!==un.UNDEFINED)return JSON.parse(n,(function(n,r){if(an(this))return r;var t,o;if(an(r)?(t=r.__type__,o=r.__val__):(t=cn(r),o=r),!t)return o;var i=e[t]||hn[t];return i?i(o,n):o}))}(r,((o={})[J.CROSS_DOMAIN_ZALGO_PROMISE]=function(n){return function(n,e,r){return new A(r.then)}(0,0,n)},o[J.CROSS_DOMAIN_FUNCTION]=function(r){return function(n,e,r,t){var o=r.id,i=r.name,u=t.send,a=function(r){function t(){var a=arguments;return vn.toProxyWindow(n,{send:u}).awaitWindow().then((function(n){var c=yn(n,o);if(c&&c.val!==t)return c.val.apply({source:window,origin:h()},a);var s={domain:e,fireAndForget:r.fireAndForget},f=[].slice.call(a);return u(n,q.METHOD,{id:o,name:i,args:f},s).then((function(n){if(!r.fireAndForget)return n.data.result}))})).catch((function(n){throw n}))}return void 0===r&&(r={}),t.__name__=i,t.__origin__=e,t.__source__=n,t.__id__=o,t.origin=e,t},c=a();return c.fireAndForget=a({fireAndForget:!0}),c}(n,e,r,{on:i,send:u})},o[J.CROSS_DOMAIN_WINDOW]=function(n){return vn.deserialize(n,{send:u})},o))}var On={};function Wn(n,e,r,t){var o,i=t.on,u=t.send;if(g(n))throw new Error("Window is closed");for(var a=_n(n,e,((o={}).__post_robot_10_0_19__=k({id:C(),origin:h(window)},r),o),{on:i,send:u}),c=Object.keys(On),s=[],f=0;f<c.length;f++){var d=c[f];try{On[d](n,a,e)}catch(n){s.push(n)}}if(s.length===c.length)throw new Error("All post-robot messaging strategies failed:\n\n"+s.map(F).join("\n\n"))}On.postrobot_post_message=function(n,e,r){(Array.isArray(r)?r:"string"==typeof r?[r]:[G]).map((function(n){return 0===n.indexOf(o.FILE)?G:n})).forEach((function(r){n.postMessage(e,r)}))};var Sn,bn="__domain_regex__";function Rn(n){return Z("responseListeners").get(n)}function xn(n){Z("responseListeners").del(n)}function In(n){return Z("erroredResponseListeners").has(n)}function Pn(n){var e=n.name,r=n.win,t=n.domain,o=V("requestListeners");if(r===G&&(r=null),t===G&&(t=null),!e)throw new Error("Name required to get request listener");for(var i=0,u=[r,Q()];i<u.length;i++){var a=u[i];if(a){var c=o.get(a);if(c){var s=c[e];if(s){if(t&&"string"==typeof t){if(s[t])return s[t];if(s[bn])for(var f=0,d=s[bn];f<d.length;f++){var l=d[f],h=l.listener;if(E(l.regex,t))return h}}if(s[G])return s[G]}}}}}var Nn=((Sn={}).postrobot_message_request=function(n,e,r,t){var o=t.on,i=t.send,u=Pn({name:r.name,win:n,domain:e});function a(t,u,a){void 0===a&&(a={}),r.fireAndForget||g(n)||Wn(n,e,k({type:t,ack:u,hash:r.hash,name:r.name},a),{on:o,send:i})}return A.all([a("postrobot_message_ack"),A.try((function(){if(!u)throw new Error("No handler found for post message: "+r.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!E(u.domain,e))throw new Error("Request origin "+e+" does not match domain "+u.domain.toString());return u.handler({source:n,origin:e,data:r.data})})).then((function(n){return a("postrobot_message_response","success",{data:n})}),(function(n){return a("postrobot_message_response","error",{error:n})}))]).then(z).catch((function(n){if(u&&u.handleError)return u.handleError(n);throw n}))},Sn.postrobot_message_ack=function(n,e,r){if(!In(r.hash)){var t=Rn(r.hash);if(!t)throw new Error("No handler found for post message ack for message: "+r.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!E(t.domain,e))throw new Error("Ack origin "+e+" does not match domain "+t.domain.toString());if(n!==t.win)throw new Error("Ack source does not match registered window");t.ack=!0}},Sn.postrobot_message_response=function(n,e,r){if(!In(r.hash)){var o,i=Rn(r.hash);if(!i)throw new Error("No handler found for post message response for message: "+r.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!E(i.domain,e))throw new Error("Response origin "+e+" does not match domain "+(o=i.domain,Array.isArray(o)?"("+o.join(" | ")+")":t(o)?"RegExp("+o.toString():o.toString()));if(n!==i.win)throw new Error("Response source does not match registered window");xn(r.hash),"error"===r.ack?i.promise.reject(r.error):"success"===r.ack&&i.promise.resolve({source:n,origin:e,data:r.data})}},Sn);function jn(n,e){var r=e.on,t=e.send,i=Z("receivedMessages");if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!n.source)return}catch(n){return}var u=n.source,a=n.origin,c=function(n,e,r,t){var o,i=t.on,u=t.send;try{o=En(e,r,n,{on:i,send:u})}catch(n){return}if(o&&"object"==typeof o&&null!==o&&(o=o.__post_robot_10_0_19__)&&"object"==typeof o&&null!==o&&o.type&&"string"==typeof o.type&&Nn[o.type])return o}(n.data,u,a,{on:r,send:t});c&&(tn(u),i.has(c.id)||(i.set(c.id,!0),g(u)&&!c.fireAndForget||(0===c.origin.indexOf(o.FILE)&&(a=o.FILE+"//"),Nn[c.type](u,a,c,{on:r,send:t}))))}function An(n,e,r){if(!n)throw new Error("Expected name");if("function"==typeof e&&(r=e,e={}),!r)throw new Error("Expected handler");(e=e||{}).name=n,e.handler=r||e.handler;var t=e.window,o=e.domain,i=function n(e,r){var t=e.name,o=e.win,i=e.domain,u=V("requestListeners");if(!t||"string"!=typeof t)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var a=[],c=0,s=o;c<s.length;c++)a.push(n({name:t,domain:i,win:s[c]},r));return{cancel:function(){for(var n=0;n<a.length;n++)a[n].cancel()}}}if(Array.isArray(i)){for(var f=[],d=0,l=i;d<l.length;d++)f.push(n({name:t,win:o,domain:l[d]},r));return{cancel:function(){for(var n=0;n<f.length;n++)f[n].cancel()}}}var h=Pn({name:t,win:o,domain:i});if(o&&o!==G||(o=Q()),i=i||G,h)throw o&&i?new Error("Request listener already exists for "+t+" on domain "+i.toString()+" for "+(o===Q()?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+t+" for "+(o===Q()?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+t+" on domain "+i.toString()):new Error("Request listener already exists for "+t);var w,p,v=u.getOrSet(o,(function(){return{}})),m=H(v,t,(function(){return{}})),y=i.toString();return B(i)?(w=H(m,bn,(function(){return[]}))).push(p={regex:i,listener:r}):m[y]=r,{cancel:function(){delete m[y],p&&(w.splice(w.indexOf(p,1)),w.length||delete m[bn]),Object.keys(m).length||delete v[t],o&&!Object.keys(v).length&&u.del(o)}}}({name:n,win:t,domain:o},{handler:e.handler,handleError:e.errorHandler||function(n){throw n},window:t,domain:o||G,name:n});return{cancel:function(){i.cancel()}}}function kn(n,e,r){"function"==typeof(e=e||{})&&(r=e,e={});var t,o=new A;return e.errorHandler=function(n){t.cancel(),o.reject(n)},t=An(n,e,(function(n){if(t.cancel(),o.resolve(n),r)return r(n)})),o.cancel=t.cancel,o}function Dn(n,e,r,t){var o=t.send;return A.try((function(){return function(n,e){var r=_(e);if(r)return r===n;if(e===n)return!1;if(function(n){if(n){try{if(n.top)return n.top}catch(n){}if(s(n)===n)return n;try{if(p(window,n)&&window.top)return window.top}catch(n){}try{if(p(n,window)&&window.top)return window.top}catch(n){}for(var e=0,r=function n(e){for(var r=[],t=0,o=v(e);t<o.length;t++){var i=o[t];r.push(i);for(var u=0,a=n(i);u<a.length;u++)r.push(a[u])}return r}(n);e<r.length;e++){var t=r[e];try{if(t.top)return t.top}catch(n){}if(s(t)===t)return t}}}(e)===e)return!1;for(var t=0,o=v(n);t<o.length;t++)if(o[t]===e)return!0;return!1}(window,n)?function(n,e,r){void 0===e&&(e=5e3),void 0===r&&(r="Window");var t=nn(n);return-1!==e&&(t=t.timeout(e,new Error(r+" did not load after "+e+"ms"))),t}(n,r):B(e)?en(n,{send:o}):{domain:e}})).then((function(n){return n.domain}))}var Mn=function n(e,r,t,o){var i=(o=o||{}).domain||G,u=o.timeout||-1,a=o.timeout||5e3,c=o.fireAndForget||!1;return A.try((function(){return function(n,e,r){if(!n)throw new Error("Expected name");if(r&&"string"!=typeof r&&!Array.isArray(r)&&!B(r))throw new TypeError("Expected domain to be a string, array, or regex");if(g(e))throw new Error("Target window is closed")}(r,e,i),Dn(e,i,a,{send:n})})).then((function(o){if(!E(i,o))throw new Error("Domain "+U(i)+" does not match "+U(o));i=o;var a,s,f=r===q.METHOD&&t&&"string"==typeof t.name?t.name+"()":r,d=new A,l=r+"_"+C();if(!c){var w={name:r,win:e,domain:i,promise:d};!function(n,e){Z("responseListeners").set(n,e)}(l,w);var p=V("requestPromises").getOrSet(e,(function(){return[]}));p.push(d),d.catch((function(){!function(n){Z("erroredResponseListeners").set(n,!0)}(l),xn(l)}));var v=function(n){return V("knownWindows").get(n,!1)}(e)?1e4:2e3,m=u,y=v,_=m,O=(a=function(){return g(e)?d.reject(new Error("Window closed for "+r+" before "+(w.ack?"response":"ack"))):w.cancelled?d.reject(new Error("Response listener was cancelled for "+r)):(y=Math.max(y-500,0),-1!==_&&(_=Math.max(_-500,0)),w.ack||0!==y?0===_?d.reject(new Error("No response for postMessage "+f+" in "+h()+" in "+m+"ms")):void 0:d.reject(new Error("No ack for postMessage "+f+" in "+h()+" in "+v+"ms")))},500,function n(){s=setTimeout((function(){a(),n()}),500)}(),{cancel:function(){clearTimeout(s)}});d.finally((function(){O.cancel(),p.splice(p.indexOf(d,1))})).catch(z)}return Wn(e,i,{type:"postrobot_message_request",hash:l,name:r,data:t,fireAndForget:c},{on:An,send:n}),c?d.resolve():d}))};function Tn(n,e,r){return _n(n,e,r,{on:An,send:Mn})}function Cn(n,e,r){return En(n,e,r,{on:An,send:Mn})}function Ln(n){return new vn({send:Mn,win:n})}function zn(n){return vn.toProxyWindow(n,{send:Mn})}function Fn(){var n,e,r;X().initialized||(X().initialized=!0,function(n){var e=n.on,r=n.send,t=X();t.receiveMessage=t.receiveMessage||function(n){return jn(n,{on:e,send:r})}}({on:An,send:Mn}),e=(n={on:An,send:Mn}).on,r=n.send,Z().getOrSet("postMessageListener",(function(){return(n=window).addEventListener("message",t=function(n){!function(n,e){var r=e.on,t=e.send,i=n.source||n.sourceElement,u=n.origin||n.originalEvent&&n.originalEvent.origin,a=n.data;if("null"===u&&(u=o.FILE+"//"),i){if(!u)throw new Error("Post message did not have origin domain");jn({source:i,origin:u,data:a},{on:r,send:t})}}(n,{on:e,send:r})}),{cancel:function(){n.removeEventListener("message",t)}};var n,t})),function(n){var e=n.on,r=n.send;Z("builtinListeners").getOrSet("helloListener",(function(){var n=e(q.HELLO,{domain:G},(function(n){var e=n.source,r=n.origin;return nn(e).resolve({win:e,domain:r}),{instanceID:$()}})),t=_();return t&&en(t,{send:r}).catch(z),n}))}({on:An,send:Mn}))}function Un(){var n;!function(){for(var n=Z("responseListeners"),e=0,r=n.keys();e<r.length;e++){var t=r[e],o=n.get(t);o&&(o.cancelled=!0),n.del(t)}}(),(n=Z().get("postMessageListener"))&&n.cancel(),delete window.__post_robot_10_0_19__}function Bn(n){for(var e=0,r=V("requestPromises").get(n,[]);e<r.length;e++)r[e].reject(new Error("Window cleaned up before response")).catch(z)}r.d(e,"bridge",(function(){})),r.d(e,"Promise",(function(){return A})),r.d(e,"TYPES",(function(){return!0})),r.d(e,"ProxyWindow",(function(){return vn})),r.d(e,"setup",(function(){return Fn})),r.d(e,"destroy",(function(){return Un})),r.d(e,"serializeMessage",(function(){return Tn})),r.d(e,"deserializeMessage",(function(){return Cn})),r.d(e,"createProxyWindow",(function(){return Ln})),r.d(e,"toProxyWindow",(function(){return zn})),r.d(e,"on",(function(){return An})),r.d(e,"once",(function(){return kn})),r.d(e,"send",(function(){return Mn})),r.d(e,"markWindowKnown",(function(){return tn})),r.d(e,"cleanUpWindow",(function(){return Bn})),Fn()}])})); | ||
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("postRobot",[],e):"object"==typeof exports?exports.postRobot=e():n.postRobot=e()}("undefined"!=typeof self?self:this,(function(){return function(n){var e={};function r(t){if(e[t])return e[t].exports;var o=e[t]={i:t,l:!1,exports:{}};return n[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=n,r.c=e,r.d=function(n,e,t){r.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:t})},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,e){if(1&e&&(n=r(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)r.d(t,o,function(e){return n[e]}.bind(null,o));return t},r.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(e,"a",e),e},r.o=function(n,e){return{}.hasOwnProperty.call(n,e)},r.p="",r(r.s=0)}([function(n,e,r){"use strict";function t(n){return"[object RegExp]"==={}.toString.call(n)}r.r(e);var o={MOCK:"mock:",FILE:"file:",ABOUT:"about:"},i="*",a={IFRAME:"iframe",POPUP:"popup"},u="Call was rejected by callee.\r\n";function c(n){return void 0===n&&(n=window),n.location.protocol===o.ABOUT}function s(n){if(void 0===n&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function f(n){if(void 0===n&&(n=window),n&&!s(n))try{return n.opener}catch(n){}}function d(n){try{return!0}catch(n){}return!1}function l(n){var e=(n=n||window).location;if(!e)throw new Error("Can not read window location");var r=e.protocol;if(!r)throw new Error("Can not read window protocol");if(r===o.FILE)return o.FILE+"//";if(r===o.ABOUT){var t=s(n);return t&&d()?l(t):o.ABOUT+"//"}var i=e.host;if(!i)throw new Error("Can not read window host");return r+"//"+i}function h(n){var e=l(n=n||window);return e&&n.mockDomain&&0===n.mockDomain.indexOf(o.MOCK)?n.mockDomain:e}function w(n){if(!function(n){try{if(n===window)return!0}catch(n){}try{var e=Object.getOwnPropertyDescriptor(n,"location");if(e&&!1===e.enumerable)return!1}catch(n){}try{if(c(n)&&d())return!0}catch(n){}try{if(l(n)===l(window))return!0}catch(n){}return!1}(n))return!1;try{if(n===window)return!0;if(c(n)&&d())return!0;if(h(window)===h(n))return!0}catch(n){}return!1}function p(n,e){if(!n||!e)return!1;var r=s(e);return r?r===n:-1!==function(n){var e=[];try{for(;n.parent!==n;)e.push(n.parent),n=n.parent}catch(n){}return e}(e).indexOf(n)}function v(n){var e,r,t=[];try{e=n.frames}catch(r){e=n}try{r=e.length}catch(n){}if(0===r)return t;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=e[o]}catch(n){continue}t.push(i)}return t}for(var a=0;a<100;a++){var u=void 0;try{u=e[a]}catch(n){return t}if(!u)return t;t.push(u)}return t}var m=[],y=[];function g(n,e){void 0===e&&(e=!0);try{if(n===window)return!1}catch(n){return!0}try{if(!n)return!0}catch(n){return!0}try{if(n.closed)return!0}catch(n){return!n||n.message!==u}if(e&&w(n))try{if(n.mockclosed)return!0}catch(n){}try{if(!n.parent||!n.top)return!0}catch(n){}var r=function(n,e){for(var r=0;r<n.length;r++)try{if(n[r]===e)return r}catch(n){}return-1}(m,n);if(-1!==r){var t=y[r];if(t&&function(n){if(!n.contentWindow)return!0;if(!n.parentNode)return!0;var e=n.ownerDocument;return!(!e||!e.documentElement||e.documentElement.contains(n))}(t))return!0}return!1}function _(n){return void 0===n&&(n=window),f(n=n||window)||s(n)||void 0}function E(n,e){if("string"==typeof n){if("string"==typeof e)return n===i||e===n;if(t(e))return!1;if(Array.isArray(e))return!1}return t(n)?t(e)?n.toString()===e.toString():!Array.isArray(e)&&Boolean(e.match(n)):!!Array.isArray(n)&&(Array.isArray(e)?JSON.stringify(n)===JSON.stringify(e):!t(e)&&n.some((function(n){return E(n,e)})))}function O(n){try{if(n===window)return!0}catch(n){if(n&&n.message===u)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===u)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===u)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===u)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===u)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===u)return!0}try{if(n&&"__unlikely_value__"===n.__cross_domain_utils_window_check__)return!1}catch(n){return!0}return!1}function W(n){try{n.close()}catch(n){}}function S(n){try{if(!n)return!1;if("undefined"!=typeof Promise&&n instanceof Promise)return!0;if("undefined"!=typeof window&&"function"==typeof window.Window&&n instanceof window.Window)return!1;if("undefined"!=typeof window&&"function"==typeof window.constructor&&n instanceof window.constructor)return!1;var e={}.toString;if(e){var r=e.call(n);if("[object Window]"===r||"[object global]"===r||"[object DOMWindow]"===r)return!1}if("function"==typeof n.then)return!0}catch(n){return!1}return!1}var b,R=[],x=[],I=0;function N(){if(!I&&b){var n=b;b=null,n.resolve()}}function P(){I+=1}function j(){I-=1,N()}var A=function(){function n(n){var e=this;if(this.resolved=void 0,this.rejected=void 0,this.errorHandled=void 0,this.value=void 0,this.error=void 0,this.handlers=void 0,this.dispatching=void 0,this.stack=void 0,this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],n){var r,t,o=!1,i=!1,a=!1;P();try{n((function(n){a?e.resolve(n):(o=!0,r=n)}),(function(n){a?e.reject(n):(i=!0,t=n)}))}catch(n){return j(),void this.reject(n)}j(),a=!0,o?this.resolve(r):i&&this.reject(t)}}var e=n.prototype;return e.resolve=function(n){if(this.resolved||this.rejected)return this;if(S(n))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=n,this.dispatch(),this},e.reject=function(n){var e=this;if(this.resolved||this.rejected)return this;if(S(n))throw new Error("Can not reject promise with another promise");if(!n){var r=n&&"function"==typeof n.toString?n.toString():{}.toString.call(n);n=new Error("Expected reject to be called with Error, got "+r)}return this.rejected=!0,this.error=n,this.errorHandled||setTimeout((function(){e.errorHandled||function(n,e){if(-1===R.indexOf(n)){R.push(n),setTimeout((function(){throw n}),1);for(var r=0;r<x.length;r++)x[r](n,e)}}(n,e)}),1),this.dispatch(),this},e.asyncReject=function(n){return this.errorHandled=!0,this.reject(n),this},e.dispatch=function(){var e=this.resolved,r=this.rejected,t=this.handlers;if(!this.dispatching&&(e||r)){this.dispatching=!0,P();for(var o=function(n,e){return n.then((function(n){e.resolve(n)}),(function(n){e.reject(n)}))},i=0;i<t.length;i++){var a=t[i],u=a.onSuccess,c=a.onError,s=a.promise,f=void 0;if(e)try{f=u?u(this.value):this.value}catch(n){s.reject(n);continue}else if(r){if(!c){s.reject(this.error);continue}try{f=c(this.error)}catch(n){s.reject(n);continue}}f instanceof n&&(f.resolved||f.rejected)?(f.resolved?s.resolve(f.value):s.reject(f.error),f.errorHandled=!0):S(f)?f instanceof n&&(f.resolved||f.rejected)?f.resolved?s.resolve(f.value):s.reject(f.error):o(f,s):s.resolve(f)}t.length=0,this.dispatching=!1,j()}},e.then=function(e,r){if(e&&"function"!=typeof e&&!e.call)throw new Error("Promise.then expected a function for success handler");if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.then expected a function for error handler");var t=new n;return this.handlers.push({promise:t,onSuccess:e,onError:r}),this.errorHandled=!0,this.dispatch(),t},e.catch=function(n){return this.then(void 0,n)},e.finally=function(e){if(e&&"function"!=typeof e&&!e.call)throw new Error("Promise.finally expected a function");return this.then((function(r){return n.try(e).then((function(){return r}))}),(function(r){return n.try(e).then((function(){throw r}))}))},e.timeout=function(n,e){var r=this;if(this.resolved||this.rejected)return this;var t=setTimeout((function(){r.resolved||r.rejected||r.reject(e||new Error("Promise timed out after "+n+"ms"))}),n);return this.then((function(n){return clearTimeout(t),n}))},e.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},n.resolve=function(e){return e instanceof n?e:S(e)?new n((function(n,r){return e.then(n,r)})):(new n).resolve(e)},n.reject=function(e){return(new n).reject(e)},n.asyncReject=function(e){return(new n).asyncReject(e)},n.all=function(e){var r=new n,t=e.length,o=[];if(!t)return r.resolve(o),r;for(var i=function(n,e,i){return e.then((function(e){o[n]=e,0==(t-=1)&&r.resolve(o)}),(function(n){i.reject(n)}))},a=0;a<e.length;a++){var u=e[a];if(u instanceof n){if(u.resolved){o[a]=u.value,t-=1;continue}}else if(!S(u)){o[a]=u,t-=1;continue}i(a,n.resolve(u),r)}return 0===t&&r.resolve(o),r},n.hash=function(e){var r={};return n.all(Object.keys(e).map((function(t){return n.resolve(e[t]).then((function(n){r[t]=n}))}))).then((function(){return r}))},n.map=function(e,r){return n.all(e.map(r))},n.onPossiblyUnhandledException=function(n){return function(n){return x.push(n),{cancel:function(){x.splice(x.indexOf(n),1)}}}(n)},n.try=function(e,r,t){if(e&&"function"!=typeof e&&!e.call)throw new Error("Promise.try expected a function");var o;P();try{o=e.apply(r,t||[])}catch(e){return j(),n.reject(e)}return j(),n.resolve(o)},n.delay=function(e){return new n((function(n){setTimeout(n,e)}))},n.isPromise=function(e){return!!(e&&e instanceof n)||S(e)},n.flush=function(){return e=b=b||new n,N(),e;var e},n}();function k(){return(k=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)({}).hasOwnProperty.call(r,t)&&(n[t]=r[t])}return n}).apply(this,arguments)}function D(n,e){for(var r=0;r<n.length;r++)try{if(n[r]===e)return r}catch(n){}return-1}var M,T=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__",function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var n=new WeakMap,e={};return Object.freeze(e),n.set(e,"__testvalue__"),"__testvalue__"===n.get(e)}catch(n){return!1}}())try{this.weakmap=new WeakMap}catch(n){}this.keys=[],this.values=[]}var e=n.prototype;return e._cleanupClosedWindows=function(){for(var n=this.weakmap,e=this.keys,r=0;r<e.length;r++){var t=e[r];if(O(t)&&g(t)){if(n)try{n.delete(t)}catch(n){}e.splice(r,1),this.values.splice(r,1),r-=1}}},e.isSafeToReadWrite=function(n){return!O(n)},e.set=function(n,e){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.set(n,e)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var t=this.name,o=n[t];return void(o&&o[0]===n?o[1]=e:Object.defineProperty(n,t,{value:[n,e],writable:!0}))}catch(n){}this._cleanupClosedWindows();var i=this.keys,a=this.values,u=D(i,n);-1===u?(i.push(n),a.push(e)):a[u]=e},e.get=function(n){if(!n)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{if(e.has(n))return e.get(n)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var r=n[this.name];return r&&r[0]===n?r[1]:void 0}catch(n){}this._cleanupClosedWindows();var t=D(this.keys,n);if(-1!==t)return this.values[t]},e.delete=function(n){if(!n)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{e.delete(n)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var r=n[this.name];r&&r[0]===n&&(r[0]=r[1]=void 0)}catch(n){}this._cleanupClosedWindows();var t=this.keys,o=D(t,n);-1!==o&&(t.splice(o,1),this.values.splice(o,1))},e.has=function(n){if(!n)throw new Error("WeakMap expected key");var e=this.weakmap;if(e)try{if(e.has(n))return!0}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n))try{var r=n[this.name];return!(!r||r[0]!==n)}catch(n){}return this._cleanupClosedWindows(),-1!==D(this.keys,n)},e.getOrSet=function(n,e){if(this.has(n))return this.get(n);var r=e();return this.set(n,r),r},n}();function C(){var n="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,(function(){return n.charAt(Math.floor(Math.random()*n.length))}))+"_"+function(n){if("function"==typeof btoa)return btoa(encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(function(n,e){return String.fromCharCode(parseInt(e,16))})));if("undefined"!=typeof Buffer)return Buffer.from(n,"utf8").toString("base64");throw new Error("Can not find window.btoa or Buffer")}((new Date).toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}function L(n){var e,r={};function t(){for(var e=this,t=arguments,o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var u=function(n){try{return JSON.stringify([].slice.call(n),(function(n,e){return"function"==typeof e?"memoize["+function(n){if(M=M||new T,null==n||"object"!=typeof n&&"function"!=typeof n)throw new Error("Invalid object");var e=M.get(n);return e||(e=typeof n+":"+C(),M.set(n,e)),e}(e)+"]":e}))}catch(n){throw new Error("Arguments not serializable -- can not be used to memoize")}}(i);return r.hasOwnProperty(u)?r[u]:(r[u]=A.try((function(){return n.apply(e,t)})).finally((function(){delete r[u]})),r[u])}return t.reset=function(){r={}},function(n,e){try{delete n.name,n.name=e}catch(n){}return n.__name__=n.displayName=e,n}(t,((e=n).name||e.__name__||e.displayName||"anonymous")+"::promiseMemoized")}function z(){}function F(n,e){if(void 0===e&&(e=1),e>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+{}.toString.call(n)+">";if("string"==typeof n)return n;if(n instanceof Error){var r=n&&n.stack,t=n&&n.message;if(r&&t)return-1!==r.indexOf(t)?r:t+"\n"+r;if(r)return r;if(t)return t}return n&&n.toString&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}catch(n){return"Error while stringifying error: "+F(n,e+1)}}function U(n){return"string"==typeof n?n:n&&n.toString&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}function B(n){return"[object RegExp]"==={}.toString.call(n)}function H(n,e,r){if(n.hasOwnProperty(e))return n[e];var t=r();return n[e]=t,t}Object.create(Error.prototype);var q={METHOD:"postrobot_method",HELLO:"postrobot_hello",OPEN_TUNNEL:"postrobot_open_tunnel"},G="*",J={CROSS_DOMAIN_ZALGO_PROMISE:"cross_domain_zalgo_promise",CROSS_DOMAIN_FUNCTION:"cross_domain_function",CROSS_DOMAIN_WINDOW:"cross_domain_window"};function X(n){return void 0===n&&(n=window),n!==window?n.__post_robot_10_0_20__:n.__post_robot_10_0_20__=n.__post_robot_10_0_20__||{}}var Y=function(){return{}};function Z(n,e){return void 0===n&&(n="store"),void 0===e&&(e=Y),H(X(),n,(function(){var n=e();return{has:function(e){return n.hasOwnProperty(e)},get:function(e,r){return n.hasOwnProperty(e)?n[e]:r},set:function(e,r){return n[e]=r,r},del:function(e){delete n[e]},getOrSet:function(e,r){return H(n,e,r)},reset:function(){n=e()},keys:function(){return Object.keys(n)}}}))}var K=function(){};function Q(){var n=X();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new K,n.WINDOW_WILDCARD}function V(n,e){return void 0===n&&(n="store"),void 0===e&&(e=Y),Z("windowStore").getOrSet(n,(function(){var r=new T,t=function(n){return r.getOrSet(n,e)};return{has:function(e){return t(e).hasOwnProperty(n)},get:function(e,r){var o=t(e);return o.hasOwnProperty(n)?o[n]:r},set:function(e,r){return t(e)[n]=r,r},del:function(e){delete t(e)[n]},getOrSet:function(e,r){return H(t(e),n,r)}}}))}function $(){return Z("instance").getOrSet("instanceID",C)}function nn(n,e){var r=e.domain,t=V("helloPromises"),o=t.get(n);o&&o.resolve({domain:r});var i=A.resolve({domain:r});return t.set(n,i),i}function en(n,e){return(0,e.send)(n,q.HELLO,{instanceID:$()},{domain:G,timeout:-1}).then((function(e){var r=e.origin,t=e.data.instanceID;return nn(n,{domain:r}),{win:n,domain:r,instanceID:t}}))}function rn(n,e){var r=e.send;return V("windowInstanceIDPromises").getOrSet(n,(function(){return en(n,{send:r}).then((function(n){return n.instanceID}))}))}function tn(n){V("knownWindows").set(n,!0)}var on,an={FUNCTION:"function",ERROR:"error",PROMISE:"promise",REGEX:"regex",DATE:"date",ARRAY:"array",OBJECT:"object",STRING:"string",NUMBER:"number",BOOLEAN:"boolean",NULL:"null",UNDEFINED:"undefined"};function un(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function cn(n){return void 0===n?an.UNDEFINED:null===n?an.NULL:Array.isArray(n)?an.ARRAY:"function"==typeof n?an.FUNCTION:"object"==typeof n?n instanceof Error?an.ERROR:"function"==typeof n.then?an.PROMISE:"[object RegExp]"==={}.toString.call(n)?an.REGEX:"[object Date]"==={}.toString.call(n)?an.DATE:an.OBJECT:"string"==typeof n?an.STRING:"number"==typeof n?an.NUMBER:"boolean"==typeof n?an.BOOLEAN:void 0}function sn(n,e){return{__type__:n,__val__:e}}var fn,dn=((on={})[an.FUNCTION]=function(){},on[an.ERROR]=function(n){return sn(an.ERROR,{message:n.message,stack:n.stack,code:n.code})},on[an.PROMISE]=function(){},on[an.REGEX]=function(n){return sn(an.REGEX,n.source)},on[an.DATE]=function(n){return sn(an.DATE,n.toJSON())},on[an.ARRAY]=function(n){return n},on[an.OBJECT]=function(n){return n},on[an.STRING]=function(n){return n},on[an.NUMBER]=function(n){return n},on[an.BOOLEAN]=function(n){return n},on[an.NULL]=function(n){return n},on),ln={},hn=((fn={})[an.FUNCTION]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},fn[an.ERROR]=function(n){var e=n.stack,r=n.code,t=new Error(n.message);return t.code=r,t.stack=e+"\n\n"+t.stack,t},fn[an.PROMISE]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},fn[an.REGEX]=function(n){return new RegExp(n)},fn[an.DATE]=function(n){return new Date(n)},fn[an.ARRAY]=function(n){return n},fn[an.OBJECT]=function(n){return n},fn[an.STRING]=function(n){return n},fn[an.NUMBER]=function(n){return n},fn[an.BOOLEAN]=function(n){return n},fn[an.NULL]=function(n){return n},fn),wn={};function pn(){for(var n=Z("idToProxyWindow"),e=0,r=n.keys();e<r.length;e++){var t=r[e];n.get(t).shouldClean()&&n.del(t)}}new A((function(n){if(window.document&&window.document.body)return n(window.document.body);var e=setInterval((function(){if(window.document&&window.document.body)return clearInterval(e),n(window.document.body)}),10)}));var vn=function(){function n(n){var e=n.send,r=n.win,t=n.serializedWindow;this.id=void 0,this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.name=void 0,this.actualWindowPromise=new A,this.serializedWindow=t||function(n,e){var r,t=e.send;return{id:C(),getType:function(){return n.then((function(n){return f(n)?a.POPUP:a.IFRAME}))},getInstanceID:L((function(){return n.then((function(n){return rn(n,{send:t})}))})),close:function(){return n.then(W)},getName:function(){return n.then((function(n){if(!g(n))return r}))},focus:function(){return n.then((function(n){n.focus()}))},isClosed:function(){return n.then((function(n){return g(n)}))},setLocation:function(e){return n.then((function(n){if(w(n))try{if(n.location&&"function"==typeof n.location.replace)return void n.location.replace(e)}catch(n){}n.location=e}))},setName:function(e){return n.then((function(n){var t=function(n){if(!w(n))throw new Error("Expected window to be same domain");return n}(n);t.name=e,t.frameElement&&t.frameElement.setAttribute("name",e),r=e}))}}}(this.actualWindowPromise,{send:e}),Z("idToProxyWindow").set(this.getID(),this),r&&this.setWindow(r)}var e=n.prototype;return e.getID=function(){return this.serializedWindow.id},e.getType=function(){return this.serializedWindow.getType()},e.isPopup=function(){return this.getType()===a.POPUP},e.setLocation=function(n){var e=this;return this.serializedWindow.setLocation(n).then((function(){return e}))},e.getName=function(){return this.serializedWindow.getName()},e.setName=function(n){var e=this;return this.serializedWindow.setName(n).then((function(){return e}))},e.close=function(){var n=this;return this.serializedWindow.close().then((function(){return n}))},e.focus=function(){var n=this;return A.all([this.isPopup()&&this.getName().then((function(n){n&&window.open("",n)})),this.serializedWindow.focus()]).then((function(){return n}))},e.isClosed=function(){return this.serializedWindow.isClosed()},e.getWindow=function(){return this.actualWindow},e.setWindow=function(n){this.actualWindow=n,this.actualWindowPromise.resolve(this.actualWindow),V("winToProxyWindow").set(n,this)},e.awaitWindow=function(){return this.actualWindowPromise},e.matchWindow=function(n,e){var r=this,t=e.send;return A.try((function(){return r.actualWindow?n===r.actualWindow:A.hash({proxyInstanceID:r.getInstanceID(),knownWindowInstanceID:rn(n,{send:t})}).then((function(e){var t=e.proxyInstanceID===e.knownWindowInstanceID;return t&&r.setWindow(n),t}))}))},e.unwrap=function(){return this.actualWindow||this},e.getInstanceID=function(){return this.serializedWindow.getInstanceID()},e.shouldClean=function(){return Boolean(this.actualWindow&&g(this.actualWindow))},e.serialize=function(){return this.serializedWindow},n.unwrap=function(e){return n.isProxyWindow(e)?e.unwrap():e},n.serialize=function(e,r){var t=r.send;return pn(),n.toProxyWindow(e,{send:t}).serialize()},n.deserialize=function(e,r){var t=r.send;return pn(),Z("idToProxyWindow").get(e.id)||new n({serializedWindow:e,send:t})},n.isProxyWindow=function(n){return Boolean(n&&!O(n)&&n.isProxyWindow)},n.toProxyWindow=function(e,r){var t=r.send;if(pn(),n.isProxyWindow(e))return e;var o=e;return V("winToProxyWindow").get(o)||new n({win:o,send:t})},n}();function mn(n,e,r,t,o){var i=V("methodStore"),a=Z("proxyWindowMethods");vn.isProxyWindow(t)?a.set(n,{val:e,name:r,domain:o,source:t}):(a.del(n),i.getOrSet(t,(function(){return{}}))[n]={domain:o,name:r,val:e,source:t})}function yn(n,e){var r=V("methodStore"),t=Z("proxyWindowMethods");return r.getOrSet(n,(function(){return{}}))[e]||t.get(e)}function gn(n,e,r,t,o){!function(n){var e=n.on,r=n.send;Z("builtinListeners").getOrSet("functionCalls",(function(){return e(q.METHOD,{domain:G},(function(n){var e=n.source,t=n.origin,o=n.data,i=o.id,a=o.name,u=yn(e,i);if(!u)throw new Error("Could not find method '"+o.name+"' with id: "+o.id+" in "+h(window));var c=u.source,s=u.domain,f=u.val;return A.try((function(){if(!E(s,t))throw new Error("Method '"+o.name+"' domain "+JSON.stringify(B(u.domain)?u.domain.source:u.domain)+" does not match origin "+t+" in "+h(window));if(vn.isProxyWindow(c))return c.matchWindow(e,{send:r}).then((function(n){if(!n)throw new Error("Method call '"+o.name+"' failed - proxy window does not match source in "+h(window))}))})).then((function(){return f.apply({source:e,origin:t},o.args)}),(function(n){return A.try((function(){if(f.onError)return f.onError(n)})).then((function(){throw n.stack&&(n.stack="Remote call to "+a+"()\n\n"+n.stack),n}))})).then((function(n){return{result:n,id:i,name:a}}))}))}))}({on:o.on,send:o.send});var i=r.__id__||C();n=vn.unwrap(n);var a=r.__name__||r.name||t;return vn.isProxyWindow(n)?(mn(i,r,a,n,e),n.awaitWindow().then((function(n){mn(i,r,a,n,e)}))):mn(i,r,a,n,e),sn(J.CROSS_DOMAIN_FUNCTION,{id:i,name:a})}function _n(n,e,r,t){var o,i=t.on,a=t.send;return function(n,e){void 0===e&&(e=ln);var r=JSON.stringify(n,(function(n){var r=this[n];if(un(this))return r;var t=cn(r);if(!t)return r;var o=e[t]||dn[t];return o?o(r,n):r}));return void 0===r?an.UNDEFINED:r}(r,((o={})[an.PROMISE]=function(r,t){return function(n,e,r,t,o){return sn(J.CROSS_DOMAIN_ZALGO_PROMISE,{then:gn(n,e,(function(n,e){return r.then(n,e)}),t,{on:o.on,send:o.send})})}(n,e,r,t,{on:i,send:a})},o[an.FUNCTION]=function(r,t){return gn(n,e,r,t,{on:i,send:a})},o[an.OBJECT]=function(n){return O(n)||vn.isProxyWindow(n)?sn(J.CROSS_DOMAIN_WINDOW,vn.serialize(n,{send:a})):n},o))}function En(n,e,r,t){var o,i=t.on,a=t.send;return function(n,e){if(void 0===e&&(e=wn),n!==an.UNDEFINED)return JSON.parse(n,(function(n,r){if(un(this))return r;var t,o;if(un(r)?(t=r.__type__,o=r.__val__):(t=cn(r),o=r),!t)return o;var i=e[t]||hn[t];return i?i(o,n):o}))}(r,((o={})[J.CROSS_DOMAIN_ZALGO_PROMISE]=function(n){return function(n,e,r){return new A(r.then)}(0,0,n)},o[J.CROSS_DOMAIN_FUNCTION]=function(r){return function(n,e,r,t){var o=r.id,i=r.name,a=t.send,u=function(r){function t(){var u=arguments;return vn.toProxyWindow(n,{send:a}).awaitWindow().then((function(n){var c=yn(n,o);if(c&&c.val!==t)return c.val.apply({source:window,origin:h()},u);var s={domain:e,fireAndForget:r.fireAndForget},f=[].slice.call(u);return a(n,q.METHOD,{id:o,name:i,args:f},s).then((function(n){if(!r.fireAndForget)return n.data.result}))})).catch((function(n){throw n}))}return void 0===r&&(r={}),t.__name__=i,t.__origin__=e,t.__source__=n,t.__id__=o,t.origin=e,t},c=u();return c.fireAndForget=u({fireAndForget:!0}),c}(n,e,r,{on:i,send:a})},o[J.CROSS_DOMAIN_WINDOW]=function(n){return vn.deserialize(n,{send:a})},o))}var On={};function Wn(n,e,r,t){var o,i=t.on,a=t.send;if(g(n))throw new Error("Window is closed");for(var u=_n(n,e,((o={}).__post_robot_10_0_20__=k({id:C(),origin:h(window)},r),o),{on:i,send:a}),c=Object.keys(On),s=[],f=0;f<c.length;f++){var d=c[f];try{On[d](n,u,e)}catch(n){s.push(n)}}if(s.length===c.length)throw new Error("All post-robot messaging strategies failed:\n\n"+s.map(F).join("\n\n"))}On.postrobot_post_message=function(n,e,r){(Array.isArray(r)?r:"string"==typeof r?[r]:[G]).map((function(n){return 0===n.indexOf(o.FILE)?G:n})).forEach((function(r){n.postMessage(e,r)}))};var Sn,bn="__domain_regex__";function Rn(n){return Z("responseListeners").get(n)}function xn(n){Z("responseListeners").del(n)}function In(n){return Z("erroredResponseListeners").has(n)}function Nn(n){var e=n.name,r=n.win,t=n.domain,o=V("requestListeners");if(r===G&&(r=null),t===G&&(t=null),!e)throw new Error("Name required to get request listener");for(var i=0,a=[r,Q()];i<a.length;i++){var u=a[i];if(u){var c=o.get(u);if(c){var s=c[e];if(s){if(t&&"string"==typeof t){if(s[t])return s[t];if(s[bn])for(var f=0,d=s[bn];f<d.length;f++){var l=d[f],h=l.listener;if(E(l.regex,t))return h}}if(s[G])return s[G]}}}}}var Pn=((Sn={}).postrobot_message_request=function(n,e,r,t){var o=t.on,i=t.send,a=Nn({name:r.name,win:n,domain:e});function u(t,a,u){void 0===u&&(u={}),r.fireAndForget||g(n)||Wn(n,e,k({type:t,ack:a,hash:r.hash,name:r.name},u),{on:o,send:i})}return A.all([u("postrobot_message_ack"),A.try((function(){if(!a)throw new Error("No handler found for post message: "+r.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!E(a.domain,e))throw new Error("Request origin "+e+" does not match domain "+a.domain.toString());return a.handler({source:n,origin:e,data:r.data})})).then((function(n){return u("postrobot_message_response","success",{data:n})}),(function(n){return u("postrobot_message_response","error",{error:n})}))]).then(z).catch((function(n){if(a&&a.handleError)return a.handleError(n);throw n}))},Sn.postrobot_message_ack=function(n,e,r){if(!In(r.hash)){var t=Rn(r.hash);if(!t)throw new Error("No handler found for post message ack for message: "+r.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!E(t.domain,e))throw new Error("Ack origin "+e+" does not match domain "+t.domain.toString());if(n!==t.win)throw new Error("Ack source does not match registered window");t.ack=!0}},Sn.postrobot_message_response=function(n,e,r){if(!In(r.hash)){var o,i=Rn(r.hash);if(!i)throw new Error("No handler found for post message response for message: "+r.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!E(i.domain,e))throw new Error("Response origin "+e+" does not match domain "+(o=i.domain,Array.isArray(o)?"("+o.join(" | ")+")":t(o)?"RegExp("+o.toString():o.toString()));if(n!==i.win)throw new Error("Response source does not match registered window");xn(r.hash),"error"===r.ack?i.promise.reject(r.error):"success"===r.ack&&i.promise.resolve({source:n,origin:e,data:r.data})}},Sn);function jn(n,e){var r=e.on,t=e.send,i=Z("receivedMessages");if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!n.source)return}catch(n){return}var a=n.source,u=n.origin,c=function(n,e,r,t){var o,i=t.on,a=t.send;try{o=En(e,r,n,{on:i,send:a})}catch(n){return}if(o&&"object"==typeof o&&null!==o&&(o=o.__post_robot_10_0_20__)&&"object"==typeof o&&null!==o&&o.type&&"string"==typeof o.type&&Pn[o.type])return o}(n.data,a,u,{on:r,send:t});c&&(tn(a),i.has(c.id)||(i.set(c.id,!0),g(a)&&!c.fireAndForget||(0===c.origin.indexOf(o.FILE)&&(u=o.FILE+"//"),Pn[c.type](a,u,c,{on:r,send:t}))))}function An(n,e,r){if(!n)throw new Error("Expected name");if("function"==typeof e&&(r=e,e={}),!r)throw new Error("Expected handler");(e=e||{}).name=n,e.handler=r||e.handler;var t=e.window,o=e.domain,i=function n(e,r){var t=e.name,o=e.win,i=e.domain,a=V("requestListeners");if(!t||"string"!=typeof t)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var u=[],c=0,s=o;c<s.length;c++)u.push(n({name:t,domain:i,win:s[c]},r));return{cancel:function(){for(var n=0;n<u.length;n++)u[n].cancel()}}}if(Array.isArray(i)){for(var f=[],d=0,l=i;d<l.length;d++)f.push(n({name:t,win:o,domain:l[d]},r));return{cancel:function(){for(var n=0;n<f.length;n++)f[n].cancel()}}}var h=Nn({name:t,win:o,domain:i});if(o&&o!==G||(o=Q()),i=i||G,h)throw o&&i?new Error("Request listener already exists for "+t+" on domain "+i.toString()+" for "+(o===Q()?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+t+" for "+(o===Q()?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+t+" on domain "+i.toString()):new Error("Request listener already exists for "+t);var w,p,v=a.getOrSet(o,(function(){return{}})),m=H(v,t,(function(){return{}})),y=i.toString();return B(i)?(w=H(m,bn,(function(){return[]}))).push(p={regex:i,listener:r}):m[y]=r,{cancel:function(){delete m[y],p&&(w.splice(w.indexOf(p,1)),w.length||delete m[bn]),Object.keys(m).length||delete v[t],o&&!Object.keys(v).length&&a.del(o)}}}({name:n,win:t,domain:o},{handler:e.handler,handleError:e.errorHandler||function(n){throw n},window:t,domain:o||G,name:n});return{cancel:function(){i.cancel()}}}function kn(n,e,r){"function"==typeof(e=e||{})&&(r=e,e={});var t,o=new A;return e.errorHandler=function(n){t.cancel(),o.reject(n)},t=An(n,e,(function(n){if(t.cancel(),o.resolve(n),r)return r(n)})),o.cancel=t.cancel,o}var Dn=function n(e,r,t,o){var i=(o=o||{}).domain||G,a=o.timeout||-1,u=o.timeout||5e3,c=o.fireAndForget||!1;return A.try((function(){if(function(n,e,r){if(!n)throw new Error("Expected name");if(r&&"string"!=typeof r&&!Array.isArray(r)&&!B(r))throw new TypeError("Expected domain to be a string, array, or regex");if(g(e))throw new Error("Target window is closed")}(r,e,i),function(n,e){var r=_(e);if(r)return r===n;if(e===n)return!1;if(function(n){if(n){try{if(n.top)return n.top}catch(n){}if(s(n)===n)return n;try{if(p(window,n)&&window.top)return window.top}catch(n){}try{if(p(n,window)&&window.top)return window.top}catch(n){}for(var e=0,r=function n(e){for(var r=[],t=0,o=v(e);t<o.length;t++){var i=o[t];r.push(i);for(var a=0,u=n(i);a<u.length;a++)r.push(u[a])}return r}(n);e<r.length;e++){var t=r[e];try{if(t.top)return t.top}catch(n){}if(s(t)===t)return t}}}(e)===e)return!1;for(var t=0,o=v(n);t<o.length;t++)if(o[t]===e)return!0;return!1}(window,e))return function(n,e,r){void 0===e&&(e=5e3),void 0===r&&(r="Window");var t=function(n){return V("helloPromises").getOrSet(n,(function(){return new A}))}(n);return-1!==e&&(t=t.timeout(e,new Error(r+" did not load after "+e+"ms"))),t}(e,u)})).then((function(r){return function(n,e,r,t){var o=t.send;return"string"==typeof e?A.resolve(e):A.try((function(){return r||en(n,{send:o}).then((function(n){return n.domain}))})).then((function(n){if(!E(e,e))throw new Error("Domain "+U(e)+" does not match "+U(e));return n}))}(e,i,(void 0===r?{}:r).domain,{send:n})})).then((function(o){i=o;var u,s,f=r===q.METHOD&&t&&"string"==typeof t.name?t.name+"()":r,d=new A,l=r+"_"+C();if(!c){var w={name:r,win:e,domain:i,promise:d};!function(n,e){Z("responseListeners").set(n,e)}(l,w);var p=V("requestPromises").getOrSet(e,(function(){return[]}));p.push(d),d.catch((function(){!function(n){Z("erroredResponseListeners").set(n,!0)}(l),xn(l)}));var v=function(n){return V("knownWindows").get(n,!1)}(e)?1e4:2e3,m=a,y=v,_=m,E=(u=function(){return g(e)?d.reject(new Error("Window closed for "+r+" before "+(w.ack?"response":"ack"))):w.cancelled?d.reject(new Error("Response listener was cancelled for "+r)):(y=Math.max(y-500,0),-1!==_&&(_=Math.max(_-500,0)),w.ack||0!==y?0===_?d.reject(new Error("No response for postMessage "+f+" in "+h()+" in "+m+"ms")):void 0:d.reject(new Error("No ack for postMessage "+f+" in "+h()+" in "+v+"ms")))},500,function n(){s=setTimeout((function(){u(),n()}),500)}(),{cancel:function(){clearTimeout(s)}});d.finally((function(){E.cancel(),p.splice(p.indexOf(d,1))})).catch(z)}return Wn(e,i,{type:"postrobot_message_request",hash:l,name:r,data:t,fireAndForget:c},{on:An,send:n}),c?d.resolve():d}))};function Mn(n,e,r){return _n(n,e,r,{on:An,send:Dn})}function Tn(n,e,r){return En(n,e,r,{on:An,send:Dn})}function Cn(n){return new vn({send:Dn,win:n})}function Ln(n){return vn.toProxyWindow(n,{send:Dn})}function zn(){var n,e,r;X().initialized||(X().initialized=!0,function(n){var e=n.on,r=n.send,t=X();t.receiveMessage=t.receiveMessage||function(n){return jn(n,{on:e,send:r})}}({on:An,send:Dn}),e=(n={on:An,send:Dn}).on,r=n.send,Z().getOrSet("postMessageListener",(function(){return(n=window).addEventListener("message",t=function(n){!function(n,e){var r=e.on,t=e.send,i=n.source||n.sourceElement,a=n.origin||n.originalEvent&&n.originalEvent.origin,u=n.data;if("null"===a&&(a=o.FILE+"//"),i){if(!a)throw new Error("Post message did not have origin domain");jn({source:i,origin:a,data:u},{on:r,send:t})}}(n,{on:e,send:r})}),{cancel:function(){n.removeEventListener("message",t)}};var n,t})),function(n){var e=n.on,r=n.send;Z("builtinListeners").getOrSet("helloListener",(function(){var n=e(q.HELLO,{domain:G},(function(n){return nn(n.source,{domain:n.origin}),{instanceID:$()}})),t=_();return t&&en(t,{send:r}).catch(z),n}))}({on:An,send:Dn}))}function Fn(){var n;!function(){for(var n=Z("responseListeners"),e=0,r=n.keys();e<r.length;e++){var t=r[e],o=n.get(t);o&&(o.cancelled=!0),n.del(t)}}(),(n=Z().get("postMessageListener"))&&n.cancel(),delete window.__post_robot_10_0_20__}function Un(n){for(var e=0,r=V("requestPromises").get(n,[]);e<r.length;e++)r[e].reject(new Error("Window cleaned up before response")).catch(z)}r.d(e,"bridge",(function(){})),r.d(e,"Promise",(function(){return A})),r.d(e,"TYPES",(function(){return!0})),r.d(e,"ProxyWindow",(function(){return vn})),r.d(e,"setup",(function(){return zn})),r.d(e,"destroy",(function(){return Fn})),r.d(e,"serializeMessage",(function(){return Mn})),r.d(e,"deserializeMessage",(function(){return Tn})),r.d(e,"createProxyWindow",(function(){return Cn})),r.d(e,"toProxyWindow",(function(){return Ln})),r.d(e,"on",(function(){return An})),r.d(e,"once",(function(){return kn})),r.d(e,"send",(function(){return Dn})),r.d(e,"markWindowKnown",(function(){return tn})),r.d(e,"cleanUpWindow",(function(){return Un})),zn()}])})); | ||
//# sourceMappingURL=post-robot.min.js.map |
{ | ||
"name": "post-robot", | ||
"version": "10.0.19", | ||
"version": "10.0.20", | ||
"description": "Simple postMessage based server.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -183,6 +183,2 @@ /* @flow */ | ||
if (name) { | ||
if (details.name && details.name !== name) { | ||
throw new Error(`Different window already linked for name ${ name }: ${ details.name }`); | ||
} | ||
details.name = name; | ||
@@ -189,0 +185,0 @@ popupWindowsByName.set(name, details); |
@@ -15,3 +15,3 @@ /* @flow */ | ||
function getHelloPromise(win : CrossDomainWindowType) : ZalgoPromise<{ win : CrossDomainWindowType, domain : string }> { | ||
function getHelloPromise(win : CrossDomainWindowType) : ZalgoPromise<{ domain : string }> { | ||
const helloPromises = windowStore('helloPromises'); | ||
@@ -21,5 +21,16 @@ return helloPromises.getOrSet(win, () => new ZalgoPromise()); | ||
function resolveHelloPromise(win : CrossDomainWindowType, { domain }) : ZalgoPromise<{ domain : string }> { | ||
const helloPromises = windowStore('helloPromises'); | ||
const existingPromise = helloPromises.get(win); | ||
if (existingPromise) { | ||
existingPromise.resolve({ domain }); | ||
} | ||
const newPromise = ZalgoPromise.resolve({ domain }); | ||
helloPromises.set(win, newPromise); | ||
return newPromise; | ||
} | ||
function listenForHello({ on } : { on : OnType }) : CancelableType { | ||
return on(MESSAGE_NAME.HELLO, { domain: WILDCARD }, ({ source, origin }) => { | ||
getHelloPromise(source).resolve({ win: source, domain: origin }); | ||
resolveHelloPromise(source, { domain: origin }); | ||
return { instanceID: getInstanceID() }; | ||
@@ -32,3 +43,3 @@ }); | ||
.then(({ origin, data: { instanceID } }) => { | ||
getHelloPromise(win).resolve({ win, domain: origin }); | ||
resolveHelloPromise(win, { domain: origin }); | ||
return { win, domain: origin, instanceID }; | ||
@@ -57,3 +68,3 @@ }); | ||
export function awaitWindowHello(win : CrossDomainWindowType, timeout : number = 5000, name : string = 'Window') : ZalgoPromise<{ win : CrossDomainWindowType, domain : string }> { | ||
export function awaitWindowHello(win : CrossDomainWindowType, timeout : number = 5000, name : string = 'Window') : ZalgoPromise<{ domain : string }> { | ||
let promise = getHelloPromise(win); | ||
@@ -60,0 +71,0 @@ |
@@ -32,16 +32,15 @@ /* @flow */ | ||
function normalizeDomain(win : CrossDomainWindowType, domain : DomainMatcher, childTimeout : number, { send } : { send : SendType }) : ZalgoPromise<string | $ReadOnlyArray<string>> { | ||
function normalizeDomain(win : CrossDomainWindowType, targetDomain : DomainMatcher, actualDomain : ?string, { send } : { send : SendType }) : ZalgoPromise<string | $ReadOnlyArray<string>> { | ||
if (typeof targetDomain === 'string') { | ||
return ZalgoPromise.resolve(targetDomain); | ||
} | ||
return ZalgoPromise.try(() => { | ||
if (isAncestor(window, win)) { | ||
return awaitWindowHello(win, childTimeout); | ||
} else if (isRegex(domain)) { | ||
// $FlowFixMe | ||
return sayHello(win, { send }); | ||
} else { | ||
return { domain }; | ||
return actualDomain || sayHello(win, { send }).then(({ domain }) => domain); | ||
}).then(normalizedDomain => { | ||
if (!matchDomain(targetDomain, targetDomain)) { | ||
throw new Error(`Domain ${ stringify(targetDomain) } does not match ${ stringify(targetDomain) }`); | ||
} | ||
// $FlowFixMe | ||
}).then(({ domain: normalizedDomain }) => { | ||
// $FlowFixMe | ||
return normalizedDomain; | ||
@@ -61,9 +60,12 @@ }); | ||
validateOptions(name, win, domain); | ||
return normalizeDomain(win, domain, childTimeout, { send }); | ||
}).then(targetDomain => { | ||
if (!matchDomain(domain, targetDomain)) { | ||
throw new Error(`Domain ${ stringify(domain) } does not match ${ stringify(targetDomain) }`); | ||
if (isAncestor(window, win)) { | ||
return awaitWindowHello(win, childTimeout); | ||
} | ||
}).then(({ domain: actualDomain } = {}) => { | ||
return normalizeDomain(win, domain, actualDomain, { send }); | ||
}).then(targetDomain => { | ||
domain = targetDomain; | ||
@@ -70,0 +72,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1535309
8862