@pitcher/js-api 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/js-api.umd.min.js CHANGED
@@ -1,18 +1,18 @@
1
- (function(x,re){typeof exports=="object"&&typeof module<"u"?re(exports):typeof define=="function"&&define.amd?define(["exports"],re):(x=typeof globalThis<"u"?globalThis:x||self,re(x.pitcher={}))})(this,function(x){"use strict";function re(t={}){return this.API.request("open",t)}function lt(){return this.API.request("get_env")}function ht(t){return this.API.request("update_my_user",t)}function vt(){return this.API.request("get_languages")}function gt(t){return x.highLevelApi.API.request("get_events",t)}function pt(t){return x.highLevelApi.API.request("create_event",t)}function wt(t){return x.highLevelApi.API.request("update_event",t)}function mt(t){return x.highLevelApi.API.request("delete_event",t)}function yt(t){return this.API.request("get_canvases",t)}function Et(t){return this.API.request("create_canvas",t)}function At(t){return this.API.request("delete_canvas",t)}function bt(t){return this.API.request("update_canvas",t)}function St(t){return this.API.request("get_canvas",t)}function xt(t){return this.API.request("share_canvas",t)}function Pt(t){const a={...t};return a.type&&(a.type=Array.isArray(a.type)?a.type:[a.type]),a.content_type&&(a.content_type=Array.isArray(a.content_type)?a.content_type:[a.content_type]),this.API.request("get_files",a)}function It(t){return this.API.request("download_file",t)}function _t(t){return this.API.request("get_app_config",t)}function Wt(t){return this.API.request("get_file",t)}function Ot(t){return this.API.request("delete_file",t)}function Rt(t){return this.API.request("create_file",t)}function Tt(){return this.API.request("select_device_file")}function Ct(t){return this.API.request("search",t)}function Dt(t){return this.API.request("get_users",t)}function Mt(t){return this.API.request("getService",t)}function Nt(t){return this.API.request("refresh_service_token",t)}function Lt(){return this.API.request("get_connections")}function jt(t){return this.API.request("connection_login",t)}function zt(t){return this.API.request("connection_logout",t)}function Ut(t){return this.API.request("fetch_document_info",t)}function qt(t){return this.API.request("render_page_as_image",t)}function Ft(t){return this.API.request("toast",t)}function $t(t){return x.highLevelApi.API.request("query",t)}function Ht(t={id:"root"}){return this.API.request("get_folder",t)}function Gt(t){return this.API.request("create_folder",t)}function Vt(t){return this.API.request("update_folder",t)}function kt(t){return this.API.request("delete_folder",t)}function Zt(t){return this.API.request("move_folder_items",t)}function Jt(t){return this.API.request("get_favorites",t)}function Yt(t){return this.API.request("create_favorite",t)}function Bt(t){return this.API.request("delete_favorite",t)}function Qt(t){return t.type||(t.type="native"),x.highLevelApi.API.request("notify",t)}function Xt(t){return x.highLevelApi.API.request("track",t)}function Kt(t){return this.API.request("get_instance_metadata_templates",t)}const er=Object.freeze(Object.defineProperty({__proto__:null,connectionLogin:jt,connectionLogout:zt,createCanvas:Et,createEvent:pt,createFavorite:Yt,createFile:Rt,createFolder:Gt,deleteCanvas:At,deleteEvent:mt,deleteFavorite:Bt,deleteFile:Ot,deleteFolder:kt,downloadFile:It,fetchDocumentInfo:Ut,getAppConfig:_t,getCanvas:St,getCanvases:yt,getConnections:Lt,getEnv:lt,getEvents:gt,getFavorites:Jt,getFile:Wt,getFiles:Pt,getFolder:Ht,getInstanceMetadataTemplates:Kt,getLanguages:vt,getService:Mt,getUsers:Dt,moveFolderItems:Zt,notify:Qt,open:re,query:$t,refreshServiceToken:Nt,renderPageAsImage:qt,search:Ct,selectDeviceFile:Tt,shareCanvas:xt,toast:Ft,track:Xt,updateCanvas:bt,updateEvent:wt,updateFolder:Vt,updateMyUser:ht},Symbol.toStringTag,{value:"Module"}));class Fe{listeners={};on(a,l){this.listeners[a]=(this.listeners[a]??[]).concat(l)}off(a,l){this.listeners[a]=(this.listeners[a]??[]).filter(w=>w!==l)}emit(a,l){(this.listeners[a]??[]).forEach(w=>w(l))}}let ge;const nr=new Uint8Array(16);function tr(){if(!ge&&(ge=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ge))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ge(nr)}const N=[];for(let t=0;t<256;++t)N.push((t+256).toString(16).slice(1));function rr(t,a=0){return N[t[a+0]]+N[t[a+1]]+N[t[a+2]]+N[t[a+3]]+"-"+N[t[a+4]]+N[t[a+5]]+"-"+N[t[a+6]]+N[t[a+7]]+"-"+N[t[a+8]]+N[t[a+9]]+"-"+N[t[a+10]]+N[t[a+11]]+N[t[a+12]]+N[t[a+13]]+N[t[a+14]]+N[t[a+15]]}const $e={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function He(t,a,l){if($e.randomUUID&&!a&&!t)return $e.randomUUID();t=t||{};const w=t.random||(t.rng||tr)();if(w[6]=w[6]&15|64,w[8]=w[8]&63|128,a){l=l||0;for(let v=0;v<16;++v)a[l+v]=w[v];return a}return rr(w)}class or extends Error{}function ir(t,a){if(!t)throw new or(a)}var ur=typeof global=="object"&&global&&global.Object===Object&&global;const ar=ur;var sr=typeof self=="object"&&self&&self.Object===Object&&self,cr=ar||sr||Function("return this")(),fr=cr.Symbol;const ee=fr;var Ge=Object.prototype,dr=Ge.hasOwnProperty,lr=Ge.toString,oe=ee?ee.toStringTag:void 0;function hr(t){var a=dr.call(t,oe),l=t[oe];try{t[oe]=void 0;var w=!0}catch{}var v=lr.call(t);return w&&(a?t[oe]=l:delete t[oe]),v}var vr=Object.prototype,gr=vr.toString;function pr(t){return gr.call(t)}var wr="[object Null]",mr="[object Undefined]",Ve=ee?ee.toStringTag:void 0;function yr(t){return t==null?t===void 0?mr:wr:Ve&&Ve in Object(t)?hr(t):pr(t)}function Er(t){return t!=null&&typeof t=="object"}var Ar="[object Symbol]";function br(t){return typeof t=="symbol"||Er(t)&&yr(t)==Ar}function Sr(t,a){for(var l=-1,w=t==null?0:t.length,v=Array(w);++l<w;)v[l]=a(t[l],l,t);return v}var xr=Array.isArray;const Pr=xr;var Ir=1/0,ke=ee?ee.prototype:void 0,Ze=ke?ke.toString:void 0;function Je(t){if(typeof t=="string")return t;if(Pr(t))return Sr(t,Je)+"";if(br(t))return Ze?Ze.call(t):"";var a=t+"";return a=="0"&&1/t==-Ir?"-0":a}function pe(t){return t==null?"":Je(t)}function _r(t,a,l){var w=-1,v=t.length;a<0&&(a=-a>v?0:v+a),l=l>v?v:l,l<0&&(l+=v),v=a>l?0:l-a>>>0,a>>>=0;for(var y=Array(v);++w<v;)y[w]=t[w+a];return y}function Wr(t,a,l){var w=t.length;return l=l===void 0?w:l,!a&&l>=w?t:_r(t,a,l)}var Or="\\ud800-\\udfff",Rr="\\u0300-\\u036f",Tr="\\ufe20-\\ufe2f",Cr="\\u20d0-\\u20ff",Dr=Rr+Tr+Cr,Mr="\\ufe0e\\ufe0f",Nr="\\u200d",Lr=RegExp("["+Nr+Or+Dr+Mr+"]");function Ye(t){return Lr.test(t)}function jr(t){return t.split("")}var Be="\\ud800-\\udfff",zr="\\u0300-\\u036f",Ur="\\ufe20-\\ufe2f",qr="\\u20d0-\\u20ff",Fr=zr+Ur+qr,$r="\\ufe0e\\ufe0f",Hr="["+Be+"]",Ie="["+Fr+"]",_e="\\ud83c[\\udffb-\\udfff]",Gr="(?:"+Ie+"|"+_e+")",Qe="[^"+Be+"]",Xe="(?:\\ud83c[\\udde6-\\uddff]){2}",Ke="[\\ud800-\\udbff][\\udc00-\\udfff]",Vr="\\u200d",en=Gr+"?",nn="["+$r+"]?",kr="(?:"+Vr+"(?:"+[Qe,Xe,Ke].join("|")+")"+nn+en+")*",Zr=nn+en+kr,Jr="(?:"+[Qe+Ie+"?",Ie,Xe,Ke,Hr].join("|")+")",Yr=RegExp(_e+"(?="+_e+")|"+Jr+Zr,"g");function Br(t){return t.match(Yr)||[]}function Qr(t){return Ye(t)?Br(t):jr(t)}function Xr(t){return function(a){a=pe(a);var l=Ye(a)?Qr(a):void 0,w=l?l[0]:a.charAt(0),v=l?Wr(l,1).join(""):a.slice(1);return w[t]()+v}}var Kr=Xr("toUpperCase");const eo=Kr;function no(t){return eo(pe(t).toLowerCase())}function to(t,a,l,w){var v=-1,y=t==null?0:t.length;for(w&&y&&(l=t[++v]);++v<y;)l=a(l,t[v],v,t);return l}function ro(t){return function(a){return t?.[a]}}var oo={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},io=ro(oo);const uo=io;var ao=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,so="\\u0300-\\u036f",co="\\ufe20-\\ufe2f",fo="\\u20d0-\\u20ff",lo=so+co+fo,ho="["+lo+"]",vo=RegExp(ho,"g");function go(t){return t=pe(t),t&&t.replace(ao,uo).replace(vo,"")}var po=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function wo(t){return t.match(po)||[]}var mo=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function yo(t){return mo.test(t)}var tn="\\ud800-\\udfff",Eo="\\u0300-\\u036f",Ao="\\ufe20-\\ufe2f",bo="\\u20d0-\\u20ff",So=Eo+Ao+bo,rn="\\u2700-\\u27bf",on="a-z\\xdf-\\xf6\\xf8-\\xff",xo="\\xac\\xb1\\xd7\\xf7",Po="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Io="\\u2000-\\u206f",_o=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",un="A-Z\\xc0-\\xd6\\xd8-\\xde",Wo="\\ufe0e\\ufe0f",an=xo+Po+Io+_o,sn="['’]",cn="["+an+"]",Oo="["+So+"]",fn="\\d+",Ro="["+rn+"]",dn="["+on+"]",ln="[^"+tn+an+fn+rn+on+un+"]",To="\\ud83c[\\udffb-\\udfff]",Co="(?:"+Oo+"|"+To+")",Do="[^"+tn+"]",hn="(?:\\ud83c[\\udde6-\\uddff]){2}",vn="[\\ud800-\\udbff][\\udc00-\\udfff]",ne="["+un+"]",Mo="\\u200d",gn="(?:"+dn+"|"+ln+")",No="(?:"+ne+"|"+ln+")",pn="(?:"+sn+"(?:d|ll|m|re|s|t|ve))?",wn="(?:"+sn+"(?:D|LL|M|RE|S|T|VE))?",mn=Co+"?",yn="["+Wo+"]?",Lo="(?:"+Mo+"(?:"+[Do,hn,vn].join("|")+")"+yn+mn+")*",jo="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",zo="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Uo=yn+mn+Lo,qo="(?:"+[Ro,hn,vn].join("|")+")"+Uo,Fo=RegExp([ne+"?"+dn+"+"+pn+"(?="+[cn,ne,"$"].join("|")+")",No+"+"+wn+"(?="+[cn,ne+gn,"$"].join("|")+")",ne+"?"+gn+"+"+pn,ne+"+"+wn,zo,jo,fn,qo].join("|"),"g");function $o(t){return t.match(Fo)||[]}function Ho(t,a,l){return t=pe(t),a=l?void 0:a,a===void 0?yo(t)?$o(t):wo(t):t.match(a)||[]}var Go="['’]",Vo=RegExp(Go,"g");function En(t){return function(a){return to(Ho(go(a).replace(Vo,"")),t,"")}}var ko=En(function(t,a,l){return a=a.toLowerCase(),t+(l?no(a):a)});const Zo=ko;var Jo=En(function(t,a,l){return t+(l?"_":"")+a.toLowerCase()});const Yo=Jo,An=["id__in","modified_at__gtr","created_at__gtr","end_at__lt","start_at__gt","account__id","end_at__gt","end_at__range","start_at__lt","start_at__range","external_objects__connection_id","external_objects__content_type","external_objects__external_content_type","external_objects__external_object_id"],bn=["context"],ie=(t,a=An,l=bn)=>Array.isArray(t)?t.map(w=>ie(w,a,l)):t!=null&&t.constructor===Object?Object.keys(t).reduce((w,v)=>{const y=a.includes(v)||l.includes(v)?v:Zo(v),S=l.includes(v)?t[v]:ie(t[v],a,l);return{...w,[y]:S}},{}):t,We=(t,a=An,l=bn)=>Array.isArray(t)?t.map(w=>We(w,a,l)):t!=null&&t.constructor===Object?Object.keys(t).reduce((w,v)=>{const y=a.includes(v)||l.includes(v)?v:Yo(v),S=l.includes(v)?t[v]:We(t[v],a,l);return{...w,[y]:S}},{}):t;class Bo extends Fe{constructor(a){super(),this.callbacks={},this.options=a??{casing:"snake",logLevel:"off"},typeof window<"u"&&(window.addEventListener("message",l=>{this.options.logLevel==="debug"&&console.log("message received",l),l.data.type==="PITCHER_RESPONSE"?(ir(l.data.request.id,"event id is required"),this.handleCallbackMessage(l.data.request.id,l.data)):l.data.type==="PITCHER_EVENT"&&this.handleEventMessage(this.options.casing==="camel"?ie(l.data.event):l.data.event)}),this.request("subscribe"))}callbacks;options;handleCallbackMessage(a,l){this.callbacks[a]&&(this.callbacks[a].callback(l),this.options.logLevel&&["info","debug"].includes(this.options.logLevel)&&console.log(`It took ${Date.now()-this.callbacks[a].dispatched_at} ms for the event ${this.callbacks[a].type}`),delete this.callbacks[a])}handleEventMessage(a){this.emit("event",a)}request(a,l=null){return new Promise((w,v)=>{const y=He(),S=U=>{if(this.options.logLevel==="debug"&&console.log(`Callback ${y} response:`,U),U.response.status==="ok")w(this.options.casing==="camel"?ie(U.response.body):U.response.body);else if(U.response.status==="error")v(this.options.casing==="camel"?ie(U.response.body):U.response.body);else throw new Error("unsupported response status")},L=We(l);this.callbacks[y]={dispatched_at:Date.now(),type:a,payload:L??{},callback:S},typeof window<"u"&&window.top&&window.top.postMessage({type:"PITCHER_REQUEST",request:{type:a,id:y,body:L}},"*")})}}function Qo(t){const a=new Bo(t),l=new Fe;return a.on("event",w=>{l.emit(w.type,w.body)}),{API:a,...er,on:(w,v)=>l.on(w,v),off:(w,v)=>l.off(w,v),quitInstance:()=>a.request("quit_instance"),getRequestTypes:()=>a.request("get_request_types"),broadcast:w=>a.request("broadcast",w),subscribe:()=>a.request("subscribe"),unsubscribe:()=>a.request("unsubscribe")}}var Xo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ko(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Sn={exports:{}},xn={exports:{}};(function(t,a){(function(l,w){t.exports=w()})(typeof self<"u"?self:Xo,function(){return function(l){var w={};function v(y){if(w[y])return w[y].exports;var S=w[y]={i:y,l:!1,exports:{}};return l[y].call(S.exports,S,S.exports,v),S.l=!0,S.exports}return v.m=l,v.c=w,v.d=function(y,S,L){v.o(y,S)||Object.defineProperty(y,S,{enumerable:!0,get:L})},v.r=function(y){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(y,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(y,"__esModule",{value:!0})},v.t=function(y,S){if(1&S&&(y=v(y)),8&S||4&S&&typeof y=="object"&&y&&y.__esModule)return y;var L=Object.create(null);if(v.r(L),Object.defineProperty(L,"default",{enumerable:!0,value:y}),2&S&&typeof y!="string")for(var U in y)v.d(L,U,function(we){return y[we]}.bind(null,U));return L},v.n=function(y){var S=y&&y.__esModule?function(){return y.default}:function(){return y};return v.d(S,"a",S),S},v.o=function(y,S){return{}.hasOwnProperty.call(y,S)},v.p="",v(v.s=0)}([function(l,w,v){v.r(w),v.d(w,"Promise",function(){return I}),v.d(w,"TYPES",function(){return Ui}),v.d(w,"ProxyWindow",function(){return $}),v.d(w,"setup",function(){return dt}),v.d(w,"destroy",function(){return zi}),v.d(w,"serializeMessage",function(){return Mi}),v.d(w,"deserializeMessage",function(){return Ni}),v.d(w,"createProxyWindow",function(){return Li}),v.d(w,"toProxyWindow",function(){return ji}),v.d(w,"on",function(){return k}),v.d(w,"once",function(){return Di}),v.d(w,"send",function(){return Z}),v.d(w,"markWindowKnown",function(){return Kn}),v.d(w,"cleanUpWindow",function(){return qi}),v.d(w,"bridge",function(){});function y(e){return{}.toString.call(e)==="[object RegExp]"}var S=`Call was rejected by callee.\r
2
- `;function L(e){return e===void 0&&(e=window),e.location.protocol}function U(e){if(e===void 0&&(e=window),e.mockDomain){var r=e.mockDomain.split("//")[0];if(r)return r}return L(e)}function we(e){return e===void 0&&(e=window),U(e)==="about:"}function Y(e){if(e===void 0&&(e=window),e)try{if(e.parent&&e.parent!==e)return e.parent}catch{}}function Mn(e){if(e===void 0&&(e=window),e&&!Y(e))try{return e.opener}catch{}}function me(e){try{return!0}catch{}return!1}function ye(e){e===void 0&&(e=window);var r=e.location;if(!r)throw new Error("Can not read window location");var n=L(e);if(!n)throw new Error("Can not read window protocol");if(n==="file:")return"file://";if(n==="about:"){var o=Y(e);return o&&me()?ye(o):"about://"}var i=r.host;if(!i)throw new Error("Can not read window host");return n+"//"+i}function j(e){e===void 0&&(e=window);var r=ye(e);return r&&e.mockDomain&&e.mockDomain.indexOf("mock:")===0?e.mockDomain:r}function B(e){if(!function(r){try{if(r===window)return!0}catch{}try{var n=Object.getOwnPropertyDescriptor(r,"location");if(n&&n.enumerable===!1)return!1}catch{}try{if(we(r)&&me())return!0}catch{}try{if(function(o){return o===void 0&&(o=window),U(o)==="mock:"}(r)&&me())return!0}catch{}try{if(ye(r)===ye(window))return!0}catch{}return!1}(e))return!1;try{if(e===window||we(e)&&me()||j(window)===j(e))return!0}catch{}return!1}function Ee(e){if(!B(e))throw new Error("Expected window to be same domain");return e}function Nn(e,r){if(!e||!r)return!1;var n=Y(r);return n?n===e:function(o){var i=[];try{for(;o.parent!==o;)i.push(o.parent),o=o.parent}catch{}return i}(r).indexOf(e)!==-1}function Ln(e){var r=[],n;try{n=e.frames}catch{n=e}var o;try{o=n.length}catch{}if(o===0)return r;if(o){for(var i=0;i<o;i++){var u=void 0;try{u=n[i]}catch{continue}r.push(u)}return r}for(var s=0;s<100;s++){var d=void 0;try{d=n[s]}catch{return r}if(!d)return r;r.push(d)}return r}var mi=[],yi=[];function H(e,r){r===void 0&&(r=!0);try{if(e===window)return!1}catch{return!0}try{if(!e)return!0}catch{return!0}try{if(e.closed)return!0}catch(i){return!i||i.message!==S}if(r&&B(e))try{if(e.mockclosed)return!0}catch{}try{if(!e.parent||!e.top)return!0}catch{}var n=function(i,u){for(var s=0;s<i.length;s++)try{if(i[s]===u)return s}catch{}return-1}(mi,e);if(n!==-1){var o=yi[n];if(o&&function(i){if(!i.contentWindow||!i.parentNode)return!0;var u=i.ownerDocument;if(u&&u.documentElement&&!u.documentElement.contains(i)){for(var s=i;s.parentNode&&s.parentNode!==s;)s=s.parentNode;if(!s.host||!u.documentElement.contains(s.host))return!0}return!1}(o))return!0}return!1}function jn(e){return e===void 0&&(e=window),Mn(e=e||window)||Y(e)||void 0}function te(e,r){if(typeof e=="string"){if(typeof r=="string")return e==="*"||r===e;if(y(r)||Array.isArray(r))return!1}return y(e)?y(r)?e.toString()===r.toString():!Array.isArray(r)&&!!r.match(e):!!Array.isArray(e)&&(Array.isArray(r)?JSON.stringify(e)===JSON.stringify(r):!y(r)&&e.some(function(n){return te(n,r)}))}function Ae(e){try{if(e===window)return!0}catch(r){if(r&&r.message===S)return!0}try{if({}.toString.call(e)==="[object Window]")return!0}catch(r){if(r&&r.message===S)return!0}try{if(window.Window&&e instanceof window.Window)return!0}catch(r){if(r&&r.message===S)return!0}try{if(e&&e.self===e)return!0}catch(r){if(r&&r.message===S)return!0}try{if(e&&e.parent===e)return!0}catch(r){if(r&&r.message===S)return!0}try{if(e&&e.top===e)return!0}catch(r){if(r&&r.message===S)return!0}try{if(e&&e.__cross_domain_utils_window_check__==="__unlikely_value__")return!1}catch{return!0}try{if("postMessage"in e&&"self"in e&&"location"in e)return!0}catch{}return!1}function zn(e){if(B(e))return Ee(e).frameElement;for(var r=0,n=document.querySelectorAll("iframe");r<n.length;r++){var o=n[r];if(o&&o.contentWindow&&o.contentWindow===e)return o}}function Ei(e){if(function(n){return n===void 0&&(n=window),!!Y(n)}(e)){var r=zn(e);if(r&&r.parentElement){r.parentElement.removeChild(r);return}}try{e.close()}catch{}}function Q(e){try{if(!e)return!1;if(typeof Promise<"u"&&e instanceof Promise)return!0;if(typeof window<"u"&&typeof window.Window=="function"&&e instanceof window.Window||typeof window<"u"&&typeof window.constructor=="function"&&e instanceof window.constructor)return!1;var r={}.toString;if(r){var n=r.call(e);if(n==="[object Window]"||n==="[object global]"||n==="[object DOMWindow]")return!1}if(typeof e.then=="function")return!0}catch{return!1}return!1}var Un=[],ue=[],Re=0,ae;function qn(){if(!Re&&ae){var e=ae;ae=null,e.resolve()}}function Te(){Re+=1}function se(){Re-=1,qn()}var I=function(){function e(n){var o=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 i,u,s=!1,d=!1,f=!1;Te();try{n(function(c){f?o.resolve(c):(s=!0,i=c)},function(c){f?o.reject(c):(d=!0,u=c)})}catch(c){se(),this.reject(c);return}se(),f=!0,s?this.resolve(i):d&&this.reject(u)}}var r=e.prototype;return r.resolve=function(n){if(this.resolved||this.rejected)return this;if(Q(n))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=n,this.dispatch(),this},r.reject=function(n){var o=this;if(this.resolved||this.rejected)return this;if(Q(n))throw new Error("Can not reject promise with another promise");if(!n){var i=n&&typeof n.toString=="function"?n.toString():{}.toString.call(n);n=new Error("Expected reject to be called with Error, got "+i)}return this.rejected=!0,this.error=n,this.errorHandled||setTimeout(function(){o.errorHandled||function(u,s){if(Un.indexOf(u)===-1){Un.push(u),setTimeout(function(){throw u},1);for(var d=0;d<ue.length;d++)ue[d](u,s)}}(n,o)},1),this.dispatch(),this},r.asyncReject=function(n){return this.errorHandled=!0,this.reject(n),this},r.dispatch=function(){var n=this.resolved,o=this.rejected,i=this.handlers;if(!this.dispatching&&(n||o)){this.dispatching=!0,Te();for(var u=function(m,b){return m.then(function(E){b.resolve(E)},function(E){b.reject(E)})},s=0;s<i.length;s++){var d=i[s],f=d.onSuccess,c=d.onError,p=d.promise,h=void 0;if(n)try{h=f?f(this.value):this.value}catch(m){p.reject(m);continue}else if(o){if(!c){p.reject(this.error);continue}try{h=c(this.error)}catch(m){p.reject(m);continue}}if(h instanceof e&&(h.resolved||h.rejected)){var g=h;g.resolved?p.resolve(g.value):p.reject(g.error),g.errorHandled=!0}else Q(h)?h instanceof e&&(h.resolved||h.rejected)?h.resolved?p.resolve(h.value):p.reject(h.error):u(h,p):p.resolve(h)}i.length=0,this.dispatching=!1,se()}},r.then=function(n,o){if(n&&typeof n!="function"&&!n.call)throw new Error("Promise.then expected a function for success handler");if(o&&typeof o!="function"&&!o.call)throw new Error("Promise.then expected a function for error handler");var i=new e;return this.handlers.push({promise:i,onSuccess:n,onError:o}),this.errorHandled=!0,this.dispatch(),i},r.catch=function(n){return this.then(void 0,n)},r.finally=function(n){if(n&&typeof n!="function"&&!n.call)throw new Error("Promise.finally expected a function");return this.then(function(o){return e.try(n).then(function(){return o})},function(o){return e.try(n).then(function(){throw o})})},r.timeout=function(n,o){var i=this;if(this.resolved||this.rejected)return this;var u=setTimeout(function(){i.resolved||i.rejected||i.reject(o||new Error("Promise timed out after "+n+"ms"))},n);return this.then(function(s){return clearTimeout(u),s})},r.toPromise=function(){if(typeof Promise>"u")throw new TypeError("Could not find Promise");return Promise.resolve(this)},r.lazy=function(){return this.errorHandled=!0,this},e.resolve=function(n){return n instanceof e?n:Q(n)?new e(function(o,i){return n.then(o,i)}):new e().resolve(n)},e.reject=function(n){return new e().reject(n)},e.asyncReject=function(n){return new e().asyncReject(n)},e.all=function(n){var o=new e,i=n.length,u=[].slice();if(!i)return o.resolve(u),o;for(var s=function(c,p,h){return p.then(function(g){u[c]=g,(i-=1)==0&&o.resolve(u)},function(g){h.reject(g)})},d=0;d<n.length;d++){var f=n[d];if(f instanceof e){if(f.resolved){u[d]=f.value,i-=1;continue}}else if(!Q(f)){u[d]=f,i-=1;continue}s(d,e.resolve(f),o)}return i===0&&o.resolve(u),o},e.hash=function(n){var o={},i=[],u=function(d){if(n.hasOwnProperty(d)){var f=n[d];Q(f)?i.push(f.then(function(c){o[d]=c})):o[d]=f}};for(var s in n)u(s);return e.all(i).then(function(){return o})},e.map=function(n,o){return e.all(n.map(o))},e.onPossiblyUnhandledException=function(n){return function(o){return ue.push(o),{cancel:function(){ue.splice(ue.indexOf(o),1)}}}(n)},e.try=function(n,o,i){if(n&&typeof n!="function"&&!n.call)throw new Error("Promise.try expected a function");var u;Te();try{u=n.apply(o,i||[])}catch(s){return se(),e.reject(s)}return se(),e.resolve(u)},e.delay=function(n){return new e(function(o){setTimeout(o,n)})},e.isPromise=function(n){return!!(n&&n instanceof e)||Q(n)},e.flush=function(){return function(n){var o=ae=ae||new n;return qn(),o}(e)},e}();function be(e,r){for(var n=0;n<e.length;n++)try{if(e[n]===r)return n}catch{}return-1}var Ce=function(){function e(){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(typeof WeakMap>"u"||Object.freeze===void 0)return!1;try{var n=new WeakMap,o={};return Object.freeze(o),n.set(o,"__testvalue__"),n.get(o)==="__testvalue__"}catch{return!1}}())try{this.weakmap=new WeakMap}catch{}this.keys=[],this.values=[]}var r=e.prototype;return r._cleanupClosedWindows=function(){for(var n=this.weakmap,o=this.keys,i=0;i<o.length;i++){var u=o[i];if(Ae(u)&&H(u)){if(n)try{n.delete(u)}catch{}o.splice(i,1),this.values.splice(i,1),i-=1}}},r.isSafeToReadWrite=function(n){return!Ae(n)},r.set=function(n,o){if(!n)throw new Error("WeakMap expected key");var i=this.weakmap;if(i)try{i.set(n,o)}catch{delete this.weakmap}if(this.isSafeToReadWrite(n))try{var u=this.name,s=n[u];s&&s[0]===n?s[1]=o:Object.defineProperty(n,u,{value:[n,o],writable:!0});return}catch{}this._cleanupClosedWindows();var d=this.keys,f=this.values,c=be(d,n);c===-1?(d.push(n),f.push(o)):f[c]=o},r.get=function(n){if(!n)throw new Error("WeakMap expected key");var o=this.weakmap;if(o)try{if(o.has(n))return o.get(n)}catch{delete this.weakmap}if(this.isSafeToReadWrite(n))try{var i=n[this.name];return i&&i[0]===n?i[1]:void 0}catch{}this._cleanupClosedWindows();var u=be(this.keys,n);if(u!==-1)return this.values[u]},r.delete=function(n){if(!n)throw new Error("WeakMap expected key");var o=this.weakmap;if(o)try{o.delete(n)}catch{delete this.weakmap}if(this.isSafeToReadWrite(n))try{var i=n[this.name];i&&i[0]===n&&(i[0]=i[1]=void 0)}catch{}this._cleanupClosedWindows();var u=this.keys,s=be(u,n);s!==-1&&(u.splice(s,1),this.values.splice(s,1))},r.has=function(n){if(!n)throw new Error("WeakMap expected key");var o=this.weakmap;if(o)try{if(o.has(n))return!0}catch{delete this.weakmap}if(this.isSafeToReadWrite(n))try{var i=n[this.name];return!(!i||i[0]!==n)}catch{}return this._cleanupClosedWindows(),be(this.keys,n)!==-1},r.getOrSet=function(n,o){if(this.has(n))return this.get(n);var i=o();return this.set(n,i),i},e}();function Fn(e){return e.name||e.__name__||e.displayName||"anonymous"}function $n(e,r){try{delete e.name,e.name=r}catch{}return e.__name__=e.displayName=r,e}function V(){var e="0123456789abcdef";return"uid_"+"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})+"_"+function(r){if(typeof btoa=="function")return btoa(encodeURIComponent(r).replace(/%([0-9A-F]{2})/g,function(n,o){return String.fromCharCode(parseInt(o,16))})).replace(/[=]/g,"");if(typeof Buffer<"u")return Buffer.from(r,"utf8").toString("base64").replace(/[=]/g,"");throw new Error("Can not find window.btoa or Buffer")}(new Date().toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}var Se;function Hn(e){try{return JSON.stringify([].slice.call(e),function(r,n){return typeof n=="function"?"memoize["+function(o){if(Se=Se||new Ce,o==null||typeof o!="object"&&typeof o!="function")throw new Error("Invalid object");var i=Se.get(o);return i||(i=typeof o+":"+V(),Se.set(o,i)),i}(n)+"]":typeof window<"u"&&n instanceof window.Element||n!==null&&typeof n=="object"&&n.nodeType===1&&typeof n.style=="object"&&typeof n.ownerDocument=="object"?{}:n})}catch{throw new Error("Arguments not serializable -- can not be used to memoize")}}function Ai(){return{}}var ce=0,Gn=0;function fe(e,r){r===void 0&&(r={});var n=r.thisNamespace,o=n!==void 0&&n,i=r.time,u,s,d=ce;ce+=1;var f=function(){for(var c=arguments.length,p=new Array(c),h=0;h<c;h++)p[h]=arguments[h];d<Gn&&(u=null,s=null,d=ce,ce+=1);var g;g=o?(s=s||new Ce).getOrSet(this,Ai):u=u||{};var m;try{m=Hn(p)}catch{return e.apply(this,arguments)}var b=g[m];if(b&&i&&Date.now()-b.time<i&&(delete g[m],b=null),b)return b.value;var E=Date.now(),A=e.apply(this,arguments);return g[m]={time:E,value:A},A};return f.reset=function(){u=null,s=null},$n(f,(r.name||Fn(e))+"::memoized")}fe.clear=function(){Gn=ce};function bi(e){var r={};function n(){for(var o=arguments,i=this,u=arguments.length,s=new Array(u),d=0;d<u;d++)s[d]=arguments[d];var f=Hn(s);return r.hasOwnProperty(f)||(r[f]=I.try(function(){return e.apply(i,o)}).finally(function(){delete r[f]})),r[f]}return n.reset=function(){r={}},$n(n,Fn(e)+"::promiseMemoized")}function X(){}function de(e,r){if(r===void 0&&(r=1),r>=3)return"stringifyError stack overflow";try{if(!e)return"<unknown error: "+{}.toString.call(e)+">";if(typeof e=="string")return e;if(e instanceof Error){var n=e&&e.stack,o=e&&e.message;if(n&&o)return n.indexOf(o)!==-1?n:o+`
3
- `+n;if(n)return n;if(o)return o}return e&&e.toString&&typeof e.toString=="function"?e.toString():{}.toString.call(e)}catch(i){return"Error while stringifying error: "+de(i,r+1)}}function Vn(e){return typeof e=="string"?e:e&&e.toString&&typeof e.toString=="function"?e.toString():{}.toString.call(e)}fe(function(e){if(Object.values)return Object.values(e);var r=[];for(var n in e)e.hasOwnProperty(n)&&r.push(e[n]);return r});function De(e){return{}.toString.call(e)==="[object RegExp]"}function le(e,r,n){if(e.hasOwnProperty(r))return e[r];var o=n();return e[r]=o,o}function kn(){var e=document.body;if(!e)throw new Error("Body element not found");return e}function Zn(){return!!document.body&&document.readyState==="complete"}function Jn(){return!!document.body&&document.readyState==="interactive"}fe(function(){return new I(function(e){if(Zn()||Jn())return e();var r=setInterval(function(){if(Zn()||Jn())return clearInterval(r),e()},10)})});var xe=typeof document<"u"?document.currentScript:null,Si=fe(function(){if(xe||(xe=function(){try{var e=function(){try{throw new Error("_")}catch(s){return s.stack||""}}(),r=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(e),n=r&&r[1];if(!n)return;for(var o=0,i=[].slice.call(document.getElementsByTagName("script")).reverse();o<i.length;o++){var u=i[o];if(u.src&&u.src===n)return u}}catch{}}()))return xe;throw new Error("Can not determine current script")}),xi=V();fe(function(){var e;try{e=Si()}catch{return xi}var r=e.getAttribute("data-uid");if(r&&typeof r=="string"||(r=e.getAttribute("data-uid-auto"))&&typeof r=="string")return r;if(e.src){var n=function(o){for(var i="",u=0;u<o.length;u++){var s=o[u].charCodeAt(0)*u;o[u+1]&&(s+=o[u+1].charCodeAt(0)*(u-1)),i+=String.fromCharCode(97+Math.abs(s)%26)}return i}(JSON.stringify({src:e.src,dataset:e.dataset}));r="uid_"+n.slice(n.length-30)}else r=V();return e.setAttribute("data-uid-auto",r),r});function he(e){e===void 0&&(e=window);var r="__post_robot_10_0_46__";return e!==window?e[r]:e[r]=e[r]||{}}var Yn=function(){return{}};function D(e,r){return e===void 0&&(e="store"),r===void 0&&(r=Yn),le(he(),e,function(){var n=r();return{has:function(o){return n.hasOwnProperty(o)},get:function(o,i){return n.hasOwnProperty(o)?n[o]:i},set:function(o,i){return n[o]=i,i},del:function(o){delete n[o]},getOrSet:function(o,i){return le(n,o,i)},reset:function(){n=r()},keys:function(){return Object.keys(n)}}})}var Pi=function(){};function Pe(){var e=he();return e.WINDOW_WILDCARD=e.WINDOW_WILDCARD||new Pi,e.WINDOW_WILDCARD}function z(e,r){return e===void 0&&(e="store"),r===void 0&&(r=Yn),D("windowStore").getOrSet(e,function(){var n=new Ce,o=function(i){return n.getOrSet(i,r)};return{has:function(i){return o(i).hasOwnProperty(e)},get:function(i,u){var s=o(i);return s.hasOwnProperty(e)?s[e]:u},set:function(i,u){return o(i)[e]=u,u},del:function(i){delete o(i)[e]},getOrSet:function(i,u){return le(o(i),e,u)}}})}function Bn(){return D("instance").getOrSet("instanceID",V)}function Qn(e,r){var n=r.domain,o=z("helloPromises"),i=o.get(e);i&&i.resolve({domain:n});var u=I.resolve({domain:n});return o.set(e,u),u}function Me(e,r){return(0,r.send)(e,"postrobot_hello",{instanceID:Bn()},{domain:"*",timeout:-1}).then(function(n){var o=n.origin,i=n.data.instanceID;return Qn(e,{domain:o}),{win:e,domain:o,instanceID:i}})}function Xn(e,r){var n=r.send;return z("windowInstanceIDPromises").getOrSet(e,function(){return Me(e,{send:n}).then(function(o){return o.instanceID})})}function Kn(e){z("knownWindows").set(e,!0)}function Ne(e){return typeof e=="object"&&e!==null&&typeof e.__type__=="string"}function et(e){return e===void 0?"undefined":e===null?"null":Array.isArray(e)?"array":typeof e=="function"?"function":typeof e=="object"?e instanceof Error?"error":typeof e.then=="function"?"promise":{}.toString.call(e)==="[object RegExp]"?"regex":{}.toString.call(e)==="[object Date]"?"date":"object":typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":void 0}function K(e,r){return{__type__:e,__val__:r}}var q,Ii=((q={}).function=function(){},q.error=function(e){return K("error",{message:e.message,stack:e.stack,code:e.code,data:e.data})},q.promise=function(){},q.regex=function(e){return K("regex",e.source)},q.date=function(e){return K("date",e.toJSON())},q.array=function(e){return e},q.object=function(e){return e},q.string=function(e){return e},q.number=function(e){return e},q.boolean=function(e){return e},q.null=function(e){return e},q[void 0]=function(e){return K("undefined",e)},q),_i={},F,Wi=((F={}).function=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},F.error=function(e){var r=e.stack,n=e.code,o=e.data,i=new Error(e.message);return i.code=n,o&&(i.data=o),i.stack=r+`
1
+ (function(x,re){typeof exports=="object"&&typeof module<"u"?re(exports):typeof define=="function"&&define.amd?define(["exports"],re):(x=typeof globalThis<"u"?globalThis:x||self,re(x.pitcher={}))})(this,function(x){"use strict";function re(t,a){for(var l=0;l<a.length;l++){const p=a[l];if(typeof p!="string"&&!Array.isArray(p)){for(const h in p)if(h!=="default"&&!(h in t)){const y=Object.getOwnPropertyDescriptor(p,h);y&&Object.defineProperty(t,h,y.get?y:{enumerable:!0,get:()=>p[h]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}function ht(t={}){return this.API.request("open",t)}function vt(){return this.API.request("get_env")}function gt(t){return this.API.request("update_my_user",t)}function pt(){return this.API.request("get_languages")}function wt(t){return x.highLevelApi.API.request("get_events",t)}function mt(t){return x.highLevelApi.API.request("create_event",t)}function yt(t){return x.highLevelApi.API.request("update_event",t)}function Et(t){return x.highLevelApi.API.request("delete_event",t)}function bt(t){return this.API.request("get_canvases",t)}function At(t){return this.API.request("create_canvas",t)}function St(t){return this.API.request("delete_canvas",t)}function xt(t){return this.API.request("update_canvas",t)}function Pt(t){return this.API.request("get_canvas",t)}function _t(t){return this.API.request("share_canvas",t)}function It(t){const a={...t};return a.type&&(a.type=Array.isArray(a.type)?a.type:[a.type]),a.content_type&&(a.content_type=Array.isArray(a.content_type)?a.content_type:[a.content_type]),this.API.request("get_files",a)}function Ot(t){return this.API.request("download_file",t)}function Wt(t){return this.API.request("get_app_config",t)}function Rt(t){return this.API.request("get_file",t)}function Tt(t){return this.API.request("delete_file",t)}function Ct(t){return this.API.request("create_file",t)}function Dt(){return this.API.request("select_device_file")}function Mt(t){return this.API.request("search",t)}function Nt(t){return this.API.request("get_users",t)}function Lt(t){return this.API.request("getService",t)}function jt(t){return this.API.request("refresh_service_token",t)}function zt(){return this.API.request("get_connections")}function Ut(t){return this.API.request("connection_login",t)}function qt(t){return this.API.request("connection_logout",t)}function Ft(t){return this.API.request("fetch_document_info",t)}function $t(t){return this.API.request("render_page_as_image",t)}function Ht(t){return this.API.request("toast",t)}function Gt(t){return x.highLevelApi.API.request("query",t)}function kt(t={id:"root"}){return this.API.request("get_folder",t)}function Vt(t){return this.API.request("create_folder",t)}function Zt(t){return this.API.request("update_folder",t)}function Jt(t){return this.API.request("delete_folder",t)}function Yt(t){return this.API.request("move_folder_items",t)}function Bt(t){return this.API.request("get_favorites",t)}function Qt(t){return this.API.request("create_favorite",t)}function Xt(t){return this.API.request("delete_favorite",t)}function Kt(t){return t.type||(t.type="native"),x.highLevelApi.API.request("notify",t)}function er(t){return x.highLevelApi.API.request("track",t)}function nr(t){return this.API.request("get_instance_metadata_templates",t)}const tr=Object.freeze(Object.defineProperty({__proto__:null,connectionLogin:Ut,connectionLogout:qt,createCanvas:At,createEvent:mt,createFavorite:Qt,createFile:Ct,createFolder:Vt,deleteCanvas:St,deleteEvent:Et,deleteFavorite:Xt,deleteFile:Tt,deleteFolder:Jt,downloadFile:Ot,fetchDocumentInfo:Ft,getAppConfig:Wt,getCanvas:Pt,getCanvases:bt,getConnections:zt,getEnv:vt,getEvents:wt,getFavorites:Bt,getFile:Rt,getFiles:It,getFolder:kt,getInstanceMetadataTemplates:nr,getLanguages:pt,getService:Lt,getUsers:Nt,moveFolderItems:Yt,notify:Kt,open:ht,query:Gt,refreshServiceToken:jt,renderPageAsImage:$t,search:Mt,selectDeviceFile:Dt,shareCanvas:_t,toast:Ht,track:er,updateCanvas:xt,updateEvent:yt,updateFolder:Zt,updateMyUser:gt},Symbol.toStringTag,{value:"Module"}));class Fe{listeners={};on(a,l){this.listeners[a]=(this.listeners[a]??[]).concat(l)}off(a,l){this.listeners[a]=(this.listeners[a]??[]).filter(p=>p!==l)}emit(a,l){(this.listeners[a]??[]).forEach(p=>p(l))}}let ge;const rr=new Uint8Array(16);function or(){if(!ge&&(ge=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ge))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ge(rr)}const N=[];for(let t=0;t<256;++t)N.push((t+256).toString(16).slice(1));function ir(t,a=0){return N[t[a+0]]+N[t[a+1]]+N[t[a+2]]+N[t[a+3]]+"-"+N[t[a+4]]+N[t[a+5]]+"-"+N[t[a+6]]+N[t[a+7]]+"-"+N[t[a+8]]+N[t[a+9]]+"-"+N[t[a+10]]+N[t[a+11]]+N[t[a+12]]+N[t[a+13]]+N[t[a+14]]+N[t[a+15]]}const $e={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function He(t,a,l){if($e.randomUUID&&!a&&!t)return $e.randomUUID();t=t||{};const p=t.random||(t.rng||or)();if(p[6]=p[6]&15|64,p[8]=p[8]&63|128,a){l=l||0;for(let h=0;h<16;++h)a[l+h]=p[h];return a}return ir(p)}class ur extends Error{}function ar(t,a){if(!t)throw new ur(a)}var sr=typeof global=="object"&&global&&global.Object===Object&&global;const cr=sr;var fr=typeof self=="object"&&self&&self.Object===Object&&self,dr=cr||fr||Function("return this")(),lr=dr.Symbol;const ee=lr;var Ge=Object.prototype,hr=Ge.hasOwnProperty,vr=Ge.toString,oe=ee?ee.toStringTag:void 0;function gr(t){var a=hr.call(t,oe),l=t[oe];try{t[oe]=void 0;var p=!0}catch{}var h=vr.call(t);return p&&(a?t[oe]=l:delete t[oe]),h}var pr=Object.prototype,wr=pr.toString;function mr(t){return wr.call(t)}var yr="[object Null]",Er="[object Undefined]",ke=ee?ee.toStringTag:void 0;function br(t){return t==null?t===void 0?Er:yr:ke&&ke in Object(t)?gr(t):mr(t)}function Ar(t){return t!=null&&typeof t=="object"}var Sr="[object Symbol]";function xr(t){return typeof t=="symbol"||Ar(t)&&br(t)==Sr}function Pr(t,a){for(var l=-1,p=t==null?0:t.length,h=Array(p);++l<p;)h[l]=a(t[l],l,t);return h}var _r=Array.isArray;const Ir=_r;var Or=1/0,Ve=ee?ee.prototype:void 0,Ze=Ve?Ve.toString:void 0;function Je(t){if(typeof t=="string")return t;if(Ir(t))return Pr(t,Je)+"";if(xr(t))return Ze?Ze.call(t):"";var a=t+"";return a=="0"&&1/t==-Or?"-0":a}function pe(t){return t==null?"":Je(t)}function Wr(t,a,l){var p=-1,h=t.length;a<0&&(a=-a>h?0:h+a),l=l>h?h:l,l<0&&(l+=h),h=a>l?0:l-a>>>0,a>>>=0;for(var y=Array(h);++p<h;)y[p]=t[p+a];return y}function Rr(t,a,l){var p=t.length;return l=l===void 0?p:l,!a&&l>=p?t:Wr(t,a,l)}var Tr="\\ud800-\\udfff",Cr="\\u0300-\\u036f",Dr="\\ufe20-\\ufe2f",Mr="\\u20d0-\\u20ff",Nr=Cr+Dr+Mr,Lr="\\ufe0e\\ufe0f",jr="\\u200d",zr=RegExp("["+jr+Tr+Nr+Lr+"]");function Ye(t){return zr.test(t)}function Ur(t){return t.split("")}var Be="\\ud800-\\udfff",qr="\\u0300-\\u036f",Fr="\\ufe20-\\ufe2f",$r="\\u20d0-\\u20ff",Hr=qr+Fr+$r,Gr="\\ufe0e\\ufe0f",kr="["+Be+"]",_e="["+Hr+"]",Ie="\\ud83c[\\udffb-\\udfff]",Vr="(?:"+_e+"|"+Ie+")",Qe="[^"+Be+"]",Xe="(?:\\ud83c[\\udde6-\\uddff]){2}",Ke="[\\ud800-\\udbff][\\udc00-\\udfff]",Zr="\\u200d",en=Vr+"?",nn="["+Gr+"]?",Jr="(?:"+Zr+"(?:"+[Qe,Xe,Ke].join("|")+")"+nn+en+")*",Yr=nn+en+Jr,Br="(?:"+[Qe+_e+"?",_e,Xe,Ke,kr].join("|")+")",Qr=RegExp(Ie+"(?="+Ie+")|"+Br+Yr,"g");function Xr(t){return t.match(Qr)||[]}function Kr(t){return Ye(t)?Xr(t):Ur(t)}function eo(t){return function(a){a=pe(a);var l=Ye(a)?Kr(a):void 0,p=l?l[0]:a.charAt(0),h=l?Rr(l,1).join(""):a.slice(1);return p[t]()+h}}var no=eo("toUpperCase");const to=no;function ro(t){return to(pe(t).toLowerCase())}function oo(t,a,l,p){var h=-1,y=t==null?0:t.length;for(p&&y&&(l=t[++h]);++h<y;)l=a(l,t[h],h,t);return l}function io(t){return function(a){return t?.[a]}}var uo={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},ao=io(uo);const so=ao;var co=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,fo="\\u0300-\\u036f",lo="\\ufe20-\\ufe2f",ho="\\u20d0-\\u20ff",vo=fo+lo+ho,go="["+vo+"]",po=RegExp(go,"g");function wo(t){return t=pe(t),t&&t.replace(co,so).replace(po,"")}var mo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function yo(t){return t.match(mo)||[]}var Eo=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function bo(t){return Eo.test(t)}var tn="\\ud800-\\udfff",Ao="\\u0300-\\u036f",So="\\ufe20-\\ufe2f",xo="\\u20d0-\\u20ff",Po=Ao+So+xo,rn="\\u2700-\\u27bf",on="a-z\\xdf-\\xf6\\xf8-\\xff",_o="\\xac\\xb1\\xd7\\xf7",Io="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Oo="\\u2000-\\u206f",Wo=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",un="A-Z\\xc0-\\xd6\\xd8-\\xde",Ro="\\ufe0e\\ufe0f",an=_o+Io+Oo+Wo,sn="['’]",cn="["+an+"]",To="["+Po+"]",fn="\\d+",Co="["+rn+"]",dn="["+on+"]",ln="[^"+tn+an+fn+rn+on+un+"]",Do="\\ud83c[\\udffb-\\udfff]",Mo="(?:"+To+"|"+Do+")",No="[^"+tn+"]",hn="(?:\\ud83c[\\udde6-\\uddff]){2}",vn="[\\ud800-\\udbff][\\udc00-\\udfff]",ne="["+un+"]",Lo="\\u200d",gn="(?:"+dn+"|"+ln+")",jo="(?:"+ne+"|"+ln+")",pn="(?:"+sn+"(?:d|ll|m|re|s|t|ve))?",wn="(?:"+sn+"(?:D|LL|M|RE|S|T|VE))?",mn=Mo+"?",yn="["+Ro+"]?",zo="(?:"+Lo+"(?:"+[No,hn,vn].join("|")+")"+yn+mn+")*",Uo="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",qo="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Fo=yn+mn+zo,$o="(?:"+[Co,hn,vn].join("|")+")"+Fo,Ho=RegExp([ne+"?"+dn+"+"+pn+"(?="+[cn,ne,"$"].join("|")+")",jo+"+"+wn+"(?="+[cn,ne+gn,"$"].join("|")+")",ne+"?"+gn+"+"+pn,ne+"+"+wn,qo,Uo,fn,$o].join("|"),"g");function Go(t){return t.match(Ho)||[]}function ko(t,a,l){return t=pe(t),a=l?void 0:a,a===void 0?bo(t)?Go(t):yo(t):t.match(a)||[]}var Vo="['’]",Zo=RegExp(Vo,"g");function En(t){return function(a){return oo(ko(wo(a).replace(Zo,"")),t,"")}}var Jo=En(function(t,a,l){return a=a.toLowerCase(),t+(l?ro(a):a)});const Yo=Jo;var Bo=En(function(t,a,l){return t+(l?"_":"")+a.toLowerCase()});const Qo=Bo,bn=["id__in","modified_at__gtr","created_at__gtr","end_at__lt","start_at__gt","account__id","end_at__gt","end_at__range","start_at__lt","start_at__range","external_objects__connection_id","external_objects__content_type","external_objects__external_content_type","external_objects__external_object_id"],An=["context","overrides"],ie=(t,a=bn,l=An)=>Array.isArray(t)?t.map(p=>ie(p,a,l)):t!=null&&t.constructor===Object?Object.keys(t).reduce((p,h)=>{const y=a.includes(h)||l.includes(h)?h:Yo(h),S=l.includes(h)?t[h]:ie(t[h],a,l);return{...p,[y]:S}},{}):t,Oe=(t,a=bn,l=An)=>Array.isArray(t)?t.map(p=>Oe(p,a,l)):t!=null&&t.constructor===Object?Object.keys(t).reduce((p,h)=>{const y=a.includes(h)||l.includes(h)?h:Qo(h),S=l.includes(h)?t[h]:Oe(t[h],a,l);return{...p,[y]:S}},{}):t;class Xo extends Fe{constructor(a){super(),this.callbacks={},this.options=a??{casing:"snake",logLevel:"off"},typeof window<"u"&&(window.addEventListener("message",l=>{this.options.logLevel==="debug"&&console.log("message received",l),l.data.type==="PITCHER_RESPONSE"?(ar(l.data.request.id,"event id is required"),this.handleCallbackMessage(l.data.request.id,l.data)):l.data.type==="PITCHER_EVENT"&&this.handleEventMessage(this.options.casing==="camel"?ie(l.data.event):l.data.event)}),this.request("subscribe"))}callbacks;options;handleCallbackMessage(a,l){this.callbacks[a]&&(this.callbacks[a].callback(l),this.options.logLevel&&["info","debug"].includes(this.options.logLevel)&&console.log(`It took ${Date.now()-this.callbacks[a].dispatched_at} ms for the event ${this.callbacks[a].type}`),delete this.callbacks[a])}handleEventMessage(a){this.emit("event",a)}request(a,l=null){return new Promise((p,h)=>{const y=He(),S=U=>{if(this.options.logLevel==="debug"&&console.log(`Callback ${y} response:`,U),U.response.status==="ok")p(this.options.casing==="camel"?ie(U.response.body):U.response.body);else if(U.response.status==="error")h(this.options.casing==="camel"?ie(U.response.body):U.response.body);else throw new Error("unsupported response status")},L=Oe(l);this.callbacks[y]={dispatched_at:Date.now(),type:a,payload:L??{},callback:S},typeof window<"u"&&window.top&&window.top.postMessage({type:"PITCHER_REQUEST",request:{type:a,id:y,body:L}},"*")})}}function Ko(t){const a=new Xo(t),l=new Fe;return a.on("event",p=>{l.emit(p.type,p.body)}),{API:a,...tr,on:(p,h)=>l.on(p,h),off:(p,h)=>l.off(p,h),quitInstance:()=>a.request("quit_instance"),getRequestTypes:()=>a.request("get_request_types"),broadcast:p=>a.request("broadcast",p),subscribe:()=>a.request("subscribe"),unsubscribe:()=>a.request("unsubscribe")}}const ei="UI_MESSAGE",Sn={UI_SELECT_CONTENT:"ui_select_content"},ni={UI_CONTENT_SELECTED:"ui_content_selected"};async function ti(t={}){return(await(await Promise.resolve().then(()=>Mn)).send(window.parent,Sn.UI_SELECT_CONTENT,t)).data}async function ri(t,a){return(await Promise.resolve().then(()=>Mn)).on(t,h=>a(h.data)).cancel}const oi=Object.freeze(Object.defineProperty({__proto__:null,on:ri,ui_select_content:ti},Symbol.toStringTag,{value:"Module"})),xn="ADMIN_MESSAGE",ii={ENV_CHANGED:"env_changed"},We={ADMIN_REQUEST:"ADMIN_REQUEST",ADMIN_RESPONSE:"ADMIN_RESPONSE"},Pn={GET_ENV:"get_env"};function ui(t,a,l={timeout:1e4}){return new Promise((p,h)=>{if(typeof window>"u"){h(new Error("This function cannot be run on the server side."));return}const y=He(),S=L=>{L.data.type===We.ADMIN_RESPONSE&&L.data.id===y&&(window.removeEventListener("message",S),p(L.data.body))};window.addEventListener("message",S),window.parent.postMessage({type:We.ADMIN_REQUEST,id:y,body:{type:t,data:a??{}}},"*"),l.timeout&&setTimeout(()=>{window.removeEventListener("message",S),h(new Error(`Admin did not respond in the timeframe of ${l.timeout}ms. Check the handler on the Admin side.`))},l.timeout)})}const J={};function ai(t,a){J[t]||(J[t]=[]),J[t]?.push(a)}function si(t,a){J[t]&&(J[t]=J[t]?.filter(l=>l!==a))}typeof window<"u"&&window.addEventListener("message",function(a){if(a.data.type!==xn)return;const l=J[a.data.body.type];l&&l.forEach(p=>p(a.data.body.data))});function ci(){return ui(Pn.GET_ENV)}const fi=Object.freeze(Object.defineProperty({__proto__:null,get_env:ci},Symbol.toStringTag,{value:"Module"})),di="PITCHER_EVENT";var _n=(t=>(t.REQUEST="PITCHER_REQUEST",t.RESPONSE="PITCHER_RESPONSE",t))(_n||{}),In=(t=>(t.OK="ok",t.ERROR="error",t))(In||{}),On=(t=>(t.ENV_CHANGED="env_changed",t.PHOTOS_CAPTURED="photos_captured",t.FILE_DOWNLOADED="file_downloaded",t.FILE_UPLOAD_PROGRESS="file_upload_progress",t.UPDATE_LOCATION="update_location",t.CANVAS_UPDATED="canvas_updated",t.FILE_CLOSED="file_closed",t))(On||{}),Wn=(t=>(t.UI_SHOW_MODAL="ui:show-modal",t.UI_HIDE_MODAL="ui:hide-modal",t.FAVORITES_CHANGED="favorites:changed",t.FILE_DOWNLOAD="file:download",t))(Wn||{}),Rn=(t=>(t.OPEN_CANVAS="open_canvas",t.START_CALL="start_call",t))(Rn||{});x.highLevelApi=void 0;function li(t){return x.highLevelApi||(x.highLevelApi=Ko(t)),x.highLevelApi}function hi(){return oi}const vi={...fi,on:ai,off:si};function gi(){return vi}var pi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Tn={exports:{}},Cn={exports:{}};(function(t,a){(function(l,p){t.exports=p()})(typeof self<"u"?self:pi,function(){return function(l){var p={};function h(y){if(p[y])return p[y].exports;var S=p[y]={i:y,l:!1,exports:{}};return l[y].call(S.exports,S,S.exports,h),S.l=!0,S.exports}return h.m=l,h.c=p,h.d=function(y,S,L){h.o(y,S)||Object.defineProperty(y,S,{enumerable:!0,get:L})},h.r=function(y){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(y,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(y,"__esModule",{value:!0})},h.t=function(y,S){if(1&S&&(y=h(y)),8&S||4&S&&typeof y=="object"&&y&&y.__esModule)return y;var L=Object.create(null);if(h.r(L),Object.defineProperty(L,"default",{enumerable:!0,value:y}),2&S&&typeof y!="string")for(var U in y)h.d(L,U,function(we){return y[we]}.bind(null,U));return L},h.n=function(y){var S=y&&y.__esModule?function(){return y.default}:function(){return y};return h.d(S,"a",S),S},h.o=function(y,S){return{}.hasOwnProperty.call(y,S)},h.p="",h(h.s=0)}([function(l,p,h){h.r(p),h.d(p,"Promise",function(){return _}),h.d(p,"TYPES",function(){return qi}),h.d(p,"ProxyWindow",function(){return $}),h.d(p,"setup",function(){return lt}),h.d(p,"destroy",function(){return Ui}),h.d(p,"serializeMessage",function(){return Ni}),h.d(p,"deserializeMessage",function(){return Li}),h.d(p,"createProxyWindow",function(){return ji}),h.d(p,"toProxyWindow",function(){return zi}),h.d(p,"on",function(){return V}),h.d(p,"once",function(){return Mi}),h.d(p,"send",function(){return Z}),h.d(p,"markWindowKnown",function(){return et}),h.d(p,"cleanUpWindow",function(){return Fi}),h.d(p,"bridge",function(){});function y(e){return{}.toString.call(e)==="[object RegExp]"}var S=`Call was rejected by callee.\r
2
+ `;function L(e){return e===void 0&&(e=window),e.location.protocol}function U(e){if(e===void 0&&(e=window),e.mockDomain){var r=e.mockDomain.split("//")[0];if(r)return r}return L(e)}function we(e){return e===void 0&&(e=window),U(e)==="about:"}function Y(e){if(e===void 0&&(e=window),e)try{if(e.parent&&e.parent!==e)return e.parent}catch{}}function Nn(e){if(e===void 0&&(e=window),e&&!Y(e))try{return e.opener}catch{}}function me(e){try{return!0}catch{}return!1}function ye(e){e===void 0&&(e=window);var r=e.location;if(!r)throw new Error("Can not read window location");var n=L(e);if(!n)throw new Error("Can not read window protocol");if(n==="file:")return"file://";if(n==="about:"){var o=Y(e);return o&&me()?ye(o):"about://"}var i=r.host;if(!i)throw new Error("Can not read window host");return n+"//"+i}function j(e){e===void 0&&(e=window);var r=ye(e);return r&&e.mockDomain&&e.mockDomain.indexOf("mock:")===0?e.mockDomain:r}function B(e){if(!function(r){try{if(r===window)return!0}catch{}try{var n=Object.getOwnPropertyDescriptor(r,"location");if(n&&n.enumerable===!1)return!1}catch{}try{if(we(r)&&me())return!0}catch{}try{if(function(o){return o===void 0&&(o=window),U(o)==="mock:"}(r)&&me())return!0}catch{}try{if(ye(r)===ye(window))return!0}catch{}return!1}(e))return!1;try{if(e===window||we(e)&&me()||j(window)===j(e))return!0}catch{}return!1}function Ee(e){if(!B(e))throw new Error("Expected window to be same domain");return e}function Ln(e,r){if(!e||!r)return!1;var n=Y(r);return n?n===e:function(o){var i=[];try{for(;o.parent!==o;)i.push(o.parent),o=o.parent}catch{}return i}(r).indexOf(e)!==-1}function jn(e){var r=[],n;try{n=e.frames}catch{n=e}var o;try{o=n.length}catch{}if(o===0)return r;if(o){for(var i=0;i<o;i++){var u=void 0;try{u=n[i]}catch{continue}r.push(u)}return r}for(var s=0;s<100;s++){var d=void 0;try{d=n[s]}catch{return r}if(!d)return r;r.push(d)}return r}var yi=[],Ei=[];function H(e,r){r===void 0&&(r=!0);try{if(e===window)return!1}catch{return!0}try{if(!e)return!0}catch{return!0}try{if(e.closed)return!0}catch(i){return!i||i.message!==S}if(r&&B(e))try{if(e.mockclosed)return!0}catch{}try{if(!e.parent||!e.top)return!0}catch{}var n=function(i,u){for(var s=0;s<i.length;s++)try{if(i[s]===u)return s}catch{}return-1}(yi,e);if(n!==-1){var o=Ei[n];if(o&&function(i){if(!i.contentWindow||!i.parentNode)return!0;var u=i.ownerDocument;if(u&&u.documentElement&&!u.documentElement.contains(i)){for(var s=i;s.parentNode&&s.parentNode!==s;)s=s.parentNode;if(!s.host||!u.documentElement.contains(s.host))return!0}return!1}(o))return!0}return!1}function zn(e){return e===void 0&&(e=window),Nn(e=e||window)||Y(e)||void 0}function te(e,r){if(typeof e=="string"){if(typeof r=="string")return e==="*"||r===e;if(y(r)||Array.isArray(r))return!1}return y(e)?y(r)?e.toString()===r.toString():!Array.isArray(r)&&!!r.match(e):!!Array.isArray(e)&&(Array.isArray(r)?JSON.stringify(e)===JSON.stringify(r):!y(r)&&e.some(function(n){return te(n,r)}))}function be(e){try{if(e===window)return!0}catch(r){if(r&&r.message===S)return!0}try{if({}.toString.call(e)==="[object Window]")return!0}catch(r){if(r&&r.message===S)return!0}try{if(window.Window&&e instanceof window.Window)return!0}catch(r){if(r&&r.message===S)return!0}try{if(e&&e.self===e)return!0}catch(r){if(r&&r.message===S)return!0}try{if(e&&e.parent===e)return!0}catch(r){if(r&&r.message===S)return!0}try{if(e&&e.top===e)return!0}catch(r){if(r&&r.message===S)return!0}try{if(e&&e.__cross_domain_utils_window_check__==="__unlikely_value__")return!1}catch{return!0}try{if("postMessage"in e&&"self"in e&&"location"in e)return!0}catch{}return!1}function Un(e){if(B(e))return Ee(e).frameElement;for(var r=0,n=document.querySelectorAll("iframe");r<n.length;r++){var o=n[r];if(o&&o.contentWindow&&o.contentWindow===e)return o}}function bi(e){if(function(n){return n===void 0&&(n=window),!!Y(n)}(e)){var r=Un(e);if(r&&r.parentElement){r.parentElement.removeChild(r);return}}try{e.close()}catch{}}function Q(e){try{if(!e)return!1;if(typeof Promise<"u"&&e instanceof Promise)return!0;if(typeof window<"u"&&typeof window.Window=="function"&&e instanceof window.Window||typeof window<"u"&&typeof window.constructor=="function"&&e instanceof window.constructor)return!1;var r={}.toString;if(r){var n=r.call(e);if(n==="[object Window]"||n==="[object global]"||n==="[object DOMWindow]")return!1}if(typeof e.then=="function")return!0}catch{return!1}return!1}var qn=[],ue=[],Re=0,ae;function Fn(){if(!Re&&ae){var e=ae;ae=null,e.resolve()}}function Te(){Re+=1}function se(){Re-=1,Fn()}var _=function(){function e(n){var o=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 i,u,s=!1,d=!1,f=!1;Te();try{n(function(c){f?o.resolve(c):(s=!0,i=c)},function(c){f?o.reject(c):(d=!0,u=c)})}catch(c){se(),this.reject(c);return}se(),f=!0,s?this.resolve(i):d&&this.reject(u)}}var r=e.prototype;return r.resolve=function(n){if(this.resolved||this.rejected)return this;if(Q(n))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=n,this.dispatch(),this},r.reject=function(n){var o=this;if(this.resolved||this.rejected)return this;if(Q(n))throw new Error("Can not reject promise with another promise");if(!n){var i=n&&typeof n.toString=="function"?n.toString():{}.toString.call(n);n=new Error("Expected reject to be called with Error, got "+i)}return this.rejected=!0,this.error=n,this.errorHandled||setTimeout(function(){o.errorHandled||function(u,s){if(qn.indexOf(u)===-1){qn.push(u),setTimeout(function(){throw u},1);for(var d=0;d<ue.length;d++)ue[d](u,s)}}(n,o)},1),this.dispatch(),this},r.asyncReject=function(n){return this.errorHandled=!0,this.reject(n),this},r.dispatch=function(){var n=this.resolved,o=this.rejected,i=this.handlers;if(!this.dispatching&&(n||o)){this.dispatching=!0,Te();for(var u=function(m,A){return m.then(function(E){A.resolve(E)},function(E){A.reject(E)})},s=0;s<i.length;s++){var d=i[s],f=d.onSuccess,c=d.onError,w=d.promise,v=void 0;if(n)try{v=f?f(this.value):this.value}catch(m){w.reject(m);continue}else if(o){if(!c){w.reject(this.error);continue}try{v=c(this.error)}catch(m){w.reject(m);continue}}if(v instanceof e&&(v.resolved||v.rejected)){var g=v;g.resolved?w.resolve(g.value):w.reject(g.error),g.errorHandled=!0}else Q(v)?v instanceof e&&(v.resolved||v.rejected)?v.resolved?w.resolve(v.value):w.reject(v.error):u(v,w):w.resolve(v)}i.length=0,this.dispatching=!1,se()}},r.then=function(n,o){if(n&&typeof n!="function"&&!n.call)throw new Error("Promise.then expected a function for success handler");if(o&&typeof o!="function"&&!o.call)throw new Error("Promise.then expected a function for error handler");var i=new e;return this.handlers.push({promise:i,onSuccess:n,onError:o}),this.errorHandled=!0,this.dispatch(),i},r.catch=function(n){return this.then(void 0,n)},r.finally=function(n){if(n&&typeof n!="function"&&!n.call)throw new Error("Promise.finally expected a function");return this.then(function(o){return e.try(n).then(function(){return o})},function(o){return e.try(n).then(function(){throw o})})},r.timeout=function(n,o){var i=this;if(this.resolved||this.rejected)return this;var u=setTimeout(function(){i.resolved||i.rejected||i.reject(o||new Error("Promise timed out after "+n+"ms"))},n);return this.then(function(s){return clearTimeout(u),s})},r.toPromise=function(){if(typeof Promise>"u")throw new TypeError("Could not find Promise");return Promise.resolve(this)},r.lazy=function(){return this.errorHandled=!0,this},e.resolve=function(n){return n instanceof e?n:Q(n)?new e(function(o,i){return n.then(o,i)}):new e().resolve(n)},e.reject=function(n){return new e().reject(n)},e.asyncReject=function(n){return new e().asyncReject(n)},e.all=function(n){var o=new e,i=n.length,u=[].slice();if(!i)return o.resolve(u),o;for(var s=function(c,w,v){return w.then(function(g){u[c]=g,(i-=1)==0&&o.resolve(u)},function(g){v.reject(g)})},d=0;d<n.length;d++){var f=n[d];if(f instanceof e){if(f.resolved){u[d]=f.value,i-=1;continue}}else if(!Q(f)){u[d]=f,i-=1;continue}s(d,e.resolve(f),o)}return i===0&&o.resolve(u),o},e.hash=function(n){var o={},i=[],u=function(d){if(n.hasOwnProperty(d)){var f=n[d];Q(f)?i.push(f.then(function(c){o[d]=c})):o[d]=f}};for(var s in n)u(s);return e.all(i).then(function(){return o})},e.map=function(n,o){return e.all(n.map(o))},e.onPossiblyUnhandledException=function(n){return function(o){return ue.push(o),{cancel:function(){ue.splice(ue.indexOf(o),1)}}}(n)},e.try=function(n,o,i){if(n&&typeof n!="function"&&!n.call)throw new Error("Promise.try expected a function");var u;Te();try{u=n.apply(o,i||[])}catch(s){return se(),e.reject(s)}return se(),e.resolve(u)},e.delay=function(n){return new e(function(o){setTimeout(o,n)})},e.isPromise=function(n){return!!(n&&n instanceof e)||Q(n)},e.flush=function(){return function(n){var o=ae=ae||new n;return Fn(),o}(e)},e}();function Ae(e,r){for(var n=0;n<e.length;n++)try{if(e[n]===r)return n}catch{}return-1}var Ce=function(){function e(){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(typeof WeakMap>"u"||Object.freeze===void 0)return!1;try{var n=new WeakMap,o={};return Object.freeze(o),n.set(o,"__testvalue__"),n.get(o)==="__testvalue__"}catch{return!1}}())try{this.weakmap=new WeakMap}catch{}this.keys=[],this.values=[]}var r=e.prototype;return r._cleanupClosedWindows=function(){for(var n=this.weakmap,o=this.keys,i=0;i<o.length;i++){var u=o[i];if(be(u)&&H(u)){if(n)try{n.delete(u)}catch{}o.splice(i,1),this.values.splice(i,1),i-=1}}},r.isSafeToReadWrite=function(n){return!be(n)},r.set=function(n,o){if(!n)throw new Error("WeakMap expected key");var i=this.weakmap;if(i)try{i.set(n,o)}catch{delete this.weakmap}if(this.isSafeToReadWrite(n))try{var u=this.name,s=n[u];s&&s[0]===n?s[1]=o:Object.defineProperty(n,u,{value:[n,o],writable:!0});return}catch{}this._cleanupClosedWindows();var d=this.keys,f=this.values,c=Ae(d,n);c===-1?(d.push(n),f.push(o)):f[c]=o},r.get=function(n){if(!n)throw new Error("WeakMap expected key");var o=this.weakmap;if(o)try{if(o.has(n))return o.get(n)}catch{delete this.weakmap}if(this.isSafeToReadWrite(n))try{var i=n[this.name];return i&&i[0]===n?i[1]:void 0}catch{}this._cleanupClosedWindows();var u=Ae(this.keys,n);if(u!==-1)return this.values[u]},r.delete=function(n){if(!n)throw new Error("WeakMap expected key");var o=this.weakmap;if(o)try{o.delete(n)}catch{delete this.weakmap}if(this.isSafeToReadWrite(n))try{var i=n[this.name];i&&i[0]===n&&(i[0]=i[1]=void 0)}catch{}this._cleanupClosedWindows();var u=this.keys,s=Ae(u,n);s!==-1&&(u.splice(s,1),this.values.splice(s,1))},r.has=function(n){if(!n)throw new Error("WeakMap expected key");var o=this.weakmap;if(o)try{if(o.has(n))return!0}catch{delete this.weakmap}if(this.isSafeToReadWrite(n))try{var i=n[this.name];return!(!i||i[0]!==n)}catch{}return this._cleanupClosedWindows(),Ae(this.keys,n)!==-1},r.getOrSet=function(n,o){if(this.has(n))return this.get(n);var i=o();return this.set(n,i),i},e}();function $n(e){return e.name||e.__name__||e.displayName||"anonymous"}function Hn(e,r){try{delete e.name,e.name=r}catch{}return e.__name__=e.displayName=r,e}function k(){var e="0123456789abcdef";return"uid_"+"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})+"_"+function(r){if(typeof btoa=="function")return btoa(encodeURIComponent(r).replace(/%([0-9A-F]{2})/g,function(n,o){return String.fromCharCode(parseInt(o,16))})).replace(/[=]/g,"");if(typeof Buffer<"u")return Buffer.from(r,"utf8").toString("base64").replace(/[=]/g,"");throw new Error("Can not find window.btoa or Buffer")}(new Date().toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}var Se;function Gn(e){try{return JSON.stringify([].slice.call(e),function(r,n){return typeof n=="function"?"memoize["+function(o){if(Se=Se||new Ce,o==null||typeof o!="object"&&typeof o!="function")throw new Error("Invalid object");var i=Se.get(o);return i||(i=typeof o+":"+k(),Se.set(o,i)),i}(n)+"]":typeof window<"u"&&n instanceof window.Element||n!==null&&typeof n=="object"&&n.nodeType===1&&typeof n.style=="object"&&typeof n.ownerDocument=="object"?{}:n})}catch{throw new Error("Arguments not serializable -- can not be used to memoize")}}function Ai(){return{}}var ce=0,kn=0;function fe(e,r){r===void 0&&(r={});var n=r.thisNamespace,o=n!==void 0&&n,i=r.time,u,s,d=ce;ce+=1;var f=function(){for(var c=arguments.length,w=new Array(c),v=0;v<c;v++)w[v]=arguments[v];d<kn&&(u=null,s=null,d=ce,ce+=1);var g;g=o?(s=s||new Ce).getOrSet(this,Ai):u=u||{};var m;try{m=Gn(w)}catch{return e.apply(this,arguments)}var A=g[m];if(A&&i&&Date.now()-A.time<i&&(delete g[m],A=null),A)return A.value;var E=Date.now(),b=e.apply(this,arguments);return g[m]={time:E,value:b},b};return f.reset=function(){u=null,s=null},Hn(f,(r.name||$n(e))+"::memoized")}fe.clear=function(){kn=ce};function Si(e){var r={};function n(){for(var o=arguments,i=this,u=arguments.length,s=new Array(u),d=0;d<u;d++)s[d]=arguments[d];var f=Gn(s);return r.hasOwnProperty(f)||(r[f]=_.try(function(){return e.apply(i,o)}).finally(function(){delete r[f]})),r[f]}return n.reset=function(){r={}},Hn(n,$n(e)+"::promiseMemoized")}function X(){}function de(e,r){if(r===void 0&&(r=1),r>=3)return"stringifyError stack overflow";try{if(!e)return"<unknown error: "+{}.toString.call(e)+">";if(typeof e=="string")return e;if(e instanceof Error){var n=e&&e.stack,o=e&&e.message;if(n&&o)return n.indexOf(o)!==-1?n:o+`
3
+ `+n;if(n)return n;if(o)return o}return e&&e.toString&&typeof e.toString=="function"?e.toString():{}.toString.call(e)}catch(i){return"Error while stringifying error: "+de(i,r+1)}}function Vn(e){return typeof e=="string"?e:e&&e.toString&&typeof e.toString=="function"?e.toString():{}.toString.call(e)}fe(function(e){if(Object.values)return Object.values(e);var r=[];for(var n in e)e.hasOwnProperty(n)&&r.push(e[n]);return r});function De(e){return{}.toString.call(e)==="[object RegExp]"}function le(e,r,n){if(e.hasOwnProperty(r))return e[r];var o=n();return e[r]=o,o}function Zn(){var e=document.body;if(!e)throw new Error("Body element not found");return e}function Jn(){return!!document.body&&document.readyState==="complete"}function Yn(){return!!document.body&&document.readyState==="interactive"}fe(function(){return new _(function(e){if(Jn()||Yn())return e();var r=setInterval(function(){if(Jn()||Yn())return clearInterval(r),e()},10)})});var xe=typeof document<"u"?document.currentScript:null,xi=fe(function(){if(xe||(xe=function(){try{var e=function(){try{throw new Error("_")}catch(s){return s.stack||""}}(),r=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(e),n=r&&r[1];if(!n)return;for(var o=0,i=[].slice.call(document.getElementsByTagName("script")).reverse();o<i.length;o++){var u=i[o];if(u.src&&u.src===n)return u}}catch{}}()))return xe;throw new Error("Can not determine current script")}),Pi=k();fe(function(){var e;try{e=xi()}catch{return Pi}var r=e.getAttribute("data-uid");if(r&&typeof r=="string"||(r=e.getAttribute("data-uid-auto"))&&typeof r=="string")return r;if(e.src){var n=function(o){for(var i="",u=0;u<o.length;u++){var s=o[u].charCodeAt(0)*u;o[u+1]&&(s+=o[u+1].charCodeAt(0)*(u-1)),i+=String.fromCharCode(97+Math.abs(s)%26)}return i}(JSON.stringify({src:e.src,dataset:e.dataset}));r="uid_"+n.slice(n.length-30)}else r=k();return e.setAttribute("data-uid-auto",r),r});function he(e){e===void 0&&(e=window);var r="__post_robot_10_0_46__";return e!==window?e[r]:e[r]=e[r]||{}}var Bn=function(){return{}};function D(e,r){return e===void 0&&(e="store"),r===void 0&&(r=Bn),le(he(),e,function(){var n=r();return{has:function(o){return n.hasOwnProperty(o)},get:function(o,i){return n.hasOwnProperty(o)?n[o]:i},set:function(o,i){return n[o]=i,i},del:function(o){delete n[o]},getOrSet:function(o,i){return le(n,o,i)},reset:function(){n=r()},keys:function(){return Object.keys(n)}}})}var _i=function(){};function Pe(){var e=he();return e.WINDOW_WILDCARD=e.WINDOW_WILDCARD||new _i,e.WINDOW_WILDCARD}function z(e,r){return e===void 0&&(e="store"),r===void 0&&(r=Bn),D("windowStore").getOrSet(e,function(){var n=new Ce,o=function(i){return n.getOrSet(i,r)};return{has:function(i){return o(i).hasOwnProperty(e)},get:function(i,u){var s=o(i);return s.hasOwnProperty(e)?s[e]:u},set:function(i,u){return o(i)[e]=u,u},del:function(i){delete o(i)[e]},getOrSet:function(i,u){return le(o(i),e,u)}}})}function Qn(){return D("instance").getOrSet("instanceID",k)}function Xn(e,r){var n=r.domain,o=z("helloPromises"),i=o.get(e);i&&i.resolve({domain:n});var u=_.resolve({domain:n});return o.set(e,u),u}function Me(e,r){return(0,r.send)(e,"postrobot_hello",{instanceID:Qn()},{domain:"*",timeout:-1}).then(function(n){var o=n.origin,i=n.data.instanceID;return Xn(e,{domain:o}),{win:e,domain:o,instanceID:i}})}function Kn(e,r){var n=r.send;return z("windowInstanceIDPromises").getOrSet(e,function(){return Me(e,{send:n}).then(function(o){return o.instanceID})})}function et(e){z("knownWindows").set(e,!0)}function Ne(e){return typeof e=="object"&&e!==null&&typeof e.__type__=="string"}function nt(e){return e===void 0?"undefined":e===null?"null":Array.isArray(e)?"array":typeof e=="function"?"function":typeof e=="object"?e instanceof Error?"error":typeof e.then=="function"?"promise":{}.toString.call(e)==="[object RegExp]"?"regex":{}.toString.call(e)==="[object Date]"?"date":"object":typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":void 0}function K(e,r){return{__type__:e,__val__:r}}var q,Ii=((q={}).function=function(){},q.error=function(e){return K("error",{message:e.message,stack:e.stack,code:e.code,data:e.data})},q.promise=function(){},q.regex=function(e){return K("regex",e.source)},q.date=function(e){return K("date",e.toJSON())},q.array=function(e){return e},q.object=function(e){return e},q.string=function(e){return e},q.number=function(e){return e},q.boolean=function(e){return e},q.null=function(e){return e},q[void 0]=function(e){return K("undefined",e)},q),Oi={},F,Wi=((F={}).function=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},F.error=function(e){var r=e.stack,n=e.code,o=e.data,i=new Error(e.message);return i.code=n,o&&(i.data=o),i.stack=r+`
4
4
 
5
- `+i.stack,i},F.promise=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},F.regex=function(e){return new RegExp(e)},F.date=function(e){return new Date(e)},F.array=function(e){return e},F.object=function(e){return e},F.string=function(e){return e},F.number=function(e){return e},F.boolean=function(e){return e},F.null=function(e){return e},F[void 0]=function(){},F),Oi={};new I(function(e){if(window.document&&window.document.body)return e(window.document.body);var r=setInterval(function(){if(window.document&&window.document.body)return clearInterval(r),e(window.document.body)},10)});function Le(){for(var e=D("idToProxyWindow"),r=0,n=e.keys();r<n.length;r++){var o=n[r];e.get(o).shouldClean()&&e.del(o)}}function nt(e,r){var n=r.send,o=r.id,i=o===void 0?V():o,u=e.then(function(f){if(B(f))return Ee(f).name}),s=e.then(function(f){if(H(f))throw new Error("Window is closed, can not determine type");return Mn(f)?"popup":"iframe"});u.catch(X),s.catch(X);var d=function(){return e.then(function(f){if(!H(f))return B(f)?Ee(f).name:u})};return{id:i,getType:function(){return s},getInstanceID:bi(function(){return e.then(function(f){return Xn(f,{send:n})})}),close:function(){return e.then(Ei)},getName:d,focus:function(){return e.then(function(f){f.focus()})},isClosed:function(){return e.then(function(f){return H(f)})},setLocation:function(f,c){return c===void 0&&(c={}),e.then(function(p){var h=window.location.protocol+"//"+window.location.host,g=c.method,m=g===void 0?"get":g,b=c.body;if(f.indexOf("/")===0)f=""+h+f;else if(!f.match(/^https?:\/\//)&&f.indexOf(h)!==0)throw new Error("Expected url to be http or https url, or absolute path, got "+JSON.stringify(f));if(m==="post")return d().then(function(E){if(!E)throw new Error("Can not post to window without target name");(function(A){var _=A.url,C=A.target,O=A.body,W=A.method,M=W===void 0?"post":W,P=document.createElement("form");if(P.setAttribute("target",C),P.setAttribute("method",M),P.setAttribute("action",_),P.style.display="none",O)for(var R=0,G=Object.keys(O);R<G.length;R++){var T,ve=G[R],qe=document.createElement("input");qe.setAttribute("name",ve),qe.setAttribute("value",(T=O[ve])==null?void 0:T.toString()),P.appendChild(qe)}kn().appendChild(P),P.submit(),kn().removeChild(P)})({url:f,target:E,method:m,body:b})});if(m!=="get")throw new Error("Unsupported method: "+m);if(B(p))try{if(p.location&&typeof p.location.replace=="function"){p.location.replace(f);return}}catch{}p.location=f})},setName:function(f){return e.then(function(c){var p=B(c),h=zn(c);if(!p)throw new Error("Can not set name for cross-domain window: "+f);Ee(c).name=f,h&&h.setAttribute("name",f),u=I.resolve(f)})}}}var $=function(){function e(n){var o=n.send,i=n.win,u=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 I,this.serializedWindow=u||nt(this.actualWindowPromise,{send:o}),D("idToProxyWindow").set(this.getID(),this),i&&this.setWindow(i,{send:o})}var r=e.prototype;return r.getID=function(){return this.serializedWindow.id},r.getType=function(){return this.serializedWindow.getType()},r.isPopup=function(){return this.getType().then(function(n){return n==="popup"})},r.setLocation=function(n,o){var i=this;return this.serializedWindow.setLocation(n,o).then(function(){return i})},r.getName=function(){return this.serializedWindow.getName()},r.setName=function(n){var o=this;return this.serializedWindow.setName(n).then(function(){return o})},r.close=function(){var n=this;return this.serializedWindow.close().then(function(){return n})},r.focus=function(){var n=this,o=this.isPopup(),i=this.getName(),u=I.hash({isPopup:o,name:i}).then(function(d){var f=d.name;d.isPopup&&f&&window.open("",f,"noopener")}),s=this.serializedWindow.focus();return I.all([u,s]).then(function(){return n})},r.isClosed=function(){return this.serializedWindow.isClosed()},r.getWindow=function(){return this.actualWindow},r.setWindow=function(n,o){var i=o.send;this.actualWindow=n,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=nt(this.actualWindowPromise,{send:i,id:this.getID()}),z("winToProxyWindow").set(n,this)},r.awaitWindow=function(){return this.actualWindowPromise},r.matchWindow=function(n,o){var i=this,u=o.send;return I.try(function(){return i.actualWindow?n===i.actualWindow:I.hash({proxyInstanceID:i.getInstanceID(),knownWindowInstanceID:Xn(n,{send:u})}).then(function(s){var d=s.proxyInstanceID===s.knownWindowInstanceID;return d&&i.setWindow(n,{send:u}),d})})},r.unwrap=function(){return this.actualWindow||this},r.getInstanceID=function(){return this.serializedWindow.getInstanceID()},r.shouldClean=function(){return!!(this.actualWindow&&H(this.actualWindow))},r.serialize=function(){return this.serializedWindow},e.unwrap=function(n){return e.isProxyWindow(n)?n.unwrap():n},e.serialize=function(n,o){var i=o.send;return Le(),e.toProxyWindow(n,{send:i}).serialize()},e.deserialize=function(n,o){var i=o.send;return Le(),D("idToProxyWindow").get(n.id)||new e({serializedWindow:n,send:i})},e.isProxyWindow=function(n){return!!(n&&!Ae(n)&&n.isProxyWindow)},e.toProxyWindow=function(n,o){var i=o.send;if(Le(),e.isProxyWindow(n))return n;var u=n;return z("winToProxyWindow").get(u)||new e({win:u,send:i})},e}();function je(e,r,n,o,i){var u=z("methodStore"),s=D("proxyWindowMethods");$.isProxyWindow(o)?s.set(e,{val:r,name:n,domain:i,source:o}):(s.del(e),u.getOrSet(o,function(){return{}})[e]={domain:i,name:n,val:r,source:o})}function tt(e,r){var n=z("methodStore"),o=D("proxyWindowMethods");return n.getOrSet(e,function(){return{}})[r]||o.get(r)}function rt(e,r,n,o,i){s=(u={on:i.on,send:i.send}).on,d=u.send,D("builtinListeners").getOrSet("functionCalls",function(){return s("postrobot_method",{domain:"*"},function(p){var h=p.source,g=p.origin,m=p.data,b=m.id,E=m.name,A=tt(h,b);if(!A)throw new Error("Could not find method '"+E+"' with id: "+m.id+" in "+j(window));var _=A.source,C=A.domain,O=A.val;return I.try(function(){if(!te(C,g))throw new Error("Method '"+m.name+"' domain "+JSON.stringify(De(A.domain)?A.domain.source:A.domain)+" does not match origin "+g+" in "+j(window));if($.isProxyWindow(_))return _.matchWindow(h,{send:d}).then(function(W){if(!W)throw new Error("Method call '"+m.name+"' failed - proxy window does not match source in "+j(window))})}).then(function(){return O.apply({source:h,origin:g},m.args)},function(W){return I.try(function(){if(O.onError)return O.onError(W)}).then(function(){throw W.stack&&(W.stack="Remote call to "+E+"("+function(M){return M===void 0&&(M=[]),(P=M,[].slice.call(P)).map(function(R){return typeof R=="string"?"'"+R+"'":R===void 0?"undefined":R===null?"null":typeof R=="boolean"?R.toString():Array.isArray(R)?"[ ... ]":typeof R=="object"?"{ ... }":typeof R=="function"?"() => { ... }":"<"+typeof R+">"}).join(", ");var P}(m.args)+`) failed
5
+ `+i.stack,i},F.promise=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},F.regex=function(e){return new RegExp(e)},F.date=function(e){return new Date(e)},F.array=function(e){return e},F.object=function(e){return e},F.string=function(e){return e},F.number=function(e){return e},F.boolean=function(e){return e},F.null=function(e){return e},F[void 0]=function(){},F),Ri={};new _(function(e){if(window.document&&window.document.body)return e(window.document.body);var r=setInterval(function(){if(window.document&&window.document.body)return clearInterval(r),e(window.document.body)},10)});function Le(){for(var e=D("idToProxyWindow"),r=0,n=e.keys();r<n.length;r++){var o=n[r];e.get(o).shouldClean()&&e.del(o)}}function tt(e,r){var n=r.send,o=r.id,i=o===void 0?k():o,u=e.then(function(f){if(B(f))return Ee(f).name}),s=e.then(function(f){if(H(f))throw new Error("Window is closed, can not determine type");return Nn(f)?"popup":"iframe"});u.catch(X),s.catch(X);var d=function(){return e.then(function(f){if(!H(f))return B(f)?Ee(f).name:u})};return{id:i,getType:function(){return s},getInstanceID:Si(function(){return e.then(function(f){return Kn(f,{send:n})})}),close:function(){return e.then(bi)},getName:d,focus:function(){return e.then(function(f){f.focus()})},isClosed:function(){return e.then(function(f){return H(f)})},setLocation:function(f,c){return c===void 0&&(c={}),e.then(function(w){var v=window.location.protocol+"//"+window.location.host,g=c.method,m=g===void 0?"get":g,A=c.body;if(f.indexOf("/")===0)f=""+v+f;else if(!f.match(/^https?:\/\//)&&f.indexOf(v)!==0)throw new Error("Expected url to be http or https url, or absolute path, got "+JSON.stringify(f));if(m==="post")return d().then(function(E){if(!E)throw new Error("Can not post to window without target name");(function(b){var I=b.url,C=b.target,W=b.body,O=b.method,M=O===void 0?"post":O,P=document.createElement("form");if(P.setAttribute("target",C),P.setAttribute("method",M),P.setAttribute("action",I),P.style.display="none",W)for(var R=0,G=Object.keys(W);R<G.length;R++){var T,ve=G[R],qe=document.createElement("input");qe.setAttribute("name",ve),qe.setAttribute("value",(T=W[ve])==null?void 0:T.toString()),P.appendChild(qe)}Zn().appendChild(P),P.submit(),Zn().removeChild(P)})({url:f,target:E,method:m,body:A})});if(m!=="get")throw new Error("Unsupported method: "+m);if(B(w))try{if(w.location&&typeof w.location.replace=="function"){w.location.replace(f);return}}catch{}w.location=f})},setName:function(f){return e.then(function(c){var w=B(c),v=Un(c);if(!w)throw new Error("Can not set name for cross-domain window: "+f);Ee(c).name=f,v&&v.setAttribute("name",f),u=_.resolve(f)})}}}var $=function(){function e(n){var o=n.send,i=n.win,u=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 _,this.serializedWindow=u||tt(this.actualWindowPromise,{send:o}),D("idToProxyWindow").set(this.getID(),this),i&&this.setWindow(i,{send:o})}var r=e.prototype;return r.getID=function(){return this.serializedWindow.id},r.getType=function(){return this.serializedWindow.getType()},r.isPopup=function(){return this.getType().then(function(n){return n==="popup"})},r.setLocation=function(n,o){var i=this;return this.serializedWindow.setLocation(n,o).then(function(){return i})},r.getName=function(){return this.serializedWindow.getName()},r.setName=function(n){var o=this;return this.serializedWindow.setName(n).then(function(){return o})},r.close=function(){var n=this;return this.serializedWindow.close().then(function(){return n})},r.focus=function(){var n=this,o=this.isPopup(),i=this.getName(),u=_.hash({isPopup:o,name:i}).then(function(d){var f=d.name;d.isPopup&&f&&window.open("",f,"noopener")}),s=this.serializedWindow.focus();return _.all([u,s]).then(function(){return n})},r.isClosed=function(){return this.serializedWindow.isClosed()},r.getWindow=function(){return this.actualWindow},r.setWindow=function(n,o){var i=o.send;this.actualWindow=n,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=tt(this.actualWindowPromise,{send:i,id:this.getID()}),z("winToProxyWindow").set(n,this)},r.awaitWindow=function(){return this.actualWindowPromise},r.matchWindow=function(n,o){var i=this,u=o.send;return _.try(function(){return i.actualWindow?n===i.actualWindow:_.hash({proxyInstanceID:i.getInstanceID(),knownWindowInstanceID:Kn(n,{send:u})}).then(function(s){var d=s.proxyInstanceID===s.knownWindowInstanceID;return d&&i.setWindow(n,{send:u}),d})})},r.unwrap=function(){return this.actualWindow||this},r.getInstanceID=function(){return this.serializedWindow.getInstanceID()},r.shouldClean=function(){return!!(this.actualWindow&&H(this.actualWindow))},r.serialize=function(){return this.serializedWindow},e.unwrap=function(n){return e.isProxyWindow(n)?n.unwrap():n},e.serialize=function(n,o){var i=o.send;return Le(),e.toProxyWindow(n,{send:i}).serialize()},e.deserialize=function(n,o){var i=o.send;return Le(),D("idToProxyWindow").get(n.id)||new e({serializedWindow:n,send:i})},e.isProxyWindow=function(n){return!!(n&&!be(n)&&n.isProxyWindow)},e.toProxyWindow=function(n,o){var i=o.send;if(Le(),e.isProxyWindow(n))return n;var u=n;return z("winToProxyWindow").get(u)||new e({win:u,send:i})},e}();function je(e,r,n,o,i){var u=z("methodStore"),s=D("proxyWindowMethods");$.isProxyWindow(o)?s.set(e,{val:r,name:n,domain:i,source:o}):(s.del(e),u.getOrSet(o,function(){return{}})[e]={domain:i,name:n,val:r,source:o})}function rt(e,r){var n=z("methodStore"),o=D("proxyWindowMethods");return n.getOrSet(e,function(){return{}})[r]||o.get(r)}function ot(e,r,n,o,i){s=(u={on:i.on,send:i.send}).on,d=u.send,D("builtinListeners").getOrSet("functionCalls",function(){return s("postrobot_method",{domain:"*"},function(w){var v=w.source,g=w.origin,m=w.data,A=m.id,E=m.name,b=rt(v,A);if(!b)throw new Error("Could not find method '"+E+"' with id: "+m.id+" in "+j(window));var I=b.source,C=b.domain,W=b.val;return _.try(function(){if(!te(C,g))throw new Error("Method '"+m.name+"' domain "+JSON.stringify(De(b.domain)?b.domain.source:b.domain)+" does not match origin "+g+" in "+j(window));if($.isProxyWindow(I))return I.matchWindow(v,{send:d}).then(function(O){if(!O)throw new Error("Method call '"+m.name+"' failed - proxy window does not match source in "+j(window))})}).then(function(){return W.apply({source:v,origin:g},m.args)},function(O){return _.try(function(){if(W.onError)return W.onError(O)}).then(function(){throw O.stack&&(O.stack="Remote call to "+E+"("+function(M){return M===void 0&&(M=[]),(P=M,[].slice.call(P)).map(function(R){return typeof R=="string"?"'"+R+"'":R===void 0?"undefined":R===null?"null":typeof R=="boolean"?R.toString():Array.isArray(R)?"[ ... ]":typeof R=="object"?"{ ... }":typeof R=="function"?"() => { ... }":"<"+typeof R+">"}).join(", ");var P}(m.args)+`) failed
6
6
 
7
- `+W.stack),W})}).then(function(W){return{result:W,id:b,name:E}})})});var u,s,d,f=n.__id__||V();e=$.unwrap(e);var c=n.__name__||n.name||o;return typeof c=="string"&&typeof c.indexOf=="function"&&c.indexOf("anonymous::")===0&&(c=c.replace("anonymous::",o+"::")),$.isProxyWindow(e)?(je(f,n,c,e,r),e.awaitWindow().then(function(p){je(f,n,c,p,r)})):je(f,n,c,e,r),K("cross_domain_function",{id:f,name:c})}function ot(e,r,n,o){var i,u=o.on,s=o.send;return function(d,f){f===void 0&&(f=_i);var c=JSON.stringify(d,function(p){var h=this[p];if(Ne(this))return h;var g=et(h);if(!g)return h;var m=f[g]||Ii[g];return m?m(h,p):h});return c===void 0?"undefined":c}(n,((i={}).promise=function(d,f){return function(c,p,h,g,m){return K("cross_domain_zalgo_promise",{then:rt(c,p,function(b,E){return h.then(b,E)},g,{on:m.on,send:m.send})})}(e,r,d,f,{on:u,send:s})},i.function=function(d,f){return rt(e,r,d,f,{on:u,send:s})},i.object=function(d){return Ae(d)||$.isProxyWindow(d)?K("cross_domain_window",$.serialize(d,{send:s})):d},i))}function it(e,r,n,o){var i,u=o.send;return function(s,d){if(d===void 0&&(d=Oi),s!=="undefined")return JSON.parse(s,function(f,c){if(Ne(this))return c;var p,h;if(Ne(c)?(p=c.__type__,h=c.__val__):(p=et(c),h=c),!p)return h;var g=d[p]||Wi[p];return g?g(h,f):h})}(n,((i={}).cross_domain_zalgo_promise=function(s){return function(d,f,c){return new I(c.then)}(0,0,s)},i.cross_domain_function=function(s){return function(d,f,c,p){var h=c.id,g=c.name,m=p.send,b=function(A){A===void 0&&(A={});function _(){var C=arguments;return $.toProxyWindow(d,{send:m}).awaitWindow().then(function(O){var W=tt(O,h);if(W&&W.val!==_)return W.val.apply({source:window,origin:j()},C);var M=[].slice.call(C);return A.fireAndForget?m(O,"postrobot_method",{id:h,name:g,args:M},{domain:f,fireAndForget:!0}):m(O,"postrobot_method",{id:h,name:g,args:M},{domain:f,fireAndForget:!1}).then(function(P){return P.data.result})}).catch(function(O){throw O})}return _.__name__=g,_.__origin__=f,_.__source__=d,_.__id__=h,_.origin=f,_},E=b();return E.fireAndForget=b({fireAndForget:!0}),E}(e,r,s,{send:u})},i.cross_domain_window=function(s){return $.deserialize(s,{send:u})},i))}var ze={};ze.postrobot_post_message=function(e,r,n){n.indexOf("file:")===0&&(n="*"),e.postMessage(r,n)};function Ue(e,r,n,o){var i=o.on,u=o.send;return I.try(function(){var s=z().getOrSet(e,function(){return{}});return s.buffer=s.buffer||[],s.buffer.push(n),s.flush=s.flush||I.flush().then(function(){if(H(e))throw new Error("Window is closed");var d=ot(e,r,((f={}).__post_robot_10_0_46__=s.buffer||[],f),{on:i,send:u}),f;delete s.buffer;for(var c=Object.keys(ze),p=[],h=0;h<c.length;h++){var g=c[h];try{ze[g](e,d,r)}catch(m){p.push(m)}}if(p.length===c.length)throw new Error(`All post-robot messaging strategies failed:
7
+ `+O.stack),O})}).then(function(O){return{result:O,id:A,name:E}})})});var u,s,d,f=n.__id__||k();e=$.unwrap(e);var c=n.__name__||n.name||o;return typeof c=="string"&&typeof c.indexOf=="function"&&c.indexOf("anonymous::")===0&&(c=c.replace("anonymous::",o+"::")),$.isProxyWindow(e)?(je(f,n,c,e,r),e.awaitWindow().then(function(w){je(f,n,c,w,r)})):je(f,n,c,e,r),K("cross_domain_function",{id:f,name:c})}function it(e,r,n,o){var i,u=o.on,s=o.send;return function(d,f){f===void 0&&(f=Oi);var c=JSON.stringify(d,function(w){var v=this[w];if(Ne(this))return v;var g=nt(v);if(!g)return v;var m=f[g]||Ii[g];return m?m(v,w):v});return c===void 0?"undefined":c}(n,((i={}).promise=function(d,f){return function(c,w,v,g,m){return K("cross_domain_zalgo_promise",{then:ot(c,w,function(A,E){return v.then(A,E)},g,{on:m.on,send:m.send})})}(e,r,d,f,{on:u,send:s})},i.function=function(d,f){return ot(e,r,d,f,{on:u,send:s})},i.object=function(d){return be(d)||$.isProxyWindow(d)?K("cross_domain_window",$.serialize(d,{send:s})):d},i))}function ut(e,r,n,o){var i,u=o.send;return function(s,d){if(d===void 0&&(d=Ri),s!=="undefined")return JSON.parse(s,function(f,c){if(Ne(this))return c;var w,v;if(Ne(c)?(w=c.__type__,v=c.__val__):(w=nt(c),v=c),!w)return v;var g=d[w]||Wi[w];return g?g(v,f):v})}(n,((i={}).cross_domain_zalgo_promise=function(s){return function(d,f,c){return new _(c.then)}(0,0,s)},i.cross_domain_function=function(s){return function(d,f,c,w){var v=c.id,g=c.name,m=w.send,A=function(b){b===void 0&&(b={});function I(){var C=arguments;return $.toProxyWindow(d,{send:m}).awaitWindow().then(function(W){var O=rt(W,v);if(O&&O.val!==I)return O.val.apply({source:window,origin:j()},C);var M=[].slice.call(C);return b.fireAndForget?m(W,"postrobot_method",{id:v,name:g,args:M},{domain:f,fireAndForget:!0}):m(W,"postrobot_method",{id:v,name:g,args:M},{domain:f,fireAndForget:!1}).then(function(P){return P.data.result})}).catch(function(W){throw W})}return I.__name__=g,I.__origin__=f,I.__source__=d,I.__id__=v,I.origin=f,I},E=A();return E.fireAndForget=A({fireAndForget:!0}),E}(e,r,s,{send:u})},i.cross_domain_window=function(s){return $.deserialize(s,{send:u})},i))}var ze={};ze.postrobot_post_message=function(e,r,n){n.indexOf("file:")===0&&(n="*"),e.postMessage(r,n)};function Ue(e,r,n,o){var i=o.on,u=o.send;return _.try(function(){var s=z().getOrSet(e,function(){return{}});return s.buffer=s.buffer||[],s.buffer.push(n),s.flush=s.flush||_.flush().then(function(){if(H(e))throw new Error("Window is closed");var d=it(e,r,((f={}).__post_robot_10_0_46__=s.buffer||[],f),{on:i,send:u}),f;delete s.buffer;for(var c=Object.keys(ze),w=[],v=0;v<c.length;v++){var g=c[v];try{ze[g](e,d,r)}catch(m){w.push(m)}}if(w.length===c.length)throw new Error(`All post-robot messaging strategies failed:
8
8
 
9
- `+p.map(function(m,b){return b+". "+de(m)}).join(`
9
+ `+w.map(function(m,A){return A+". "+de(m)}).join(`
10
10
 
11
- `))}),s.flush.then(function(){delete s.flush})}).then(X)}function ut(e){return D("responseListeners").get(e)}function at(e){D("responseListeners").del(e)}function st(e){return D("erroredResponseListeners").has(e)}function ct(e){var r=e.name,n=e.win,o=e.domain,i=z("requestListeners");if(n==="*"&&(n=null),o==="*"&&(o=null),!r)throw new Error("Name required to get request listener");for(var u=0,s=[n,Pe()];u<s.length;u++){var d=s[u];if(d){var f=i.get(d);if(f){var c=f[r];if(c){if(o&&typeof o=="string"){if(c[o])return c[o];if(c.__domain_regex__)for(var p=0,h=c.__domain_regex__;p<h.length;p++){var g=h[p],m=g.listener;if(te(g.regex,o))return m}}if(c["*"])return c["*"]}}}}}function Ri(e,r,n,o){var i=o.on,u=o.send,s=ct({name:n.name,win:e,domain:r}),d=n.name==="postrobot_method"&&n.data&&typeof n.data.name=="string"?n.data.name+"()":n.name;function f(c,p,h){return I.flush().then(function(){if(!n.fireAndForget&&!H(e))try{return Ue(e,r,{id:V(),origin:j(window),type:"postrobot_message_response",hash:n.hash,name:n.name,ack:c,data:p,error:h},{on:i,send:u})}catch(g){throw new Error("Send response message failed for "+d+" in "+j()+`
11
+ `))}),s.flush.then(function(){delete s.flush})}).then(X)}function at(e){return D("responseListeners").get(e)}function st(e){D("responseListeners").del(e)}function ct(e){return D("erroredResponseListeners").has(e)}function ft(e){var r=e.name,n=e.win,o=e.domain,i=z("requestListeners");if(n==="*"&&(n=null),o==="*"&&(o=null),!r)throw new Error("Name required to get request listener");for(var u=0,s=[n,Pe()];u<s.length;u++){var d=s[u];if(d){var f=i.get(d);if(f){var c=f[r];if(c){if(o&&typeof o=="string"){if(c[o])return c[o];if(c.__domain_regex__)for(var w=0,v=c.__domain_regex__;w<v.length;w++){var g=v[w],m=g.listener;if(te(g.regex,o))return m}}if(c["*"])return c["*"]}}}}}function Ti(e,r,n,o){var i=o.on,u=o.send,s=ft({name:n.name,win:e,domain:r}),d=n.name==="postrobot_method"&&n.data&&typeof n.data.name=="string"?n.data.name+"()":n.name;function f(c,w,v){return _.flush().then(function(){if(!n.fireAndForget&&!H(e))try{return Ue(e,r,{id:k(),origin:j(window),type:"postrobot_message_response",hash:n.hash,name:n.name,ack:c,data:w,error:v},{on:i,send:u})}catch(g){throw new Error("Send response message failed for "+d+" in "+j()+`
12
12
 
13
- `+de(g))}})}return I.all([I.flush().then(function(){if(!n.fireAndForget&&!H(e))try{return Ue(e,r,{id:V(),origin:j(window),type:"postrobot_message_ack",hash:n.hash,name:n.name},{on:i,send:u})}catch(c){throw new Error("Send ack message failed for "+d+" in "+j()+`
13
+ `+de(g))}})}return _.all([_.flush().then(function(){if(!n.fireAndForget&&!H(e))try{return Ue(e,r,{id:k(),origin:j(window),type:"postrobot_message_ack",hash:n.hash,name:n.name},{on:i,send:u})}catch(c){throw new Error("Send ack message failed for "+d+" in "+j()+`
14
14
 
15
- `+de(c))}}),I.try(function(){if(!s)throw new Error("No handler found for post message: "+n.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);return s.handler({source:e,origin:r,data:n.data})}).then(function(c){return f("success",c)},function(c){return f("error",null,c)})]).then(X).catch(function(c){if(s&&s.handleError)return s.handleError(c);throw c})}function Ti(e,r,n){if(!st(n.hash)){var o=ut(n.hash);if(!o)throw new Error("No handler found for post message ack for message: "+n.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);try{if(!te(o.domain,r))throw new Error("Ack origin "+r+" does not match domain "+o.domain.toString());if(e!==o.win)throw new Error("Ack source does not match registered window")}catch(i){o.promise.reject(i)}o.ack=!0}}function Ci(e,r,n){if(!st(n.hash)){var o=ut(n.hash);if(!o)throw new Error("No handler found for post message response for message: "+n.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!te(o.domain,r))throw new Error("Response origin "+r+" does not match domain "+(i=o.domain,Array.isArray(i)?"("+i.join(" | ")+")":y(i)?"RegExp("+i.toString()+")":i.toString()));var i;if(e!==o.win)throw new Error("Response source does not match registered window");at(n.hash),n.ack==="error"?o.promise.reject(n.error):n.ack==="success"&&o.promise.resolve({source:e,origin:r,data:n.data})}}function ft(e,r){var n=r.on,o=r.send,i=D("receivedMessages");try{if(!window||window.closed||!e.source)return}catch{return}var u=e.source,s=e.origin,d=function(p,h,g,m){var b=m.on,E=m.send,A;try{A=it(h,g,p,{on:b,send:E})}catch{return}if(A&&typeof A=="object"&&A!==null){var _=A.__post_robot_10_0_46__;if(Array.isArray(_))return _}}(e.data,u,s,{on:n,send:o});if(d){Kn(u);for(var f=0;f<d.length;f++){var c=d[f];if(i.has(c.id)||(i.set(c.id,!0),H(u)&&!c.fireAndForget))return;c.origin.indexOf("file:")===0&&(s="file://");try{c.type==="postrobot_message_request"?Ri(u,s,c,{on:n,send:o}):c.type==="postrobot_message_response"?Ci(u,s,c):c.type==="postrobot_message_ack"&&Ti(u,s,c)}catch(p){setTimeout(function(){throw p},0)}}}}function k(e,r,n){if(!e)throw new Error("Expected name");if(typeof(r=r||{})=="function"&&(n=r,r={}),!n)throw new Error("Expected handler");var o=function i(u,s){var d=u.name,f=u.win,c=u.domain,p=z("requestListeners");if(!d||typeof d!="string")throw new Error("Name required to add request listener");if(f&&f!=="*"&&$.isProxyWindow(f)){var h=f.awaitWindow().then(function(T){return i({name:d,win:T,domain:c},s)});return{cancel:function(){h.then(function(T){return T.cancel()},X)}}}var g=f;if(Array.isArray(g)){for(var m=[],b=0,E=g;b<E.length;b++)m.push(i({name:d,domain:c,win:E[b]},s));return{cancel:function(){for(var T=0;T<m.length;T++)m[T].cancel()}}}if(Array.isArray(c)){for(var A=[],_=0,C=c;_<C.length;_++)A.push(i({name:d,win:g,domain:C[_]},s));return{cancel:function(){for(var T=0;T<A.length;T++)A[T].cancel()}}}var O=ct({name:d,win:g,domain:c});g&&g!=="*"||(g=Pe());var W=(c=c||"*").toString();if(O)throw g&&c?new Error("Request listener already exists for "+d+" on domain "+c.toString()+" for "+(g===Pe()?"wildcard":"specified")+" window"):g?new Error("Request listener already exists for "+d+" for "+(g===Pe()?"wildcard":"specified")+" window"):c?new Error("Request listener already exists for "+d+" on domain "+c.toString()):new Error("Request listener already exists for "+d);var M=p.getOrSet(g,function(){return{}}),P=le(M,d,function(){return{}}),R,G;return De(c)?(R=le(P,"__domain_regex__",function(){return[]})).push(G={regex:c,listener:s}):P[W]=s,{cancel:function(){delete P[W],G&&(R.splice(R.indexOf(G,1)),R.length||delete P.__domain_regex__),Object.keys(P).length||delete M[d],g&&!Object.keys(M).length&&p.del(g)}}}({name:e,win:r.window,domain:r.domain||"*"},{handler:n||r.handler,handleError:r.errorHandler||function(i){throw i}});return{cancel:function(){o.cancel()}}}function Di(e,r,n){typeof(r=r||{})=="function"&&(n=r,r={});var o=new I,i;return r.errorHandler=function(u){i.cancel(),o.reject(u)},i=k(e,r,function(u){if(i.cancel(),o.resolve(u),n)return n(u)}),o.cancel=i.cancel,o}var Z=function e(r,n,o,i){var u=(i=i||{}).domain||"*",s=i.timeout||-1,d=i.timeout||5e3,f=i.fireAndForget||!1;return $.toProxyWindow(r,{send:e}).awaitWindow().then(function(c){return I.try(function(){if(function(p,h,g){if(!p)throw new Error("Expected name");if(g&&typeof g!="string"&&!Array.isArray(g)&&!De(g))throw new TypeError("Can not send "+p+". Expected domain "+JSON.stringify(g)+" to be a string, array, or regex");if(H(h))throw new Error("Can not send "+p+". Target window is closed")}(n,c,u),function(p,h){var g=jn(h);if(g)return g===p;if(h===p||function(E){E===void 0&&(E=window);try{if(E.top)return E.top}catch{}if(Y(E)===E)return E;try{if(Nn(window,E)&&window.top)return window.top}catch{}try{if(Nn(E,window)&&window.top)return window.top}catch{}for(var A=0,_=function O(W){for(var M=[],P=0,R=Ln(W);P<R.length;P++){var G=R[P];M.push(G);for(var T=0,ve=O(G);T<ve.length;T++)M.push(ve[T])}return M}(E);A<_.length;A++){var C=_[A];try{if(C.top)return C.top}catch{}if(Y(C)===C)return C}}(h)===h)return!1;for(var m=0,b=Ln(p);m<b.length;m++)if(b[m]===h)return!0;return!1}(window,c))return function(p,h,g){h===void 0&&(h=5e3),g===void 0&&(g="Window");var m=function(b){return z("helloPromises").getOrSet(b,function(){return new I})}(p);return h!==-1&&(m=m.timeout(h,new Error(g+" did not load after "+h+"ms"))),m}(c,d)}).then(function(p){return function(h,g,m,b){var E=b.send;return I.try(function(){return typeof g=="string"?g:I.try(function(){return m||Me(h,{send:E}).then(function(A){return A.domain})}).then(function(A){if(!te(g,g))throw new Error("Domain "+Vn(g)+" does not match "+Vn(g));return A})})}(c,u,(p===void 0?{}:p).domain,{send:e})}).then(function(p){var h=p,g=n==="postrobot_method"&&o&&typeof o.name=="string"?o.name+"()":n,m=new I,b=n+"_"+V();if(!f){var E={name:n,win:c,domain:h,promise:m};(function(P,R){D("responseListeners").set(P,R)})(b,E);var A=z("requestPromises").getOrSet(c,function(){return[]});A.push(m),m.catch(function(){(function(P){D("erroredResponseListeners").set(P,!0)})(b),at(b)});var _=function(P){return z("knownWindows").get(P,!1)}(c)?1e4:2e3,C=s,O=_,W=C,M=function(P,R){var G;return function T(){G=setTimeout(function(){(function(){if(H(c))return m.reject(new Error("Window closed for "+n+" before "+(E.ack?"response":"ack")));if(E.cancelled)return m.reject(new Error("Response listener was cancelled for "+n));O=Math.max(O-500,0),W!==-1&&(W=Math.max(W-500,0)),E.ack||O!==0?W===0&&m.reject(new Error("No response for postMessage "+g+" in "+j()+" in "+C+"ms")):m.reject(new Error("No ack for postMessage "+g+" in "+j()+" in "+_+"ms"))})(),T()},500)}(),{cancel:function(){clearTimeout(G)}}}();m.finally(function(){M.cancel(),A.splice(A.indexOf(m,1))}).catch(X)}return Ue(c,h,{id:V(),origin:j(window),type:"postrobot_message_request",hash:b,name:n,data:o,fireAndForget:f},{on:k,send:e}).then(function(){return f?m.resolve():m},function(P){throw new Error("Send request message failed for "+g+" in "+j()+`
15
+ `+de(c))}}),_.try(function(){if(!s)throw new Error("No handler found for post message: "+n.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);return s.handler({source:e,origin:r,data:n.data})}).then(function(c){return f("success",c)},function(c){return f("error",null,c)})]).then(X).catch(function(c){if(s&&s.handleError)return s.handleError(c);throw c})}function Ci(e,r,n){if(!ct(n.hash)){var o=at(n.hash);if(!o)throw new Error("No handler found for post message ack for message: "+n.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);try{if(!te(o.domain,r))throw new Error("Ack origin "+r+" does not match domain "+o.domain.toString());if(e!==o.win)throw new Error("Ack source does not match registered window")}catch(i){o.promise.reject(i)}o.ack=!0}}function Di(e,r,n){if(!ct(n.hash)){var o=at(n.hash);if(!o)throw new Error("No handler found for post message response for message: "+n.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!te(o.domain,r))throw new Error("Response origin "+r+" does not match domain "+(i=o.domain,Array.isArray(i)?"("+i.join(" | ")+")":y(i)?"RegExp("+i.toString()+")":i.toString()));var i;if(e!==o.win)throw new Error("Response source does not match registered window");st(n.hash),n.ack==="error"?o.promise.reject(n.error):n.ack==="success"&&o.promise.resolve({source:e,origin:r,data:n.data})}}function dt(e,r){var n=r.on,o=r.send,i=D("receivedMessages");try{if(!window||window.closed||!e.source)return}catch{return}var u=e.source,s=e.origin,d=function(w,v,g,m){var A=m.on,E=m.send,b;try{b=ut(v,g,w,{on:A,send:E})}catch{return}if(b&&typeof b=="object"&&b!==null){var I=b.__post_robot_10_0_46__;if(Array.isArray(I))return I}}(e.data,u,s,{on:n,send:o});if(d){et(u);for(var f=0;f<d.length;f++){var c=d[f];if(i.has(c.id)||(i.set(c.id,!0),H(u)&&!c.fireAndForget))return;c.origin.indexOf("file:")===0&&(s="file://");try{c.type==="postrobot_message_request"?Ti(u,s,c,{on:n,send:o}):c.type==="postrobot_message_response"?Di(u,s,c):c.type==="postrobot_message_ack"&&Ci(u,s,c)}catch(w){setTimeout(function(){throw w},0)}}}}function V(e,r,n){if(!e)throw new Error("Expected name");if(typeof(r=r||{})=="function"&&(n=r,r={}),!n)throw new Error("Expected handler");var o=function i(u,s){var d=u.name,f=u.win,c=u.domain,w=z("requestListeners");if(!d||typeof d!="string")throw new Error("Name required to add request listener");if(f&&f!=="*"&&$.isProxyWindow(f)){var v=f.awaitWindow().then(function(T){return i({name:d,win:T,domain:c},s)});return{cancel:function(){v.then(function(T){return T.cancel()},X)}}}var g=f;if(Array.isArray(g)){for(var m=[],A=0,E=g;A<E.length;A++)m.push(i({name:d,domain:c,win:E[A]},s));return{cancel:function(){for(var T=0;T<m.length;T++)m[T].cancel()}}}if(Array.isArray(c)){for(var b=[],I=0,C=c;I<C.length;I++)b.push(i({name:d,win:g,domain:C[I]},s));return{cancel:function(){for(var T=0;T<b.length;T++)b[T].cancel()}}}var W=ft({name:d,win:g,domain:c});g&&g!=="*"||(g=Pe());var O=(c=c||"*").toString();if(W)throw g&&c?new Error("Request listener already exists for "+d+" on domain "+c.toString()+" for "+(g===Pe()?"wildcard":"specified")+" window"):g?new Error("Request listener already exists for "+d+" for "+(g===Pe()?"wildcard":"specified")+" window"):c?new Error("Request listener already exists for "+d+" on domain "+c.toString()):new Error("Request listener already exists for "+d);var M=w.getOrSet(g,function(){return{}}),P=le(M,d,function(){return{}}),R,G;return De(c)?(R=le(P,"__domain_regex__",function(){return[]})).push(G={regex:c,listener:s}):P[O]=s,{cancel:function(){delete P[O],G&&(R.splice(R.indexOf(G,1)),R.length||delete P.__domain_regex__),Object.keys(P).length||delete M[d],g&&!Object.keys(M).length&&w.del(g)}}}({name:e,win:r.window,domain:r.domain||"*"},{handler:n||r.handler,handleError:r.errorHandler||function(i){throw i}});return{cancel:function(){o.cancel()}}}function Mi(e,r,n){typeof(r=r||{})=="function"&&(n=r,r={});var o=new _,i;return r.errorHandler=function(u){i.cancel(),o.reject(u)},i=V(e,r,function(u){if(i.cancel(),o.resolve(u),n)return n(u)}),o.cancel=i.cancel,o}var Z=function e(r,n,o,i){var u=(i=i||{}).domain||"*",s=i.timeout||-1,d=i.timeout||5e3,f=i.fireAndForget||!1;return $.toProxyWindow(r,{send:e}).awaitWindow().then(function(c){return _.try(function(){if(function(w,v,g){if(!w)throw new Error("Expected name");if(g&&typeof g!="string"&&!Array.isArray(g)&&!De(g))throw new TypeError("Can not send "+w+". Expected domain "+JSON.stringify(g)+" to be a string, array, or regex");if(H(v))throw new Error("Can not send "+w+". Target window is closed")}(n,c,u),function(w,v){var g=zn(v);if(g)return g===w;if(v===w||function(E){E===void 0&&(E=window);try{if(E.top)return E.top}catch{}if(Y(E)===E)return E;try{if(Ln(window,E)&&window.top)return window.top}catch{}try{if(Ln(E,window)&&window.top)return window.top}catch{}for(var b=0,I=function W(O){for(var M=[],P=0,R=jn(O);P<R.length;P++){var G=R[P];M.push(G);for(var T=0,ve=W(G);T<ve.length;T++)M.push(ve[T])}return M}(E);b<I.length;b++){var C=I[b];try{if(C.top)return C.top}catch{}if(Y(C)===C)return C}}(v)===v)return!1;for(var m=0,A=jn(w);m<A.length;m++)if(A[m]===v)return!0;return!1}(window,c))return function(w,v,g){v===void 0&&(v=5e3),g===void 0&&(g="Window");var m=function(A){return z("helloPromises").getOrSet(A,function(){return new _})}(w);return v!==-1&&(m=m.timeout(v,new Error(g+" did not load after "+v+"ms"))),m}(c,d)}).then(function(w){return function(v,g,m,A){var E=A.send;return _.try(function(){return typeof g=="string"?g:_.try(function(){return m||Me(v,{send:E}).then(function(b){return b.domain})}).then(function(b){if(!te(g,g))throw new Error("Domain "+Vn(g)+" does not match "+Vn(g));return b})})}(c,u,(w===void 0?{}:w).domain,{send:e})}).then(function(w){var v=w,g=n==="postrobot_method"&&o&&typeof o.name=="string"?o.name+"()":n,m=new _,A=n+"_"+k();if(!f){var E={name:n,win:c,domain:v,promise:m};(function(P,R){D("responseListeners").set(P,R)})(A,E);var b=z("requestPromises").getOrSet(c,function(){return[]});b.push(m),m.catch(function(){(function(P){D("erroredResponseListeners").set(P,!0)})(A),st(A)});var I=function(P){return z("knownWindows").get(P,!1)}(c)?1e4:2e3,C=s,W=I,O=C,M=function(P,R){var G;return function T(){G=setTimeout(function(){(function(){if(H(c))return m.reject(new Error("Window closed for "+n+" before "+(E.ack?"response":"ack")));if(E.cancelled)return m.reject(new Error("Response listener was cancelled for "+n));W=Math.max(W-500,0),O!==-1&&(O=Math.max(O-500,0)),E.ack||W!==0?O===0&&m.reject(new Error("No response for postMessage "+g+" in "+j()+" in "+C+"ms")):m.reject(new Error("No ack for postMessage "+g+" in "+j()+" in "+I+"ms"))})(),T()},500)}(),{cancel:function(){clearTimeout(G)}}}();m.finally(function(){M.cancel(),b.splice(b.indexOf(m,1))}).catch(X)}return Ue(c,v,{id:k(),origin:j(window),type:"postrobot_message_request",hash:A,name:n,data:o,fireAndForget:f},{on:V,send:e}).then(function(){return f?m.resolve():m},function(P){throw new Error("Send request message failed for "+g+" in "+j()+`
16
16
 
17
- `+de(P))})})})};function Mi(e,r,n){return ot(e,r,n,{on:k,send:Z})}function Ni(e,r,n){return it(e,r,n,{on:k,send:Z})}function Li(e){return new $({send:Z,win:e})}function ji(e){return $.toProxyWindow(e,{send:Z})}function dt(){he().initialized||(he().initialized=!0,r=(e={on:k,send:Z}).on,n=e.send,(o=he()).receiveMessage=o.receiveMessage||function(i){return ft(i,{on:r,send:n})},function(i){var u=i.on,s=i.send;D().getOrSet("postMessageListener",function(){return function(d,f,c){return d.addEventListener("message",c),{cancel:function(){d.removeEventListener("message",c)}}}(window,0,function(d){(function(f,c){var p=c.on,h=c.send;I.try(function(){var g=f.source||f.sourceElement,m=f.origin||f.originalEvent&&f.originalEvent.origin,b=f.data;if(m==="null"&&(m="file://"),g){if(!m)throw new Error("Post message did not have origin domain");ft({source:g,origin:m,data:b},{on:p,send:h})}})})(d,{on:u,send:s})})})}({on:k,send:Z}),function(i){var u=i.on,s=i.send;D("builtinListeners").getOrSet("helloListener",function(){var d=u("postrobot_hello",{domain:"*"},function(c){return Qn(c.source,{domain:c.origin}),{instanceID:Bn()}}),f=jn();return f&&Me(f,{send:s}).catch(function(c){}),d})}({on:k,send:Z}));var e,r,n,o}function zi(){(function(){for(var r=D("responseListeners"),n=0,o=r.keys();n<o.length;n++){var i=o[n],u=r.get(i);u&&(u.cancelled=!0),r.del(i)}})(),(e=D().get("postMessageListener"))&&e.cancel();var e;delete window.__post_robot_10_0_46__}var Ui=!0;function qi(e){for(var r=0,n=z("requestPromises").get(e,[]);r<n.length;r++)n[r].reject(new Error("Window "+(H(e)?"closed":"cleaned up")+" before response")).catch(X)}dt()}])})})(xn);var ei=xn.exports;(function(t){t.exports=ei,t.exports.default=t.exports})(Sn);var ni=Sn.exports;const Pn=Ko(ni),ti="UI_MESSAGE",In={UI_SELECT_CONTENT:"ui_select_content"},ri={UI_CONTENT_SELECTED:"ui_content_selected"};async function oi(t={}){return(await Pn.send(window.parent,In.UI_SELECT_CONTENT,t)).data}function ii(t,a){return Pn.on(t,w=>a(w.data)).cancel}const ui=Object.freeze(Object.defineProperty({__proto__:null,on:ii,ui_select_content:oi},Symbol.toStringTag,{value:"Module"})),_n="ADMIN_MESSAGE",ai={ENV_CHANGED:"env_changed"},Oe={ADMIN_REQUEST:"ADMIN_REQUEST",ADMIN_RESPONSE:"ADMIN_RESPONSE"},Wn={GET_ENV:"get_env"};function si(t,a,l={timeout:1e4}){return new Promise((w,v)=>{if(typeof window>"u"){v(new Error("This function cannot be run on the server side."));return}const y=He(),S=L=>{L.data.type===Oe.ADMIN_RESPONSE&&L.data.id===y&&(window.removeEventListener("message",S),w(L.data.body))};window.addEventListener("message",S),window.parent.postMessage({type:Oe.ADMIN_REQUEST,id:y,body:{type:t,data:a??{}}},"*"),l.timeout&&setTimeout(()=>{window.removeEventListener("message",S),v(new Error(`Admin did not respond in the timeframe of ${l.timeout}ms. Check the handler on the Admin side.`))},l.timeout)})}const J={};function ci(t,a){J[t]||(J[t]=[]),J[t]?.push(a)}function fi(t,a){J[t]&&(J[t]=J[t]?.filter(l=>l!==a))}typeof window<"u"&&window.addEventListener("message",function(a){if(a.data.type!==_n)return;const l=J[a.data.body.type];l&&l.forEach(w=>w(a.data.body.data))});function di(){return si(Wn.GET_ENV)}const li=Object.freeze(Object.defineProperty({__proto__:null,get_env:di},Symbol.toStringTag,{value:"Module"})),hi="PITCHER_EVENT";var On=(t=>(t.REQUEST="PITCHER_REQUEST",t.RESPONSE="PITCHER_RESPONSE",t))(On||{}),Rn=(t=>(t.OK="ok",t.ERROR="error",t))(Rn||{}),Tn=(t=>(t.ENV_CHANGED="env_changed",t.PHOTOS_CAPTURED="photos_captured",t.FILE_DOWNLOADED="file_downloaded",t.FILE_UPLOAD_PROGRESS="file_upload_progress",t.UPDATE_LOCATION="update_location",t.CANVAS_UPDATED="canvas_updated",t))(Tn||{}),Cn=(t=>(t.UI_SHOW_MODAL="ui:show-modal",t.UI_HIDE_MODAL="ui:hide-modal",t.FAVORITES_CHANGED="favorites:changed",t.FILE_DOWNLOAD="file:download",t))(Cn||{}),Dn=(t=>(t.OPEN_CANVAS="open_canvas",t.START_CALL="start_call",t))(Dn||{});x.highLevelApi=void 0;function vi(t){return x.highLevelApi||(x.highLevelApi=Qo(t)),x.highLevelApi}function gi(){return ui}const pi={...li,on:ci,off:fi};function wi(){return pi}x.ADMIN_API_METHOD_TYPES=Wn,x.ADMIN_API_TYPES=Oe,x.ADMIN_MESSAGE=_n,x.ADMIN_MESSAGE_TYPES=ai,x.PITCHER_EVENT=hi,x.PitcherBroadcastedEventName=Cn,x.PitcherEventName=Tn,x.PitcherExternalEventName=Dn,x.PitcherMessageType=On,x.PitcherResponseStatus=Rn,x.UI_API_METHOD_TYPES=In,x.UI_MESSAGE=ti,x.UI_MESSAGE_TYPES=ri,x.useAdmin=wi,x.usePitcherApi=vi,x.useUi=gi,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
17
+ `+de(P))})})})};function Ni(e,r,n){return it(e,r,n,{on:V,send:Z})}function Li(e,r,n){return ut(e,r,n,{on:V,send:Z})}function ji(e){return new $({send:Z,win:e})}function zi(e){return $.toProxyWindow(e,{send:Z})}function lt(){he().initialized||(he().initialized=!0,r=(e={on:V,send:Z}).on,n=e.send,(o=he()).receiveMessage=o.receiveMessage||function(i){return dt(i,{on:r,send:n})},function(i){var u=i.on,s=i.send;D().getOrSet("postMessageListener",function(){return function(d,f,c){return d.addEventListener("message",c),{cancel:function(){d.removeEventListener("message",c)}}}(window,0,function(d){(function(f,c){var w=c.on,v=c.send;_.try(function(){var g=f.source||f.sourceElement,m=f.origin||f.originalEvent&&f.originalEvent.origin,A=f.data;if(m==="null"&&(m="file://"),g){if(!m)throw new Error("Post message did not have origin domain");dt({source:g,origin:m,data:A},{on:w,send:v})}})})(d,{on:u,send:s})})})}({on:V,send:Z}),function(i){var u=i.on,s=i.send;D("builtinListeners").getOrSet("helloListener",function(){var d=u("postrobot_hello",{domain:"*"},function(c){return Xn(c.source,{domain:c.origin}),{instanceID:Qn()}}),f=zn();return f&&Me(f,{send:s}).catch(function(c){}),d})}({on:V,send:Z}));var e,r,n,o}function Ui(){(function(){for(var r=D("responseListeners"),n=0,o=r.keys();n<o.length;n++){var i=o[n],u=r.get(i);u&&(u.cancelled=!0),r.del(i)}})(),(e=D().get("postMessageListener"))&&e.cancel();var e;delete window.__post_robot_10_0_46__}var qi=!0;function Fi(e){for(var r=0,n=z("requestPromises").get(e,[]);r<n.length;r++)n[r].reject(new Error("Window "+(H(e)?"closed":"cleaned up")+" before response")).catch(X)}lt()}])})})(Cn);var mi=Cn.exports;(function(t){t.exports=mi,t.exports.default=t.exports})(Tn);var Dn=Tn.exports;const Mn=re({__proto__:null,default:wi(Dn)},[Dn]);x.ADMIN_API_METHOD_TYPES=Pn,x.ADMIN_API_TYPES=We,x.ADMIN_MESSAGE=xn,x.ADMIN_MESSAGE_TYPES=ii,x.PITCHER_EVENT=di,x.PitcherBroadcastedEventName=Wn,x.PitcherEventName=On,x.PitcherExternalEventName=Rn,x.PitcherMessageType=_n,x.PitcherResponseStatus=In,x.UI_API_METHOD_TYPES=Sn,x.UI_MESSAGE=ei,x.UI_MESSAGE_TYPES=ni,x.useAdmin=gi,x.usePitcherApi=li,x.useUi=hi,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
18
18
  //# sourceMappingURL=js-api.umd.min.js.map