post-robot
Advanced tools
Comparing version 10.0.23 to 10.0.24
@@ -137,3 +137,3 @@ "use strict"; | ||
if (name.indexOf('anonymous::') === 0) { | ||
if (typeof name === 'string' && typeof name.indexOf === 'function' && name.indexOf('anonymous::') === 0) { | ||
name = name.replace('anonymous::', `${key}::`); | ||
@@ -140,0 +140,0 @@ } |
@@ -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"},s="Call was rejected by callee.\r\n";function u(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){void 0===n&&(n=window);var e=n.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){void 0===n&&(n=window);var e=w(n);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(u(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(u(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 s=void 0;try{s=e[a]}catch(n){return t}if(!s)return t;t.push(s)}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){void 0===n&&(n=window);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!==s}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 P(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 A(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(P(o,i))return!0;var a=f(r),s=f(t);return!(a&&P(_(a),i)||(s&&P(_(s),o),1))}function R(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 R(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===s)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===s)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===s)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===s)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===s)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===s)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.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],s=a.onSuccess,u=a.onError,c=a.promise,f=void 0;if(e)try{f=s?s(this.value):this.value}catch(n){c.reject(n);continue}else if(r){if(!u){c.reject(this.error);continue}try{f=u(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 s=e[a];if(s instanceof n){if(s.resolved){o[a]=s.value,t-=1;continue}}else if(!j(s)){o[a]=s,t-=1;continue}i(a,n.resolve(s),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=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,s=q(i,n);-1===s?(i.push(n),a.push(e)):a[s]=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 s=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(s)?r[s]:(r[s]=U.try((function(){return n.apply(e,t)})).finally((function(){delete r[s]})),r[s])}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_23__:n.__post_robot_10_0_23__=n.__post_robot_10_0_23__||{}}var an=function(){return{}};function sn(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 un=function(){};function cn(){var n=on();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new un,n.WINDOW_WILDCARD}function fn(n,e){return void 0===n&&(n="store"),void 0===e&&(e=an),sn("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 sn("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 Pn(n){return!A(window,n)}function An(n,e){if(n){if(h()!==I(n))return!0}else if(e&&!l(e))return!0;return!1}function Rn(n){var e=n.win,r=n.domain;return!(!Nn()||r&&!An(r,e)||e&&!Pn(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(!R(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=sn("popupWindowsByName"),i=fn("popupWindowsByWin"),a=0,s=o.keys();a<s.length;a++){var u=s[a],c=o.get(u);c&&!b(c.win)||o.del(u)}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=sn("popupWindowsByName");e(nn.OPEN_TUNNEL,(function(n){var i=n.source,a=n.origin,s=n.data,u=sn("bridges").get(a);if(!u)throw new Error("Can not find bridge promise for domain "+a);return u.then((function(n){if(i!==n)throw new Error("Message source does not matched registered bridge for domain "+a);if(!s.name)throw new Error("Register window expected to be passed window name");if(!s.sendMessage)throw new Error("Register window expected to be passed sendMessage method");if(!o.has(s.name))throw new Error("Window with name "+s.name+" does not exist, or was not opened by this window");if(!o.get(s.name).domain)throw new Error("We do not have a registered domain for window "+s.name);if(o.get(s.name).domain!==a)throw new Error("Message origin "+a+" does not matched registered window origin "+o.get(s.name).domain);return Tn(o.get(s.name).win,a,s.sendMessage),{sendMessage:function(n){if(window&&!window.closed){var i=o.get(s.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=sn("tunnelWindows"),s=c(window);if(!s)throw new Error("No parent window found to open tunnel to");var u=function(n){var e=n.name,r=n.source,t=n.canary,o=n.sendMessage;!function(){for(var n=sn("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 sn("tunnelWindows").set(i,{name:e,source:r,canary:t,sendMessage:o}),i}({name:r,source:t,canary:o,sendMessage:i});return e(s,nn.OPEN_TUNNEL,{name:r,sendMessage:function(){var n=a.get(u);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&&Rn({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=sn("idToProxyWindow"),e=0,r=n.keys();e<r.length;e++){var t=r[e];n.get(t).shouldClean()&&n.del(t)}}function zn(n,e){var r,t=e.send,o=e.id;return{id:void 0===o?X():o,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}))}}}var Un=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||zn(this.actualWindowPromise,{send:e}),sn("idToProxyWindow").set(this.getID(),this),r&&this.setWindow(r,{send:e})}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().then((function(n){return n===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,e=this.isPopup(),r=this.getName(),t=U.hash({isPopup:e,name:r}).then((function(n){var e=n.name;n.isPopup&&e&&window.open("",e)})),o=this.serializedWindow.focus();return U.all([t,o]).then((function(){return n}))},e.isClosed=function(){return this.serializedWindow.isClosed()},e.getWindow=function(){return this.actualWindow},e.setWindow=function(n,e){var r=e.send;this.actualWindow=n,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=zn(this.actualWindowPromise,{send:r,id:this.getID()}),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 o=e.proxyInstanceID===e.knownWindowInstanceID;return o&&r.setWindow(n,{send:t}),o}))}))},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(),sn("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 Hn(n,e,r,t,o){var i=fn("methodStore"),a=sn("proxyWindowMethods");Un.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 qn(n,e){var r=fn("methodStore"),t=sn("proxyWindowMethods");return r.getOrSet(n,(function(){return{}}))[e]||t.get(e)}function Gn(n,e,r,t,o){var i,a,s;a=(i={on:o.on,send:o.send}).on,s=i.send,sn("builtinListeners").getOrSet("functionCalls",(function(){return a(nn.METHOD,{domain:rn},(function(n){var e=n.source,r=n.origin,t=n.data,o=t.id,i=t.name,a=qn(e,o);if(!a)throw new Error("Could not find method '"+i+"' with id: "+t.id+" in "+h(window));var u=a.source,c=a.domain,f=a.val;return U.try((function(){if(!R(c,r))throw new Error("Method '"+t.name+"' domain "+JSON.stringify(V(a.domain)?a.domain.source:a.domain)+" does not match origin "+r+" in "+h(window));if(Un.isProxyWindow(u))return u.matchWindow(e,{send:s}).then((function(n){if(!n)throw new Error("Method call '"+t.name+"' failed - proxy window does not match source in "+h(window))}))})).then((function(){return f.apply({source:e,origin:r},t.args)}),(function(n){return U.try((function(){if(f.onError)return f.onError(n)})).then((function(){throw n.stack&&(n.stack="Remote call to "+i+"()\n\n"+n.stack),n}))})).then((function(n){return{result:n,id:o,name:i}}))}))}));var u=r.__id__||X();n=Un.unwrap(n);var c=r.__name__||r.name||t;return 0===c.indexOf("anonymous::")&&(c=c.replace("anonymous::",t+"::")),Un.isProxyWindow(n)?(Hn(u,r,c,n,e),n.awaitWindow().then((function(n){Hn(u,r,c,n,e)}))):Hn(u,r,c,n,e),En(tn.CROSS_DOMAIN_FUNCTION,{id:u,name:c})}function Jn(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: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[gn.FUNCTION]=function(r,t){return Gn(n,e,r,t,{on:i,send:a})},o[gn.OBJECT]=function(n){return M(n)||Un.isProxyWindow(n)?En(tn.CROSS_DOMAIN_WINDOW,Un.serialize(n,{send:a})):n},o))}function Xn(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,s=function(r){function t(){var s=arguments;return Un.toProxyWindow(n,{send:a}).awaitWindow().then((function(n){var u=qn(n,o);if(u&&u.val!==t)return u.val.apply({source:window,origin:h()},s);var c={domain:e,fireAndForget:r.fireAndForget},f=[].slice.call(s);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},u=s();return u.fireAndForget=s({fireAndForget:!0}),u}(n,e,r,{on:i,send:a})},o[tn.CROSS_DOMAIN_WINDOW]=function(n){return Un.deserialize(n,{send:a})},o))}var Yn={};function Zn(n,e,r,t){var o,i=t.on,a=t.send;if(b(n))throw new Error("Window is closed");for(var s=Jn(n,e,((o={}).__post_robot_10_0_23__=H({id:X(),origin:h(window)},r),o),{on:i,send:a}),u=Object.keys(Yn),c=[],f=0;f<u.length;f++){var d=u[f];try{Yn[d](n,s,e)}catch(n){c.push(n)}}if(c.length===u.length)throw new Error("All post-robot messaging strategies failed:\n\n"+c.map((function(n,e){return e+". "+K(n)})).join("\n\n"))}Yn.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)}))},Yn.postrobot_bridge=function(n,e,r){if(!Nn()&&!Mn())throw new Error("Bridge not needed for browser");if(l(n))throw new Error("Post message through bridge disabled between same domain windows");if(!1!==A(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)},Yn.postrobot_global=function(n,e){if(!W(window).match(/MSIE|rv:11|trident|edge\/12|edge\/13/i))throw new Error("Global messaging not needed for browser");if(!l(n))throw new Error("Post message through global disabled between different domain windows");if(!1!==A(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 Kn,Qn="__domain_regex__";function Vn(n){return sn("responseListeners").get(n)}function $n(n){sn("responseListeners").del(n)}function ne(n){return sn("erroredResponseListeners").has(n)}function ee(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 s=a[i];if(s){var u=o.get(s);if(u){var c=u[e];if(c){if(t&&"string"==typeof t){if(c[t])return c[t];if(c[Qn])for(var f=0,d=c[Qn];f<d.length;f++){var w=d[f],h=w.listener;if(R(w.regex,t))return h}}if(c[rn])return c[rn]}}}}}var re=((Kn={}).postrobot_message_request=function(n,e,r,t){var o=t.on,i=t.send,a=ee({name:r.name,win:n,domain:e}),s=r.name===nn.METHOD&&r.data&&"string"==typeof r.data.name?r.data.name+"()":r.name;function u(t,a,u){if(void 0===u&&(u={}),!r.fireAndForget&&!b(n))try{Zn(n,e,H({type:t,ack:a,hash:r.hash,name:r.name},u),{on:o,send:i})}catch(n){throw new Error("Send response message failed for "+s+" in "+h()+"\n\n"+K(n))}}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(!R(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}))},Kn.postrobot_message_ack=function(n,e,r){if(!ne(r.hash)){var t=Vn(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);try{if(!R(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")}catch(n){t.promise.reject(n)}t.ack=!0}},Kn.postrobot_message_response=function(n,e,r){if(!ne(r.hash)){var o,i=Vn(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(!R(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");$n(r.hash),"error"===r.ack?i.promise.reject(r.error):"success"===r.ack&&i.promise.resolve({source:n,origin:e,data:r.data})}},Kn);function te(n,e){var r=e.on,t=e.send,i=sn("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,s=n.origin,u=function(n,e,r,t){var o,i=t.on,a=t.send;try{o=Xn(e,r,n,{on:i,send:a})}catch(n){return}if(o&&"object"==typeof o&&null!==o&&(o=o.__post_robot_10_0_23__)&&"object"==typeof o&&null!==o&&o.type&&"string"==typeof o.type&&re[o.type])return o}(n.data,a,s,{on:r,send:t});u&&(vn(a),i.has(u.id)||(i.set(u.id,!0),b(a)&&!u.fireAndForget||(0===u.origin.indexOf(o.FILE)&&(s=o.FILE+"//"),re[u.type](a,s,u,{on:r,send:t}))))}function oe(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 s=[],u=0,c=o;u<c.length;u++)s.push(n({name:t,domain:i,win:c[u]},r));return{cancel:function(){for(var n=0;n<s.length;n++)s[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=ee({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,Qn,(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[Qn]),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 ie(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=oe(n,e,(function(n){if(t.cancel(),o.resolve(n),r)return r(n)})),o.cancel=t.cancel,o}var ae,se=function n(e,r,t,o){var i=(o=o||{}).domain||rn,a=o.timeout||-1,s=o.timeout||5e3,u=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,s)})).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(!R(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 s,c,f=r===nn.METHOD&&t&&"string"==typeof t.name?t.name+"()":r,d=new U,w=r+"_"+X();if(!u){var l={name:r,win:e,domain:i,promise:d};!function(n,e){sn("responseListeners").set(n,e)}(w,l);var m=fn("requestPromises").getOrSet(e,(function(){return[]}));m.push(d),d.catch((function(){!function(n){sn("erroredResponseListeners").set(n,!0)}(w),$n(w)}));var v=function(n){return fn("knownWindows").get(n,!1)}(e)?1e4:2e3,p=a,g=v,y=p,_=(s=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(){s(),n()}),500)}(),{cancel:function(){clearTimeout(c)}});d.finally((function(){_.cancel(),m.splice(m.indexOf(d,1))})).catch(Z)}try{Zn(e,i,{type:"postrobot_message_request",hash:w,name:r,data:t,fireAndForget:u},{on:oe,send:n})}catch(n){throw new Error("Send request message failed for "+f+" in "+h()+"\n\n"+K(n))}return u?d.resolve():d}))};function ue(n,e,r){return Jn(n,e,r,{on:oe,send:se})}function ce(n,e,r){return Xn(n,e,r,{on:oe,send:se})}function fe(n){return new Un({send:se,win:n})}function de(n){return Un.toProxyWindow(n,{send:se})}function we(){var n,e,r,t;on().initialized||(on().initialized=!0,e=(n={on:oe,send:se}).on,r=n.send,(t=on()).receiveMessage=t.receiveMessage||function(n){return te(n,{on:e,send:r})},function(n){var e=n.on,r=n.send;sn().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,s=n.data;if("null"===a&&(a=o.FILE+"//"),i){if(!a)throw new Error("Post message did not have origin domain");te({source:i,origin:a,data:s},{on:r,send:t})}}(n,{on:e,send:r})}),{cancel:function(){n.removeEventListener("message",t)}};var n,t}))}({on:oe,send:se}),Bn({on:oe,send:se,receiveMessage:te}),function(n){var e=n.on,r=n.send;sn("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:oe,send:se}))}function he(){var n;!function(){for(var n=sn("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=sn().get("postMessageListener"))&&n.cancel(),delete window.__post_robot_10_0_23__}function le(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 ae})),r.d(e,"Promise",(function(){return U})),r.d(e,"TYPES",(function(){return!0})),r.d(e,"ProxyWindow",(function(){return Un})),r.d(e,"setup",(function(){return we})),r.d(e,"destroy",(function(){return he})),r.d(e,"serializeMessage",(function(){return ue})),r.d(e,"deserializeMessage",(function(){return ce})),r.d(e,"createProxyWindow",(function(){return fe})),r.d(e,"toProxyWindow",(function(){return de})),r.d(e,"on",(function(){return oe})),r.d(e,"once",(function(){return ie})),r.d(e,"send",(function(){return se})),r.d(e,"markWindowKnown",(function(){return vn})),r.d(e,"cleanUpWindow",(function(){return le})),ae={setupBridge:Bn,openBridge:function(n,e){var r=sn("bridges"),t=sn("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:Rn,needsBridgeForBrowser:Nn,hasBridge:function(n,e){return sn("bridges").has(e||I(n))},needsBridgeForWin:Pn,needsBridgeForDomain:An,destroyBridges:function(){for(var n=sn("bridges"),e=sn("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()}},we()}])})); | ||
!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"},s="Call was rejected by callee.\r\n";function u(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){void 0===n&&(n=window);var e=n.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){void 0===n&&(n=window);var e=w(n);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(u(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(u(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 p(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 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 s=void 0;try{s=e[a]}catch(n){return t}if(!s)return t;t.push(s)}return t}function g(n){for(var e=[],r=0,t=v(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){void 0===n&&(n=window);try{if(n.top)return n.top}catch(n){}if(c(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=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!==s}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=v(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 P(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 A(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(P(o,i))return!0;var a=f(r),s=f(t);return!(a&&P(_(a),i)||(s&&P(_(s),o),1))}function R(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 R(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===s)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===s)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===s)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===s)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===s)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===s)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.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],s=a.onSuccess,u=a.onError,c=a.promise,f=void 0;if(e)try{f=s?s(this.value):this.value}catch(n){c.reject(n);continue}else if(r){if(!u){c.reject(this.error);continue}try{f=u(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 s=e[a];if(s instanceof n){if(s.resolved){o[a]=s.value,t-=1;continue}}else if(!j(s)){o[a]=s,t-=1;continue}i(a,n.resolve(s),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=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,s=q(i,n);-1===s?(i.push(n),a.push(e)):a[s]=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 s=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(s)?r[s]:(r[s]=U.try((function(){return n.apply(e,t)})).finally((function(){delete r[s]})),r[s])}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_24__:n.__post_robot_10_0_24__=n.__post_robot_10_0_24__||{}}var an=function(){return{}};function sn(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 un=function(){};function cn(){var n=on();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new un,n.WINDOW_WILDCARD}function fn(n,e){return void 0===n&&(n="store"),void 0===e&&(e=an),sn("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 sn("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 pn(n){fn("knownWindows").set(n,!0)}var vn,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=((vn={})[gn.FUNCTION]=function(){},vn[gn.ERROR]=function(n){return En(gn.ERROR,{message:n.message,stack:n.stack,code:n.code})},vn[gn.PROMISE]=function(){},vn[gn.REGEX]=function(n){return En(gn.REGEX,n.source)},vn[gn.DATE]=function(n){return En(gn.DATE,n.toJSON())},vn[gn.ARRAY]=function(n){return n},vn[gn.OBJECT]=function(n){return n},vn[gn.STRING]=function(n){return n},vn[gn.NUMBER]=function(n){return n},vn[gn.BOOLEAN]=function(n){return n},vn[gn.NULL]=function(n){return n},vn),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 Pn(n){return!A(window,n)}function An(n,e){if(n){if(h()!==I(n))return!0}else if(e&&!l(e))return!0;return!1}function Rn(n){var e=n.win,r=n.domain;return!(!Nn()||r&&!An(r,e)||e&&!Pn(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(!R(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=sn("popupWindowsByName"),i=fn("popupWindowsByWin"),a=0,s=o.keys();a<s.length;a++){var u=s[a],c=o.get(u);c&&!b(c.win)||o.del(u)}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=sn("popupWindowsByName");e(nn.OPEN_TUNNEL,(function(n){var i=n.source,a=n.origin,s=n.data,u=sn("bridges").get(a);if(!u)throw new Error("Can not find bridge promise for domain "+a);return u.then((function(n){if(i!==n)throw new Error("Message source does not matched registered bridge for domain "+a);if(!s.name)throw new Error("Register window expected to be passed window name");if(!s.sendMessage)throw new Error("Register window expected to be passed sendMessage method");if(!o.has(s.name))throw new Error("Window with name "+s.name+" does not exist, or was not opened by this window");if(!o.get(s.name).domain)throw new Error("We do not have a registered domain for window "+s.name);if(o.get(s.name).domain!==a)throw new Error("Message origin "+a+" does not matched registered window origin "+o.get(s.name).domain);return Tn(o.get(s.name).win,a,s.sendMessage),{sendMessage:function(n){if(window&&!window.closed){var i=o.get(s.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=sn("tunnelWindows"),s=c(window);if(!s)throw new Error("No parent window found to open tunnel to");var u=function(n){var e=n.name,r=n.source,t=n.canary,o=n.sendMessage;!function(){for(var n=sn("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 sn("tunnelWindows").set(i,{name:e,source:r,canary:t,sendMessage:o}),i}({name:r,source:t,canary:o,sendMessage:i});return e(s,nn.OPEN_TUNNEL,{name:r,sendMessage:function(){var n=a.get(u);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&&Rn({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=sn("idToProxyWindow"),e=0,r=n.keys();e<r.length;e++){var t=r[e];n.get(t).shouldClean()&&n.del(t)}}function zn(n,e){var r,t=e.send,o=e.id;return{id:void 0===o?X():o,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}))}}}var Un=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||zn(this.actualWindowPromise,{send:e}),sn("idToProxyWindow").set(this.getID(),this),r&&this.setWindow(r,{send:e})}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().then((function(n){return n===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,e=this.isPopup(),r=this.getName(),t=U.hash({isPopup:e,name:r}).then((function(n){var e=n.name;n.isPopup&&e&&window.open("",e)})),o=this.serializedWindow.focus();return U.all([t,o]).then((function(){return n}))},e.isClosed=function(){return this.serializedWindow.isClosed()},e.getWindow=function(){return this.actualWindow},e.setWindow=function(n,e){var r=e.send;this.actualWindow=n,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=zn(this.actualWindowPromise,{send:r,id:this.getID()}),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 o=e.proxyInstanceID===e.knownWindowInstanceID;return o&&r.setWindow(n,{send:t}),o}))}))},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(),sn("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 Hn(n,e,r,t,o){var i=fn("methodStore"),a=sn("proxyWindowMethods");Un.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 qn(n,e){var r=fn("methodStore"),t=sn("proxyWindowMethods");return r.getOrSet(n,(function(){return{}}))[e]||t.get(e)}function Gn(n,e,r,t,o){var i,a,s;a=(i={on:o.on,send:o.send}).on,s=i.send,sn("builtinListeners").getOrSet("functionCalls",(function(){return a(nn.METHOD,{domain:rn},(function(n){var e=n.source,r=n.origin,t=n.data,o=t.id,i=t.name,a=qn(e,o);if(!a)throw new Error("Could not find method '"+i+"' with id: "+t.id+" in "+h(window));var u=a.source,c=a.domain,f=a.val;return U.try((function(){if(!R(c,r))throw new Error("Method '"+t.name+"' domain "+JSON.stringify(V(a.domain)?a.domain.source:a.domain)+" does not match origin "+r+" in "+h(window));if(Un.isProxyWindow(u))return u.matchWindow(e,{send:s}).then((function(n){if(!n)throw new Error("Method call '"+t.name+"' failed - proxy window does not match source in "+h(window))}))})).then((function(){return f.apply({source:e,origin:r},t.args)}),(function(n){return U.try((function(){if(f.onError)return f.onError(n)})).then((function(){throw n.stack&&(n.stack="Remote call to "+i+"()\n\n"+n.stack),n}))})).then((function(n){return{result:n,id:o,name:i}}))}))}));var u=r.__id__||X();n=Un.unwrap(n);var c=r.__name__||r.name||t;return"string"==typeof c&&"function"==typeof c.indexOf&&0===c.indexOf("anonymous::")&&(c=c.replace("anonymous::",t+"::")),Un.isProxyWindow(n)?(Hn(u,r,c,n,e),n.awaitWindow().then((function(n){Hn(u,r,c,n,e)}))):Hn(u,r,c,n,e),En(tn.CROSS_DOMAIN_FUNCTION,{id:u,name:c})}function Jn(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: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[gn.FUNCTION]=function(r,t){return Gn(n,e,r,t,{on:i,send:a})},o[gn.OBJECT]=function(n){return M(n)||Un.isProxyWindow(n)?En(tn.CROSS_DOMAIN_WINDOW,Un.serialize(n,{send:a})):n},o))}function Xn(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,s=function(r){function t(){var s=arguments;return Un.toProxyWindow(n,{send:a}).awaitWindow().then((function(n){var u=qn(n,o);if(u&&u.val!==t)return u.val.apply({source:window,origin:h()},s);var c={domain:e,fireAndForget:r.fireAndForget},f=[].slice.call(s);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},u=s();return u.fireAndForget=s({fireAndForget:!0}),u}(n,e,r,{on:i,send:a})},o[tn.CROSS_DOMAIN_WINDOW]=function(n){return Un.deserialize(n,{send:a})},o))}var Yn={};function Zn(n,e,r,t){var o,i=t.on,a=t.send;if(b(n))throw new Error("Window is closed");for(var s=Jn(n,e,((o={}).__post_robot_10_0_24__=H({id:X(),origin:h(window)},r),o),{on:i,send:a}),u=Object.keys(Yn),c=[],f=0;f<u.length;f++){var d=u[f];try{Yn[d](n,s,e)}catch(n){c.push(n)}}if(c.length===u.length)throw new Error("All post-robot messaging strategies failed:\n\n"+c.map((function(n,e){return e+". "+K(n)})).join("\n\n"))}Yn.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)}))},Yn.postrobot_bridge=function(n,e,r){if(!Nn()&&!Mn())throw new Error("Bridge not needed for browser");if(l(n))throw new Error("Post message through bridge disabled between same domain windows");if(!1!==A(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)},Yn.postrobot_global=function(n,e){if(!W(window).match(/MSIE|rv:11|trident|edge\/12|edge\/13/i))throw new Error("Global messaging not needed for browser");if(!l(n))throw new Error("Post message through global disabled between different domain windows");if(!1!==A(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 Kn,Qn="__domain_regex__";function Vn(n){return sn("responseListeners").get(n)}function $n(n){sn("responseListeners").del(n)}function ne(n){return sn("erroredResponseListeners").has(n)}function ee(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 s=a[i];if(s){var u=o.get(s);if(u){var c=u[e];if(c){if(t&&"string"==typeof t){if(c[t])return c[t];if(c[Qn])for(var f=0,d=c[Qn];f<d.length;f++){var w=d[f],h=w.listener;if(R(w.regex,t))return h}}if(c[rn])return c[rn]}}}}}var re=((Kn={}).postrobot_message_request=function(n,e,r,t){var o=t.on,i=t.send,a=ee({name:r.name,win:n,domain:e}),s=r.name===nn.METHOD&&r.data&&"string"==typeof r.data.name?r.data.name+"()":r.name;function u(t,a,u){if(void 0===u&&(u={}),!r.fireAndForget&&!b(n))try{Zn(n,e,H({type:t,ack:a,hash:r.hash,name:r.name},u),{on:o,send:i})}catch(n){throw new Error("Send response message failed for "+s+" in "+h()+"\n\n"+K(n))}}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(!R(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}))},Kn.postrobot_message_ack=function(n,e,r){if(!ne(r.hash)){var t=Vn(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);try{if(!R(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")}catch(n){t.promise.reject(n)}t.ack=!0}},Kn.postrobot_message_response=function(n,e,r){if(!ne(r.hash)){var o,i=Vn(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(!R(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");$n(r.hash),"error"===r.ack?i.promise.reject(r.error):"success"===r.ack&&i.promise.resolve({source:n,origin:e,data:r.data})}},Kn);function te(n,e){var r=e.on,t=e.send,i=sn("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,s=n.origin,u=function(n,e,r,t){var o,i=t.on,a=t.send;try{o=Xn(e,r,n,{on:i,send:a})}catch(n){return}if(o&&"object"==typeof o&&null!==o&&(o=o.__post_robot_10_0_24__)&&"object"==typeof o&&null!==o&&o.type&&"string"==typeof o.type&&re[o.type])return o}(n.data,a,s,{on:r,send:t});u&&(pn(a),i.has(u.id)||(i.set(u.id,!0),b(a)&&!u.fireAndForget||(0===u.origin.indexOf(o.FILE)&&(s=o.FILE+"//"),re[u.type](a,s,u,{on:r,send:t}))))}function oe(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 s=[],u=0,c=o;u<c.length;u++)s.push(n({name:t,domain:i,win:c[u]},r));return{cancel:function(){for(var n=0;n<s.length;n++)s[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=ee({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,p=a.getOrSet(o,(function(){return{}})),v=$(p,t,(function(){return{}})),g=i.toString();return V(i)?(l=$(v,Qn,(function(){return[]}))).push(m={regex:i,listener:r}):v[g]=r,{cancel:function(){delete v[g],m&&(l.splice(l.indexOf(m,1)),l.length||delete v[Qn]),Object.keys(v).length||delete p[t],o&&!Object.keys(p).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 ie(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=oe(n,e,(function(n){if(t.cancel(),o.resolve(n),r)return r(n)})),o.cancel=t.cancel,o}var ae,se=function n(e,r,t,o){var i=(o=o||{}).domain||rn,a=o.timeout||-1,s=o.timeout||5e3,u=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=v(n);t<o.length;t++)if(o[t]===e)return!0;return!1}(window,e))return mn(e,s)})).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(!R(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 s,c,f=r===nn.METHOD&&t&&"string"==typeof t.name?t.name+"()":r,d=new U,w=r+"_"+X();if(!u){var l={name:r,win:e,domain:i,promise:d};!function(n,e){sn("responseListeners").set(n,e)}(w,l);var m=fn("requestPromises").getOrSet(e,(function(){return[]}));m.push(d),d.catch((function(){!function(n){sn("erroredResponseListeners").set(n,!0)}(w),$n(w)}));var p=function(n){return fn("knownWindows").get(n,!1)}(e)?1e4:2e3,v=a,g=p,y=v,_=(s=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 "+v+"ms")):void 0:d.reject(new Error("No ack for postMessage "+f+" in "+h()+" in "+p+"ms")))},500,function n(){c=setTimeout((function(){s(),n()}),500)}(),{cancel:function(){clearTimeout(c)}});d.finally((function(){_.cancel(),m.splice(m.indexOf(d,1))})).catch(Z)}try{Zn(e,i,{type:"postrobot_message_request",hash:w,name:r,data:t,fireAndForget:u},{on:oe,send:n})}catch(n){throw new Error("Send request message failed for "+f+" in "+h()+"\n\n"+K(n))}return u?d.resolve():d}))};function ue(n,e,r){return Jn(n,e,r,{on:oe,send:se})}function ce(n,e,r){return Xn(n,e,r,{on:oe,send:se})}function fe(n){return new Un({send:se,win:n})}function de(n){return Un.toProxyWindow(n,{send:se})}function we(){var n,e,r,t;on().initialized||(on().initialized=!0,e=(n={on:oe,send:se}).on,r=n.send,(t=on()).receiveMessage=t.receiveMessage||function(n){return te(n,{on:e,send:r})},function(n){var e=n.on,r=n.send;sn().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,s=n.data;if("null"===a&&(a=o.FILE+"//"),i){if(!a)throw new Error("Post message did not have origin domain");te({source:i,origin:a,data:s},{on:r,send:t})}}(n,{on:e,send:r})}),{cancel:function(){n.removeEventListener("message",t)}};var n,t}))}({on:oe,send:se}),Bn({on:oe,send:se,receiveMessage:te}),function(n){var e=n.on,r=n.send;sn("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:oe,send:se}))}function he(){var n;!function(){for(var n=sn("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=sn().get("postMessageListener"))&&n.cancel(),delete window.__post_robot_10_0_24__}function le(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 ae})),r.d(e,"Promise",(function(){return U})),r.d(e,"TYPES",(function(){return!0})),r.d(e,"ProxyWindow",(function(){return Un})),r.d(e,"setup",(function(){return we})),r.d(e,"destroy",(function(){return he})),r.d(e,"serializeMessage",(function(){return ue})),r.d(e,"deserializeMessage",(function(){return ce})),r.d(e,"createProxyWindow",(function(){return fe})),r.d(e,"toProxyWindow",(function(){return de})),r.d(e,"on",(function(){return oe})),r.d(e,"once",(function(){return ie})),r.d(e,"send",(function(){return se})),r.d(e,"markWindowKnown",(function(){return pn})),r.d(e,"cleanUpWindow",(function(){return le})),ae={setupBridge:Bn,openBridge:function(n,e){var r=sn("bridges"),t=sn("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:Rn,needsBridgeForBrowser:Nn,hasBridge:function(n,e){return sn("bridges").has(e||I(n))},needsBridgeForWin:Pn,needsBridgeForDomain:An,destroyBridges:function(){for(var n=sn("bridges"),e=sn("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()}},we()}])})); | ||
//# 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="*",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 h(n){void 0===n&&(n=window);var e=n.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()?h(t):o.ABOUT+"//"}var i=e.host;if(!i)throw new Error("Can not read window host");return r+"//"+i}function l(n){void 0===n&&(n=window);var e=h(n);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(s(n)&&d())return!0}catch(n){}try{if(h(n)===h(window))return!0}catch(n){}return!1}(n))return!1;try{if(n===window)return!0;if(s(n)&&d())return!0;if(l(window)===l(n))return!0}catch(n){}return!1}function p(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 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)||c(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,x=[],R=[],P=0;function I(){if(!P&&b){var n=b;b=null,n.resolve()}}function N(){P+=1}function j(){P-=1,I()}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;N();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===x.indexOf(n)){x.push(n),setTimeout((function(){throw n}),1);for(var r=0;r<R.length;r++)R[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,N();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):S(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,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 R.push(n),{cancel:function(){R.splice(R.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,I(),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_23__:n.__post_robot_10_0_23__=n.__post_robot_10_0_23__||{}}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 sn(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 cn(n,e){return{__type__:n,__val__:e}}var fn,dn=((on={})[an.FUNCTION]=function(){},on[an.ERROR]=function(n){return cn(an.ERROR,{message:n.message,stack:n.stack,code:n.code})},on[an.PROMISE]=function(){},on[an.REGEX]=function(n){return cn(an.REGEX,n.source)},on[an.DATE]=function(n){return cn(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),hn={},ln=((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)}}function vn(n,e){var r,t=e.send,o=e.id;return{id:void 0===o?C():o,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}))}}}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 mn=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||vn(this.actualWindowPromise,{send:e}),Z("idToProxyWindow").set(this.getID(),this),r&&this.setWindow(r,{send:e})}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().then((function(n){return n===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,e=this.isPopup(),r=this.getName(),t=A.hash({isPopup:e,name:r}).then((function(n){var e=n.name;n.isPopup&&e&&window.open("",e)})),o=this.serializedWindow.focus();return A.all([t,o]).then((function(){return n}))},e.isClosed=function(){return this.serializedWindow.isClosed()},e.getWindow=function(){return this.actualWindow},e.setWindow=function(n,e){var r=e.send;this.actualWindow=n,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=vn(this.actualWindowPromise,{send:r,id:this.getID()}),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 o=e.proxyInstanceID===e.knownWindowInstanceID;return o&&r.setWindow(n,{send:t}),o}))}))},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 yn(n,e,r,t,o){var i=V("methodStore"),a=Z("proxyWindowMethods");mn.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 gn(n,e){var r=V("methodStore"),t=Z("proxyWindowMethods");return r.getOrSet(n,(function(){return{}}))[e]||t.get(e)}function _n(n,e,r,t,o){var i,a,u;a=(i={on:o.on,send:o.send}).on,u=i.send,Z("builtinListeners").getOrSet("functionCalls",(function(){return a(q.METHOD,{domain:G},(function(n){var e=n.source,r=n.origin,t=n.data,o=t.id,i=t.name,a=gn(e,o);if(!a)throw new Error("Could not find method '"+i+"' with id: "+t.id+" in "+l(window));var s=a.source,c=a.domain,f=a.val;return A.try((function(){if(!E(c,r))throw new Error("Method '"+t.name+"' domain "+JSON.stringify(B(a.domain)?a.domain.source:a.domain)+" does not match origin "+r+" in "+l(window));if(mn.isProxyWindow(s))return s.matchWindow(e,{send:u}).then((function(n){if(!n)throw new Error("Method call '"+t.name+"' failed - proxy window does not match source in "+l(window))}))})).then((function(){return f.apply({source:e,origin:r},t.args)}),(function(n){return A.try((function(){if(f.onError)return f.onError(n)})).then((function(){throw n.stack&&(n.stack="Remote call to "+i+"()\n\n"+n.stack),n}))})).then((function(n){return{result:n,id:o,name:i}}))}))}));var s=r.__id__||C();n=mn.unwrap(n);var c=r.__name__||r.name||t;return 0===c.indexOf("anonymous::")&&(c=c.replace("anonymous::",t+"::")),mn.isProxyWindow(n)?(yn(s,r,c,n,e),n.awaitWindow().then((function(n){yn(s,r,c,n,e)}))):yn(s,r,c,n,e),cn(J.CROSS_DOMAIN_FUNCTION,{id:s,name:c})}function En(n,e,r,t){var o,i=t.on,a=t.send;return function(n,e){void 0===e&&(e=hn);var r=JSON.stringify(n,(function(n){var r=this[n];if(un(this))return r;var t=sn(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 cn(J.CROSS_DOMAIN_ZALGO_PROMISE,{then:_n(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 _n(n,e,r,t,{on:i,send:a})},o[an.OBJECT]=function(n){return O(n)||mn.isProxyWindow(n)?cn(J.CROSS_DOMAIN_WINDOW,mn.serialize(n,{send:a})):n},o))}function On(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=sn(r),o=r),!t)return o;var i=e[t]||ln[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 mn.toProxyWindow(n,{send:a}).awaitWindow().then((function(n){var s=gn(n,o);if(s&&s.val!==t)return s.val.apply({source:window,origin:l()},u);var c={domain:e,fireAndForget:r.fireAndForget},f=[].slice.call(u);return a(n,q.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[J.CROSS_DOMAIN_WINDOW]=function(n){return mn.deserialize(n,{send:a})},o))}var Wn={};function Sn(n,e,r,t){var o,i=t.on,a=t.send;if(g(n))throw new Error("Window is closed");for(var u=En(n,e,((o={}).__post_robot_10_0_23__=k({id:C(),origin:l(window)},r),o),{on:i,send:a}),s=Object.keys(Wn),c=[],f=0;f<s.length;f++){var d=s[f];try{Wn[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((function(n,e){return e+". "+F(n)})).join("\n\n"))}Wn.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 bn,xn="__domain_regex__";function Rn(n){return Z("responseListeners").get(n)}function Pn(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 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[xn])for(var f=0,d=c[xn];f<d.length;f++){var h=d[f],l=h.listener;if(E(h.regex,t))return l}}if(c[G])return c[G]}}}}}var jn=((bn={}).postrobot_message_request=function(n,e,r,t){var o=t.on,i=t.send,a=Nn({name:r.name,win:n,domain:e}),u=r.name===q.METHOD&&r.data&&"string"==typeof r.data.name?r.data.name+"()":r.name;function s(t,a,s){if(void 0===s&&(s={}),!r.fireAndForget&&!g(n))try{Sn(n,e,k({type:t,ack:a,hash:r.hash,name:r.name},s),{on:o,send:i})}catch(n){throw new Error("Send response message failed for "+u+" in "+l()+"\n\n"+F(n))}}return A.all([s("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 s("postrobot_message_response","success",{data:n})}),(function(n){return s("postrobot_message_response","error",{error:n})}))]).then(z).catch((function(n){if(a&&a.handleError)return a.handleError(n);throw n}))},bn.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);try{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")}catch(n){t.promise.reject(n)}t.ack=!0}},bn.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");Pn(r.hash),"error"===r.ack?i.promise.reject(r.error):"success"===r.ack&&i.promise.resolve({source:n,origin:e,data:r.data})}},bn);function An(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,s=function(n,e,r,t){var o,i=t.on,a=t.send;try{o=On(e,r,n,{on:i,send:a})}catch(n){return}if(o&&"object"==typeof o&&null!==o&&(o=o.__post_robot_10_0_23__)&&"object"==typeof o&&null!==o&&o.type&&"string"==typeof o.type&&jn[o.type])return o}(n.data,a,u,{on:r,send:t});s&&(tn(a),i.has(s.id)||(i.set(s.id,!0),g(a)&&!s.fireAndForget||(0===s.origin.indexOf(o.FILE)&&(u=o.FILE+"//"),jn[s.type](a,u,s,{on:r,send:t}))))}function kn(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=[],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,h=i;d<h.length;d++)f.push(n({name:t,win:o,domain:h[d]},r));return{cancel:function(){for(var n=0;n<f.length;n++)f[n].cancel()}}}var l=Nn({name:t,win:o,domain:i});if(o&&o!==G||(o=Q()),i=i||G,l)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,xn,(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[xn]),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 Dn(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=kn(n,e,(function(n){if(t.cancel(),o.resolve(n),r)return r(n)})),o.cancel=t.cancel,o}var Mn=function n(e,r,t,o){var i=(o=o||{}).domain||G,a=o.timeout||-1,u=o.timeout||5e3,s=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){void 0===n&&(n=window);try{if(n.top)return n.top}catch(n){}if(c(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(c(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,c,f=r===q.METHOD&&t&&"string"==typeof t.name?t.name+"()":r,d=new A,h=r+"_"+C();if(!s){var w={name:r,win:e,domain:i,promise:d};!function(n,e){Z("responseListeners").set(n,e)}(h,w);var p=V("requestPromises").getOrSet(e,(function(){return[]}));p.push(d),d.catch((function(){!function(n){Z("erroredResponseListeners").set(n,!0)}(h),Pn(h)}));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 "+l()+" in "+m+"ms")):void 0:d.reject(new Error("No ack for postMessage "+f+" in "+l()+" in "+v+"ms")))},500,function n(){c=setTimeout((function(){u(),n()}),500)}(),{cancel:function(){clearTimeout(c)}});d.finally((function(){E.cancel(),p.splice(p.indexOf(d,1))})).catch(z)}try{Sn(e,i,{type:"postrobot_message_request",hash:h,name:r,data:t,fireAndForget:s},{on:kn,send:n})}catch(n){throw new Error("Send request message failed for "+f+" in "+l()+"\n\n"+F(n))}return s?d.resolve():d}))};function Tn(n,e,r){return En(n,e,r,{on:kn,send:Mn})}function Cn(n,e,r){return On(n,e,r,{on:kn,send:Mn})}function Ln(n){return new mn({send:Mn,win:n})}function zn(n){return mn.toProxyWindow(n,{send:Mn})}function Fn(){var n,e,r,t;X().initialized||(X().initialized=!0,e=(n={on:kn,send:Mn}).on,r=n.send,(t=X()).receiveMessage=t.receiveMessage||function(n){return An(n,{on:e,send:r})},function(n){var e=n.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");An({source:i,origin:a,data:u},{on:r,send:t})}}(n,{on:e,send:r})}),{cancel:function(){n.removeEventListener("message",t)}};var n,t}))}({on:kn,send:Mn}),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:kn,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_23__}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 mn})),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 kn})),r.d(e,"once",(function(){return Dn})),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 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 h(n){void 0===n&&(n=window);var e=n.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()?h(t):o.ABOUT+"//"}var i=e.host;if(!i)throw new Error("Can not read window host");return r+"//"+i}function l(n){void 0===n&&(n=window);var e=h(n);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(s(n)&&d())return!0}catch(n){}try{if(h(n)===h(window))return!0}catch(n){}return!1}(n))return!1;try{if(n===window)return!0;if(s(n)&&d())return!0;if(l(window)===l(n))return!0}catch(n){}return!1}function p(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 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)||c(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,x=[],R=[],P=0;function I(){if(!P&&b){var n=b;b=null,n.resolve()}}function N(){P+=1}function j(){P-=1,I()}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;N();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===x.indexOf(n)){x.push(n),setTimeout((function(){throw n}),1);for(var r=0;r<R.length;r++)R[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,N();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):S(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,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 R.push(n),{cancel:function(){R.splice(R.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,I(),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_24__:n.__post_robot_10_0_24__=n.__post_robot_10_0_24__||{}}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 sn(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 cn(n,e){return{__type__:n,__val__:e}}var fn,dn=((on={})[an.FUNCTION]=function(){},on[an.ERROR]=function(n){return cn(an.ERROR,{message:n.message,stack:n.stack,code:n.code})},on[an.PROMISE]=function(){},on[an.REGEX]=function(n){return cn(an.REGEX,n.source)},on[an.DATE]=function(n){return cn(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),hn={},ln=((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)}}function vn(n,e){var r,t=e.send,o=e.id;return{id:void 0===o?C():o,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}))}}}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 mn=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||vn(this.actualWindowPromise,{send:e}),Z("idToProxyWindow").set(this.getID(),this),r&&this.setWindow(r,{send:e})}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().then((function(n){return n===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,e=this.isPopup(),r=this.getName(),t=A.hash({isPopup:e,name:r}).then((function(n){var e=n.name;n.isPopup&&e&&window.open("",e)})),o=this.serializedWindow.focus();return A.all([t,o]).then((function(){return n}))},e.isClosed=function(){return this.serializedWindow.isClosed()},e.getWindow=function(){return this.actualWindow},e.setWindow=function(n,e){var r=e.send;this.actualWindow=n,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=vn(this.actualWindowPromise,{send:r,id:this.getID()}),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 o=e.proxyInstanceID===e.knownWindowInstanceID;return o&&r.setWindow(n,{send:t}),o}))}))},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 yn(n,e,r,t,o){var i=V("methodStore"),a=Z("proxyWindowMethods");mn.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 gn(n,e){var r=V("methodStore"),t=Z("proxyWindowMethods");return r.getOrSet(n,(function(){return{}}))[e]||t.get(e)}function _n(n,e,r,t,o){var i,a,u;a=(i={on:o.on,send:o.send}).on,u=i.send,Z("builtinListeners").getOrSet("functionCalls",(function(){return a(q.METHOD,{domain:G},(function(n){var e=n.source,r=n.origin,t=n.data,o=t.id,i=t.name,a=gn(e,o);if(!a)throw new Error("Could not find method '"+i+"' with id: "+t.id+" in "+l(window));var s=a.source,c=a.domain,f=a.val;return A.try((function(){if(!E(c,r))throw new Error("Method '"+t.name+"' domain "+JSON.stringify(B(a.domain)?a.domain.source:a.domain)+" does not match origin "+r+" in "+l(window));if(mn.isProxyWindow(s))return s.matchWindow(e,{send:u}).then((function(n){if(!n)throw new Error("Method call '"+t.name+"' failed - proxy window does not match source in "+l(window))}))})).then((function(){return f.apply({source:e,origin:r},t.args)}),(function(n){return A.try((function(){if(f.onError)return f.onError(n)})).then((function(){throw n.stack&&(n.stack="Remote call to "+i+"()\n\n"+n.stack),n}))})).then((function(n){return{result:n,id:o,name:i}}))}))}));var s=r.__id__||C();n=mn.unwrap(n);var c=r.__name__||r.name||t;return"string"==typeof c&&"function"==typeof c.indexOf&&0===c.indexOf("anonymous::")&&(c=c.replace("anonymous::",t+"::")),mn.isProxyWindow(n)?(yn(s,r,c,n,e),n.awaitWindow().then((function(n){yn(s,r,c,n,e)}))):yn(s,r,c,n,e),cn(J.CROSS_DOMAIN_FUNCTION,{id:s,name:c})}function En(n,e,r,t){var o,i=t.on,a=t.send;return function(n,e){void 0===e&&(e=hn);var r=JSON.stringify(n,(function(n){var r=this[n];if(un(this))return r;var t=sn(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 cn(J.CROSS_DOMAIN_ZALGO_PROMISE,{then:_n(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 _n(n,e,r,t,{on:i,send:a})},o[an.OBJECT]=function(n){return O(n)||mn.isProxyWindow(n)?cn(J.CROSS_DOMAIN_WINDOW,mn.serialize(n,{send:a})):n},o))}function On(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=sn(r),o=r),!t)return o;var i=e[t]||ln[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 mn.toProxyWindow(n,{send:a}).awaitWindow().then((function(n){var s=gn(n,o);if(s&&s.val!==t)return s.val.apply({source:window,origin:l()},u);var c={domain:e,fireAndForget:r.fireAndForget},f=[].slice.call(u);return a(n,q.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[J.CROSS_DOMAIN_WINDOW]=function(n){return mn.deserialize(n,{send:a})},o))}var Wn={};function Sn(n,e,r,t){var o,i=t.on,a=t.send;if(g(n))throw new Error("Window is closed");for(var u=En(n,e,((o={}).__post_robot_10_0_24__=k({id:C(),origin:l(window)},r),o),{on:i,send:a}),s=Object.keys(Wn),c=[],f=0;f<s.length;f++){var d=s[f];try{Wn[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((function(n,e){return e+". "+F(n)})).join("\n\n"))}Wn.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 bn,xn="__domain_regex__";function Rn(n){return Z("responseListeners").get(n)}function Pn(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 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[xn])for(var f=0,d=c[xn];f<d.length;f++){var h=d[f],l=h.listener;if(E(h.regex,t))return l}}if(c[G])return c[G]}}}}}var jn=((bn={}).postrobot_message_request=function(n,e,r,t){var o=t.on,i=t.send,a=Nn({name:r.name,win:n,domain:e}),u=r.name===q.METHOD&&r.data&&"string"==typeof r.data.name?r.data.name+"()":r.name;function s(t,a,s){if(void 0===s&&(s={}),!r.fireAndForget&&!g(n))try{Sn(n,e,k({type:t,ack:a,hash:r.hash,name:r.name},s),{on:o,send:i})}catch(n){throw new Error("Send response message failed for "+u+" in "+l()+"\n\n"+F(n))}}return A.all([s("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 s("postrobot_message_response","success",{data:n})}),(function(n){return s("postrobot_message_response","error",{error:n})}))]).then(z).catch((function(n){if(a&&a.handleError)return a.handleError(n);throw n}))},bn.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);try{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")}catch(n){t.promise.reject(n)}t.ack=!0}},bn.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");Pn(r.hash),"error"===r.ack?i.promise.reject(r.error):"success"===r.ack&&i.promise.resolve({source:n,origin:e,data:r.data})}},bn);function An(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,s=function(n,e,r,t){var o,i=t.on,a=t.send;try{o=On(e,r,n,{on:i,send:a})}catch(n){return}if(o&&"object"==typeof o&&null!==o&&(o=o.__post_robot_10_0_24__)&&"object"==typeof o&&null!==o&&o.type&&"string"==typeof o.type&&jn[o.type])return o}(n.data,a,u,{on:r,send:t});s&&(tn(a),i.has(s.id)||(i.set(s.id,!0),g(a)&&!s.fireAndForget||(0===s.origin.indexOf(o.FILE)&&(u=o.FILE+"//"),jn[s.type](a,u,s,{on:r,send:t}))))}function kn(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=[],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,h=i;d<h.length;d++)f.push(n({name:t,win:o,domain:h[d]},r));return{cancel:function(){for(var n=0;n<f.length;n++)f[n].cancel()}}}var l=Nn({name:t,win:o,domain:i});if(o&&o!==G||(o=Q()),i=i||G,l)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,xn,(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[xn]),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 Dn(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=kn(n,e,(function(n){if(t.cancel(),o.resolve(n),r)return r(n)})),o.cancel=t.cancel,o}var Mn=function n(e,r,t,o){var i=(o=o||{}).domain||G,a=o.timeout||-1,u=o.timeout||5e3,s=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){void 0===n&&(n=window);try{if(n.top)return n.top}catch(n){}if(c(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(c(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,c,f=r===q.METHOD&&t&&"string"==typeof t.name?t.name+"()":r,d=new A,h=r+"_"+C();if(!s){var w={name:r,win:e,domain:i,promise:d};!function(n,e){Z("responseListeners").set(n,e)}(h,w);var p=V("requestPromises").getOrSet(e,(function(){return[]}));p.push(d),d.catch((function(){!function(n){Z("erroredResponseListeners").set(n,!0)}(h),Pn(h)}));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 "+l()+" in "+m+"ms")):void 0:d.reject(new Error("No ack for postMessage "+f+" in "+l()+" in "+v+"ms")))},500,function n(){c=setTimeout((function(){u(),n()}),500)}(),{cancel:function(){clearTimeout(c)}});d.finally((function(){E.cancel(),p.splice(p.indexOf(d,1))})).catch(z)}try{Sn(e,i,{type:"postrobot_message_request",hash:h,name:r,data:t,fireAndForget:s},{on:kn,send:n})}catch(n){throw new Error("Send request message failed for "+f+" in "+l()+"\n\n"+F(n))}return s?d.resolve():d}))};function Tn(n,e,r){return En(n,e,r,{on:kn,send:Mn})}function Cn(n,e,r){return On(n,e,r,{on:kn,send:Mn})}function Ln(n){return new mn({send:Mn,win:n})}function zn(n){return mn.toProxyWindow(n,{send:Mn})}function Fn(){var n,e,r,t;X().initialized||(X().initialized=!0,e=(n={on:kn,send:Mn}).on,r=n.send,(t=X()).receiveMessage=t.receiveMessage||function(n){return An(n,{on:e,send:r})},function(n){var e=n.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");An({source:i,origin:a,data:u},{on:r,send:t})}}(n,{on:e,send:r})}),{cancel:function(){n.removeEventListener("message",t)}};var n,t}))}({on:kn,send:Mn}),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:kn,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_24__}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 mn})),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 kn})),r.d(e,"once",(function(){return Dn})),r.d(e,"send",(function(){return Mn})),r.d(e,"markWindowKnown",(function(){return tn})),r.d(e,"cleanUpWindow",(function(){return Bn})),Fn()}])})); | ||
//# sourceMappingURL=post-robot.min.js.map |
{ | ||
"name": "post-robot", | ||
"version": "10.0.23", | ||
"version": "10.0.24", | ||
"description": "Simple postMessage based server.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -111,3 +111,3 @@ /* @flow */ | ||
if (name.indexOf('anonymous::') === 0) { | ||
if (typeof name === 'string' && typeof name.indexOf === 'function' && name.indexOf('anonymous::') === 0) { | ||
name = name.replace('anonymous::', `${ key }::`); | ||
@@ -114,0 +114,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
2042061
17333