zoid
Version:
Cross domain components.
1 lines • 97.9 kB
JavaScript
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("zoid",[],e):"object"==typeof exports?exports.zoid=e():n.zoid=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,e){return(t=Object.setPrototypeOf||function(n,e){return n.__proto__=e,n})(n,e)}function o(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,t(n,e)}function i(){return(i=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 a(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}r.r(e),r.d(e,"PopupOpenError",(function(){return $n})),r.d(e,"create",(function(){return Hr})),r.d(e,"destroy",(function(){return Gr})),r.d(e,"destroyComponents",(function(){return Yr})),r.d(e,"destroyAll",(function(){return Zr})),r.d(e,"PROP_TYPE",(function(){return gr})),r.d(e,"PROP_SERIALIZATION",(function(){return br})),r.d(e,"CONTEXT",(function(){return Er})),r.d(e,"EVENT",(function(){return _r}));var u,c=[],s=[],d=0;function f(){if(!d&&u){var n=u;u=null,n.resolve()}}function l(){d+=1}function h(){d-=1,f()}var w=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;l();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 h(),void this.reject(n)}h(),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(a(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(a(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===c.indexOf(n)){c.push(n),setTimeout((function(){throw n}),1);for(var r=0;r<s.length;r++)s[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,l();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 u=t[i],c=u.onSuccess,s=u.onError,d=u.promise,f=void 0;if(e)try{f=c?c(this.value):this.value}catch(n){d.reject(n);continue}else if(r){if(!s){d.reject(this.error);continue}try{f=s(this.error)}catch(n){d.reject(n);continue}}if(f instanceof n&&(f.resolved||f.rejected)){var w=f;w.resolved?d.resolve(w.value):d.reject(w.error),w.errorHandled=!0}else a(f)?f instanceof n&&(f.resolved||f.rejected)?f.resolved?d.resolve(f.value):d.reject(f.error):o(f,d):d.resolve(f)}t.length=0,this.dispatching=!1,h()}},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)},e.lazy=function(){return this.errorHandled=!0,this},n.resolve=function(e){return e instanceof n?e:a(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=[].slice();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)}))},u=0;u<e.length;u++){var c=e[u];if(c instanceof n){if(c.resolved){o[u]=c.value,t-=1;continue}}else if(!a(c)){o[u]=c,t-=1;continue}i(u,n.resolve(c),r)}return 0===t&&r.resolve(o),r},n.hash=function(e){var r={},t=[],o=function(n){if(e.hasOwnProperty(n)){var o=e[n];a(o)?t.push(o.then((function(e){r[n]=e}))):r[n]=o}};for(var i in e)o(i);return n.all(t).then((function(){return r}))},n.map=function(e,r){return n.all(e.map(r))},n.onPossiblyUnhandledException=function(n){return function(n){return s.push(n),{cancel:function(){s.splice(s.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;l();try{o=e.apply(r,t||[])}catch(e){return h(),n.reject(e)}return h(),n.resolve(o)},n.delay=function(e){return new n((function(n){setTimeout(n,e)}))},n.isPromise=function(e){return!!(e&&e instanceof n)||a(e)},n.flush=function(){return e=u=u||new n,f(),e;var e},n}();function p(n){return"[object RegExp]"==={}.toString.call(n)}var v={IFRAME:"iframe",POPUP:"popup"},m="Call was rejected by callee.\r\n";function y(n){return void 0===n&&(n=window),n.location.protocol}function g(n){if(void 0===n&&(n=window),n.mockDomain){var e=n.mockDomain.split("//")[0];if(e)return e}return y(n)}function b(n){return void 0===n&&(n=window),"about:"===g(n)}function E(n){if(void 0===n&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function _(n){if(void 0===n&&(n=window),n&&!E(n))try{return n.opener}catch(n){}}function x(n){try{return!0}catch(n){}return!1}function P(n){void 0===n&&(n=window);var e=n.location;if(!e)throw new Error("Can not read window location");var r=y(n);if(!r)throw new Error("Can not read window protocol");if("file:"===r)return"file://";if("about:"===r){var t=E(n);return t&&x()?P(t):"about://"}var o=e.host;if(!o)throw new Error("Can not read window host");return r+"//"+o}function O(n){void 0===n&&(n=window);var e=P(n);return e&&n.mockDomain&&0===n.mockDomain.indexOf("mock:")?n.mockDomain:e}function C(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(b(n)&&x())return!0}catch(n){}try{if(function(n){return void 0===n&&(n=window),"mock:"===g(n)}(n)&&x())return!0}catch(n){}try{if(P(n)===P(window))return!0}catch(n){}return!1}(n))return!1;try{if(n===window)return!0;if(b(n)&&x())return!0;if(O(window)===O(n))return!0}catch(n){}return!1}function W(n){if(!C(n))throw new Error("Expected window to be same domain");return n}function S(n,e){if(!n||!e)return!1;var r=E(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 D(n){var e,r,t=[];try{e=n.frames}catch(r){e=n}try{r=e.length}catch(n){}if(0===r)return t;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=e[o]}catch(n){continue}t.push(i)}return t}for(var a=0;a<100;a++){var u=void 0;try{u=e[a]}catch(n){return t}if(!u)return t;t.push(u)}return t}function j(n){for(var e=[],r=0,t=D(n);r<t.length;r++){var o=t[r];e.push(o);for(var i=0,a=j(o);i<a.length;i++)e.push(a[i])}return e}function A(n){void 0===n&&(n=window);try{if(n.top)return n.top}catch(n){}if(E(n)===n)return n;try{if(S(window,n)&&window.top)return window.top}catch(n){}try{if(S(n,window)&&window.top)return window.top}catch(n){}for(var e=0,r=j(n);e<r.length;e++){var t=r[e];try{if(t.top)return t.top}catch(n){}if(E(t)===t)return t}}function N(n){var e=A(n);if(!e)throw new Error("Can not determine top window");var r=[].concat(j(e),[e]);return-1===r.indexOf(n)&&(r=[].concat(r,[n],j(n))),r}var R=[],T=[];function k(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!==m}if(e&&C(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}(R,n);if(-1!==r){var t=T[r];if(t&&function(n){if(!n.contentWindow)return!0;if(!n.parentNode)return!0;var e=n.ownerDocument;if(e&&e.documentElement&&!e.documentElement.contains(n)){for(var r=n;r.parentNode&&r.parentNode!==r;)r=r.parentNode;if(!r.host||!e.documentElement.contains(r.host))return!0}return!1}(t))return!0}return!1}function I(n){return(n=n||window).navigator.mockUserAgent||n.navigator.userAgent}function z(n,e){for(var r=D(n),t=0;t<r.length;t++){var o=r[t];try{if(C(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 F(n,e){return n===_(e)}function M(n){return void 0===n&&(n=window),_(n=n||window)||E(n)||void 0}function U(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 L(n){void 0===n&&(n=window);for(var e=0,r=n;r;)(r=E(r))&&(e+=1);return e}function q(n,e){var r=A(n)||n,t=A(e)||e;try{if(r&&t)return r===t}catch(n){}var o=N(n),i=N(e);if(U(o,i))return!0;var a=_(r),u=_(t);return a&&U(N(a),i)||u&&U(N(u),o),!1}function B(n,e){if("string"==typeof n){if("string"==typeof e)return"*"===n||e===n;if(p(e))return!1;if(Array.isArray(e))return!1}return p(n)?p(e)?n.toString()===e.toString():!Array.isArray(e)&&Boolean(e.match(n)):!!Array.isArray(n)&&(Array.isArray(e)?JSON.stringify(n)===JSON.stringify(e):!p(e)&&n.some((function(n){return B(n,e)})))}function $(n){return n.match(/^(https?|mock|file):\/\//)?n.split("/").slice(0,3).join("/"):O()}function J(n,e,r,t){var o;return void 0===r&&(r=1e3),void 0===t&&(t=1/0),function i(){if(k(n))return o&&clearTimeout(o),e();t<=0?clearTimeout(o):(t-=r,o=setTimeout(i,r))}(),{cancel:function(){o&&clearTimeout(o)}}}function H(n){try{if(n===window)return!0}catch(n){if(n&&n.message===m)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===m)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===m)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===m)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===m)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===m)return!0}try{if(n&&"__unlikely_value__"===n.__cross_domain_utils_window_check__)return!1}catch(n){return!0}try{if("postMessage"in n&&"self"in n&&"location"in n)return!0}catch(n){}return!1}function Y(n){if(0!==$(n).indexOf("mock:"))return n;throw new Error("Mock urls not supported out of test mode")}function Z(n){if(C(n))return W(n).frameElement;for(var e=0,r=document.querySelectorAll("iframe");e<r.length;e++){var t=r[e];if(t&&t.contentWindow&&t.contentWindow===n)return t}}function G(n){if(function(n){return void 0===n&&(n=window),Boolean(E(n))}(n)){var e=Z(n);if(e&&e.parentElement)return void e.parentElement.removeChild(e)}try{n.close()}catch(n){}}function V(n,e){for(var r=0;r<n.length;r++)try{if(n[r]===e)return r}catch(n){}return-1}var X,K=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(H(t)&&k(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!H(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=V(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=V(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=V(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!==V(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 Q(n){return(Q=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)})(n)}function nn(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(n){return!1}}function en(n,e,r){return(en=nn()?Reflect.construct:function(n,e,r){var o=[null];o.push.apply(o,e);var i=new(Function.bind.apply(n,o));return r&&t(i,r.prototype),i}).apply(null,arguments)}function rn(n){var e="function"==typeof Map?new Map:void 0;return(rn=function(n){if(null===n||-1===Function.toString.call(n).indexOf("[native code]"))return n;if("function"!=typeof n)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(n))return e.get(n);e.set(n,r)}function r(){return en(n,arguments,Q(this).constructor)}return r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),t(r,n)})(n)}function tn(n){return n.name||n.__name__||n.displayName||"anonymous"}function on(n,e){try{delete n.name,n.name=e}catch(n){}return n.__name__=n.displayName=e,n}function an(n){if("function"==typeof btoa)return btoa(encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(function(n,e){return String.fromCharCode(parseInt(e,16))}))).replace(/[=]/g,"");if("undefined"!=typeof Buffer)return Buffer.from(n,"utf8").toString("base64").replace(/[=]/g,"");throw new Error("Can not find window.btoa or Buffer")}function un(){var n="0123456789abcdef";return"uid_"+"xxxxxxxxxx".replace(/./g,(function(){return n.charAt(Math.floor(Math.random()*n.length))}))+"_"+an((new Date).toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}function cn(n){try{return JSON.stringify([].slice.call(n),(function(n,e){return"function"==typeof e?"memoize["+function(n){if(X=X||new K,null==n||"object"!=typeof n&&"function"!=typeof n)throw new Error("Invalid object");var e=X.get(n);return e||(e=typeof n+":"+un(),X.set(n,e)),e}(e)+"]":e}))}catch(n){throw new Error("Arguments not serializable -- can not be used to memoize")}}function sn(){return{}}var dn=0,fn=0;function ln(n,e){void 0===e&&(e={});var r,t,o=e.thisNamespace,i=void 0!==o&&o,a=e.time,u=dn;dn+=1;var c=function(){for(var e=arguments.length,o=new Array(e),c=0;c<e;c++)o[c]=arguments[c];var s;u<fn&&(r=null,t=null,u=dn,dn+=1),s=i?(t=t||new K).getOrSet(this,sn):r=r||{};var d=cn(o),f=s[d];if(f&&a&&Date.now()-f.time<a&&(delete s[d],f=null),f)return f.value;var l=Date.now(),h=n.apply(this,arguments);return s[d]={time:l,value:h},h};return c.reset=function(){r=null,t=null},on(c,(e.name||tn(n))+"::memoized")}function hn(n){var e={};function r(){for(var r=arguments,t=this,o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var u=cn(i);return e.hasOwnProperty(u)||(e[u]=w.try((function(){return n.apply(t,r)})).finally((function(){delete e[u]}))),e[u]}return r.reset=function(){e={}},on(r,tn(n)+"::promiseMemoized")}function wn(){}function pn(n){var e=!1;return on((function(){if(!e)return e=!0,n.apply(this,arguments)}),tn(n)+"::once")}function vn(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: "+vn(n,e+1)}}function mn(n){return"string"==typeof n?n:n&&n.toString&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}function yn(n,e){if(!e)return n;if(Object.assign)return Object.assign(n,e);for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);return n}function gn(n){return n}function bn(n,e){var r;return function t(){r=setTimeout((function(){n(),t()}),e)}(),{cancel:function(){clearTimeout(r)}}}function En(n){return n.replace(/-([a-z])/g,(function(n){return n[1].toUpperCase()}))}function _n(n,e,r){if(Array.isArray(n)){if("number"!=typeof e)throw new TypeError("Array key must be number")}else if("object"==typeof n&&null!==n&&"string"!=typeof e)throw new TypeError("Object key must be string");Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){delete n[e];var t=r();return n[e]=t,t},set:function(r){delete n[e],n[e]=r}})}function xn(n){return[].slice.call(n)}function Pn(n){return"object"==typeof(e=n)&&null!==e&&"[object Object]"==={}.toString.call(n);var e}function On(n){if(!Pn(n))return!1;var e=n.constructor;if("function"!=typeof e)return!1;var r=e.prototype;return!!Pn(r)&&!!r.hasOwnProperty("isPrototypeOf")}function Cn(n,e,r){if(void 0===r&&(r=""),Array.isArray(n)){for(var t=n.length,o=[],i=function(t){_n(o,t,(function(){var o=r?r+"."+t:""+t,i=e(n[t],t,o);return(On(i)||Array.isArray(i))&&(i=Cn(i,e,o)),i}))},a=0;a<t;a++)i(a);return o}if(On(n)){var u={},c=function(t){if(!n.hasOwnProperty(t))return"continue";_n(u,t,(function(){var o=r?r+"."+t:""+t,i=e(n[t],t,o);return(On(i)||Array.isArray(i))&&(i=Cn(i,e,o)),i}))};for(var s in n)c(s);return u}throw new Error("Pass an object or array")}function Wn(n){return null!=n}function Sn(n){return"[object RegExp]"==={}.toString.call(n)}function Dn(n,e,r){if(n.hasOwnProperty(e))return n[e];var t=r();return n[e]=t,t}function jn(n){var e,r=[],t=!1,o={set:function(e,r){return t||(n[e]=r,o.register((function(){delete n[e]}))),r},register:function(n){var o=pn((function(){return n(e)}));return t?n(e):r.push(o),{cancel:function(){var n=r.indexOf(o);-1!==n&&r.splice(n,1)}}},all:function(n){e=n;var o=[];for(t=!0;r.length;){var i=r.shift();o.push(i())}return w.all(o).then(wn)}};return o}function An(n,e){if(null==e)throw new Error("Expected "+n+" to be present");return e}ln.clear=function(){fn=dn},ln((function(n){if(Object.values)return Object.values(n);var e=[];for(var r in n)n.hasOwnProperty(r)&&e.push(n[r]);return e}));var Nn=function(n){function e(e){var r;return(r=n.call(this,e)||this).name=r.constructor.name,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(function(n){if(void 0===n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}(r),r.constructor):r.stack=new Error(e).stack,r}return o(e,n),e}(rn(Error));function Rn(){var n=document.body;if(!n)throw new Error("Body element not found");return n}function Tn(){return Boolean(document.body)&&"complete"===document.readyState}function kn(){return Boolean(document.body)&&"interactive"===document.readyState}function In(n){return encodeURIComponent(n)}function zn(n){return function(e,r,t){void 0===t&&(t=[]);var o=e.__inline_memoize_cache__=e.__inline_memoize_cache__||{},i=cn(t);return o.hasOwnProperty(i)?o[i]:o[i]=function(){var e={};if(!n)return e;if(-1===n.indexOf("="))return e;for(var r=0,t=n.split("&");r<t.length;r++){var o=t[r];(o=o.split("="))[0]&&o[1]&&(e[decodeURIComponent(o[0])]=decodeURIComponent(o[1]))}return e}.apply(void 0,t)}(zn,0,[n])}function Fn(n,e){return void 0===e&&(e={}),e&&Object.keys(e).length?(void 0===(r=i({},zn(n),e))&&(r={}),Object.keys(r).filter((function(n){return"string"==typeof r[n]||"boolean"==typeof r[n]})).map((function(n){var e=r[n];if("string"!=typeof e&&"boolean"!=typeof e)throw new TypeError("Invalid type for query");return In(n)+"="+In(e.toString())})).join("&")):n;var r}function Mn(n,e){n.appendChild(e)}function Un(n){return n instanceof window.Element||null!==n&&"object"==typeof n&&1===n.nodeType&&"object"==typeof n.style&&"object"==typeof n.ownerDocument}function Ln(n,e){return void 0===e&&(e=document),Un(n)?n:"string"==typeof n?e.querySelector(n):void 0}function qn(n){return new w((function(e,r){var t=mn(n),o=Ln(n);if(o)return e(o);if(Tn())return r(new Error("Document is ready and element "+t+" does not exist"));var i=setInterval((function(){return(o=Ln(n))?(e(o),void clearInterval(i)):Tn()?(clearInterval(i),r(new Error("Document is ready and element "+t+" does not exist"))):void 0}),10)}))}ln((function(){return new w((function(n){if(Tn()||kn())return n();var e=setInterval((function(){if(Tn()||kn())return clearInterval(e),n()}),10)}))}));var Bn,$n=function(n){function e(){return n.apply(this,arguments)||this}return o(e,n),e}(Nn);function Jn(n){if((Bn=Bn||new K).has(n)){var e=Bn.get(n);if(e)return e}var r=new w((function(e,r){n.addEventListener("load",(function(){(function(n){if(function(){for(var n=0;n<R.length;n++){var e=!1;try{e=R[n].closed}catch(n){}e&&(T.splice(n,1),R.splice(n,1))}}(),n&&n.contentWindow)try{R.push(n.contentWindow),T.push(n)}catch(n){}})(n),e(n)})),n.addEventListener("error",(function(t){n.contentWindow?e(n):r(t)}))}));return Bn.set(n,r),r}function Hn(n){return Jn(n).then((function(n){if(!n.contentWindow)throw new Error("Could not find window in iframe");return n.contentWindow}))}function Yn(n,e){void 0===n&&(n={});var r=n.style||{},t=function(n,e,r){void 0===n&&(n="div"),void 0===e&&(e={}),n=n.toLowerCase();var t,o,i,a=document.createElement(n);if(e.style&&yn(a.style,e.style),e.class&&(a.className=e.class.join(" ")),e.id&&a.setAttribute("id",e.id),e.attributes)for(var u=0,c=Object.keys(e.attributes);u<c.length;u++){var s=c[u];a.setAttribute(s,e.attributes[s])}if(e.styleSheet&&(t=a,o=e.styleSheet,void 0===i&&(i=window.document),t.styleSheet?t.styleSheet.cssText=o:t.appendChild(i.createTextNode(o))),e.html){if("iframe"===n)throw new Error("Iframe html can not be written unless container provided and iframe in DOM");a.innerHTML=e.html}return a}("iframe",{attributes:i({allowTransparency:"true"},n.attributes||{}),style:i({backgroundColor:"transparent",border:"none"},r),html:n.html,class:n.class}),o=window.navigator.userAgent.match(/MSIE|Edge/i);return t.hasAttribute("id")||t.setAttribute("id",un()),Jn(t),e&&function(n,e){void 0===e&&(e=document);var r=Ln(n,e);if(r)return r;throw new Error("Can not find element: "+mn(n))}(e).appendChild(t),(n.url||o)&&t.setAttribute("src",n.url||"about:blank"),t}function Zn(n,e,r){return n.addEventListener(e,r),{cancel:function(){n.removeEventListener(e,r)}}}function Gn(n){n.style.setProperty("display","")}function Vn(n){n.style.setProperty("display","none","important")}function Xn(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function Kn(n){return!(n&&n.parentNode&&n.ownerDocument&&n.ownerDocument.documentElement&&n.ownerDocument.documentElement.contains(n))}function Qn(n,e,r){var t=void 0===r?{}:r,o=t.width,i=void 0===o||o,a=t.height,u=void 0===a||a,c=t.interval,s=void 0===c?100:c,d=t.win,f=void 0===d?window:d,l=n.offsetWidth,h=n.offsetHeight,w=!1;e({width:l,height:h});var p,v,m=function(){if(!w&&function(n){return Boolean(n.offsetWidth||n.offsetHeight||n.getClientRects().length)}(n)){var r=n.offsetWidth,t=n.offsetHeight;(i&&r!==l||u&&t!==h)&&e({width:r,height:t}),l=r,h=t}};return f.addEventListener("resize",m),void 0!==f.ResizeObserver?((p=new f.ResizeObserver(m)).observe(n),v=bn(m,10*s)):void 0!==f.MutationObserver?((p=new f.MutationObserver(m)).observe(n,{attributes:!0,childList:!0,subtree:!0,characterData:!1}),v=bn(m,10*s)):v=bn(m,s),{cancel:function(){w=!0,p.disconnect(),window.removeEventListener("resize",m),v.cancel()}}}function ne(n){for(;n.parentNode;)n=n.parentNode;return"[object ShadowRoot]"===n.toString()}var ee="undefined"!=typeof document?document.currentScript:null,re=ln((function(){if(ee)return ee;if(ee=function(){try{var n=function(){try{throw new Error("_")}catch(n){return n.stack||""}}(),e=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(n),r=e&&e[1];if(!r)return;for(var t=0,o=[].slice.call(document.getElementsByTagName("script")).reverse();t<o.length;t++){var i=o[t];if(i.src&&i.src===r)return i}}catch(n){}}())return ee;throw new Error("Can not determine current script")})),te=un();function oe(n){return"string"==typeof n&&/^[0-9]+%$/.test(n)}function ie(n){if("number"==typeof n)return n;var e=n.match(/^([0-9]+)(px|%)$/);if(!e)throw new Error("Could not match css value from "+n);return parseInt(e[1],10)}function ae(n){return ie(n)+"px"}function ue(n){return"number"==typeof n?ae(n):oe(n)?n:ae(n)}function ce(n,e){if("number"==typeof n)return n;if(oe(n))return parseInt(e*ie(n)/100,10);var r;if("string"==typeof(r=n)&&/^[0-9]+px$/.test(r))return ie(n);throw new Error("Can not normalize dimension: "+n)}function se(n){void 0===n&&(n=window);var e="__post_robot_10_0_44__";return n!==window?n[e]:n[e]=n[e]||{}}ln((function(){var n;try{n=re()}catch(n){return te}var e=n.getAttribute("data-uid");if(e&&"string"==typeof e)return e;if((e=n.getAttribute("data-uid-auto"))&&"string"==typeof e)return e;if(n.src){var r=function(n){for(var e="",r=0;r<n.length;r++){var t=n[r].charCodeAt(0)*r;n[r+1]&&(t+=n[r+1].charCodeAt(0)*(r-1)),e+=String.fromCharCode(97+Math.abs(t)%26)}return e}(JSON.stringify({src:n.src,dataset:n.dataset}));e="uid_"+r.slice(r.length-30)}else e=un();return n.setAttribute("data-uid-auto",e),e}));var de=function(){return{}};function fe(n,e){return void 0===n&&(n="store"),void 0===e&&(e=de),Dn(se(),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 Dn(n,e,r)},reset:function(){n=e()},keys:function(){return Object.keys(n)}}}))}var le,he=function(){};function we(){var n=se();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new he,n.WINDOW_WILDCARD}function pe(n,e){return void 0===n&&(n="store"),void 0===e&&(e=de),fe("windowStore").getOrSet(n,(function(){var r=new K,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 Dn(t(e),n,r)}}}))}function ve(){return fe("instance").getOrSet("instanceID",un)}function me(n,e){var r=e.domain,t=pe("helloPromises"),o=t.get(n);o&&o.resolve({domain:r});var i=w.resolve({domain:r});return t.set(n,i),i}function ye(n,e){return(0,e.send)(n,"postrobot_hello",{instanceID:ve()},{domain:"*",timeout:-1}).then((function(e){var r=e.origin,t=e.data.instanceID;return me(n,{domain:r}),{win:n,domain:r,instanceID:t}}))}function ge(n,e){var r=e.send;return pe("windowInstanceIDPromises").getOrSet(n,(function(){return ye(n,{send:r}).then((function(n){return n.instanceID}))}))}function be(n,e,r){void 0===e&&(e=5e3),void 0===r&&(r="Window");var t=function(n){return pe("helloPromises").getOrSet(n,(function(){return new w}))}(n);return-1!==e&&(t=t.timeout(e,new Error(r+" did not load after "+e+"ms"))),t}function Ee(n){pe("knownWindows").set(n,!0)}function _e(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function xe(n){return void 0===n?"undefined":null===n?"null":Array.isArray(n)?"array":"function"==typeof n?"function":"object"==typeof n?n instanceof Error?"error":"function"==typeof n.then?"promise":"[object RegExp]"==={}.toString.call(n)?"regex":"[object Date]"==={}.toString.call(n)?"date":"object":"string"==typeof n?"string":"number"==typeof n?"number":"boolean"==typeof n?"boolean":void 0}function Pe(n,e){return{__type__:n,__val__:e}}var Oe,Ce=((le={}).function=function(){},le.error=function(n){return Pe("error",{message:n.message,stack:n.stack,code:n.code,data:n.data})},le.promise=function(){},le.regex=function(n){return Pe("regex",n.source)},le.date=function(n){return Pe("date",n.toJSON())},le.array=function(n){return n},le.object=function(n){return n},le.string=function(n){return n},le.number=function(n){return n},le.boolean=function(n){return n},le.null=function(n){return n},le[void 0]=function(n){return Pe("undefined",n)},le),We={},Se=((Oe={}).function=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},Oe.error=function(n){var e=n.stack,r=n.code,t=n.data,o=new Error(n.message);return o.code=r,t&&(o.data=t),o.stack=e+"\n\n"+o.stack,o},Oe.promise=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},Oe.regex=function(n){return new RegExp(n)},Oe.date=function(n){return new Date(n)},Oe.array=function(n){return n},Oe.object=function(n){return n},Oe.string=function(n){return n},Oe.number=function(n){return n},Oe.boolean=function(n){return n},Oe.null=function(n){return n},Oe[void 0]=function(){},Oe),De={};function je(){return!!I(window).match(/MSIE|trident|edge\/12|edge\/13/i)}function Ae(n){return!q(window,n)}function Ne(n,e){if(n){if(O()!==$(n))return!0}else if(e&&!C(e))return!0;return!1}function Re(n){var e=n.win,r=n.domain;return!(!je()||r&&!Ne(r,e)||e&&!Ae(e))}function Te(n){return"__postrobot_bridge___"+(n=n||$(n)).replace(/[^a-zA-Z0-9]+/g,"_")}function ke(){return Boolean(window.name&&window.name===Te(O()))}var Ie=new w((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 ze(n){pe("remoteWindowPromises").getOrSet(n,(function(){return new w}))}function Fe(n){var e=pe("remoteWindowPromises").get(n);if(!e)throw new Error("Remote window promise not found");return e}function Me(n,e,r){Fe(n).resolve((function(t,o,i){if(t!==n)throw new Error("Remote window does not match window");if(!B(o,e))throw new Error("Remote domain "+o+" does not match domain "+e);r.fireAndForget(i)}))}function Ue(n,e){Fe(n).reject(e).catch(wn)}function Le(n){for(var e=n.win,r=n.name,t=n.domain,o=fe("popupWindowsByName"),i=pe("popupWindowsByWin"),a=0,u=o.keys();a<u.length;a++){var c=u[a],s=o.get(c);s&&!k(s.win)||o.del(c)}if(k(e))return{win:e,name:r,domain:t};var d=i.getOrSet(e,(function(){return r?o.getOrSet(r,(function(){return{win:e,name:r}})):{win:e}}));if(d.win&&d.win!==e)throw new Error("Different window already linked for window: "+(r||"undefined"));return r&&(d.name=r,o.set(r,d)),t&&(d.domain=t,ze(e)),i.set(e,d),d}function qe(n){var e,r=n.on,t=n.send,o=n.receiveMessage;e=window.open,window.open=function(n,r,t,o){var i=e.call(this,Y(n),r,t,o);return i?(Le({win:i,name:r,domain:n?$(n):null}),i):i},function(n){var e=n.on,r=n.send,t=n.receiveMessage,o=fe("popupWindowsByName");e("postrobot_open_tunnel",(function(n){var i=n.source,a=n.origin,u=n.data,c=fe("bridges").get(a);if(!c)throw new Error("Can not find bridge promise for domain "+a);return c.then((function(n){if(i!==n)throw new Error("Message source does not matched registered bridge for domain "+a);if(!u.name)throw new Error("Register window expected to be passed window name");if(!u.sendMessage)throw new Error("Register window expected to be passed sendMessage method");if(!o.has(u.name))throw new Error("Window with name "+u.name+" does not exist, or was not opened by this window");var c=function(){return o.get(u.name)};if(!c().domain)throw new Error("We do not have a registered domain for window "+u.name);if(c().domain!==a)throw new Error("Message origin "+a+" does not matched registered window origin "+(c().domain||"unknown"));return Me(c().win,a,u.sendMessage),{sendMessage:function(n){if(window&&!window.closed&&c()){var o=c().domain;if(o)try{t({data:n,origin:o,source:c().win},{on:e,send:r})}catch(n){w.reject(n)}}}}}))}))}({on:r,send:t,receiveMessage:o}),function(n){var e=n.send;se(window).openTunnelToParent=function(n){var r=n.name,t=n.source,o=n.canary,i=n.sendMessage,a=fe("tunnelWindows"),u=E(window);if(!u)throw new Error("No parent window found to open tunnel to");var c=function(n){var e=n.name,r=n.source,t=n.canary,o=n.sendMessage;!function(){for(var n=fe("tunnelWindows"),e=0,r=n.keys();e<r.length;e++){var t=r[e];k(n[t].source)&&n.del(t)}}();var i=un();return fe("tunnelWindows").set(i,{name:e,source:r,canary:t,sendMessage:o}),i}({name:r,source:t,canary:o,sendMessage:i});return e(u,"postrobot_open_tunnel",{name:r,sendMessage:function(){var n=a.get(c);if(n&&n.source&&!k(n.source)){try{n.canary()}catch(n){return}n.sendMessage.apply(this,arguments)}}},{domain:"*"})}}({send:t}),function(n){var e=n.on,r=n.send,t=n.receiveMessage;w.try((function(){var n,o=_(window);if(o&&Re({win:o}))return ze(o),(n=o,pe("remoteBridgeAwaiters").getOrSet(n,(function(){return w.try((function(){var e=z(n,Te(O()));if(e)return C(e)&&se(W(e))?e:new w((function(n){var r,t;r=setInterval((function(){if(e&&C(e)&&se(W(e)))return clearInterval(r),clearTimeout(t),n(e)}),100),t=setTimeout((function(){return clearInterval(r),n()}),2e3)}))}))}))).then((function(n){return n?window.name?se(W(n)).openTunnelToParent({name:window.name,source:window,canary:function(){},sendMessage:function(n){try{window}catch(n){return}if(window&&!window.closed)try{t({data:n,origin:this.origin,source:this.source},{on:e,send:r})}catch(n){w.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");Me(e,r,t.sendMessage)})).catch((function(n){throw Ue(o,n),n})):Ue(o,new Error("Can not register with opener: window does not have a name")):Ue(o,new Error("Can not register with opener: no bridge found in opener"))}))}))}({on:r,send:t,receiveMessage:o})}function Be(){for(var n=fe("idToProxyWindow"),e=0,r=n.keys();e<r.length;e++){var t=r[e];n.get(t).shouldClean()&&n.del(t)}}function $e(n,e){var r=e.send,t=e.id,o=void 0===t?un():t,i=n.then((function(n){if(C(n))return W(n).name})),a=n.then((function(n){if(k(n))throw new Error("Window is closed, can not determine type");return _(n)?v.POPUP:v.IFRAME}));i.catch(wn),a.catch(wn);var u=function(){return n.then((function(n){if(!k(n))return C(n)?W(n).name:i}))};return{id:o,getType:function(){return a},getInstanceID:hn((function(){return n.then((function(n){return ge(n,{send:r})}))})),close:function(){return n.then(G)},getName:u,focus:function(){return n.then((function(n){n.focus()}))},isClosed:function(){return n.then((function(n){return k(n)}))},setLocation:function(e,r){return void 0===r&&(r={}),n.then((function(n){var t=window.location.protocol+"//"+window.location.host,o=r.method,i=void 0===o?"get":o,a=r.body;if(0===e.indexOf("/"))e=""+t+e;else if(!e.match(/^https?:\/\//)&&0!==e.indexOf(t))throw new Error("Expected url to be http or https url, or absolute path, got "+JSON.stringify(e));if("post"===i)return u().then((function(n){if(!n)throw new Error("Can not post to window without target name");!function(n){var e=n.url,r=n.target,t=n.body,o=n.method,i=void 0===o?"post":o,a=document.createElement("form");if(a.setAttribute("target",r),a.setAttribute("method",i),a.setAttribute("action",e),a.style.display="none",t)for(var u=0,c=Object.keys(t);u<c.length;u++){var s,d=c[u],f=document.createElement("input");f.setAttribute("name",d),f.setAttribute("value",null==(s=t[d])?void 0:s.toString()),a.appendChild(f)}Rn().appendChild(a),a.submit(),Rn().removeChild(a)}({url:e,target:n,method:i,body:a})}));if("get"!==i)throw new Error("Unsupported method: "+i);if(C(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){Le({win:n,name:e});var r=C(n),t=Z(n);if(!r)throw new Error("Can not set name for cross-domain window: "+e);W(n).name=e,t&&t.setAttribute("name",e),i=w.resolve(e)}))}}}var Je=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 w,this.serializedWindow=t||$e(this.actualWindowPromise,{send:e}),fe("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===v.POPUP}))},e.setLocation=function(n,e){var r=this;return this.serializedWindow.setLocation(n,e).then((function(){return r}))},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=w.hash({isPopup:e,name:r}).then((function(n){var e=n.name;n.isPopup&&e&&window.open("",e)})),o=this.serializedWindow.focus();return w.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=$e(this.actualWindowPromise,{send:r,id:this.getID()}),pe("winToProxyWindow").set(n,this)},e.awaitWindow=function(){return this.actualWindowPromise},e.matchWindow=function(n,e){var r=this,t=e.send;return w.try((function(){return r.actualWindow?n===r.actualWindow:w.hash({proxyInstanceID:r.getInstanceID(),knownWindowInstanceID:ge(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&&k(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 Be(),n.toProxyWindow(e,{send:t}).serialize()},n.deserialize=function(e,r){var t=r.send;return Be(),fe("idToProxyWindow").get(e.id)||new n({serializedWindow:e,send:t})},n.isProxyWindow=function(n){return Boolean(n&&!H(n)&&n.isProxyWindow)},n.toProxyWindow=function(e,r){var t=r.send;if(Be(),n.isProxyWindow(e))return e;var o=e;return pe("winToProxyWindow").get(o)||new n({win:o,send:t})},n}();function He(n,e,r,t,o){var i=pe("methodStore"),a=fe("proxyWindowMethods");Je.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 Ye(n,e){var r=pe("methodStore"),t=fe("proxyWindowMethods");return r.getOrSet(n,(function(){return{}}))[e]||t.get(e)}function Ze(n,e,r,t,o){var i,a,u;a=(i={on:o.on,send:o.send}).on,u=i.send,fe("builtinListeners").getOrSet("functionCalls",(function(){return a("postrobot_method",{domain:"*"},(function(n){var e=n.source,r=n.origin,t=n.data,o=t.id,i=t.name,a=Ye(e,o);if(!a)throw new Error("Could not find method '"+i+"' with id: "+t.id+" in "+O(window));var c=a.source,s=a.domain,d=a.val;return w.try((function(){if(!B(s,r))throw new Error("Method '"+t.name+"' domain "+JSON.stringify(Sn(a.domain)?a.domain.source:a.domain)+" does not match origin "+r+" in "+O(window));if(Je.isProxyWindow(c))return c.matchWindow(e,{send:u}).then((function(n){if(!n)throw new Error("Method call '"+t.name+"' failed - proxy window does not match source in "+O(window))}))})).then((function(){return d.apply({source:e,origin:r},t.args)}),(function(n){return w.try((function(){if(d.onError)return d.onError(n)})).then((function(){var e;throw n.stack&&(n.stack="Remote call to "+i+"("+(void 0===(e=t.args)&&(e=[]),xn(e).map((function(n){return"string"==typeof n?"'"+n+"'":void 0===n?"undefined":null===n?"null":"boolean"==typeof n?n.toString():Array.isArray(n)?"[ ... ]":"object"==typeof n?"{ ... }":"function"==typeof n?"() => { ... }":"<"+typeof n+">"})).join(", ")+") failed\n\n")+n.stack),n}))})).then((function(n){return{result:n,id:o,name:i}}))}))}));var c=r.__id__||un();n=Je.unwrap(n);var s=r.__name__||r.name||t;return"string"==typeof s&&"function"==typeof s.indexOf&&0===s.indexOf("anonymous::")&&(s=s.replace("anonymous::",t+"::")),Je.isProxyWindow(n)?(He(c,r,s,n,e),n.awaitWindow().then((function(n){He(c,r,s,n,e)}))):He(c,r,s,n,e),Pe("cross_domain_function",{id:c,name:s})}function Ge(n,e,r,t){var o,i=t.on,a=t.send;return function(n,e){void 0===e&&(e=We);var r=JSON.stringify(n,(function(n){var r=this[n];if(_e(this))return r;var t=xe(r);if(!t)return r;var o=e[t]||Ce[t];return o?o(r,n):r}));return void 0===r?"undefined":r}(r,((o={}).promise=function(r,t){return function(n,e,r,t,o){return Pe("cross_domain_zalgo_promise",{then:Ze(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.function=function(r,t){return Ze(n,e,r,t,{on:i,send:a})},o.object=function(n){return H(n)||Je.isProxyWindow(n)?Pe("cross_domain_window",Je.serialize(n,{send:a})):n},o))}function Ve(n,e,r,t){var o,i=t.send;return function(n,e){if(void 0===e&&(e=De),"undefined"!==n)return JSON.parse(n,(function(n,r){if(_e(this))return r;var t,o;if(_e(r)?(t=r.__type__,o=r.__val__):(t=xe(r),o=r),!t)return o;var i=e[t]||Se[t];return i?i(o,n):o}))}(r,((o={}).cross_domain_zalgo_promise=function(n){return function(n,e,r){return new w(r.then)}(0,0,n)},o.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 Je.toProxyWindow(n,{send:a}).awaitWindow().then((function(n){var c=Ye(n,o);if(c&&c.val!==t)return c.val.apply({source:window,origin:O()},u);var s=[].slice.call(u);return r.fireAndForget?a(n,"postrobot_method",{id:o,name:i,args:s},{domain:e,fireAndForget:!0}):a(n,"postrobot_method",{id:o,name:i,args:s},{domain:e,fireAndForget:!1}).then((function(n){return n.data.result}))})).catch((function(n){throw n}))}return void 0===r&&(r={}),t.__name__=i,t.__origin__=e,t.__source__=n,t.__id__=o,t.origin=e,t},c=u();return c.fireAndForget=u({fireAndForget:!0}),c}(n,e,r,{send:i})},o.cross_domain_window=function(n){return Je.deserialize(n,{send:i})},o))}var Xe={};function Ke(n,e,r,t){var o=t.on,i=t.send;return w.try((function(){var t=pe().getOrSet(n,(function(){return{}}));return t.buffer=t.buffer||[],t.buffer.push(r),t.flush=t.flush||w.flush().then((function(){if(k(n))throw new Error("Window is closed");var r,a=Ge(n,e,((r={}).__post_robot_10_0_44__=t.buffer||[],r),{on:o,send:i});delete t.buffer;for(var u=Object.keys(Xe),c=[],s=0;s<u.length;s++){var d=u[s];try{Xe[d](n,a,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+". "+vn(n)})).join("\n\n"))})),t.flush.then((function(){delete t.flush}))})).then(wn)}function Qe(n){return fe("responseListeners").get(n)}function nr(n){fe("responseListeners").del(n)}function er(n){return fe("erroredResponseListeners").has(n)}function rr(n){var e=n.name,r=n.win,t=n.domain,o=pe("requestListeners");if("*"===r&&(r=null),"*"===t&&(t=null),!e)throw new Error("Name required to get request listener");for(var i=0,a=[r,we()];i<a.length;i++){var u=a[i];if(u){var c=o.get(u);if(c){var s=c[e];if(s){if(t&&"string"==typeof t){if(s[t])return s[t];if(s.__domain_regex__)for(var d=0,f=s.__domain_regex__;d<f.length;d++){var l=f[d],h=l.listener;if(B(l.regex,t))return h}}if(s["*"])return s["*"]}}}}}function tr(n,e,r,t){var o=t.on,i=t.send,a=rr({name:r.name,win:n,domain:e}),u="postrobot_method"===r.name&&r.data&&"string"==typeof r.data.name?r.data.name+"()":r.name;function c(t,a,c){return w.flush().then((function(){if(!r.fireAndForget&&!k(n))try{return Ke(n,e,{id:un(),origin:O(window),type:"postrobot_message_response",hash:r.hash,name:r.name,ack:t,data:a,error:c},{on:o,send:i})}catch(n){throw new Error("Send response message failed for "+u+" in "+O()+"\n\n"+vn(n))}}))}return w.all([w.flush().then((function(){if(!r.fireAndForget&&!k(n))try{return Ke(n,e,{id:un(),origin:O(window),type:"postrobot_message_ack",hash:r.hash,name:r.name},{on:o,send:i})}catch(n){throw new Error("Send ack message failed for "+u+" in "+O()+"\n\n"+vn(n))}})),w.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(!B(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 c("success",n)}),(function(n){return c("error",null,n)}))]).then(wn).catch((function(n){if(a&&a.handleError)return a.handleError(n);throw n}))}function or(n,e,r){if(!er(r.hash)){var t=Qe(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(!B(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}}function ir(n,e,r){if(!er(r.hash)){var t,o=Qe(r.hash);if(!o)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(!B(o.domain,e))throw new Error("Response origin "+e+" does not match domain "+(t=o.domain,Array.isArray(t)?"("+t.join(" | ")+")":p(t)?"RegExp("+t.toString()+")":t.toString()));if(n!==o.win)throw new Error("Response source does not match registered window");nr(r.hash),"error"===r.ack?o.promise.reject(r.error):"success"===r.ack&&o.promise.resolve({source:n,origin:e,data:r.data})}}function ar(n,e){var r=e.on,t=e.send,o=fe("receivedMessages");try{if(!window||window.closed||!n.source)return}catch(n){return}var i=n.source,a=n.origin,u=function(n,e,r,t){var o,i=t.on,a=t.send;try{o=Ve(e,r,n,{on:i,send:a})}catch(n){return}if(o&&"object"==typeof o&&null!==o){var u=o.__post_robot_10_0_44__;if(Array.isArray(u))return u}}(n.data,i,a,{on:r,send:t});if(u){Ee(i);for(var c=0;c<u.length;c++){var s=u[c];if(o.has(s.id))return;if(o.set(s.id,!0),k(i)&&!s.fireAndForget)return;0===s.origin.indexOf("file:")&&(a="file://");try{"postrobot_message_request"===s.type?tr(i,a,s,{on:r,send:t}):"postrobot_message_response"===s.type?ir(i,a,s):"postrobot_message_ack"===s.type&&or(i,a,s)}catch(n){setTimeout((function(){throw n}),0)}}}}function ur(n,e,r){if(!n)throw new Error("Expected name");if("function"==typeof(e=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=pe("requestListeners");if(!t||"string"!=typeof t)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var u=[],c=0,s=o;c<s.length;c++)u.push(n({name:t,domain:i,win:s[c]},r));return{cancel:function(){for(var n=0;n<u.length;n++)u[n].cancel()}}}if(Array.isArray(i)){for(var d=[],f=0,l=i;f<l.length;f++)d.push(n({name:t,win:o,domain:l[f]},r));return{cancel:function(){for(var n=0;n<d.length;n++)d[n].cancel()}}}var h=rr({name:t,win:o,domain:i});if(o&&"*"!==o||(o=we()),i=i||"*",h)throw o&&i?new Error("Request listener already