UNPKG

zoid

Version:
1 lines 93.4 kB
!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 Mn})),r.d(e,"create",(function(){return Ir})),r.d(e,"destroy",(function(){return Mr})),r.d(e,"destroyComponents",(function(){return zr})),r.d(e,"destroyAll",(function(){return Fr})),r.d(e,"PROP_TYPE",(function(){return wr})),r.d(e,"PROP_SERIALIZATION",(function(){return pr})),r.d(e,"CONTEXT",(function(){return mr})),r.d(e,"EVENT",(function(){return vr}));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 m={IFRAME:"iframe",POPUP:"popup"},v="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 N(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=N(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=N(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 j(n){var e=A(n);if(!e)throw new Error("Can not determine top window");var r=[].concat(N(e),[e]);return-1===r.indexOf(n)&&(r=[].concat(r,[n],N(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!==v}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=j(n),i=j(e);if(U(o,i))return!0;var a=_(r),u=_(t);return a&&U(j(a),i)||u&&U(j(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 J(n){return n.match(/^(https?|mock|file):\/\//)?n.split("/").slice(0,3).join("/"):O()}function H(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 Y(n){try{if(n===window)return!0}catch(n){if(n&&n.message===v)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===v)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===v)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===v)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===v)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===v)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 Z(n){if(0!==J(n).indexOf("mock:"))return n;throw new Error("Mock urls not supported out of test mode")}function G(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 V(n){if(function(n){return void 0===n&&(n=window),Boolean(E(n))}(n)){var e=G(n);if(e&&e.parentElement)return void e.parentElement.removeChild(e)}try{n.close()}catch(n){}}function X(n,e){for(var r=0;r<n.length;r++)try{if(n[r]===e)return r}catch(n){}return-1}var $,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(Y(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!Y(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=X(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=X(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=X(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!==X(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($=$||new K,null==n||"object"!=typeof n&&"function"!=typeof n)throw new Error("Invalid object");var e=$.get(n);return e||(e=typeof n+":"+un(),$.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 mn(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: "+mn(n,e+1)}}function vn(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[].slice.call(n)}function _n(n){return null!=n}function xn(n){return"[object RegExp]"==={}.toString.call(n)}function Pn(n,e,r){if(n.hasOwnProperty(e))return n[e];var t=r();return n[e]=t,t}function On(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 Cn(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 Wn=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 Sn(){var n=document.body;if(!n)throw new Error("Body element not found");return n}function Dn(){return Boolean(document.body)&&"complete"===document.readyState}function Nn(){return Boolean(document.body)&&"interactive"===document.readyState}function An(n){return encodeURIComponent(n)}function jn(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)}(jn,0,[n])}function Rn(n,e){return void 0===e&&(e={}),e&&Object.keys(e).length?(void 0===(r=i({},jn(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 An(n)+"="+An(e.toString())})).join("&")):n;var r}function Tn(n,e){n.appendChild(e)}function kn(n){return n instanceof window.Element||null!==n&&"object"==typeof n&&1===n.nodeType&&"object"==typeof n.style&&"object"==typeof n.ownerDocument}function In(n,e){return void 0===e&&(e=document),kn(n)?n:"string"==typeof n?e.querySelector(n):void 0}function zn(n){return new w((function(e,r){var t=vn(n),o=In(n);if(o)return e(o);if(Dn())return r(new Error("Document is ready and element "+t+" does not exist"));var i=setInterval((function(){return(o=In(n))?(e(o),void clearInterval(i)):Dn()?(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(Dn()||Nn())return n();var e=setInterval((function(){if(Dn()||Nn())return clearInterval(e),n()}),10)}))}));var Fn,Mn=function(n){function e(){return n.apply(this,arguments)||this}return o(e,n),e}(Wn);function Un(n){if((Fn=Fn||new K).has(n)){var e=Fn.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 Fn.set(n,r),r}function Ln(n){return Un(n).then((function(n){if(!n.contentWindow)throw new Error("Could not find window in iframe");return n.contentWindow}))}function qn(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()),Un(t),e&&function(n,e){void 0===e&&(e=document);var r=In(n,e);if(r)return r;throw new Error("Can not find element: "+vn(n))}(e).appendChild(t),(n.url||o)&&t.setAttribute("src",n.url||"about:blank"),t}function Bn(n,e,r){return n.addEventListener(e,r),{cancel:function(){n.removeEventListener(e,r)}}}function Jn(n){n.style.setProperty("display","")}function Hn(n){n.style.setProperty("display","none","important")}function Yn(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function Zn(n){return!(n&&n.parentNode&&n.ownerDocument&&n.ownerDocument.documentElement&&n.ownerDocument.documentElement.contains(n))}function Gn(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,m,v=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",v),void 0!==f.ResizeObserver?((p=new f.ResizeObserver(v)).observe(n),m=bn(v,10*s)):void 0!==f.MutationObserver?((p=new f.MutationObserver(v)).observe(n,{attributes:!0,childList:!0,subtree:!0,characterData:!1}),m=bn(v,10*s)):m=bn(v,s),{cancel:function(){w=!0,p.disconnect(),window.removeEventListener("resize",v),m.cancel()}}}function Vn(n){for(;n.parentNode;)n=n.parentNode;return"[object ShadowRoot]"===n.toString()}var Xn="undefined"!=typeof document?document.currentScript:null,$n=ln((function(){if(Xn)return Xn;if(Xn=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 Xn;throw new Error("Can not determine current script")})),Kn=un();function Qn(n){return"string"==typeof n&&/^[0-9]+%$/.test(n)}function ne(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 ee(n){return ne(n)+"px"}function re(n){return"number"==typeof n?ee(n):Qn(n)?n:ee(n)}function te(n,e){if("number"==typeof n)return n;if(Qn(n))return parseInt(e*ne(n)/100,10);var r;if("string"==typeof(r=n)&&/^[0-9]+px$/.test(r))return ne(n);throw new Error("Can not normalize dimension: "+n)}function oe(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=$n()}catch(n){return Kn}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 ie=function(){return{}};function ae(n,e){return void 0===n&&(n="store"),void 0===e&&(e=ie),Pn(oe(),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 Pn(n,e,r)},reset:function(){n=e()},keys:function(){return Object.keys(n)}}}))}var ue,ce=function(){};function se(){var n=oe();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new ce,n.WINDOW_WILDCARD}function de(n,e){return void 0===n&&(n="store"),void 0===e&&(e=ie),ae("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 Pn(t(e),n,r)}}}))}function fe(){return ae("instance").getOrSet("instanceID",un)}function le(n,e){var r=e.domain,t=de("helloPromises"),o=t.get(n);o&&o.resolve({domain:r});var i=w.resolve({domain:r});return t.set(n,i),i}function he(n,e){return(0,e.send)(n,"postrobot_hello",{instanceID:fe()},{domain:"*",timeout:-1}).then((function(e){var r=e.origin,t=e.data.instanceID;return le(n,{domain:r}),{win:n,domain:r,instanceID:t}}))}function we(n,e){var r=e.send;return de("windowInstanceIDPromises").getOrSet(n,(function(){return he(n,{send:r}).then((function(n){return n.instanceID}))}))}function pe(n,e,r){void 0===e&&(e=5e3),void 0===r&&(r="Window");var t=function(n){return de("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 me(n){de("knownWindows").set(n,!0)}function ve(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function ye(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 ge(n,e){return{__type__:n,__val__:e}}var be,Ee=((ue={}).function=function(){},ue.error=function(n){return ge("error",{message:n.message,stack:n.stack,code:n.code,data:n.data})},ue.promise=function(){},ue.regex=function(n){return ge("regex",n.source)},ue.date=function(n){return ge("date",n.toJSON())},ue.array=function(n){return n},ue.object=function(n){return n},ue.string=function(n){return n},ue.number=function(n){return n},ue.boolean=function(n){return n},ue.null=function(n){return n},ue[void 0]=function(n){return ge("undefined",n)},ue),_e={},xe=((be={}).function=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},be.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},be.promise=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},be.regex=function(n){return new RegExp(n)},be.date=function(n){return new Date(n)},be.array=function(n){return n},be.object=function(n){return n},be.string=function(n){return n},be.number=function(n){return n},be.boolean=function(n){return n},be.null=function(n){return n},be[void 0]=function(){},be),Pe={};function Oe(){return!!I(window).match(/MSIE|trident|edge\/12|edge\/13/i)}function Ce(n){return!q(window,n)}function We(n,e){if(n){if(O()!==J(n))return!0}else if(e&&!C(e))return!0;return!1}function Se(n){var e=n.win,r=n.domain;return!(!Oe()||r&&!We(r,e)||e&&!Ce(e))}function De(n){return"__postrobot_bridge___"+(n=n||J(n)).replace(/[^a-zA-Z0-9]+/g,"_")}function Ne(){return Boolean(window.name&&window.name===De(O()))}var Ae=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 je(n){de("remoteWindowPromises").getOrSet(n,(function(){return new w}))}function Re(n){var e=de("remoteWindowPromises").get(n);if(!e)throw new Error("Remote window promise not found");return e}function Te(n,e,r){Re(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 ke(n,e){Re(n).reject(e).catch(wn)}function Ie(n){for(var e=n.win,r=n.name,t=n.domain,o=ae("popupWindowsByName"),i=de("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,je(e)),i.set(e,d),d}function ze(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,Z(n),r,t,o);return i?(Ie({win:i,name:r,domain:n?J(n):null}),i):i},function(n){var e=n.on,r=n.send,t=n.receiveMessage,o=ae("popupWindowsByName");e("postrobot_open_tunnel",(function(n){var i=n.source,a=n.origin,u=n.data,c=ae("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 Te(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;oe(window).openTunnelToParent=function(n){var r=n.name,t=n.source,o=n.canary,i=n.sendMessage,a=ae("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=ae("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 ae("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&&Se({win:o}))return je(o),(n=o,de("remoteBridgeAwaiters").getOrSet(n,(function(){return w.try((function(){var e=z(n,De(O()));if(e)return C(e)&&oe(W(e))?e:new w((function(n){var r,t;r=setInterval((function(){if(e&&C(e)&&oe(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?oe(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");Te(e,r,t.sendMessage)})).catch((function(n){throw ke(o,n),n})):ke(o,new Error("Can not register with opener: window does not have a name")):ke(o,new Error("Can not register with opener: no bridge found in opener"))}))}))}({on:r,send:t,receiveMessage:o})}function Fe(){for(var n=ae("idToProxyWindow"),e=0,r=n.keys();e<r.length;e++){var t=r[e];n.get(t).shouldClean()&&n.del(t)}}function Me(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)?m.POPUP:m.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 we(n,{send:r})}))})),close:function(){return n.then(V)},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)}Sn().appendChild(a),a.submit(),Sn().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){Ie({win:n,name:e});var r=C(n),t=G(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 Ue=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||Me(this.actualWindowPromise,{send:e}),ae("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===m.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=Me(this.actualWindowPromise,{send:r,id:this.getID()}),de("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:we(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 Fe(),n.toProxyWindow(e,{send:t}).serialize()},n.deserialize=function(e,r){var t=r.send;return Fe(),ae("idToProxyWindow").get(e.id)||new n({serializedWindow:e,send:t})},n.isProxyWindow=function(n){return Boolean(n&&!Y(n)&&n.isProxyWindow)},n.toProxyWindow=function(e,r){var t=r.send;if(Fe(),n.isProxyWindow(e))return e;var o=e;return de("winToProxyWindow").get(o)||new n({win:o,send:t})},n}();function Le(n,e,r,t,o){var i=de("methodStore"),a=ae("proxyWindowMethods");Ue.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 qe(n,e){var r=de("methodStore"),t=ae("proxyWindowMethods");return r.getOrSet(n,(function(){return{}}))[e]||t.get(e)}function Be(n,e,r,t,o){var i,a,u;a=(i={on:o.on,send:o.send}).on,u=i.send,ae("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=qe(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(xn(a.domain)?a.domain.source:a.domain)+" does not match origin "+r+" in "+O(window));if(Ue.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=[]),En(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=Ue.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+"::")),Ue.isProxyWindow(n)?(Le(c,r,s,n,e),n.awaitWindow().then((function(n){Le(c,r,s,n,e)}))):Le(c,r,s,n,e),ge("cross_domain_function",{id:c,name:s})}function Je(n,e,r,t){var o,i=t.on,a=t.send;return function(n,e){void 0===e&&(e=_e);var r=JSON.stringify(n,(function(n){var r=this[n];if(ve(this))return r;var t=ye(r);if(!t)return r;var o=e[t]||Ee[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 ge("cross_domain_zalgo_promise",{then:Be(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 Be(n,e,r,t,{on:i,send:a})},o.object=function(n){return Y(n)||Ue.isProxyWindow(n)?ge("cross_domain_window",Ue.serialize(n,{send:a})):n},o))}function He(n,e,r,t){var o,i=t.send;return function(n,e){if(void 0===e&&(e=Pe),"undefined"!==n)return JSON.parse(n,(function(n,r){if(ve(this))return r;var t,o;if(ve(r)?(t=r.__type__,o=r.__val__):(t=ye(r),o=r),!t)return o;var i=e[t]||xe[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 Ue.toProxyWindow(n,{send:a}).awaitWindow().then((function(n){var c=qe(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 Ue.deserialize(n,{send:i})},o))}var Ye={};function Ze(n,e,r,t){var o=t.on,i=t.send;return w.try((function(){var t=de().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=Je(n,e,((r={}).__post_robot_10_0_44__=t.buffer||[],r),{on:o,send:i});delete t.buffer;for(var u=Object.keys(Ye),c=[],s=0;s<u.length;s++){var d=u[s];try{Ye[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+". "+mn(n)})).join("\n\n"))})),t.flush.then((function(){delete t.flush}))})).then(wn)}function Ge(n){return ae("responseListeners").get(n)}function Ve(n){ae("responseListeners").del(n)}function Xe(n){return ae("erroredResponseListeners").has(n)}function $e(n){var e=n.name,r=n.win,t=n.domain,o=de("requestListeners");if("*"===r&&(r=null),"*"===t&&(t=null),!e)throw new Error("Name required to get request listener");for(var i=0,a=[r,se()];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 Ke(n,e,r,t){var o=t.on,i=t.send,a=$e({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 Ze(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"+mn(n))}}))}return w.all([w.flush().then((function(){if(!r.fireAndForget&&!k(n))try{return Ze(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"+mn(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 Qe(n,e,r){if(!Xe(r.hash)){var t=Ge(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 nr(n,e,r){if(!Xe(r.hash)){var t,o=Ge(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");Ve(r.hash),"error"===r.ack?o.promise.reject(r.error):"success"===r.ack&&o.promise.resolve({source:n,origin:e,data:r.data})}}function er(n,e){var r=e.on,t=e.send,o=ae("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=He(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){me(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?Ke(i,a,s,{on:r,send:t}):"postrobot_message_response"===s.type?nr(i,a,s):"postrobot_message_ack"===s.type&&Qe(i,a,s)}catch(n){setTimeout((function(){throw n}),0)}}}}function rr(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=de("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=$e({name:t,win:o,domain:i});if(o&&"*"!==o||(o=se()),i=i||"*",h)throw o&&i?new Error("Request listener already exists for "+t+" on domain "+i.toString()+" for "+(o===se()?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+t+" for "+(o===se()?"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,m=a.getOrSet(o,(function(){return{}})),v=Pn(m,t,(function(){return{}})),y=i.toString();return xn(i)?(w=Pn(v,"__domain_regex__",(function(){return[]}))).push(p={regex:i,listener:r}):v[y]=r,{cancel:function(){delete v[y],p&&(w.splice(w.indexOf(p,1)),w.length||delete v.__domain_regex__),Object.keys(v).length||delete m[t],o&&!Object.keys(m).length&&a.del(o)}}}({name:n,win:t,domain:o},{handler:e.handler,handleError:e.errorHandler||function(n){throw n},window:t,domain:o||"*",name:n});return{cancel:function(){i.cancel()}}}Ye.postrobot_post_message=function(n,e,r){0===r.indexOf("file:")&&(r="*"),n.postMessage(e,r)},Ye.postrobot_bridge=function(n,e,r){if(!Oe()&&!Ne())throw new Error("Bridge not needed for browser");if(C(n))throw new Error("Post message through bridge disabled between same domain windows");if(!1!==q(window,n))throw new Error("Can