@twilio/conversations 3.0.0-canary.100 → 3.0.0-canary.2
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/builds/browser.js +599 -436
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +6 -2
- package/builds/lib.js +599 -436
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +3599 -2598
- package/builds/twilio-conversations.min.js +1 -1
- package/dist/client.js +6 -7
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +16 -9
- package/dist/command-executor.js.map +1 -1
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +1 -4
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/users.js +1 -3
- package/dist/data/users.js.map +1 -1
- package/dist/message.js +0 -1
- package/dist/message.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/participant.js +33 -33
- package/dist/participant.js.map +1 -1
- package/dist/rest-paginator.js +11 -11
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +95 -26
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +12 -6
- package/dist/services/typing-indicator.js.map +1 -1
- package/package.json +10 -10
@@ -126,4 +126,4 @@ This software includes platform.js under the following license.
|
|
126
126
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
127
127
|
|
128
128
|
*/
|
129
|
-
this.Twilio=this.Twilio||{},this.Twilio.Conversations=function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}var r=function(e){return e&&e.Math==Math&&e},i=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof t&&t)||function(){return this}()||Function("return this")(),a={},o=function(e){try{return!!e()}catch(e){return!0}},s=!o((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),u=!o((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),c=u,l=Function.prototype.call,f=c?l.bind(l):function(){return l.apply(l,arguments)},d={},p={}.propertyIsEnumerable,h=Object.getOwnPropertyDescriptor,v=h&&!p.call({1:2},1);d.f=v?function(e){var t=h(this,e);return!!t&&t.enumerable}:p;var y,m,g=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},b=u,w=Function.prototype,k=w.call,x=b&&w.bind.bind(k,k),_=function(e){return b?x(e):function(){return k.apply(e,arguments)}},S=_,O=S({}.toString),E=S("".slice),T=function(e){return E(O(e),8,-1)},R=T,I=_,C=function(e){if("Function"===R(e))return I(e)},P=o,A=T,j=Object,M=C("".split),L=P((function(){return!j("z").propertyIsEnumerable(0)}))?function(e){return"String"==A(e)?M(e,""):j(e)}:j,U=function(e){return null==e},N=U,F=TypeError,D=function(e){if(N(e))throw F("Can't call method on "+e);return e},q=L,B=D,z=function(e){return q(B(e))},W="object"==typeof document&&document.all,$={all:W,IS_HTMLDDA:void 0===W&&void 0!==W},K=$.all,H=$.IS_HTMLDDA?function(e){return"function"==typeof e||e===K}:function(e){return"function"==typeof e},G=H,V=$.all,Y=$.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:G(e)||e===V}:function(e){return"object"==typeof e?null!==e:G(e)},J=i,Q=H,X=function(e){return Q(e)?e:void 0},Z=function(e,t){return arguments.length<2?X(J[e]):J[e]&&J[e][t]},ee=C({}.isPrototypeOf),te=Z("navigator","userAgent")||"",ne=i,re=te,ie=ne.process,ae=ne.Deno,oe=ie&&ie.versions||ae&&ae.version,se=oe&&oe.v8;se&&(m=(y=se.split("."))[0]>0&&y[0]<4?1:+(y[0]+y[1])),!m&&re&&(!(y=re.match(/Edge\/(\d+)/))||y[1]>=74)&&(y=re.match(/Chrome\/(\d+)/))&&(m=+y[1]);var ue=m,ce=ue,le=o,fe=!!Object.getOwnPropertySymbols&&!le((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ce&&ce<41})),de=fe&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,pe=Z,he=H,ve=ee,ye=Object,me=de?function(e){return"symbol"==typeof e}:function(e){var t=pe("Symbol");return he(t)&&ve(t.prototype,ye(e))},ge=String,be=function(e){try{return ge(e)}catch(e){return"Object"}},we=H,ke=be,xe=TypeError,_e=function(e){if(we(e))return e;throw xe(ke(e)+" is not a function")},Se=_e,Oe=U,Ee=function(e,t){var n=e[t];return Oe(n)?void 0:Se(n)},Te=f,Re=H,Ie=Y,Ce=TypeError,Pe={exports:{}},Ae=i,je=Object.defineProperty,Me=function(e,t){try{je(Ae,e,{value:t,configurable:!0,writable:!0})}catch(n){Ae[e]=t}return t},Le=Me,Ue="__core-js_shared__",Ne=i[Ue]||Le(Ue,{}),Fe=Ne;(Pe.exports=function(e,t){return Fe[e]||(Fe[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.25.5",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.25.5/LICENSE",source:"https://github.com/zloirock/core-js"});var De=D,qe=Object,Be=function(e){return qe(De(e))},ze=Be,We=C({}.hasOwnProperty),$e=Object.hasOwn||function(e,t){return We(ze(e),t)},Ke=C,He=0,Ge=Math.random(),Ve=Ke(1..toString),Ye=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Ve(++He+Ge,36)},Je=i,Qe=Pe.exports,Xe=$e,Ze=Ye,et=fe,tt=de,nt=Qe("wks"),rt=Je.Symbol,it=rt&&rt.for,at=tt?rt:rt&&rt.withoutSetter||Ze,ot=function(e){if(!Xe(nt,e)||!et&&"string"!=typeof nt[e]){var t="Symbol."+e;et&&Xe(rt,e)?nt[e]=rt[e]:nt[e]=tt&&it?it(t):at(t)}return nt[e]},st=f,ut=Y,ct=me,lt=Ee,ft=function(e,t){var n,r;if("string"===t&&Re(n=e.toString)&&!Ie(r=Te(n,e)))return r;if(Re(n=e.valueOf)&&!Ie(r=Te(n,e)))return r;if("string"!==t&&Re(n=e.toString)&&!Ie(r=Te(n,e)))return r;throw Ce("Can't convert object to primitive value")},dt=TypeError,pt=ot("toPrimitive"),ht=function(e,t){if(!ut(e)||ct(e))return e;var n,r=lt(e,pt);if(r){if(void 0===t&&(t="default"),n=st(r,e,t),!ut(n)||ct(n))return n;throw dt("Can't convert object to primitive value")}return void 0===t&&(t="number"),ft(e,t)},vt=ht,yt=me,mt=function(e){var t=vt(e,"string");return yt(t)?t:t+""},gt=Y,bt=i.document,wt=gt(bt)&>(bt.createElement),kt=function(e){return wt?bt.createElement(e):{}},xt=kt,_t=!s&&!o((function(){return 7!=Object.defineProperty(xt("div"),"a",{get:function(){return 7}}).a})),St=s,Ot=f,Et=d,Tt=g,Rt=z,It=mt,Ct=$e,Pt=_t,At=Object.getOwnPropertyDescriptor;a.f=St?At:function(e,t){if(e=Rt(e),t=It(t),Pt)try{return At(e,t)}catch(e){}if(Ct(e,t))return Tt(!Ot(Et.f,e,t),e[t])};var jt={},Mt=s&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Lt=Y,Ut=String,Nt=TypeError,Ft=function(e){if(Lt(e))return e;throw Nt(Ut(e)+" is not an object")},Dt=s,qt=_t,Bt=Mt,zt=Ft,Wt=mt,$t=TypeError,Kt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Gt="enumerable",Vt="configurable",Yt="writable";jt.f=Dt?Bt?function(e,t,n){if(zt(e),t=Wt(t),zt(n),"function"==typeof e&&"prototype"===t&&"value"in n&&Yt in n&&!n.writable){var r=Ht(e,t);r&&r.writable&&(e[t]=n.value,n={configurable:Vt in n?n.configurable:r.configurable,enumerable:Gt in n?n.enumerable:r.enumerable,writable:!1})}return Kt(e,t,n)}:Kt:function(e,t,n){if(zt(e),t=Wt(t),zt(n),qt)try{return Kt(e,t,n)}catch(e){}if("get"in n||"set"in n)throw $t("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var Jt=jt,Qt=g,Xt=s?function(e,t,n){return Jt.f(e,t,Qt(1,n))}:function(e,t,n){return e[t]=n,e},Zt={exports:{}},en=s,tn=$e,nn=Function.prototype,rn=en&&Object.getOwnPropertyDescriptor,an=tn(nn,"name"),on={EXISTS:an,PROPER:an&&"something"===function(){}.name,CONFIGURABLE:an&&(!en||en&&rn(nn,"name").configurable)},sn=H,un=Ne,cn=C(Function.toString);sn(un.inspectSource)||(un.inspectSource=function(e){return cn(e)});var ln,fn,dn,pn=un.inspectSource,hn=H,vn=i.WeakMap,yn=hn(vn)&&/native code/.test(String(vn)),mn=Pe.exports,gn=Ye,bn=mn("keys"),wn=function(e){return bn[e]||(bn[e]=gn(e))},kn={},xn=yn,_n=i,Sn=Y,On=Xt,En=$e,Tn=Ne,Rn=wn,In=kn,Cn="Object already initialized",Pn=_n.TypeError,An=_n.WeakMap;if(xn||Tn.state){var jn=Tn.state||(Tn.state=new An);jn.get=jn.get,jn.has=jn.has,jn.set=jn.set,ln=function(e,t){if(jn.has(e))throw Pn(Cn);return t.facade=e,jn.set(e,t),t},fn=function(e){return jn.get(e)||{}},dn=function(e){return jn.has(e)}}else{var Mn=Rn("state");In[Mn]=!0,ln=function(e,t){if(En(e,Mn))throw Pn(Cn);return t.facade=e,On(e,Mn,t),t},fn=function(e){return En(e,Mn)?e[Mn]:{}},dn=function(e){return En(e,Mn)}}var Ln={set:ln,get:fn,has:dn,enforce:function(e){return dn(e)?fn(e):ln(e,{})},getterFor:function(e){return function(t){var n;if(!Sn(t)||(n=fn(t)).type!==e)throw Pn("Incompatible receiver, "+e+" required");return n}}},Un=o,Nn=H,Fn=$e,Dn=s,qn=on.CONFIGURABLE,Bn=pn,zn=Ln.enforce,Wn=Ln.get,$n=Object.defineProperty,Kn=Dn&&!Un((function(){return 8!==$n((function(){}),"length",{value:8}).length})),Hn=String(String).split("String"),Gn=Zt.exports=function(e,t,n){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!Fn(e,"name")||qn&&e.name!==t)&&(Dn?$n(e,"name",{value:t,configurable:!0}):e.name=t),Kn&&n&&Fn(n,"arity")&&e.length!==n.arity&&$n(e,"length",{value:n.arity});try{n&&Fn(n,"constructor")&&n.constructor?Dn&&$n(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var r=zn(e);return Fn(r,"source")||(r.source=Hn.join("string"==typeof t?t:"")),e};Function.prototype.toString=Gn((function(){return Nn(this)&&Wn(this).source||Bn(this)}),"toString");var Vn=H,Yn=jt,Jn=Zt.exports,Qn=Me,Xn=function(e,t,n,r){r||(r={});var i=r.enumerable,a=void 0!==r.name?r.name:t;if(Vn(n)&&Jn(n,a,r),r.global)i?e[t]=n:Qn(t,n);else{try{r.unsafe?e[t]&&(i=!0):delete e[t]}catch(e){}i?e[t]=n:Yn.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},Zn={},er=Math.ceil,tr=Math.floor,nr=Math.trunc||function(e){var t=+e;return(t>0?tr:er)(t)},rr=nr,ir=function(e){var t=+e;return t!=t||0===t?0:rr(t)},ar=ir,or=Math.max,sr=Math.min,ur=function(e,t){var n=ar(e);return n<0?or(n+t,0):sr(n,t)},cr=ir,lr=Math.min,fr=function(e){return e>0?lr(cr(e),9007199254740991):0},dr=fr,pr=function(e){return dr(e.length)},hr=z,vr=ur,yr=pr,mr=function(e){return function(t,n,r){var i,a=hr(t),o=yr(a),s=vr(r,o);if(e&&n!=n){for(;o>s;)if((i=a[s++])!=i)return!0}else for(;o>s;s++)if((e||s in a)&&a[s]===n)return e||s||0;return!e&&-1}},gr={includes:mr(!0),indexOf:mr(!1)},br=$e,wr=z,kr=gr.indexOf,xr=kn,_r=C([].push),Sr=function(e,t){var n,r=wr(e),i=0,a=[];for(n in r)!br(xr,n)&&br(r,n)&&_r(a,n);for(;t.length>i;)br(r,n=t[i++])&&(~kr(a,n)||_r(a,n));return a},Or=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Er=Sr,Tr=Or.concat("length","prototype");Zn.f=Object.getOwnPropertyNames||function(e){return Er(e,Tr)};var Rr={};Rr.f=Object.getOwnPropertySymbols;var Ir=Z,Cr=Zn,Pr=Rr,Ar=Ft,jr=C([].concat),Mr=Ir("Reflect","ownKeys")||function(e){var t=Cr.f(Ar(e)),n=Pr.f;return n?jr(t,n(e)):t},Lr=$e,Ur=Mr,Nr=a,Fr=jt,Dr=function(e,t,n){for(var r=Ur(t),i=Fr.f,a=Nr.f,o=0;o<r.length;o++){var s=r[o];Lr(e,s)||n&&Lr(n,s)||i(e,s,a(t,s))}},qr=o,Br=H,zr=/#|\.prototype\./,Wr=function(e,t){var n=Kr[$r(e)];return n==Gr||n!=Hr&&(Br(t)?qr(t):!!t)},$r=Wr.normalize=function(e){return String(e).replace(zr,".").toLowerCase()},Kr=Wr.data={},Hr=Wr.NATIVE="N",Gr=Wr.POLYFILL="P",Vr=Wr,Yr=i,Jr=a.f,Qr=Xt,Xr=Xn,Zr=Me,ei=Dr,ti=Vr,ni=function(e,t){var n,r,i,a,o,s=e.target,u=e.global,c=e.stat;if(n=u?Yr:c?Yr[s]||Zr(s,{}):(Yr[s]||{}).prototype)for(r in t){if(a=t[r],i=e.dontCallGetSet?(o=Jr(n,r))&&o.value:n[r],!ti(u?r:s+(c?".":"#")+r,e.forced)&&void 0!==i){if(typeof a==typeof i)continue;ei(a,i)}(e.sham||i&&i.sham)&&Qr(a,"sham",!0),Xr(n,r,a,e)}},ri=jt.f,ii=$e,ai=ot("toStringTag"),oi=function(e,t,n){e&&!n&&(e=e.prototype),e&&!ii(e,ai)&&ri(e,ai,{configurable:!0,value:t})},si=i,ui=oi;ni({global:!0},{Reflect:{}}),ui(si.Reflect,"Reflect",!0);var ci=u,li=Function.prototype,fi=li.apply,di=li.call,pi="object"==typeof Reflect&&Reflect.apply||(ci?di.bind(fi):function(){return di.apply(fi,arguments)}),hi=C([].slice),vi=C,yi=_e,mi=Y,gi=$e,bi=hi,wi=u,ki=Function,xi=vi([].concat),_i=vi([].join),Si={},Oi=function(e,t,n){if(!gi(Si,t)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";Si[t]=ki("C,a","return new C("+_i(r,",")+")")}return Si[t](e,n)},Ei=wi?ki.bind:function(e){var t=yi(this),n=t.prototype,r=bi(arguments,1),i=function(){var n=xi(r,bi(arguments));return this instanceof i?Oi(t,n.length,n):t.apply(e,n)};return mi(n)&&(i.prototype=n),i},Ti={};Ti[ot("toStringTag")]="z";var Ri="[object z]"===String(Ti),Ii=Ri,Ci=H,Pi=T,Ai=ot("toStringTag"),ji=Object,Mi="Arguments"==Pi(function(){return arguments}()),Li=Ii?Pi:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=ji(e),Ai))?n:Mi?Pi(t):"Object"==(r=Pi(t))&&Ci(t.callee)?"Arguments":r},Ui=C,Ni=o,Fi=H,Di=Li,qi=pn,Bi=function(){},zi=[],Wi=Z("Reflect","construct"),$i=/^\s*(?:class|function)\b/,Ki=Ui($i.exec),Hi=!$i.exec(Bi),Gi=function(e){if(!Fi(e))return!1;try{return Wi(Bi,zi,e),!0}catch(e){return!1}},Vi=function(e){if(!Fi(e))return!1;switch(Di(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Hi||!!Ki($i,qi(e))}catch(e){return!0}};Vi.sham=!0;var Yi=!Wi||Ni((function(){var e;return Gi(Gi.call)||!Gi(Object)||!Gi((function(){e=!0}))||e}))?Vi:Gi,Ji=Yi,Qi=be,Xi=TypeError,Zi=function(e){if(Ji(e))return e;throw Xi(Qi(e)+" is not a constructor")},ea={},ta=Sr,na=Or,ra=Object.keys||function(e){return ta(e,na)},ia=s,aa=Mt,oa=jt,sa=Ft,ua=z,ca=ra;ea.f=ia&&!aa?Object.defineProperties:function(e,t){sa(e);for(var n,r=ua(t),i=ca(t),a=i.length,o=0;a>o;)oa.f(e,n=i[o++],r[n]);return e};var la,fa=Z("document","documentElement"),da=Ft,pa=ea,ha=Or,va=kn,ya=fa,ma=kt,ga=wn("IE_PROTO"),ba=function(){},wa=function(e){return"<script>"+e+"</"+"script>"},ka=function(e){e.write(wa("")),e.close();var t=e.parentWindow.Object;return e=null,t},xa=function(){try{la=new ActiveXObject("htmlfile")}catch(e){}var e,t;xa="undefined"!=typeof document?document.domain&&la?ka(la):((t=ma("iframe")).style.display="none",ya.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(wa("document.F=Object")),e.close(),e.F):ka(la);for(var n=ha.length;n--;)delete xa.prototype[ha[n]];return xa()};va[ga]=!0;var _a=Object.create||function(e,t){var n;return null!==e?(ba.prototype=da(e),n=new ba,ba.prototype=null,n[ga]=e):n=xa(),void 0===t?n:pa.f(n,t)},Sa=ni,Oa=pi,Ea=Ei,Ta=Zi,Ra=Ft,Ia=Y,Ca=_a,Pa=o,Aa=Z("Reflect","construct"),ja=Object.prototype,Ma=[].push,La=Pa((function(){function e(){}return!(Aa((function(){}),[],e)instanceof e)})),Ua=!Pa((function(){Aa((function(){}))})),Na=La||Ua;Sa({target:"Reflect",stat:!0,forced:Na,sham:Na},{construct:function(e,t){Ta(e),Ra(t);var n=arguments.length<3?e:Ta(arguments[2]);if(Ua&&!La)return Aa(e,t,n);if(e==n){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var r=[null];return Oa(Ma,r,t),new(Oa(Ea,e,r))}var i=n.prototype,a=Ca(Ia(i)?i:ja),o=Oa(e,a,t);return Ia(o)?o:a}});var Fa=Be,Da=ra;ni({target:"Object",stat:!0,forced:o((function(){Da(1)}))},{keys:function(e){return Da(Fa(e))}});var qa=Li,Ba=String,za=function(e){if("Symbol"===qa(e))throw TypeError("Cannot convert a Symbol value to a string");return Ba(e)},Wa={},$a=mt,Ka=jt,Ha=g,Ga=function(e,t,n){var r=$a(t);r in e?Ka.f(e,r,Ha(0,n)):e[r]=n},Va=ur,Ya=pr,Ja=Ga,Qa=Array,Xa=Math.max,Za=function(e,t,n){for(var r=Ya(e),i=Va(t,r),a=Va(void 0===n?r:n,r),o=Qa(Xa(a-i,0)),s=0;i<a;i++,s++)Ja(o,s,e[i]);return o.length=s,o},eo=T,to=z,no=Zn.f,ro=Za,io="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Wa.f=function(e){return io&&"Window"==eo(e)?function(e){try{return no(e)}catch(e){return ro(io)}}(e):no(to(e))};var ao={},oo=ot;ao.f=oo;var so=i,uo=$e,co=ao,lo=jt.f,fo=function(e){var t=so.Symbol||(so.Symbol={});uo(t,e)||lo(t,e,{value:co.f(e)})},po=f,ho=Z,vo=ot,yo=Xn,mo=_e,go=u,bo=C(C.bind),wo=function(e,t){return mo(e),void 0===t?e:go?bo(e,t):function(){return e.apply(t,arguments)}},ko=T,xo=Array.isArray||function(e){return"Array"==ko(e)},_o=xo,So=Yi,Oo=Y,Eo=ot("species"),To=Array,Ro=function(e){var t;return _o(e)&&(t=e.constructor,(So(t)&&(t===To||_o(t.prototype))||Oo(t)&&null===(t=t[Eo]))&&(t=void 0)),void 0===t?To:t},Io=function(e,t){return new(Ro(e))(0===t?0:t)},Co=wo,Po=L,Ao=Be,jo=pr,Mo=Io,Lo=C([].push),Uo=function(e){var t=1==e,n=2==e,r=3==e,i=4==e,a=6==e,o=7==e,s=5==e||a;return function(u,c,l,f){for(var d,p,h=Ao(u),v=Po(h),y=Co(c,l),m=jo(v),g=0,b=f||Mo,w=t?b(u,m):n||o?b(u,0):void 0;m>g;g++)if((s||g in v)&&(p=y(d=v[g],g,h),e))if(t)w[g]=p;else if(p)switch(e){case 3:return!0;case 5:return d;case 6:return g;case 2:Lo(w,d)}else switch(e){case 4:return!1;case 7:Lo(w,d)}return a?-1:r||i?i:w}},No={forEach:Uo(0),map:Uo(1),filter:Uo(2),some:Uo(3),every:Uo(4),find:Uo(5),findIndex:Uo(6),filterReject:Uo(7)},Fo=ni,Do=i,qo=f,Bo=C,zo=s,Wo=fe,$o=o,Ko=$e,Ho=ee,Go=Ft,Vo=z,Yo=mt,Jo=za,Qo=g,Xo=_a,Zo=ra,es=Zn,ts=Wa,ns=Rr,rs=a,is=jt,as=ea,os=d,ss=Xn,us=Pe.exports,cs=kn,ls=Ye,fs=ot,ds=ao,ps=fo,hs=function(){var e=ho("Symbol"),t=e&&e.prototype,n=t&&t.valueOf,r=vo("toPrimitive");t&&!t[r]&&yo(t,r,(function(e){return po(n,this)}),{arity:1})},vs=oi,ys=Ln,ms=No.forEach,gs=wn("hidden"),bs="Symbol",ws=ys.set,ks=ys.getterFor(bs),xs=Object.prototype,_s=Do.Symbol,Ss=_s&&_s.prototype,Os=Do.TypeError,Es=Do.QObject,Ts=rs.f,Rs=is.f,Is=ts.f,Cs=os.f,Ps=Bo([].push),As=us("symbols"),js=us("op-symbols"),Ms=us("wks"),Ls=!Es||!Es.prototype||!Es.prototype.findChild,Us=zo&&$o((function(){return 7!=Xo(Rs({},"a",{get:function(){return Rs(this,"a",{value:7}).a}})).a}))?function(e,t,n){var r=Ts(xs,t);r&&delete xs[t],Rs(e,t,n),r&&e!==xs&&Rs(xs,t,r)}:Rs,Ns=function(e,t){var n=As[e]=Xo(Ss);return ws(n,{type:bs,tag:e,description:t}),zo||(n.description=t),n},Fs=function(e,t,n){e===xs&&Fs(js,t,n),Go(e);var r=Yo(t);return Go(n),Ko(As,r)?(n.enumerable?(Ko(e,gs)&&e[gs][r]&&(e[gs][r]=!1),n=Xo(n,{enumerable:Qo(0,!1)})):(Ko(e,gs)||Rs(e,gs,Qo(1,{})),e[gs][r]=!0),Us(e,r,n)):Rs(e,r,n)},Ds=function(e,t){Go(e);var n=Vo(t),r=Zo(n).concat(Ws(n));return ms(r,(function(t){zo&&!qo(qs,n,t)||Fs(e,t,n[t])})),e},qs=function(e){var t=Yo(e),n=qo(Cs,this,t);return!(this===xs&&Ko(As,t)&&!Ko(js,t))&&(!(n||!Ko(this,t)||!Ko(As,t)||Ko(this,gs)&&this[gs][t])||n)},Bs=function(e,t){var n=Vo(e),r=Yo(t);if(n!==xs||!Ko(As,r)||Ko(js,r)){var i=Ts(n,r);return!i||!Ko(As,r)||Ko(n,gs)&&n[gs][r]||(i.enumerable=!0),i}},zs=function(e){var t=Is(Vo(e)),n=[];return ms(t,(function(e){Ko(As,e)||Ko(cs,e)||Ps(n,e)})),n},Ws=function(e){var t=e===xs,n=Is(t?js:Vo(e)),r=[];return ms(n,(function(e){!Ko(As,e)||t&&!Ko(xs,e)||Ps(r,As[e])})),r};Wo||(_s=function(){if(Ho(Ss,this))throw Os("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Jo(arguments[0]):void 0,t=ls(e),n=function(e){this===xs&&qo(n,js,e),Ko(this,gs)&&Ko(this[gs],t)&&(this[gs][t]=!1),Us(this,t,Qo(1,e))};return zo&&Ls&&Us(xs,t,{configurable:!0,set:n}),Ns(t,e)},ss(Ss=_s.prototype,"toString",(function(){return ks(this).tag})),ss(_s,"withoutSetter",(function(e){return Ns(ls(e),e)})),os.f=qs,is.f=Fs,as.f=Ds,rs.f=Bs,es.f=ts.f=zs,ns.f=Ws,ds.f=function(e){return Ns(fs(e),e)},zo&&(Rs(Ss,"description",{configurable:!0,get:function(){return ks(this).description}}),ss(xs,"propertyIsEnumerable",qs,{unsafe:!0}))),Fo({global:!0,constructor:!0,wrap:!0,forced:!Wo,sham:!Wo},{Symbol:_s}),ms(Zo(Ms),(function(e){ps(e)})),Fo({target:bs,stat:!0,forced:!Wo},{useSetter:function(){Ls=!0},useSimple:function(){Ls=!1}}),Fo({target:"Object",stat:!0,forced:!Wo,sham:!zo},{create:function(e,t){return void 0===t?Xo(e):Ds(Xo(e),t)},defineProperty:Fs,defineProperties:Ds,getOwnPropertyDescriptor:Bs}),Fo({target:"Object",stat:!0,forced:!Wo},{getOwnPropertyNames:zs}),hs(),vs(_s,bs),cs[gs]=!0;var $s=fe&&!!Symbol.for&&!!Symbol.keyFor,Ks=ni,Hs=Z,Gs=$e,Vs=za,Ys=Pe.exports,Js=$s,Qs=Ys("string-to-symbol-registry"),Xs=Ys("symbol-to-string-registry");Ks({target:"Symbol",stat:!0,forced:!Js},{for:function(e){var t=Vs(e);if(Gs(Qs,t))return Qs[t];var n=Hs("Symbol")(t);return Qs[t]=n,Xs[n]=t,n}});var Zs=ni,eu=$e,tu=me,nu=be,ru=$s,iu=(0,Pe.exports)("symbol-to-string-registry");Zs({target:"Symbol",stat:!0,forced:!ru},{keyFor:function(e){if(!tu(e))throw TypeError(nu(e)+" is not a symbol");if(eu(iu,e))return iu[e]}});var au=ni,ou=Z,su=pi,uu=f,cu=C,lu=o,fu=xo,du=H,pu=Y,hu=me,vu=hi,yu=fe,mu=ou("JSON","stringify"),gu=cu(/./.exec),bu=cu("".charAt),wu=cu("".charCodeAt),ku=cu("".replace),xu=cu(1..toString),_u=/[\uD800-\uDFFF]/g,Su=/^[\uD800-\uDBFF]$/,Ou=/^[\uDC00-\uDFFF]$/,Eu=!yu||lu((function(){var e=ou("Symbol")();return"[null]"!=mu([e])||"{}"!=mu({a:e})||"{}"!=mu(Object(e))})),Tu=lu((function(){return'"\\udf06\\ud834"'!==mu("\udf06\ud834")||'"\\udead"'!==mu("\udead")})),Ru=function(e,t){var n=vu(arguments),r=t;if((pu(t)||void 0!==e)&&!hu(e))return fu(t)||(t=function(e,t){if(du(r)&&(t=uu(r,this,e,t)),!hu(t))return t}),n[1]=t,su(mu,null,n)},Iu=function(e,t,n){var r=bu(n,t-1),i=bu(n,t+1);return gu(Su,e)&&!gu(Ou,i)||gu(Ou,e)&&!gu(Su,r)?"\\u"+xu(wu(e,0),16):e};mu&&au({target:"JSON",stat:!0,arity:3,forced:Eu||Tu},{stringify:function(e,t,n){var r=vu(arguments),i=su(Eu?Ru:mu,null,r);return Tu&&"string"==typeof i?ku(i,_u,Iu):i}});var Cu=Rr,Pu=Be;ni({target:"Object",stat:!0,forced:!fe||o((function(){Cu.f(1)}))},{getOwnPropertySymbols:function(e){var t=Cu.f;return t?t(Pu(e)):[]}});var Au=o,ju=ue,Mu=ot("species"),Lu=function(e){return ju>=51||!Au((function(){var t=[];return(t.constructor={})[Mu]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Uu=No.filter;ni({target:"Array",proto:!0,forced:!Lu("filter")},{filter:function(e){return Uu(this,e,arguments.length>1?arguments[1]:void 0)}});var Nu=ni,Fu=o,Du=z,qu=a.f,Bu=s,zu=Fu((function(){qu(1)}));Nu({target:"Object",stat:!0,forced:!Bu||zu,sham:!Bu},{getOwnPropertyDescriptor:function(e,t){return qu(Du(e),t)}});var Wu=Mr,$u=z,Ku=a,Hu=Ga;function Gu(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function Vu(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Gu(a,r,i,o,s,"next",e)}function s(e){Gu(a,r,i,o,s,"throw",e)}o(void 0)}))}}function Yu(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ju(e,t){return Ju=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ju(e,t)}function Qu(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ju(e,t)}function Xu(e){return Xu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xu(e)}function Zu(e,t){if(t&&("object"===Xu(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Yu(e)}function ec(e){return ec=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ec(e)}function tc(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function nc(e,t,n){return t&&tc(e.prototype,t),n&&tc(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function rc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ic(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}ni({target:"Object",stat:!0,sham:!s},{getOwnPropertyDescriptors:function(e){for(var t,n,r=$u(e),i=Ku.f,a=Wu(r),o={},s=0;a.length>s;)void 0!==(n=i(r,t=a[s++]))&&Hu(o,t,n);return o}});var ac=Li,oc=Ri?{}.toString:function(){return"[object "+ac(this)+"]"};Ri||Xn(Object.prototype,"toString",oc,{unsafe:!0});var sc,uc,cc,lc,fc="process"==T(i.process),dc=H,pc=String,hc=TypeError,vc=C,yc=Ft,mc=function(e){if("object"==typeof e||dc(e))return e;throw hc("Can't set "+pc(e)+" as a prototype")},gc=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=vc(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),t=n instanceof Array}catch(e){}return function(n,r){return yc(n),mc(r),t?e(n,r):n.__proto__=r,n}}():void 0),bc=Z,wc=jt,kc=s,xc=ot("species"),_c=function(e){var t=bc(e),n=wc.f;kc&&t&&!t[xc]&&n(t,xc,{configurable:!0,get:function(){return this}})},Sc=ee,Oc=TypeError,Ec=function(e,t){if(Sc(t,e))return e;throw Oc("Incorrect invocation")},Tc=Ft,Rc=Zi,Ic=U,Cc=ot("species"),Pc=function(e,t){var n,r=Tc(e).constructor;return void 0===r||Ic(n=Tc(r)[Cc])?t:Rc(n)},Ac=TypeError,jc=function(e,t){if(e<t)throw Ac("Not enough arguments");return e},Mc=/(?:ipad|iphone|ipod).*applewebkit/i.test(te),Lc=i,Uc=pi,Nc=wo,Fc=H,Dc=$e,qc=o,Bc=fa,zc=hi,Wc=kt,$c=jc,Kc=Mc,Hc=fc,Gc=Lc.setImmediate,Vc=Lc.clearImmediate,Yc=Lc.process,Jc=Lc.Dispatch,Qc=Lc.Function,Xc=Lc.MessageChannel,Zc=Lc.String,el=0,tl={},nl="onreadystatechange";try{sc=Lc.location}catch(e){}var rl=function(e){if(Dc(tl,e)){var t=tl[e];delete tl[e],t()}},il=function(e){return function(){rl(e)}},al=function(e){rl(e.data)},ol=function(e){Lc.postMessage(Zc(e),sc.protocol+"//"+sc.host)};Gc&&Vc||(Gc=function(e){$c(arguments.length,1);var t=Fc(e)?e:Qc(e),n=zc(arguments,1);return tl[++el]=function(){Uc(t,void 0,n)},uc(el),el},Vc=function(e){delete tl[e]},Hc?uc=function(e){Yc.nextTick(il(e))}:Jc&&Jc.now?uc=function(e){Jc.now(il(e))}:Xc&&!Kc?(lc=(cc=new Xc).port2,cc.port1.onmessage=al,uc=Nc(lc.postMessage,lc)):Lc.addEventListener&&Fc(Lc.postMessage)&&!Lc.importScripts&&sc&&"file:"!==sc.protocol&&!qc(ol)?(uc=ol,Lc.addEventListener("message",al,!1)):uc=nl in Wc("script")?function(e){Bc.appendChild(Wc("script")).onreadystatechange=function(){Bc.removeChild(this),rl(e)}}:function(e){setTimeout(il(e),0)});var sl,ul,cl,ll,fl,dl,pl,hl,vl={set:Gc,clear:Vc},yl=i,ml=/ipad|iphone|ipod/i.test(te)&&void 0!==yl.Pebble,gl=/web0s(?!.*chrome)/i.test(te),bl=i,wl=wo,kl=a.f,xl=vl.set,_l=Mc,Sl=ml,Ol=gl,El=fc,Tl=bl.MutationObserver||bl.WebKitMutationObserver,Rl=bl.document,Il=bl.process,Cl=bl.Promise,Pl=kl(bl,"queueMicrotask"),Al=Pl&&Pl.value;Al||(sl=function(){var e,t;for(El&&(e=Il.domain)&&e.exit();ul;){t=ul.fn,ul=ul.next;try{t()}catch(e){throw ul?ll():cl=void 0,e}}cl=void 0,e&&e.enter()},_l||El||Ol||!Tl||!Rl?!Sl&&Cl&&Cl.resolve?((pl=Cl.resolve(void 0)).constructor=Cl,hl=wl(pl.then,pl),ll=function(){hl(sl)}):El?ll=function(){Il.nextTick(sl)}:(xl=wl(xl,bl),ll=function(){xl(sl)}):(fl=!0,dl=Rl.createTextNode(""),new Tl(sl).observe(dl,{characterData:!0}),ll=function(){dl.data=fl=!fl}));var jl=Al||function(e){var t={fn:e,next:void 0};cl&&(cl.next=t),ul||(ul=t,ll()),cl=t},Ml=i,Ll=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},Ul=function(){this.head=null,this.tail=null};Ul.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var Nl=Ul,Fl=i.Promise,Dl="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,ql=!Dl&&!fc&&"object"==typeof window&&"object"==typeof document,Bl=i,zl=Fl,Wl=H,$l=Vr,Kl=pn,Hl=ot,Gl=ql,Vl=Dl,Yl=ue;zl&&zl.prototype;var Jl=Hl("species"),Ql=!1,Xl=Wl(Bl.PromiseRejectionEvent),Zl=$l("Promise",(function(){var e=Kl(zl),t=e!==String(zl);if(!t&&66===Yl)return!0;if(!Yl||Yl<51||!/native code/.test(e)){var n=new zl((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((n.constructor={})[Jl]=r,!(Ql=n.then((function(){}))instanceof r))return!0}return!t&&(Gl||Vl)&&!Xl})),ef={CONSTRUCTOR:Zl,REJECTION_EVENT:Xl,SUBCLASSING:Ql},tf={},nf=_e,rf=TypeError,af=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw rf("Bad Promise constructor");t=e,n=r})),this.resolve=nf(t),this.reject=nf(n)};tf.f=function(e){return new af(e)};var of,sf,uf,cf=ni,lf=fc,ff=i,df=f,pf=Xn,hf=gc,vf=oi,yf=_c,mf=_e,gf=H,bf=Y,wf=Ec,kf=Pc,xf=vl.set,_f=jl,Sf=function(e,t){var n=Ml.console;n&&n.error&&(1==arguments.length?n.error(e):n.error(e,t))},Of=Ll,Ef=Nl,Tf=Ln,Rf=Fl,If=tf,Cf="Promise",Pf=ef.CONSTRUCTOR,Af=ef.REJECTION_EVENT,jf=ef.SUBCLASSING,Mf=Tf.getterFor(Cf),Lf=Tf.set,Uf=Rf&&Rf.prototype,Nf=Rf,Ff=Uf,Df=ff.TypeError,qf=ff.document,Bf=ff.process,zf=If.f,Wf=zf,$f=!!(qf&&qf.createEvent&&ff.dispatchEvent),Kf="unhandledrejection",Hf=function(e){var t;return!(!bf(e)||!gf(t=e.then))&&t},Gf=function(e,t){var n,r,i,a=t.value,o=1==t.state,s=o?e.ok:e.fail,u=e.resolve,c=e.reject,l=e.domain;try{s?(o||(2===t.rejection&&Xf(t),t.rejection=1),!0===s?n=a:(l&&l.enter(),n=s(a),l&&(l.exit(),i=!0)),n===e.promise?c(Df("Promise-chain cycle")):(r=Hf(n))?df(r,n,u,c):u(n)):c(a)}catch(e){l&&!i&&l.exit(),c(e)}},Vf=function(e,t){e.notified||(e.notified=!0,_f((function(){for(var n,r=e.reactions;n=r.get();)Gf(n,e);e.notified=!1,t&&!e.rejection&&Jf(e)})))},Yf=function(e,t,n){var r,i;$f?((r=qf.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),ff.dispatchEvent(r)):r={promise:t,reason:n},!Af&&(i=ff["on"+e])?i(r):e===Kf&&Sf("Unhandled promise rejection",n)},Jf=function(e){df(xf,ff,(function(){var t,n=e.facade,r=e.value;if(Qf(e)&&(t=Of((function(){lf?Bf.emit("unhandledRejection",r,n):Yf(Kf,n,r)})),e.rejection=lf||Qf(e)?2:1,t.error))throw t.value}))},Qf=function(e){return 1!==e.rejection&&!e.parent},Xf=function(e){df(xf,ff,(function(){var t=e.facade;lf?Bf.emit("rejectionHandled",t):Yf("rejectionhandled",t,e.value)}))},Zf=function(e,t,n){return function(r){e(t,r,n)}},ed=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,Vf(e,!0))},td=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw Df("Promise can't be resolved itself");var r=Hf(t);r?_f((function(){var n={done:!1};try{df(r,t,Zf(td,n,e),Zf(ed,n,e))}catch(t){ed(n,t,e)}})):(e.value=t,e.state=1,Vf(e,!1))}catch(t){ed({done:!1},t,e)}}};if(Pf&&(Ff=(Nf=function(e){wf(this,Ff),mf(e),df(of,this);var t=Mf(this);try{e(Zf(td,t),Zf(ed,t))}catch(e){ed(t,e)}}).prototype,(of=function(e){Lf(this,{type:Cf,done:!1,notified:!1,parent:!1,reactions:new Ef,rejection:!1,state:0,value:void 0})}).prototype=pf(Ff,"then",(function(e,t){var n=Mf(this),r=zf(kf(this,Nf));return n.parent=!0,r.ok=!gf(e)||e,r.fail=gf(t)&&t,r.domain=lf?Bf.domain:void 0,0==n.state?n.reactions.add(r):_f((function(){Gf(r,n)})),r.promise})),sf=function(){var e=new of,t=Mf(e);this.promise=e,this.resolve=Zf(td,t),this.reject=Zf(ed,t)},If.f=zf=function(e){return e===Nf||undefined===e?new sf(e):Wf(e)},gf(Rf)&&Uf!==Object.prototype)){uf=Uf.then,jf||pf(Uf,"then",(function(e,t){var n=this;return new Nf((function(e,t){df(uf,n,e,t)})).then(e,t)}),{unsafe:!0});try{delete Uf.constructor}catch(e){}hf&&hf(Uf,Ff)}cf({global:!0,constructor:!0,wrap:!0,forced:Pf},{Promise:Nf}),vf(Nf,Cf,!1),yf(Cf);var nd={},rd=nd,id=ot("iterator"),ad=Array.prototype,od=function(e){return void 0!==e&&(rd.Array===e||ad[id]===e)},sd=Li,ud=Ee,cd=U,ld=nd,fd=ot("iterator"),dd=function(e){if(!cd(e))return ud(e,fd)||ud(e,"@@iterator")||ld[sd(e)]},pd=f,hd=_e,vd=Ft,yd=be,md=dd,gd=TypeError,bd=function(e,t){var n=arguments.length<2?md(e):t;if(hd(n))return vd(pd(n,e));throw gd(yd(e)+" is not iterable")},wd=f,kd=Ft,xd=Ee,_d=function(e,t,n){var r,i;kd(e);try{if(!(r=xd(e,"return"))){if("throw"===t)throw n;return n}r=wd(r,e)}catch(e){i=!0,r=e}if("throw"===t)throw n;if(i)throw r;return kd(r),n},Sd=wo,Od=f,Ed=Ft,Td=be,Rd=od,Id=pr,Cd=ee,Pd=bd,Ad=dd,jd=_d,Md=TypeError,Ld=function(e,t){this.stopped=e,this.result=t},Ud=Ld.prototype,Nd=function(e,t,n){var r,i,a,o,s,u,c,l=n&&n.that,f=!(!n||!n.AS_ENTRIES),d=!(!n||!n.IS_RECORD),p=!(!n||!n.IS_ITERATOR),h=!(!n||!n.INTERRUPTED),v=Sd(t,l),y=function(e){return r&&jd(r,"normal",e),new Ld(!0,e)},m=function(e){return f?(Ed(e),h?v(e[0],e[1],y):v(e[0],e[1])):h?v(e,y):v(e)};if(d)r=e.iterator;else if(p)r=e;else{if(!(i=Ad(e)))throw Md(Td(e)+" is not iterable");if(Rd(i)){for(a=0,o=Id(e);o>a;a++)if((s=m(e[a]))&&Cd(Ud,s))return s;return new Ld(!1)}r=Pd(e,i)}for(u=d?e.next:r.next;!(c=Od(u,r)).done;){try{s=m(c.value)}catch(e){jd(r,"throw",e)}if("object"==typeof s&&s&&Cd(Ud,s))return s}return new Ld(!1)},Fd=ot("iterator"),Dd=!1;try{var qd=0,Bd={next:function(){return{done:!!qd++}},return:function(){Dd=!0}};Bd[Fd]=function(){return this},Array.from(Bd,(function(){throw 2}))}catch(e){}var zd=function(e,t){if(!t&&!Dd)return!1;var n=!1;try{var r={};r[Fd]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n},Wd=Fl,$d=ef.CONSTRUCTOR||!zd((function(e){Wd.all(e).then(void 0,(function(){}))})),Kd=f,Hd=_e,Gd=tf,Vd=Ll,Yd=Nd;ni({target:"Promise",stat:!0,forced:$d},{all:function(e){var t=this,n=Gd.f(t),r=n.resolve,i=n.reject,a=Vd((function(){var n=Hd(t.resolve),a=[],o=0,s=1;Yd(e,(function(e){var u=o++,c=!1;s++,Kd(n,t,e).then((function(e){c||(c=!0,a[u]=e,--s||r(a))}),i)})),--s||r(a)}));return a.error&&i(a.value),n.promise}});var Jd=ni,Qd=ef.CONSTRUCTOR,Xd=Fl,Zd=Z,ep=H,tp=Xn,np=Xd&&Xd.prototype;if(Jd({target:"Promise",proto:!0,forced:Qd,real:!0},{catch:function(e){return this.then(void 0,e)}}),ep(Xd)){var rp=Zd("Promise").prototype.catch;np.catch!==rp&&tp(np,"catch",rp,{unsafe:!0})}var ip=f,ap=_e,op=tf,sp=Ll,up=Nd;ni({target:"Promise",stat:!0,forced:$d},{race:function(e){var t=this,n=op.f(t),r=n.reject,i=sp((function(){var i=ap(t.resolve);up(e,(function(e){ip(i,t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var cp=f,lp=tf;ni({target:"Promise",stat:!0,forced:ef.CONSTRUCTOR},{reject:function(e){var t=lp.f(this);return cp(t.reject,void 0,e),t.promise}});var fp=Ft,dp=Y,pp=tf,hp=function(e,t){if(fp(e),dp(t)&&t.constructor===e)return t;var n=pp.f(e);return(0,n.resolve)(t),n.promise},vp=ni,yp=ef.CONSTRUCTOR,mp=hp;Z("Promise"),vp({target:"Promise",stat:!0,forced:yp},{resolve:function(e){return mp(this,e)}});var gp=No.map;ni({target:"Array",proto:!0,forced:!Lu("map")},{map:function(e){return gp(this,e,arguments.length>1?arguments[1]:void 0)}});var bp={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},wp=kt("span").classList,kp=wp&&wp.constructor&&wp.constructor.prototype,xp=kp===Object.prototype?void 0:kp,_p=o,Sp=function(e,t){var n=[][e];return!!n&&_p((function(){n.call(null,t||function(){return 1},1)}))},Op=No.forEach,Ep=Sp("forEach")?[].forEach:function(e){return Op(this,e,arguments.length>1?arguments[1]:void 0)},Tp=i,Rp=bp,Ip=xp,Cp=Ep,Pp=Xt,Ap=function(e){if(e&&e.forEach!==Cp)try{Pp(e,"forEach",Cp)}catch(t){e.forEach=Cp}};for(var jp in Rp)Rp[jp]&&Ap(Tp[jp]&&Tp[jp].prototype);Ap(Ip);var Mp,Lp=Object.prototype,Up=Lp.hasOwnProperty,Np="function"==typeof Symbol?Symbol:{},Fp=Np.iterator||"@@iterator",Dp=Np.asyncIterator||"@@asyncIterator",qp=Np.toStringTag||"@@toStringTag";function Bp(e,t,n,r){var i=t&&t.prototype instanceof Vp?t:Vp,a=Object.create(i.prototype),o=new sh(r||[]);return a._invoke=function(e,t,n){var r=Wp;return function(i,a){if(r===Kp)throw new Error("Generator is already running");if(r===Hp){if("throw"===i)throw a;return ch()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=ih(o,n);if(s){if(s===Gp)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===Wp)throw r=Hp,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=Kp;var u=zp(e,t,n);if("normal"===u.type){if(r=n.done?Hp:$p,u.arg===Gp)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=Hp,n.method="throw",n.arg=u.arg)}}}(e,n,o),a}function zp(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}var Wp="suspendedStart",$p="suspendedYield",Kp="executing",Hp="completed",Gp={};function Vp(){}function Yp(){}function Jp(){}var Qp={};Qp[Fp]=function(){return this};var Xp=Object.getPrototypeOf,Zp=Xp&&Xp(Xp(uh([])));Zp&&Zp!==Lp&&Up.call(Zp,Fp)&&(Qp=Zp);var eh=Jp.prototype=Vp.prototype=Object.create(Qp);function th(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function nh(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===Yp||"GeneratorFunction"===(t.displayName||t.name))}function rh(e,t){function n(r,i,a,o){var s=zp(e[r],e,i);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"===Xu(c)&&Up.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,a,o)}),(function(e){n("throw",e,a,o)})):t.resolve(c).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,o)}))}o(s.arg)}var r;this._invoke=function(e,i){function a(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(a,a):a()}}function ih(e,t){var n=e.iterator[t.method];if(n===Mp){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=Mp,ih(e,t),"throw"===t.method))return Gp;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return Gp}var r=zp(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,Gp;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=Mp),t.delegate=null,Gp):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,Gp)}function ah(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function oh(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function sh(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(ah,this),this.reset(!0)}function uh(e){if(e){var t=e[Fp];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(Up.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=Mp,t.done=!0,t};return r.next=r}}return{next:ch}}function ch(){return{value:Mp,done:!0}}Yp.prototype=eh.constructor=Jp,Jp.constructor=Yp,Jp[qp]=Yp.displayName="GeneratorFunction",th(rh.prototype),rh.prototype[Dp]=function(){return this},th(eh),eh[qp]="Generator",eh[Fp]=function(){return this},eh.toString=function(){return"[object Generator]"},sh.prototype={constructor:sh,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=Mp,this.done=!1,this.delegate=null,this.method="next",this.arg=Mp,this.tryEntries.forEach(oh),!e)for(var t in this)"t"===t.charAt(0)&&Up.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=Mp)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=Mp),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var o=Up.call(i,"catchLoc"),s=Up.call(i,"finallyLoc");if(o&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(o){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&Up.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,Gp):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),Gp},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),oh(n),Gp}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;oh(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:uh(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=Mp),Gp}};var lh={wrap:Bp,isGeneratorFunction:nh,AsyncIterator:rh,mark:function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,Jp):(e.__proto__=Jp,qp in e||(e[qp]="GeneratorFunction")),e.prototype=Object.create(eh),e},awrap:function(e){return{__await:e}},async:function(e,t,n,r,i){void 0===i&&(i=Promise);var a=new rh(Bp(e,t,n,r),i);return nh(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},keys:function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},values:uh},fh=Object.freeze({__proto__:null,default:lh});function dh(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":Xu(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function ph(e,t){if("object"===("undefined"==typeof Reflect?"undefined":Xu(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var hh=TypeError,vh=function(e){if(e>9007199254740991)throw hh("Maximum allowed index exceeded");return e},yh=ni,mh=o,gh=xo,bh=Y,wh=Be,kh=pr,xh=vh,_h=Ga,Sh=Io,Oh=Lu,Eh=ue,Th=ot("isConcatSpreadable"),Rh=Eh>=51||!mh((function(){var e=[];return e[Th]=!1,e.concat()[0]!==e})),Ih=Oh("concat"),Ch=function(e){if(!bh(e))return!1;var t=e[Th];return void 0!==t?!!t:gh(e)};yh({target:"Array",proto:!0,arity:1,forced:!Rh||!Ih},{concat:function(e){var t,n,r,i,a,o=wh(this),s=Sh(o,0),u=0;for(t=-1,r=arguments.length;t<r;t++)if(Ch(a=-1===t?o:arguments[t]))for(i=kh(a),xh(u+i),n=0;n<i;n++,u++)n in a&&_h(s,u,a[n]);else xh(u+1),_h(s,u++,a);return s.length=u,s}});var Ph=Ft,Ah=_d,jh=wo,Mh=f,Lh=Be,Uh=function(e,t,n,r){try{return r?t(Ph(n)[0],n[1]):t(n)}catch(t){Ah(e,"throw",t)}},Nh=od,Fh=Yi,Dh=pr,qh=Ga,Bh=bd,zh=dd,Wh=Array,$h=function(e){var t=Lh(e),n=Fh(this),r=arguments.length,i=r>1?arguments[1]:void 0,a=void 0!==i;a&&(i=jh(i,r>2?arguments[2]:void 0));var o,s,u,c,l,f,d=zh(t),p=0;if(!d||this===Wh&&Nh(d))for(o=Dh(t),s=n?new this(o):Wh(o);o>p;p++)f=a?i(t[p],p):t[p],qh(s,p,f);else for(l=(c=Bh(t,d)).next,s=n?new this:[];!(u=Mh(l,c)).done;p++)f=a?Uh(c,i,[u.value,p],!0):u.value,qh(s,p,f);return s.length=p,s},Kh=$h;ni({target:"Array",stat:!0,forced:!zd((function(e){Array.from(e)}))},{from:Kh});var Hh,Gh,Vh,Yh=C,Jh=ir,Qh=za,Xh=D,Zh=Yh("".charAt),ev=Yh("".charCodeAt),tv=Yh("".slice),nv=function(e){return function(t,n){var r,i,a=Qh(Xh(t)),o=Jh(n),s=a.length;return o<0||o>=s?e?"":void 0:(r=ev(a,o))<55296||r>56319||o+1===s||(i=ev(a,o+1))<56320||i>57343?e?Zh(a,o):r:e?tv(a,o,o+2):i-56320+(r-55296<<10)+65536}},rv={codeAt:nv(!1),charAt:nv(!0)},iv=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),av=$e,ov=H,sv=Be,uv=iv,cv=wn("IE_PROTO"),lv=Object,fv=lv.prototype,dv=uv?lv.getPrototypeOf:function(e){var t=sv(e);if(av(t,cv))return t[cv];var n=t.constructor;return ov(n)&&t instanceof n?n.prototype:t instanceof lv?fv:null},pv=o,hv=H,vv=Y,yv=dv,mv=Xn,gv=ot("iterator"),bv=!1;[].keys&&("next"in(Vh=[].keys())?(Gh=yv(yv(Vh)))!==Object.prototype&&(Hh=Gh):bv=!0);var wv=!vv(Hh)||pv((function(){var e={};return Hh[gv].call(e)!==e}));wv&&(Hh={}),hv(Hh[gv])||mv(Hh,gv,(function(){return this}));var kv={IteratorPrototype:Hh,BUGGY_SAFARI_ITERATORS:bv},xv=kv.IteratorPrototype,_v=_a,Sv=g,Ov=oi,Ev=nd,Tv=function(){return this},Rv=function(e,t,n,r){var i=t+" Iterator";return e.prototype=_v(xv,{next:Sv(+!r,n)}),Ov(e,i,!1),Ev[i]=Tv,e},Iv=ni,Cv=f,Pv=H,Av=Rv,jv=dv,Mv=gc,Lv=oi,Uv=Xt,Nv=Xn,Fv=nd,Dv=on.PROPER,qv=on.CONFIGURABLE,Bv=kv.IteratorPrototype,zv=kv.BUGGY_SAFARI_ITERATORS,Wv=ot("iterator"),$v="keys",Kv="values",Hv="entries",Gv=function(){return this},Vv=function(e,t,n,r,i,a,o){Av(n,t,r);var s,u,c,l=function(e){if(e===i&&v)return v;if(!zv&&e in p)return p[e];switch(e){case $v:case Kv:case Hv:return function(){return new n(this,e)}}return function(){return new n(this)}},f=t+" Iterator",d=!1,p=e.prototype,h=p[Wv]||p["@@iterator"]||i&&p[i],v=!zv&&h||l(i),y="Array"==t&&p.entries||h;if(y&&(s=jv(y.call(new e)))!==Object.prototype&&s.next&&(jv(s)!==Bv&&(Mv?Mv(s,Bv):Pv(s[Wv])||Nv(s,Wv,Gv)),Lv(s,f,!0)),Dv&&i==Kv&&h&&h.name!==Kv&&(qv?Uv(p,"name",Kv):(d=!0,v=function(){return Cv(h,this)})),i)if(u={values:l(Kv),keys:a?v:l($v),entries:l(Hv)},o)for(c in u)(zv||d||!(c in p))&&Nv(p,c,u[c]);else Iv({target:t,proto:!0,forced:zv||d},u);return p[Wv]!==v&&Nv(p,Wv,v,{name:i}),Fv[t]=v,u},Yv=function(e,t){return{value:e,done:t}},Jv=rv.charAt,Qv=za,Xv=Ln,Zv=Vv,ey=Yv,ty="String Iterator",ny=Xv.set,ry=Xv.getterFor(ty);Zv(String,"String",(function(e){ny(this,{type:ty,string:Qv(e),index:0})}),(function(){var e,t=ry(this),n=t.string,r=t.index;return r>=n.length?ey(void 0,!0):(e=Jv(n,r),t.index+=e.length,ey(e,!1))}));var iy,ay,oy,sy={exports:{}};function uy(e,t){return["".concat((new Date).toISOString()," Conversations ").concat(e,":")].concat(Array.from(t))}ay=t,oy=function(){var e=function(){},t="undefined",n=("undefined"==typeof window?"undefined":Xu(window))!==t&&Xu(window.navigator)!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"];function i(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function a(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(r){return"debug"===r&&(r="log"),("undefined"==typeof console?"undefined":Xu(console))!==t&&("trace"===r&&n?a:void 0!==console[r]?i(console,r):void 0!==console.log?i(console,"log"):e)}function s(t,n){for(var i=0;i<r.length;i++){var a=r[i];this[a]=i<t?e:this.methodFactory(a,t,n)}this.log=this.debug}function u(e,n,r){return function(){("undefined"==typeof console?"undefined":Xu(console))!==t&&(s.call(this,n,r),this[e].apply(this,arguments))}}function c(e,t,n){return o(e)||u.apply(this,arguments)}function l(e,n,i){var a,o=this;n=null==n?"WARN":n;var u="loglevel";function l(){var e;if(("undefined"==typeof window?"undefined":Xu(window))!==t&&u){try{e=window.localStorage[u]}catch(e){}if(Xu(e)===t)try{var n=window.document.cookie,r=n.indexOf(encodeURIComponent(u)+"=");-1!==r&&(e=/^([^;]+)/.exec(n.slice(r))[1])}catch(e){}return void 0===o.levels[e]&&(e=void 0),e}}"string"==typeof e?u+=":"+e:"symbol"===Xu(e)&&(u=void 0),o.name=e,o.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},o.methodFactory=i||c,o.getLevel=function(){return a},o.setLevel=function(n,i){if("string"==typeof n&&void 0!==o.levels[n.toUpperCase()]&&(n=o.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=o.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(a=n,!1!==i&&function(e){var n=(r[e]||"silent").toUpperCase();if(("undefined"==typeof window?"undefined":Xu(window))!==t&&u){try{return void(window.localStorage[u]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"="+n+";"}catch(e){}}}(n),s.call(o,n,e),("undefined"==typeof console?"undefined":Xu(console))===t&&n<o.levels.SILENT)return"No console available for logging"},o.setDefaultLevel=function(e){n=e,l()||o.setLevel(e,!1)},o.resetLevel=function(){o.setLevel(n,!1),function(){if(("undefined"==typeof window?"undefined":Xu(window))!==t&&u){try{return void window.localStorage.removeItem(u)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},o.enableAll=function(e){o.setLevel(o.levels.TRACE,e)},o.disableAll=function(e){o.setLevel(o.levels.SILENT,e)};var f=l();null==f&&(f=n),o.setLevel(f,!1)}var f=new l,d={};f.getLogger=function(e){if("symbol"!==Xu(e)&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=d[e];return t||(t=d[e]=new l(e,f.getLevel(),f.methodFactory)),t};var p=("undefined"==typeof window?"undefined":Xu(window))!==t?window.log:void 0;return f.noConflict=function(){return("undefined"==typeof window?"undefined":Xu(window))!==t&&window.log===f&&(window.log=p),f},f.getLoggers=function(){return d},f.default=f,f},(iy=sy).exports?iy.exports=oy():ay.log=oy();var cy,ly,fy=sy.exports.getLogger("twilio-conversations"),dy=function(){function e(t){rc(this,e),ic(this,"prefix",""),this.prefix=null!=t&&t.length>0?t+" ":""}return nc(e,[{key:"setLevel",value:function(e){fy.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];fy.trace.apply(null,uy(this.prefix+"T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];fy.debug.apply(null,uy(this.prefix+"D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];fy.info.apply(null,uy(this.prefix+"I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];fy.warn.apply(null,uy(this.prefix+"W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];fy.error.apply(null,uy(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){fy.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];fy.trace.apply(null,uy("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];fy.debug.apply(null,uy("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];fy.info.apply(null,uy("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];fy.warn.apply(null,uy("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];fy.error.apply(null,uy("E",t))}}]),e}(),py={};Object.defineProperty(py,"__esModule",{value:!0});var hy=["weeks","years","months","days","hours","minutes","seconds"],vy=py.pattern=new RegExp("P(?:(\\d+(?:[\\.,]\\d+)?W)|(\\d+(?:[\\.,]\\d+)?Y)?(\\d+(?:[\\.,]\\d+)?M)?(\\d+(?:[\\.,]\\d+)?D)?(?:T(\\d+(?:[\\.,]\\d+)?H)?(\\d+(?:[\\.,]\\d+)?M)?(\\d+(?:[\\.,]\\d+)?S)?)?)"),yy=ly=py.parse=function(e){return e.match(vy).slice(1).reduce((function(e,t,n){return e[hy[n]]=parseFloat(t)||0,e}),{})},my=py.end=function(e,t){var n=t?t.getTime():Date.now(),r=new Date(n);return r.setFullYear(r.getFullYear()+e.years),r.setMonth(r.getMonth()+e.months),r.setDate(r.getDate()+e.days),r.setHours(r.getHours()+e.hours),r.setMinutes(r.getMinutes()+e.minutes),r.setMilliseconds(r.getMilliseconds()+1e3*e.seconds),r.setDate(r.getDate()+7*e.weeks),r},gy=cy=py.toSeconds=function(e,t){var n=t?t.getTime():Date.now(),r=new Date(n);return(my(e,r).getTime()-r.getTime())/1e3};function by(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function wy(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?by(Object(n),!0).forEach((function(t){ic(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):by(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}py.default={end:my,toSeconds:gy,pattern:vy,parse:yy};var ky="PT5S",xy="PT5S",_y=nc((function e(){var t,n,r,i,a,o,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},u=arguments.length>1?arguments[1]:void 0,c=arguments.length>2?arguments[2]:void 0;rc(this,e),ic(this,"links",void 0),ic(this,"limits",void 0),ic(this,"productId",void 0),ic(this,"typingIndicatorTimeoutOverride",void 0),ic(this,"typingIndicatorTimeoutDefault",5e3),ic(this,"backoffConfiguration",void 0),ic(this,"retryWhenThrottled",void 0),ic(this,"consumptionReportInterval",void 0),ic(this,"userInfosToSubscribe",void 0),ic(this,"httpCacheInterval",void 0),ic(this,"reachabilityEnabled",void 0),ic(this,"userIdentity",void 0),ic(this,"userInfo",void 0),ic(this,"myConversations",void 0);var l=s.Chat||s.IPMessaging||s||{};this.productId=l.productId,this.links={myConversations:u.links.my_conversations,conversations:u.links.conversations,users:u.links.users,currentUser:u.links.current_user,typing:u.links.typing,mediaService:u.links.media_service,mediaSetService:u.links.media_set_service,messagesReceipts:u.links.messages_receipts},this.limits={mediaAttachmentsCountLimit:u.options.media_attachments_count_limit,mediaAttachmentSizeLimitInMb:u.options.media_attachment_size_limit_in_mb,mediaAttachmentsTotalSizeLimitInMb:u.options.media_attachments_total_size_limit_in_mb,emailHistoriesAllowedContentTypes:u.options.email_histories_allowed_mime_types,emailBodiesAllowedContentTypes:u.options.email_bodies_allowed_mime_types},this.typingIndicatorTimeoutOverride=l.typingIndicatorTimeoutOverride,this.backoffConfiguration=wy({min:1e3,max:4e3,maxAttemptsCount:3},l.backoffConfigOverride),this.retryWhenThrottled=void 0===l.retryWhenThrottledOverride||l.retryWhenThrottledOverride,this.userInfosToSubscribe=null!==(t=null!==(n=l.userInfosToSubscribeOverride)&&void 0!==n?n:u.options.user_infos_to_subscribe)&&void 0!==t?t:100,this.reachabilityEnabled=u.options.reachability_enabled,this.userIdentity=u.identity,this.userInfo=u.sync_objects.my_user_info,this.myConversations=u.sync_objects.my_conversations;var f=null!==(r=null!==(i=l.httpCacheIntervalOverride)&&void 0!==i?i:u.options.http_cache_interval)&&void 0!==r?r:ky;try{this.httpCacheInterval=cy(ly(f))}catch(e){c.error("Failed to parse http cache interval ".concat(f,", using default value ").concat(ky)),this.httpCacheInterval=cy(ly(ky))}var d=null!==(a=null!==(o=l.consumptionReportIntervalOverride)&&void 0!==o?o:u.options.consumption_report_interval)&&void 0!==a?a:xy;try{this.consumptionReportInterval=cy(ly(d))}catch(e){c.error("Failed to parse consumption report interval ".concat(d,", using default value ").concat(xy)),this.consumptionReportInterval=cy(ly(xy))}})),Sy=ot,Oy=_a,Ey=jt.f,Ty=Sy("unscopables"),Ry=Array.prototype;null==Ry[Ty]&&Ey(Ry,Ty,{configurable:!0,value:Oy(null)});var Iy=function(e){Ry[Ty][e]=!0},Cy=z,Py=Iy,Ay=nd,jy=Ln,My=jt.f,Ly=Vv,Uy=Yv,Ny=s,Fy="Array Iterator",Dy=jy.set,qy=jy.getterFor(Fy),By=Ly(Array,"Array",(function(e,t){Dy(this,{type:Fy,target:Cy(e),index:0,kind:t})}),(function(){var e=qy(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,Uy(void 0,!0)):Uy("keys"==n?r:"values"==n?t[r]:[r,t[r]],!1)}),"values"),zy=Ay.Arguments=Ay.Array;if(Py("keys"),Py("values"),Py("entries"),Ny&&"values"!==zy.name)try{My(zy,"name",{value:"values"})}catch(e){}var Wy=i,$y=bp,Ky=xp,Hy=By,Gy=Xt,Vy=ot,Yy=Vy("iterator"),Jy=Vy("toStringTag"),Qy=Hy.values,Xy=function(e,t){if(e){if(e[Yy]!==Qy)try{Gy(e,Yy,Qy)}catch(t){e[Yy]=Qy}if(e[Jy]||Gy(e,Jy,t),$y[t])for(var n in Hy)if(e[n]!==Hy[n])try{Gy(e,n,Hy[n])}catch(t){e[n]=Hy[n]}}};for(var Zy in $y)Xy(Wy[Zy]&&Wy[Zy].prototype,Zy);Xy(Ky,"DOMTokenList");var em=H,tm=Y,nm=gc,rm=function(e,t,n){var r,i;return nm&&em(r=t.constructor)&&r!==n&&tm(i=r.prototype)&&i!==n.prototype&&nm(e,i),e},im=C(1..valueOf),am=D,om=za,sm=C("".replace),um="[\t\n\v\f\r \u2028\u2029\ufeff]",cm=RegExp("^"+um+um+"*"),lm=RegExp(um+um+"*$"),fm=function(e){return function(t){var n=om(am(t));return 1&e&&(n=sm(n,cm,"")),2&e&&(n=sm(n,lm,"")),n}},dm={start:fm(1),end:fm(2),trim:fm(3)},pm=s,hm=i,vm=C,ym=Vr,mm=Xn,gm=$e,bm=rm,wm=ee,km=me,xm=ht,_m=o,Sm=Zn.f,Om=a.f,Em=jt.f,Tm=im,Rm=dm.trim,Im="Number",Cm=hm.Number,Pm=Cm.prototype,Am=hm.TypeError,jm=vm("".slice),Mm=vm("".charCodeAt),Lm=function(e){var t=xm(e,"number");return"bigint"==typeof t?t:Um(t)},Um=function(e){var t,n,r,i,a,o,s,u,c=xm(e,"number");if(km(c))throw Am("Cannot convert a Symbol value to a number");if("string"==typeof c&&c.length>2)if(c=Rm(c),43===(t=Mm(c,0))||45===t){if(88===(n=Mm(c,2))||120===n)return NaN}else if(48===t){switch(Mm(c,1)){case 66:case 98:r=2,i=49;break;case 79:case 111:r=8,i=55;break;default:return+c}for(o=(a=jm(c,2)).length,s=0;s<o;s++)if((u=Mm(a,s))<48||u>i)return NaN;return parseInt(a,r)}return+c};if(ym(Im,!Cm(" 0o1")||!Cm("0b1")||Cm("+0x1"))){for(var Nm,Fm=function(e){var t=arguments.length<1?0:Cm(Lm(e)),n=this;return wm(Pm,n)&&_m((function(){Tm(n)}))?bm(Object(t),n,Fm):t},Dm=pm?Sm(Cm):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),qm=0;Dm.length>qm;qm++)gm(Cm,Nm=Dm[qm])&&!gm(Fm,Nm)&&Em(Fm,Nm,Om(Cm,Nm));Fm.prototype=Pm,Pm.constructor=Fm,mm(hm,Im,Fm,{constructor:!0})}var Bm,zm,Wm=Ft,$m=function(){var e=Wm(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Km=o,Hm=i.RegExp,Gm=Km((function(){var e=Hm("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),Vm=Gm||Km((function(){return!Hm("a","y").sticky})),Ym=Gm||Km((function(){var e=Hm("^r","gy");return e.lastIndex=2,null!=e.exec("str")})),Jm={BROKEN_CARET:Ym,MISSED_STICKY:Vm,UNSUPPORTED_Y:Gm},Qm=o,Xm=i.RegExp,Zm=Qm((function(){var e=Xm(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),eg=o,tg=i.RegExp,ng=eg((function(){var e=tg("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),rg=f,ig=C,ag=za,og=$m,sg=Jm,ug=Pe.exports,cg=_a,lg=Ln.get,fg=Zm,dg=ng,pg=ug("native-string-replace",String.prototype.replace),hg=RegExp.prototype.exec,vg=hg,yg=ig("".charAt),mg=ig("".indexOf),gg=ig("".replace),bg=ig("".slice),wg=(zm=/b*/g,rg(hg,Bm=/a/,"a"),rg(hg,zm,"a"),0!==Bm.lastIndex||0!==zm.lastIndex),kg=sg.BROKEN_CARET,xg=void 0!==/()??/.exec("")[1];(wg||xg||kg||fg||dg)&&(vg=function(e){var t,n,r,i,a,o,s,u=this,c=lg(u),l=ag(e),f=c.raw;if(f)return f.lastIndex=u.lastIndex,t=rg(vg,f,l),u.lastIndex=f.lastIndex,t;var d=c.groups,p=kg&&u.sticky,h=rg(og,u),v=u.source,y=0,m=l;if(p&&(h=gg(h,"y",""),-1===mg(h,"g")&&(h+="g"),m=bg(l,u.lastIndex),u.lastIndex>0&&(!u.multiline||u.multiline&&"\n"!==yg(l,u.lastIndex-1))&&(v="(?: "+v+")",m=" "+m,y++),n=new RegExp("^(?:"+v+")",h)),xg&&(n=new RegExp("^"+v+"$(?!\\s)",h)),wg&&(r=u.lastIndex),i=rg(hg,p?n:u,m),p?i?(i.input=bg(i.input,y),i[0]=bg(i[0],y),i.index=u.lastIndex,u.lastIndex+=i[0].length):u.lastIndex=0:wg&&i&&(u.lastIndex=u.global?i.index+i[0].length:r),xg&&i&&i.length>1&&rg(pg,i[0],n,(function(){for(a=1;a<arguments.length-2;a++)void 0===arguments[a]&&(i[a]=void 0)})),i&&d)for(i.groups=o=cg(null),a=0;a<d.length;a++)o[(s=d[a])[0]]=i[s[1]];return i});var _g=vg;ni({target:"RegExp",proto:!0,forced:/./.exec!==_g},{exec:_g});var Sg=C,Og=Xn,Eg=_g,Tg=o,Rg=ot,Ig=Xt,Cg=Rg("species"),Pg=RegExp.prototype,Ag=function(e,t,n,r){var i=Rg(e),a=!Tg((function(){var t={};return t[i]=function(){return 7},7!=""[e](t)})),o=a&&!Tg((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[Cg]=function(){return n},n.flags="",n[i]=/./[i]),n.exec=function(){return t=!0,null},n[i](""),!t}));if(!a||!o||n){var s=Sg(/./[i]),u=t(i,""[e],(function(e,t,n,r,i){var o=Sg(e),u=t.exec;return u===Eg||u===Pg.exec?a&&!i?{done:!0,value:s(t,n,r)}:{done:!0,value:o(n,t,r)}:{done:!1}}));Og(String.prototype,e,u[0]),Og(Pg,i,u[1])}r&&Ig(Pg[i],"sham",!0)},jg=rv.charAt,Mg=function(e,t,n){return t+(n?jg(e,t).length:1)},Lg=C,Ug=Be,Ng=Math.floor,Fg=Lg("".charAt),Dg=Lg("".replace),qg=Lg("".slice),Bg=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,zg=/\$([$&'`]|\d{1,2})/g,Wg=f,$g=Ft,Kg=H,Hg=T,Gg=_g,Vg=TypeError,Yg=function(e,t){var n=e.exec;if(Kg(n)){var r=Wg(n,e,t);return null!==r&&$g(r),r}if("RegExp"===Hg(e))return Wg(Gg,e,t);throw Vg("RegExp#exec called on incompatible receiver")},Jg=pi,Qg=f,Xg=C,Zg=Ag,eb=o,tb=Ft,nb=H,rb=U,ib=ir,ab=fr,ob=za,sb=D,ub=Mg,cb=Ee,lb=function(e,t,n,r,i,a){var o=n+e.length,s=r.length,u=zg;return void 0!==i&&(i=Ug(i),u=Bg),Dg(a,u,(function(a,u){var c;switch(Fg(u,0)){case"$":return"$";case"&":return e;case"`":return qg(t,0,n);case"'":return qg(t,o);case"<":c=i[qg(u,1,-1)];break;default:var l=+u;if(0===l)return a;if(l>s){var f=Ng(l/10);return 0===f?a:f<=s?void 0===r[f-1]?Fg(u,1):r[f-1]+Fg(u,1):a}c=r[l-1]}return void 0===c?"":c}))},fb=Yg,db=ot("replace"),pb=Math.max,hb=Math.min,vb=Xg([].concat),yb=Xg([].push),mb=Xg("".indexOf),gb=Xg("".slice),bb="$0"==="a".replace(/./,"$0"),wb=!!/./[db]&&""===/./[db]("a","$0"),kb=!eb((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));Zg("replace",(function(e,t,n){var r=wb?"$":"$0";return[function(e,n){var r=sb(this),i=rb(e)?void 0:cb(e,db);return i?Qg(i,e,r,n):Qg(t,ob(r),e,n)},function(e,i){var a=tb(this),o=ob(e);if("string"==typeof i&&-1===mb(i,r)&&-1===mb(i,"$<")){var s=n(t,a,o,i);if(s.done)return s.value}var u=nb(i);u||(i=ob(i));var c=a.global;if(c){var l=a.unicode;a.lastIndex=0}for(var f=[];;){var d=fb(a,o);if(null===d)break;if(yb(f,d),!c)break;""===ob(d[0])&&(a.lastIndex=ub(o,ab(a.lastIndex),l))}for(var p,h="",v=0,y=0;y<f.length;y++){for(var m=ob((d=f[y])[0]),g=pb(hb(ib(d.index),o.length),0),b=[],w=1;w<d.length;w++)yb(b,void 0===(p=d[w])?p:String(p));var k=d.groups;if(u){var x=vb([m],b,g,o);void 0!==k&&yb(x,k);var _=ob(Jg(i,void 0,x))}else _=lb(m,o,g,b,k,i);g>=v&&(h+=gb(o,v,g)+_,v=g+m.length)}return h+gb(o,v)}]}),!kb||!bb||wb);var xb=ni,_b=L,Sb=z,Ob=Sp,Eb=C([].join),Tb=_b!=Object,Rb=Ob("join",",");function Ib(e){return JSON.parse(JSON.stringify(e))}function Cb(e){return void 0===e||isNaN(Number(e))?null:Number(e)}function Pb(e){try{return new Date(e)}catch(e){return null}}function Ab(e,t,n){var r={};if(e)try{r=JSON.parse(e)}catch(e){n.warn(t,e)}return r}xb({target:"Array",proto:!0,forced:Tb||!Rb},{join:function(e){return Eb(Sb(this),void 0===e?",":e)}});var jb=function(){function e(t){rc(this,e),ic(this,"base",void 0),ic(this,"args",void 0),ic(this,"paths",void 0),this.base=t.replace(/\/$/,""),this.args=[],this.paths=[]}return nc(e,[{key:"arg",value:function(e,t){return void 0!==t&&this.args.push(encodeURIComponent(e)+"="+encodeURIComponent(t)),this}},{key:"path",value:function(e){return this.paths.push(encodeURIComponent(e)),this}},{key:"build",value:function(){var e=this.base;return this.paths.length&&(e+="/"+this.paths.join("/")),this.args.length&&(e+="?"+this.args.join("&")),e}}]),e}(),Mb={},Lb=ni,Ub=xo,Nb=Yi,Fb=Y,Db=ur,qb=pr,Bb=z,zb=Ga,Wb=ot,$b=hi,Kb=Lu("slice"),Hb=Wb("species"),Gb=Array,Vb=Math.max;Lb({target:"Array",proto:!0,forced:!Kb},{slice:function(e,t){var n,r,i,a=Bb(this),o=qb(a),s=Db(e,o),u=Db(void 0===t?o:t,o);if(Ub(a)&&(n=a.constructor,(Nb(n)&&(n===Gb||Ub(n.prototype))||Fb(n)&&null===(n=n[Hb]))&&(n=void 0),n===Gb||void 0===n))return $b(a,s,u);for(r=new(void 0===n?Gb:n)(Vb(u-s,0)),i=0;s<u;s++,i++)s in a&&zb(r,i,a[s]);return r.length=i,r}});var Yb,Jb,Qb=ni,Xb=f,Zb=H,ew=Ft,tw=za,nw=(Yb=!1,(Jb=/[ac]/).exec=function(){return Yb=!0,/./.exec.apply(this,arguments)},!0===Jb.test("abc")&&Yb),rw=/./.test;Qb({target:"RegExp",proto:!0,forced:!nw},{test:function(e){var t=ew(this),n=tw(e),r=t.exec;if(!Zb(r))return Xb(rw,t,n);var i=Xb(r,t,n);return null!==i&&(ew(i),!0)}});var iw=ni,aw=s,ow=i,sw=C,uw=$e,cw=H,lw=ee,fw=za,dw=jt.f,pw=Dr,hw=ow.Symbol,vw=hw&&hw.prototype;if(aw&&cw(hw)&&(!("description"in vw)||void 0!==hw().description)){var yw={},mw=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:fw(arguments[0]),t=lw(vw,this)?new hw(e):void 0===e?hw():hw(e);return""===e&&(yw[t]=!0),t};pw(mw,hw),mw.prototype=vw,vw.constructor=mw;var gw="Symbol(test)"==String(hw("test")),bw=sw(vw.valueOf),ww=sw(vw.toString),kw=/^Symbol\((.*)\)[^)]+$/,xw=sw("".replace),_w=sw("".slice);dw(vw,"description",{configurable:!0,get:function(){var e=bw(this);if(uw(yw,e))return"";var t=ww(e),n=gw?_w(t,7,-1):xw(t,kw,"$1");return""===n?void 0:n}}),iw({global:!0,constructor:!0,forced:!0},{Symbol:mw})}fo("iterator");var Sw={exports:{}};!function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(Sw);var Ow=s,Ew=on.EXISTS,Tw=C,Rw=jt.f,Iw=Function.prototype,Cw=Tw(Iw.toString),Pw=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,Aw=Tw(Pw.exec);Ow&&!Ew&&Rw(Iw,"name",{configurable:!0,get:function(){try{return Aw(Pw,Cw(this))[1]}catch(e){return""}}});var jw={exports:{}},Mw={exports:{}};!function(e){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports}(Mw);var Lw={exports:{}};!function(e){e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a=[],o=!0,s=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){s=!0,i=e}finally{try{o||null==n.return||n.return()}finally{if(s)throw i}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports}(Lw);var Uw={exports:{}},Nw={exports:{}};!function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports}(Nw),function(e){var t=Nw.exports;e.exports=function(e,n){if(e){if("string"==typeof e)return t(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}(Uw);var Fw={exports:{}};!function(e){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}(Fw),function(e){var t=Mw.exports,n=Lw.exports,r=Uw.exports,i=Fw.exports;e.exports=function(e,a){return t(e)||n(e,a)||r(e,a)||i()},e.exports.__esModule=!0,e.exports.default=e.exports}(jw);var Dw={exports:{}},qw={exports:{}};!function(e){var t=Nw.exports;e.exports=function(e){if(Array.isArray(e))return t(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(qw);var Bw={exports:{}};!function(e){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(Bw);var zw={exports:{}};!function(e){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}(zw),function(e){var t=qw.exports,n=Bw.exports,r=Uw.exports,i=zw.exports;e.exports=function(e){return t(e)||n(e)||r(e)||i()},e.exports.__esModule=!0,e.exports.default=e.exports}(Dw);var Ww={exports:{}};!function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports}(Ww);var $w={exports:{}};!function(e){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports}($w);var Kw={exports:{}},Hw={exports:{}};!function(e){function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(Hw),function(e){var t=Hw.exports;e.exports=function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),n&&t(e,n)},e.exports.__esModule=!0,e.exports.default=e.exports}(Kw);var Gw={exports:{}},Vw={exports:{}};!function(e){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports}(Vw),function(e){var t=Sw.exports.default,n=Vw.exports;e.exports=function(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(Gw);var Yw={exports:{}};!function(e){function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(Yw);var Jw=gr.includes,Qw=Iy;ni({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return Jw(this,e,arguments.length>1?arguments[1]:void 0)}}),Qw("includes");var Xw=Y,Zw=Math.floor,ek=Number.isInteger||function(e){return!Xw(e)&&isFinite(e)&&Zw(e)===e};ni({target:"Number",stat:!0},{isInteger:ek});var tk=s,nk=C,rk=ra,ik=z,ak=nk(d.f),ok=nk([].push),sk=function(e){return function(t){for(var n,r=ik(t),i=rk(r),a=i.length,o=0,s=[];a>o;)n=i[o++],tk&&!ak(r,n)||ok(s,e?[n,r[n]]:r[n]);return s}},uk={entries:sk(!0),values:sk(!1)}.entries;ni({target:"Object",stat:!0},{entries:function(e){return uk(e)}}),Object.defineProperty(Mb,"__esModule",{value:!0});var ck=jw.exports,lk=Dw.exports,fk=Ww.exports,dk=$w.exports,pk=Kw.exports,hk=Gw.exports,vk=Yw.exports;function yk(e){return e&&"object"===Xu(e)&&"default"in e?e:{default:e}}var mk=yk(Sw.exports),gk=yk(ck),bk=yk(lk),wk=yk(fk),kk=yk(dk),xk=yk(pk),_k=yk(hk),Sk=yk(vk),Ok=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return{checks:t}};function Ek(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Tk(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Tk(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Tk(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Rk=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ok((function(e){var n,r=!1,i=[],a=Ek(t);try{for(a.s();!(n=a.n()).done;){var o=n.value;"string"!=typeof o?(r=r||e instanceof o,i.push("an instance of ".concat(o.name))):(r=r||mk.default(e)===o,i.push("of type ".concat(o)))}}catch(e){a.e(e)}finally{a.f()}return[r,i]}))};function Ik(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ck(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ck(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Ck(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Pk(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Sk.default(e);if(t){var i=Sk.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return _k.default(this,n)}}function Ak(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return jk(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return jk(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function jk(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Mk=function(e,t){if(t.length>e.length)throw new Error("Expected at most ".concat(e.length," argument(s), but got ").concat(t.length));for(;t.length<e.length;)t.push(void 0);var n,r=Ak(t.entries());try{for(r.s();!(n=r.n()).done;){var i=gk.default(n.value,2),a=i[0],o=i[1],s=Fk(e[a],o),u=gk.default(s,4),c=u[0],l=u[1],f=u[2],d=u[3];if(!c)throw new Error("Argument ".concat(a+1," is expected to be ").concat(f).concat(d," but got ").concat(l))}}catch(e){r.e(e)}finally{r.f()}},Lk=function(e){var t,n,r;(["undefined","boolean","number","bigint","string"].includes(mk.default(e))&&(n="string"==typeof e?'"'.concat(e,'"'):"".concat(e)),"object"===mk.default(e)&&"Object"!==(null==e||null===(t=e.constructor)||void 0===t?void 0:t.name))&&(n=null===e?"null":"instance of ".concat(null==e||null===(r=e.constructor)||void 0===r?void 0:r.name));return n||(n=mk.default(e)),n},Uk=function(e){var t,n=[],r=Ak(e);try{for(r.s();!(t=r.n()).done;){var i=t.value;n.push(Nk(i))}}catch(e){r.e(e)}finally{r.f()}return n},Nk=function(e){var t,n=[],r=Ak(Array.isArray(e)?e:[e]);try{for(r.s();!(t=r.n()).done;){var i=t.value;"string"!=typeof i&&"function"!=typeof i?n.push(i):n.push(Rk(i))}}catch(e){r.e(e)}finally{r.f()}return n},Fk=function(e,t){var n,r,i=[],a=!1,o=Ak(e);try{for(o.s();!(r=o.n()).done;){var s,u=Ak(r.value.checks);try{for(u.s();!(s=u.n()).done;){var c=(0,s.value)(t),l=gk.default(c,3),f=l[0],d=l[1],p=l[2];a=a||f,!n&&p&&(n=p),d&&(i=[].concat(bk.default(i),"string"==typeof d?[d]:bk.default(d)))}}catch(e){u.e(e)}finally{u.f()}}}catch(e){o.e(e)}finally{o.f()}if(a)return[!0];var h=n||Lk(t),v=i.length-1;return[!1,h,v>0?"".concat(i.slice(0,v).join(", ")," or ").concat(i[v]):i.join(", "),v>1?";":","]};function Dk(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return qk(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qk(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function qk(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Bk=Ok((function(e){return["string"==typeof e&&e.length>0,"a non-empty string"]})),zk=Ok((function(e){return["number"==typeof e&&Number.isInteger(e)&&e>=0,"a non-negative integer"]})),Wk=Ok((function(e){return["object"===mk.default(e)&&null!==e&&!Array.isArray(e),"a pure object (non-null and non-array)"]}));function $k(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Kk(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Kk(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Kk(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}Mb.array=function(e,t){return Ok((function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(e)];var r,i=$k(n.entries());try{for(i.s();!(r=i.n()).done;){var a=gk.default(r.value,2),o=a[0],s=a[1],u=Fk(Nk(t),s),c=gk.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"a valid array of ".concat(e," (index ").concat(o," should be ").concat(d,")"),"malformed array of ".concat(e," (index ").concat(o," is ").concat(f,")")]}}catch(e){i.e(e)}finally{i.f()}return[!0]}))};var Hk=Mb.custom=Ok,Gk=Mb.literal=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ok((function(e){var n,r=!1,i=[],a=Ik(t);try{for(a.s();!(n=a.n()).done;){var o=n.value;r=r||e===o,i.push("string"==typeof o?'"'.concat(o,'"'):"".concat(o))}}catch(e){a.e(e)}finally{a.f()}return[r,i]}))},Vk=Mb.nonEmptyArray=function(e,t){return Ok((function(n){if(!Array.isArray(n)||n.length<1)return[!1,"a non-empty array of ".concat(e)];var r,i=Dk(n.entries());try{for(i.s();!(r=i.n()).done;){var a=gk.default(r.value,2),o=a[0],s=a[1],u=Fk(Nk(t),s),c=gk.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"a valid non-empty array of ".concat(e," (index ").concat(o," should be ").concat(d,")"),"malformed array of ".concat(e," (index ").concat(o," is ").concat(f,")")]}}catch(e){i.e(e)}finally{i.f()}return[!0]}))},Yk=Mb.nonEmptyString=Bk,Jk=Mb.nonNegativeInteger=zk,Qk=Mb.objectSchema=function(e,t){return Ok((function(n){if("object"!==mk.default(n)||null===n||Array.isArray(n))return[!1,"valid ".concat(e," (should be a pure object)")];for(var r=0,i=Object.entries(t);r<i.length;r++){var a=gk.default(i[r],2),o=a[0],s=a[1],u=Fk(Nk(s),n[o]),c=gk.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"valid ".concat(e,' (key "').concat(o,'" should be ').concat(d,")"),"malformed ".concat(e,' (key "').concat(o,'" is ').concat(f,")")]}return[!0]}))},Xk=Mb.pureObject=Wk;Mb.runtimeTypeValidation=Mk,Mb.stringifyReceivedType=Lk,Mb.type=Rk;var Zk=Mb.validateConstructorTypes=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Uk(t);return function(e){return function(e){xk.default(n,e);var t=Pk(n);function n(){kk.default(this,n);for(var e=arguments.length,i=new Array(e),a=0;a<e;a++)i[a]=arguments[a];return Mk(r,i),t.call.apply(t,[this].concat(i))}return wk.default(n)}(e)}},ex=Mb.validateTypes=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Uk(t);return function(e,t,n){if("function"!=typeof n.value)throw new Error("The validateTypes decorator can only be applied to methods");var i=n.value;n.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Mk(r,t),i.apply(this,t)}}},tx=Mb.validateTypesAsync=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Uk(t);return function(e,t,n){if("function"!=typeof n.value)throw new Error("The validateTypesAsync decorator can only be applied to methods");var i=n.value;n.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];try{Mk(r,t)}catch(e){return Promise.reject(e)}return i.apply(this,t)}}},nx=Hk((function(e){return[["string","number","boolean","object"].includes(Xu(e)),"a JSON type"]})),rx=Hk((function(e){return[["undefined","string","number","boolean","object"].includes(Xu(e)),"an optional JSON type"]})),ix={},ax={exports:{}},ox={exports:{}};!function(e){var t=Yw.exports;e.exports=function(e,n){for(;!Object.prototype.hasOwnProperty.call(e,n)&&null!==(e=t(e)););return e},e.exports.__esModule=!0,e.exports.default=e.exports}(ox),function(e){var t=ox.exports;function n(){return"undefined"!=typeof Reflect&&Reflect.get?(e.exports=n=Reflect.get.bind(),e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=n=function(e,n,r){var i=t(e,n);if(i){var a=Object.getOwnPropertyDescriptor(i,n);return a.get?a.get.call(arguments.length<3?e:r):a.value}},e.exports.__esModule=!0,e.exports.default=e.exports),n.apply(this,arguments)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(ax);var sx={exports:{}};!function(e){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports}(sx),Object.defineProperty(ix,"__esModule",{value:!0});var ux=$w.exports,cx=Ww.exports,lx=Vw.exports,fx=ax.exports,dx=Kw.exports,px=Gw.exports,hx=Yw.exports,vx=sx.exports;function yx(e){return e&&"object"===Xu(e)&&"default"in e?e:{default:e}}var mx=yx(Dw.exports),gx=yx(ux),bx=yx(cx),wx=yx(lx),kx=yx(fx),xx=yx(dx),_x=yx(px),Sx=yx(hx),Ox=yx(vx);function Ex(){}function Tx(){Tx.init.call(this)}function Rx(e){return void 0===e._maxListeners?Tx.defaultMaxListeners:e._maxListeners}function Ix(e,t,n){if(t)e.call(n);else for(var r=e.length,i=Nx(e,r),a=0;a<r;++a)i[a].call(n)}function Cx(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=Nx(e,i),o=0;o<i;++o)a[o].call(n,r)}function Px(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=Nx(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function Ax(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=Nx(e,o),u=0;u<o;++u)s[u].call(n,r,i,a)}function jx(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=Nx(e,i),o=0;o<i;++o)a[o].apply(n,r)}function Mx(e,t,n,r){var i,a,o;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new Ex,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=Rx(e))&&i>0&&o.length>i){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=o.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(s)}}else o=a[t]=n,++e._eventsCount;return e}function Lx(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function Ux(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function Nx(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function Fx(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Sx.default(e);if(t){var i=Sx.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return _x.default(this,n)}}Ex.prototype=Object.create(null),Tx.EventEmitter=Tx,Tx.usingDomains=!1,Tx.prototype.domain=void 0,Tx.prototype._events=void 0,Tx.prototype._maxListeners=void 0,Tx.defaultMaxListeners=10,Tx.init=function(){this.domain=null,Tx.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Ex,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Tx.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Tx.prototype.getMaxListeners=function(){return Rx(this)},Tx.prototype.emit=function(e){var t,n,r,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:Ix(n,l,this);break;case 2:Cx(n,l,this,arguments[1]);break;case 3:Px(n,l,this,arguments[1],arguments[2]);break;case 4:Ax(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];jx(n,l,this,i)}return!0},Tx.prototype.addListener=function(e,t){return Mx(this,e,t,!1)},Tx.prototype.on=Tx.prototype.addListener,Tx.prototype.prependListener=function(e,t){return Mx(this,e,t,!0)},Tx.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Lx(this,e,t)),this},Tx.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Lx(this,e,t)),this},Tx.prototype.removeListener=function(e,t){var n,r,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new Ex:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new Ex,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},Tx.prototype.off=function(e,t){return this.removeListener(e,t)},Tx.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new Ex,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new Ex:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),a=0;a<i.length;++a)"removeListener"!==(r=i[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new Ex,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Tx.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},Tx.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ux.call(e,t)},Tx.prototype.listenerCount=Ux,Tx.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Dx=function(e){xx.default(n,e);var t=Fx(n);function n(){var e;return gx.default(this,n),e=t.call(this),Ox.default(wx.default(e),"eventHistory",new Map),e}return bx.default(n,[{key:"on",value:function(e,t){return kx.default(Sx.default(n.prototype),"on",this).call(this,e,t)}},{key:"once",value:function(e,t){return kx.default(Sx.default(n.prototype),"once",this).call(this,e,t)}},{key:"off",value:function(e,t){return kx.default(Sx.default(n.prototype),"off",this).call(this,e,t)}},{key:"emit",value:function(e){for(var t,r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return this.eventHistory.set(e,i),(t=kx.default(Sx.default(n.prototype),"emit",this)).call.apply(t,[this,e].concat(i))}},{key:"addListener",value:function(e,t){return kx.default(Sx.default(n.prototype),"addListener",this).call(this,e,t)}},{key:"removeListener",value:function(e,t){return kx.default(Sx.default(n.prototype),"removeListener",this).call(this,e,t)}},{key:"addListenerWithReplay",value:function(e,t){var n=this.eventHistory.get(e);return void 0!==n&&t.apply(void 0,mx.default(n)),this.addListener(e,t)}},{key:"onWithReplay",value:function(e,t){return this.addListenerWithReplay(e,t)}},{key:"onceWithReplay",value:function(e,t){var r=this.eventHistory.get(e);return void 0!==r?(t.apply(void 0,mx.default(r)),this):kx.default(Sx.default(n.prototype),"once",this).call(this,e,t)}}]),n}(Tx),qx=ix.ReplayEventEmitter=Dx,Bx={exports:{}};!function(e,n){var r="__lodash_hash_undefined__",i=9007199254740991,a="[object Arguments]",o="[object Array]",s="[object Boolean]",u="[object Date]",c="[object Error]",l="[object Function]",f="[object Map]",d="[object Number]",p="[object Object]",h="[object Promise]",v="[object RegExp]",y="[object Set]",m="[object String]",g="[object Symbol]",b="[object WeakMap]",w="[object ArrayBuffer]",k="[object DataView]",x=/^\[object .+?Constructor\]$/,_=/^(?:0|[1-9]\d*)$/,S={};S["[object Float32Array]"]=S["[object Float64Array]"]=S["[object Int8Array]"]=S["[object Int16Array]"]=S["[object Int32Array]"]=S["[object Uint8Array]"]=S["[object Uint8ClampedArray]"]=S["[object Uint16Array]"]=S["[object Uint32Array]"]=!0,S[a]=S[o]=S[w]=S[s]=S[k]=S[u]=S[c]=S[l]=S[f]=S[d]=S[p]=S[v]=S[y]=S[m]=S[b]=!1;var O="object"==Xu(t)&&t&&t.Object===Object&&t,E="object"==("undefined"==typeof self?"undefined":Xu(self))&&self&&self.Object===Object&&self,T=O||E||Function("return this")(),R=n&&!n.nodeType&&n,I=R&&e&&!e.nodeType&&e,C=I&&I.exports===R,P=C&&O.process,A=function(){try{return P&&P.binding&&P.binding("util")}catch(e){}}(),j=A&&A.isTypedArray;function M(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function L(e,t){return e.has(t)}function U(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function N(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var F,D,q=Array.prototype,B=Function.prototype,z=Object.prototype,W=T["__core-js_shared__"],$=B.toString,K=z.hasOwnProperty,H=function(){var e=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),G=z.toString,V=RegExp("^"+$.call(K).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Y=C?T.Buffer:void 0,J=T.Symbol,Q=T.Uint8Array,X=z.propertyIsEnumerable,Z=q.splice,ee=J?J.toStringTag:void 0,te=Object.getOwnPropertySymbols,ne=Y?Y.isBuffer:void 0,re=(F=Object.keys,D=Object,function(e){return F(D(e))}),ie=Ae(T,"DataView"),ae=Ae(T,"Map"),oe=Ae(T,"Promise"),se=Ae(T,"Set"),ue=Ae(T,"WeakMap"),ce=Ae(Object,"create"),le=Ue(ie),fe=Ue(ae),de=Ue(oe),pe=Ue(se),he=Ue(ue),ve=J?J.prototype:void 0,ye=ve?ve.valueOf:void 0;function me(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ge(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function be(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function we(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new be;++t<n;)this.add(e[t])}function ke(e){var t=this.__data__=new ge(e);this.size=t.size}function xe(e,t){var n=De(e),r=!n&&Fe(e),i=!n&&!r&&qe(e),a=!n&&!r&&!i&&Ke(e),o=n||r||i||a,s=o?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],u=s.length;for(var c in e)!t&&!K.call(e,c)||o&&("length"==c||i&&("offset"==c||"parent"==c)||a&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Le(c,u))||s.push(c);return s}function _e(e,t){for(var n=e.length;n--;)if(Ne(e[n][0],t))return n;return-1}function Se(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":ee&&ee in Object(e)?function(e){var t=K.call(e,ee),n=e[ee];try{e[ee]=void 0;var r=!0}catch(e){}var i=G.call(e);r&&(t?e[ee]=n:delete e[ee]);return i}(e):function(e){return G.call(e)}(e)}function Oe(e){return $e(e)&&Se(e)==a}function Ee(e,t,n,r,i){return e===t||(null==e||null==t||!$e(e)&&!$e(t)?e!=e&&t!=t:function(e,t,n,r,i,l){var h=De(e),b=De(t),x=h?o:Me(e),_=b?o:Me(t),S=(x=x==a?p:x)==p,O=(_=_==a?p:_)==p,E=x==_;if(E&&qe(e)){if(!qe(t))return!1;h=!0,S=!1}if(E&&!S)return l||(l=new ke),h||Ke(e)?Ie(e,t,n,r,i,l):function(e,t,n,r,i,a,o){switch(n){case k:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case w:return!(e.byteLength!=t.byteLength||!a(new Q(e),new Q(t)));case s:case u:case d:return Ne(+e,+t);case c:return e.name==t.name&&e.message==t.message;case v:case m:return e==t+"";case f:var l=U;case y:var p=1&r;if(l||(l=N),e.size!=t.size&&!p)return!1;var h=o.get(e);if(h)return h==t;r|=2,o.set(e,t);var b=Ie(l(e),l(t),r,i,a,o);return o.delete(e),b;case g:if(ye)return ye.call(e)==ye.call(t)}return!1}(e,t,x,n,r,i,l);if(!(1&n)){var T=S&&K.call(e,"__wrapped__"),R=O&&K.call(t,"__wrapped__");if(T||R){var I=T?e.value():e,C=R?t.value():t;return l||(l=new ke),i(I,C,n,r,l)}}if(!E)return!1;return l||(l=new ke),function(e,t,n,r,i,a){var o=1&n,s=Ce(e),u=s.length,c=Ce(t).length;if(u!=c&&!o)return!1;var l=u;for(;l--;){var f=s[l];if(!(o?f in t:K.call(t,f)))return!1}var d=a.get(e);if(d&&a.get(t))return d==t;var p=!0;a.set(e,t),a.set(t,e);var h=o;for(;++l<u;){var v=e[f=s[l]],y=t[f];if(r)var m=o?r(y,v,f,t,e,a):r(v,y,f,e,t,a);if(!(void 0===m?v===y||i(v,y,n,r,a):m)){p=!1;break}h||(h="constructor"==f)}if(p&&!h){var g=e.constructor,b=t.constructor;g==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof g&&g instanceof g&&"function"==typeof b&&b instanceof b||(p=!1)}return a.delete(e),a.delete(t),p}(e,t,n,r,i,l)}(e,t,n,r,Ee,i))}function Te(e){return!(!We(e)||function(e){return!!H&&H in e}(e))&&(Be(e)?V:x).test(Ue(e))}function Re(e){if(n=(t=e)&&t.constructor,r="function"==typeof n&&n.prototype||z,t!==r)return re(e);var t,n,r,i=[];for(var a in Object(e))K.call(e,a)&&"constructor"!=a&&i.push(a);return i}function Ie(e,t,n,r,i,a){var o=1&n,s=e.length,u=t.length;if(s!=u&&!(o&&u>s))return!1;var c=a.get(e);if(c&&a.get(t))return c==t;var l=-1,f=!0,d=2&n?new we:void 0;for(a.set(e,t),a.set(t,e);++l<s;){var p=e[l],h=t[l];if(r)var v=o?r(h,p,l,t,e,a):r(p,h,l,e,t,a);if(void 0!==v){if(v)continue;f=!1;break}if(d){if(!M(t,(function(e,t){if(!L(d,t)&&(p===e||i(p,e,n,r,a)))return d.push(t)}))){f=!1;break}}else if(p!==h&&!i(p,h,n,r,a)){f=!1;break}}return a.delete(e),a.delete(t),f}function Ce(e){return function(e,t,n){var r=t(e);return De(e)?r:function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}(r,n(e))}(e,He,je)}function Pe(e,t){var n=e.__data__;return function(e){var t=Xu(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?n["string"==typeof t?"string":"hash"]:n.map}function Ae(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Te(n)?n:void 0}me.prototype.clear=function(){this.__data__=ce?ce(null):{},this.size=0},me.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},me.prototype.get=function(e){var t=this.__data__;if(ce){var n=t[e];return n===r?void 0:n}return K.call(t,e)?t[e]:void 0},me.prototype.has=function(e){var t=this.__data__;return ce?void 0!==t[e]:K.call(t,e)},me.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ce&&void 0===t?r:t,this},ge.prototype.clear=function(){this.__data__=[],this.size=0},ge.prototype.delete=function(e){var t=this.__data__,n=_e(t,e);return!(n<0)&&(n==t.length-1?t.pop():Z.call(t,n,1),--this.size,!0)},ge.prototype.get=function(e){var t=this.__data__,n=_e(t,e);return n<0?void 0:t[n][1]},ge.prototype.has=function(e){return _e(this.__data__,e)>-1},ge.prototype.set=function(e,t){var n=this.__data__,r=_e(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},be.prototype.clear=function(){this.size=0,this.__data__={hash:new me,map:new(ae||ge),string:new me}},be.prototype.delete=function(e){var t=Pe(this,e).delete(e);return this.size-=t?1:0,t},be.prototype.get=function(e){return Pe(this,e).get(e)},be.prototype.has=function(e){return Pe(this,e).has(e)},be.prototype.set=function(e,t){var n=Pe(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},we.prototype.add=we.prototype.push=function(e){return this.__data__.set(e,r),this},we.prototype.has=function(e){return this.__data__.has(e)},ke.prototype.clear=function(){this.__data__=new ge,this.size=0},ke.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},ke.prototype.get=function(e){return this.__data__.get(e)},ke.prototype.has=function(e){return this.__data__.has(e)},ke.prototype.set=function(e,t){var n=this.__data__;if(n instanceof ge){var r=n.__data__;if(!ae||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new be(r)}return n.set(e,t),this.size=n.size,this};var je=te?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}(te(e),(function(t){return X.call(e,t)})))}:function(){return[]},Me=Se;function Le(e,t){return!!(t=null==t?i:t)&&("number"==typeof e||_.test(e))&&e>-1&&e%1==0&&e<t}function Ue(e){if(null!=e){try{return $.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ne(e,t){return e===t||e!=e&&t!=t}(ie&&Me(new ie(new ArrayBuffer(1)))!=k||ae&&Me(new ae)!=f||oe&&Me(oe.resolve())!=h||se&&Me(new se)!=y||ue&&Me(new ue)!=b)&&(Me=function(e){var t=Se(e),n=t==p?e.constructor:void 0,r=n?Ue(n):"";if(r)switch(r){case le:return k;case fe:return f;case de:return h;case pe:return y;case he:return b}return t});var Fe=Oe(function(){return arguments}())?Oe:function(e){return $e(e)&&K.call(e,"callee")&&!X.call(e,"callee")},De=Array.isArray;var qe=ne||function(){return!1};function Be(e){if(!We(e))return!1;var t=Se(e);return t==l||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}function ze(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=i}function We(e){var t=Xu(e);return null!=e&&("object"==t||"function"==t)}function $e(e){return null!=e&&"object"==Xu(e)}var Ke=j?function(e){return function(t){return e(t)}}(j):function(e){return $e(e)&&ze(e.length)&&!!S[Se(e)]};function He(e){return null!=(t=e)&&ze(t.length)&&!Be(t)?xe(e):Re(e);var t}e.exports=function(e,t){return Ee(e,t)}}(Bx,Bx.exports);var zx=Bx.exports;function Wx(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}var $x=dy.scope("User"),User=function(e){Qu(User,e);var t,n,r,i,a,o,s,u=Wx(User);function User(e,t,n,r){var i;return rc(this,User),ic(Yu(i=u.call(this)),"links",void 0),ic(Yu(i),"configuration",void 0),ic(Yu(i),"services",void 0),ic(Yu(i),"entity",void 0),ic(Yu(i),"state",void 0),ic(Yu(i),"promiseToFetch",null),ic(Yu(i),"subscribed",void 0),ic(Yu(i),"_initializationPromise",void 0),ic(Yu(i),"_resolveInitializationPromise",void 0),ic(Yu(i),"updated","updated"),ic(Yu(i),"userSubscribed","userSubscribed"),ic(Yu(i),"userUnsubscribed","userUnsubscribed"),i.services=r,i.subscribed="initializing",i.setMaxListeners(0),i.state={identity:e,entityName:t,friendlyName:null,attributes:{},online:null,notifiable:null},i._initializationPromise=new Promise((function(e){i._resolveInitializationPromise=e})),null!==n&&i._resolveInitialization(n,e,t,!1),i}return nc(User,[{key:"identity",get:function(){return this.state.identity},set:function(e){this.state.identity=e}},{key:"entityName",set:function(e){this.state.entityName=e}},{key:"attributes",get:function(){return this.state.attributes}},{key:"friendlyName",get:function(){return this.state.friendlyName}},{key:"isOnline",get:function(){return this.state.online}},{key:"isNotifiable",get:function(){return this.state.notifiable}},{key:"isSubscribed",get:function(){return"subscribed"==this.subscribed}},{key:"_update",value:(s=Vu(lh.mark((function e(t,n){var r,i;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:r=[],$x.debug("User for",this.state.identity,"updated:",t,n),e.t0=t,e.next="friendlyName"===e.t0?7:"attributes"===e.t0?9:"reachability"===e.t0?12:15;break;case 7:return this.state.friendlyName!==n.value&&(r.push("friendlyName"),this.state.friendlyName=n.value),e.abrupt("break",16);case 9:return i=Ab(n.value,"Retrieved malformed attributes from the server for user: ".concat(this.state.identity),$x),zx(this.state.attributes,i)||(this.state.attributes=i,r.push("attributes")),e.abrupt("break",16);case 12:return this.state.online!==n.online&&(this.state.online=n.online,r.push("reachabilityOnline")),this.state.notifiable!==n.notifiable&&(this.state.notifiable=n.notifiable,r.push("reachabilityNotifiable")),e.abrupt("break",16);case 15:return e.abrupt("return");case 16:r.length>0&&this.emit("updated",{user:this,updateReasons:r});case 17:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_updateReachabilityInfo",value:(o=Vu(lh.mark((function e(t,n){var r=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if(this.configuration.reachabilityEnabled){e.next=4;break}return e.abrupt("return",Promise.resolve());case 4:return e.abrupt("return",t.get("reachability").then(n).catch((function(e){$x.warn("Failed to get reachability info for ",r.state.identity,e)})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"_fetch",value:(a=Vu(lh.mark((function e(){var t=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if(this.state.entityName){e.next=4;break}return e.abrupt("return",this);case 4:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then((function(e){return t.entity=e,e.on("itemUpdated",(function(e){return $x.debug(t.state.entityName+" ("+t.state.identity+") itemUpdated: "+e.item.key),t._update(e.item.key,e.item.data)})),Promise.all([e.get("friendlyName").then((function(e){return t._update(e.key,e.data)})),e.get("attributes").then((function(e){return t._update(e.key,e.data)})),t._updateReachabilityInfo(e,(function(e){return t._update(e.key,e.data)}))])})).then((function(){return $x.debug("Fetched for",t.identity),t.subscribed="subscribed",t.emit("userSubscribed",t),t})).catch((function(e){throw t.promiseToFetch=null,e})),e.abrupt("return",this.promiseToFetch);case 6:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_ensureFetched",value:(i=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:return e.abrupt("return",this.promiseToFetch||this._fetch());case 3:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"updateAttributes",value:(r=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if("unsubscribed"!=this.subscribed){e.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return e.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(t)});case 6:return e.abrupt("return",this);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"updateFriendlyName",value:(n=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if("unsubscribed"!=this.subscribed){e.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return e.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{friendly_name:t});case 6:return e.abrupt("return",this);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribe",value:(t=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if(!this.promiseToFetch){e.next=9;break}return e.next=5,this.promiseToFetch;case 5:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 9:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_resolveInitialization",value:function(e,t,n,r){this.configuration=e,this.identity=t,this.entityName=n,this.links={self:"".concat(this.configuration.links.users,"/").concat(encodeURIComponent(this.identity))},this._resolveInitializationPromise(),r&&this.emit("updated",{user:this,updateReasons:["friendlyName","attributes","reachabilityOnline","reachabilityNotifiable"]})}}]),User}(qx);function Kx(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Hx(e,t){if(e){if("string"==typeof e)return Kx(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Kx(e,t):void 0}}function Gx(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a=[],o=!0,s=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){s=!0,i=e}finally{try{o||null==n.return||n.return()}finally{if(s)throw i}}return a}}(e,t)||Hx(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}dh([tx(nx),ph("design:type",Function),ph("design:paramtypes",[Object]),ph("design:returntype",Promise)],User.prototype,"updateAttributes",null),dh([tx(["string"]),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],User.prototype,"updateFriendlyName",null);var Vx={exports:{}},Yx=o((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),Jx=o,Qx=Y,Xx=T,Zx=Yx,e_=Object.isExtensible,t_=Jx((function(){e_(1)}))||Zx?function(e){return!!Qx(e)&&((!Zx||"ArrayBuffer"!=Xx(e))&&(!e_||e_(e)))}:e_,n_=!o((function(){return Object.isExtensible(Object.preventExtensions({}))})),r_=ni,i_=C,a_=kn,o_=Y,s_=$e,u_=jt.f,c_=Zn,l_=Wa,f_=t_,d_=n_,p_=!1,h_=Ye("meta"),v_=0,y_=function(e){u_(e,h_,{value:{objectID:"O"+v_++,weakData:{}}})},m_=Vx.exports={enable:function(){m_.enable=function(){},p_=!0;var e=c_.f,t=i_([].splice),n={};n[h_]=1,e(n).length&&(c_.f=function(n){for(var r=e(n),i=0,a=r.length;i<a;i++)if(r[i]===h_){t(r,i,1);break}return r},r_({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:l_.f}))},fastKey:function(e,t){if(!o_(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!s_(e,h_)){if(!f_(e))return"F";if(!t)return"E";y_(e)}return e[h_].objectID},getWeakData:function(e,t){if(!s_(e,h_)){if(!f_(e))return!0;if(!t)return!1;y_(e)}return e[h_].weakData},onFreeze:function(e){return d_&&p_&&f_(e)&&!s_(e,h_)&&y_(e),e}};a_[h_]=!0;var g_=ni,b_=i,w_=C,k_=Vr,x_=Xn,__=Vx.exports,S_=Nd,O_=Ec,E_=H,T_=U,R_=Y,I_=o,C_=zd,P_=oi,A_=rm,j_=function(e,t,n){var r=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),a=r?"set":"add",o=b_[e],s=o&&o.prototype,u=o,c={},l=function(e){var t=w_(s[e]);x_(s,e,"add"==e?function(e){return t(this,0===e?0:e),this}:"delete"==e?function(e){return!(i&&!R_(e))&&t(this,0===e?0:e)}:"get"==e?function(e){return i&&!R_(e)?void 0:t(this,0===e?0:e)}:"has"==e?function(e){return!(i&&!R_(e))&&t(this,0===e?0:e)}:function(e,n){return t(this,0===e?0:e,n),this})};if(k_(e,!E_(o)||!(i||s.forEach&&!I_((function(){(new o).entries().next()})))))u=n.getConstructor(t,e,r,a),__.enable();else if(k_(e,!0)){var f=new u,d=f[a](i?{}:-0,1)!=f,p=I_((function(){f.has(1)})),h=C_((function(e){new o(e)})),v=!i&&I_((function(){for(var e=new o,t=5;t--;)e[a](t,t);return!e.has(-0)}));h||((u=t((function(e,t){O_(e,s);var n=A_(new o,e,u);return T_(t)||S_(t,n[a],{that:n,AS_ENTRIES:r}),n}))).prototype=s,s.constructor=u),(p||v)&&(l("delete"),l("has"),r&&l("get")),(v||d)&&l(a),i&&s.clear&&delete s.clear}return c[e]=u,g_({global:!0,constructor:!0,forced:u!=o},c),P_(u,e),i||n.setStrong(u,e,r),u},M_=Xn,L_=function(e,t,n){for(var r in t)M_(e,r,t[r],n);return e},U_=jt.f,N_=_a,F_=L_,D_=wo,q_=Ec,B_=U,z_=Nd,W_=Vv,$_=Yv,K_=_c,H_=s,G_=Vx.exports.fastKey,V_=Ln.set,Y_=Ln.getterFor,J_={getConstructor:function(e,t,n,r){var i=e((function(e,i){q_(e,a),V_(e,{type:t,index:N_(null),first:void 0,last:void 0,size:0}),H_||(e.size=0),B_(i)||z_(i,e[r],{that:e,AS_ENTRIES:n})})),a=i.prototype,o=Y_(t),s=function(e,t,n){var r,i,a=o(e),s=u(e,t);return s?s.value=n:(a.last=s={index:i=G_(t,!0),key:t,value:n,previous:r=a.last,next:void 0,removed:!1},a.first||(a.first=s),r&&(r.next=s),H_?a.size++:e.size++,"F"!==i&&(a.index[i]=s)),e},u=function(e,t){var n,r=o(e),i=G_(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==t)return n};return F_(a,{clear:function(){for(var e=o(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,H_?e.size=0:this.size=0},delete:function(e){var t=this,n=o(t),r=u(t,e);if(r){var i=r.next,a=r.previous;delete n.index[r.index],r.removed=!0,a&&(a.next=i),i&&(i.previous=a),n.first==r&&(n.first=i),n.last==r&&(n.last=a),H_?n.size--:t.size--}return!!r},forEach:function(e){for(var t,n=o(this),r=D_(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!u(this,e)}}),F_(a,n?{get:function(e){var t=u(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),H_&&U_(a,"size",{get:function(){return o(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=Y_(t),a=Y_(r);W_(e,t,(function(e,t){V_(this,{type:r,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=a(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?$_("keys"==t?n.key:"values"==t?n.value:[n.key,n.value],!1):(e.target=void 0,$_(void 0,!0))}),n?"entries":"values",!n,!0),K_(t)}};j_("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),J_);var Q_={};Object.defineProperty(Q_,"__esModule",{value:!0});var X_=Ww.exports,Z_=Vw.exports,eS=Kw.exports,tS=Gw.exports,nS=Yw.exports,rS=sx.exports;function iS(e){return e&&"object"===Xu(e)&&"default"in e?e:{default:e}}var aS=iS($w.exports),oS=iS(X_),sS=iS(Z_),uS=iS(eS),cS=iS(tS),lS=iS(nS),fS=iS(rS);function dS(){}function pS(){pS.init.call(this)}function hS(e){return void 0===e._maxListeners?pS.defaultMaxListeners:e._maxListeners}function vS(e,t,n){if(t)e.call(n);else for(var r=e.length,i=_S(e,r),a=0;a<r;++a)i[a].call(n)}function yS(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=_S(e,i),o=0;o<i;++o)a[o].call(n,r)}function mS(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=_S(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function gS(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=_S(e,o),u=0;u<o;++u)s[u].call(n,r,i,a)}function bS(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=_S(e,i),o=0;o<i;++o)a[o].apply(n,r)}function wS(e,t,n,r){var i,a,o;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new dS,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=hS(e))&&i>0&&o.length>i){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=o.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(s)}}else o=a[t]=n,++e._eventsCount;return e}function kS(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function xS(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function _S(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function SS(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=lS.default(e);if(t){var i=lS.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return cS.default(this,n)}}dS.prototype=Object.create(null),pS.EventEmitter=pS,pS.usingDomains=!1,pS.prototype.domain=void 0,pS.prototype._events=void 0,pS.prototype._maxListeners=void 0,pS.defaultMaxListeners=10,pS.init=function(){this.domain=null,pS.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new dS,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},pS.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},pS.prototype.getMaxListeners=function(){return hS(this)},pS.prototype.emit=function(e){var t,n,r,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:vS(n,l,this);break;case 2:yS(n,l,this,arguments[1]);break;case 3:mS(n,l,this,arguments[1],arguments[2]);break;case 4:gS(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];bS(n,l,this,i)}return!0},pS.prototype.addListener=function(e,t){return wS(this,e,t,!1)},pS.prototype.on=pS.prototype.addListener,pS.prototype.prependListener=function(e,t){return wS(this,e,t,!0)},pS.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,kS(this,e,t)),this},pS.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,kS(this,e,t)),this},pS.prototype.removeListener=function(e,t){var n,r,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new dS:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new dS,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},pS.prototype.off=function(e,t){return this.removeListener(e,t)},pS.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new dS,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new dS:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),a=0;a<i.length;++a)"removeListener"!==(r=i[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new dS,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},pS.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},pS.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):xS.call(e,t)},pS.prototype.listenerCount=xS,pS.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var OS=function(e){uS.default(n,e);var t=SS(n);function n(e){var r;return aS.default(this,n),r=t.call(this),fS.default(sS.default(r),"minDelay",void 0),fS.default(sS.default(r),"maxDelay",void 0),fS.default(sS.default(r),"initialDelay",void 0),fS.default(sS.default(r),"maxAttemptsCount",void 0),fS.default(sS.default(r),"maxAttemptsTime",void 0),fS.default(sS.default(r),"randomness",void 0),fS.default(sS.default(r),"prevDelay",void 0),fS.default(sS.default(r),"currDelay",void 0),fS.default(sS.default(r),"timeout",null),fS.default(sS.default(r),"inProgress",void 0),fS.default(sS.default(r),"attemptNum",void 0),fS.default(sS.default(r),"startTimestamp",-1),r.minDelay=e.min,r.maxDelay=e.max,r.initialDelay=e.initial||0,r.maxAttemptsCount=e.maxAttemptsCount||0,r.maxAttemptsTime=e.maxAttemptsTime||0,r.randomness=e.randomness||0,r.inProgress=!1,r.attemptNum=0,r.prevDelay=0,r.currDelay=0,r}return oS.default(n,[{key:"attempt",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}},{key:"nextDelay",value:function(e){if("number"==typeof e)return this.prevDelay=0,this.currDelay=e,e;if(0==this.attemptNum)return this.initialDelay;if(1==this.attemptNum)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var t=this.currDelay+this.prevDelay;return this.maxDelay&&t>this.maxDelay&&(this.currDelay=this.maxDelay,t=this.maxDelay),this.currDelay=t,t}},{key:"randomize",value:function(e){var t=e*this.randomness,n=Math.round(Math.random()*t*2-t);return Math.max(0,e+n)}},{key:"scheduleAttempt",value:function(e){var t=this;if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt count limit reached"));var n=this.nextDelay(e);if(n=this.randomize(n),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+n)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt time limit reached"));this.timeout=setTimeout((function(){return t.attempt()}),n)}},{key:"cleanup",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}},{key:"start",value:function(){if(this.inProgress)throw new Error("Retrier is already in progress");this.inProgress=!0,this.startTimestamp=Date.now(),this.scheduleAttempt(this.initialDelay)}},{key:"cancel",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.emit("cancelled"))}},{key:"succeeded",value:function(e){this.emit("succeeded",e)}},{key:"failed",value:function(e,t){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(t)}}]),n}(pS),ES=function(e){uS.default(n,e);var t=SS(n);function n(e){var r;return aS.default(this,n),r=t.call(this),fS.default(sS.default(r),"retrier",void 0),fS.default(sS.default(r),"resolve",(function(){})),fS.default(sS.default(r),"reject",(function(){})),r.retrier=new OS(e),r}return oS.default(n,[{key:"run",value:function(e){var t=this;return this.retrier.on("attempt",(function(){e().then((function(e){return t.retrier.succeeded(e)})).catch((function(e){return t.retrier.failed(e)}))})),this.retrier.on("succeeded",(function(e){return t.resolve(e)})),this.retrier.on("cancelled",(function(){return t.reject(new Error("Cancelled"))})),this.retrier.on("failed",(function(e){return t.reject(e)})),new Promise((function(e,n){t.resolve=e,t.reject=n,t.retrier.start()}))}},{key:"cancel",value:function(){this.retrier.cancel()}}]),n}(pS);function TS(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=lS.default(e);if(t){var i=lS.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return cS.default(this,n)}}function RS(e){return null!=e}var IS=function(e){uS.default(n,e);var t=TS(n);function n(e){var r;aS.default(this,n),r=t.call(this),fS.default(sS.default(r),"maxDelay",void 0),fS.default(sS.default(r),"initialDelay",void 0),fS.default(sS.default(r),"factor",void 0),fS.default(sS.default(r),"randomisationFactor",void 0),fS.default(sS.default(r),"backoffDelay",0),fS.default(sS.default(r),"nextBackoffDelay",0),fS.default(sS.default(r),"backoffNumber",0),fS.default(sS.default(r),"timeoutID",null),fS.default(sS.default(r),"maxNumberOfRetry",-1);var i=e=e||{},a=i.initialDelay,o=i.maxDelay,s=i.randomisationFactor,u=i.factor;if(RS(a)&&a<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(RS(o)&&o<=1)throw new Error("The maximal timeout must be greater than 1.");if(RS(s)&&(s<0||s>1))throw new Error("The randomisation factor must be between 0 and 1.");if(RS(u)&&u<=1)throw new Error("Exponential factor should be greater than 1.");if(r.initialDelay=a||100,r.maxDelay=o||1e4,r.maxDelay<=r.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return r.randomisationFactor=s||0,r.factor=u||2,r.reset(),r}return oS.default(n,[{key:"backoff",value:function(e){null==this.timeoutID&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",e),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,e)))}},{key:"reset",value:function(){this.backoffDelay=0,this.nextBackoffDelay=this.initialDelay,this.backoffNumber=0,this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=null}},{key:"failAfter",value:function(e){if(e<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(e));this.maxNumberOfRetry=e}},{key:"next",value:function(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var e=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*e))}},{key:"onBackoff",value:function(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}],[{key:"exponential",value:function(e){return new n(e)}}]),n}(pS),CS=Q_.AsyncRetrier=ES;Q_.Backoff=IS;var PS=Q_.Retrier=OS;function AS(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return jS(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return jS(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function jS(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var MS=function(){function e(t,n){rc(this,e),ic(this,"configuration",void 0),ic(this,"services",void 0),ic(this,"cacheLifetime",void 0),ic(this,"cache",void 0),ic(this,"timer",void 0),this.configuration=t,this.services=n,this.cache=new Map,this.cacheLifetime=100*this.configuration.httpCacheInterval,this.cleanupCache()}return nc(e,[{key:"isExpired",value:function(e){return!this.cacheLifetime||Date.now()-e>this.cacheLifetime}},{key:"cleanupCache",value:function(){var e,t=AS(this.cache);try{for(t.s();!(e=t.n()).done;){var n=Gx(e.value,2),r=n[0],i=n[1];this.isExpired(i.timestamp)&&this.cache.delete(r)}}catch(e){t.e(e)}finally{t.f()}0===this.cache.size&&clearInterval(this.timer)}},{key:"pokeTimer",value:function(){var e=this;this.timer=this.timer||setInterval((function(){return e.cleanupCache()}),2*this.cacheLifetime)}},{key:"executeWithRetry",value:function(e){var t=this;return new Promise((function(n,r){var i=new PS(t.configuration.backoffConfiguration);i.on("attempt",(function(){e().then((function(e){if(e.statusCode>=400&&e.statusCode<500){var t=JSON.parse(e.payload);i.failed(new Error("".concat(t.message)))}else i.succeeded(e)})).catch((function(e){i.removeAllListeners(),i.cancel(),r(e)}))})),i.on("succeeded",(function(e){n(e)})),i.on("cancelled",(function(e){return r(e)})),i.on("failed",(function(e){return r(e)})),i.start()}))}},{key:"get",value:function(){var e=Vu(lh.mark((function e(t){var n,r,i=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.cache.get(t))||this.isExpired(n.timestamp)){e.next=3;break}return e.abrupt("return",n.response);case 3:return e.next=5,this.executeWithRetry((function(){return i.services.transport.get({url:t,grant:i.configuration.productId})}),this.configuration.retryWhenThrottled);case 5:return r=e.sent,this.cache.set(t,{response:r,timestamp:Date.now()}),this.pokeTimer(),e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()}]),e}(),LS=nc((function e(){rc(this,e)}));ic(LS,"TYPING_INDICATOR","twilio.ipmsg.typing_indicator"),ic(LS,"NEW_MESSAGE","twilio.conversations.new_message"),ic(LS,"ADDED_TO_CONVERSATION","twilio.conversations.added_to_conversation"),ic(LS,"REMOVED_FROM_CONVERSATION","twilio.conversations.removed_from_conversation"),ic(LS,"CONSUMPTION_UPDATE","twilio.channel.consumption_update");var US={},NS={exports:{}},FS={exports:{}};!function(e){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports}(FS),function(e){var t=Hw.exports,n=FS.exports;function r(i,a,o){return n()?(e.exports=r=Reflect.construct.bind(),e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=r=function(e,n,r){var i=[null];i.push.apply(i,n);var a=new(Function.bind.apply(e,i));return r&&t(a,r.prototype),a},e.exports.__esModule=!0,e.exports.default=e.exports),r.apply(null,arguments)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(NS);var DS={exports:{}};!function(e){function t(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}e.exports=function(e){return function(){var n=this,r=arguments;return new Promise((function(i,a){var o=e.apply(n,r);function s(e){t(o,i,a,s,u,"next",e)}function u(e){t(o,i,a,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports}(DS);var qS=n(fh),BS={},zS={exports:{}},WS={exports:{}};!function(e){e.exports=function(e){return-1!==Function.toString.call(e).indexOf("[native code]")},e.exports.__esModule=!0,e.exports.default=e.exports}(WS),function(e){var t=Yw.exports,n=Hw.exports,r=WS.exports,i=NS.exports;function a(o){var s="function"==typeof Map?new Map:void 0;return e.exports=a=function(e){if(null===e||!r(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==s){if(s.has(e))return s.get(e);s.set(e,a)}function a(){return i(e,arguments,t(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),n(a,e)},e.exports.__esModule=!0,e.exports.default=e.exports,a(o)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}(zS);var $S=function(e){return crypto.getRandomValues(new Uint8Array(e))},KS=function(e,t,n){var r=(2<<Math.log(e.length-1)/Math.LN2)-1,i=-~(1.6*r*t/e.length);return function(){for(var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t,o="";;)for(var s=n(i),u=i;u--;)if((o+=e[s[u]&r]||"").length===a)return o}},HS=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21;return crypto.getRandomValues(new Uint8Array(e)).reduce((function(e,t){return e+=(t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_"}),"")},GS=Object.freeze({__proto__:null,nanoid:HS,customAlphabet:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:21;return KS(e,t,$S)},customRandom:KS,urlAlphabet:"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",random:$S}),VS=n(GS),YS=ni,JS=n_,QS=o,XS=Y,ZS=Vx.exports.onFreeze,eO=Object.freeze;YS({target:"Object",stat:!0,forced:QS((function(){eO(1)})),sham:!JS},{freeze:function(e){return eO&&XS(e)?eO(ZS(e)):e}}),Object.defineProperty(BS,"__esModule",{value:!0});var tO=sy.exports,nO=Vw.exports,rO=sx.exports,iO=Ww.exports,aO=$w.exports,oO=Kw.exports,sO=Gw.exports,uO=Yw.exports,cO=zS.exports,lO=VS,fO=Dw.exports;function dO(e){return e&&"object"===Xu(e)&&"default"in e?e:{default:e}}var pO=dO(tO),hO=dO(nO),vO=dO(rO),yO=dO(iO),mO=dO(aO),gO=dO(oO),bO=dO(sO),wO=dO(uO),kO=dO(cO),xO=dO(fO),_O=function(e){var t=pO.default.getLevel();pO.default.setLevel("warn"),pO.default.warn(e),pO.default.setLevel(t)};function SO(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=wO.default(e);if(t){var i=wO.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bO.default(this,n)}}var OO=function(e){gO.default(n,e);var t=SO(n);function n(){return mO.default(this,n),t.call(this,"Promise was cancelled")}return yO.default(n)}(kO.default(Error)),EO=function(e){gO.default(n,e);var t=SO(n);function n(e){var r;mO.default(this,n);var i,a=lO.nanoid();return r=t.call(this,(function(t,r){return i=r,e((function(e){n.onCancelCallbackMap.delete(a),t(e)}),(function(e){n.onCancelCallbackMap.delete(a),r(e)}),(function(e){n.onCancelCallbackMap.set(a,e)}))})),vO.default(hO.default(r),"id",void 0),vO.default(hO.default(r),"rejectPromise",void 0),r.id=a,r.rejectPromise=i,r}return yO.default(n,[{key:"cancel",value:function(){var e=n.onCancelCallbackMap.get(this.id);return null==e||e(),this.rejectPromise&&(this.catch((function(){})),this.rejectPromise(new OO)),this}}]),n}(kO.default(Promise));function TO(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=wO.default(e);if(t){var i=wO.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bO.default(this,n)}}vO.default(EO,"onCancelCallbackMap",new Map);var RO={unknown:"Unknown error",cancelled:"Job was cancelled",timeout:"Timeout occurred",mediaUploadError:"Media upload error",mediaFetchError:"Media fetch error",tooManyAttachments:"Too many attachments",unsupportedEmailBodyContentType:"Unsupported email body content type",unsupportedEmailHistoryContentType:"Unsupported email history content type",transportDisconnected:"Transport has been disconnected",networkBecameUnreachable:"Network became unreachable",unauthorized:"Unauthorized",tokenExpired:"Token expired",tokenUpdatedLocally:"Transport disconnected, token updated locally and will be used at reconnect",tooManyRequests:"Request failed with 429 reply",hostnameUnverified:"Failed on ssl handshake: CERTIFICATE_VERIFY_FAILED",sslHandshakeError:"Failed on ssl handshake: UNAUTHORIZED",closeMessageReceived:"Twilsock received a close message from the server",cannotParse:"Error while parsing an incoming message"},IO=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;mO.default(this,e),vO.default(this,"reason",void 0),vO.default(this,"message",void 0),vO.default(this,"status",void 0),vO.default(this,"code",void 0),vO.default(this,"description",void 0),this.reason=t,this.message=n,this.status=r,this.code=i,this.description=RO[t]}return yO.default(e,[{key:"toString",value:function(){return"".concat(this.description," ").concat(this.status,":").concat(this.code," ").concat(this.message)}}]),e}(),CO=function(e){gO.default(n,e);var t=TO(n);function n(e){var r;return mO.default(this,n),r=t.call(this,"".concat(e)),vO.default(hO.default(r),"errorInfo",void 0),r.errorInfo=e,Object.freeze(e),r}return yO.default(n)}(kO.default(Error)),PO=function(){function e(){var t=this;mO.default(this,e),vO.default(this,"promise",void 0),vO.default(this,"_resolve",void 0),vO.default(this,"_reject",void 0),vO.default(this,"_isDone",!1),this.promise=new Promise((function(e,n){t._resolve=function(n){t._isDone=!0,e(n)},t._reject=function(e){t._isDone=!0,n(e)}}))}return yO.default(e,[{key:"resolve",get:function(){return this._resolve}},{key:"reject",get:function(){return this._reject}},{key:"isDone",get:function(){return this._isDone}}]),e}(),AO=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";mO.default(this,e),vO.default(this,"_prefix",void 0),vO.default(this,"_logger",void 0),this._prefix=n,this._logger=tO.getLogger(t)}return yO.default(e,[{key:"setLevel",value:function(e){this._logger.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.trace.apply(null,this._prepareLine("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.debug.apply(null,this._prepareLine("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.info.apply(null,this._prepareLine("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.warn.apply(null,this._prepareLine("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.error.apply(null,this._prepareLine("E",t))}},{key:"_prepareLine",value:function(e,t){return["".concat((new Date).toISOString()," ").concat(this._prefix," ").concat(e,":")].concat(xO.default(t))}}]),e}();BS.CancellablePromise=EO,BS.CancellationError=OO,BS.Deferred=PO,BS.ErrorInfo=IO,BS.Logger=AO,BS.TwilioError=CO,BS.deprecated=function(e,t,n){return function(r,i,a){if("function"!=typeof a.value&&void 0===(null==a?void 0:a.get))throw new Error("The deprecated decorator can only be applied to methods or getters");if("function"!=typeof a.value){var o=a.get;a.get=function(){return _O("The getter ".concat(e," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:".")),null==o?void 0:o.apply(this)}}else{var s=a.value;a.value=function(){_O("The method ".concat(e," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:"."));for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return s.apply(this,i)}}}},BS.deprecationWarning=_O;var jO="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,MO=ir,LO=fr,UO=RangeError,NO=function(e){if(void 0===e)return 0;var t=MO(e),n=LO(t);if(t!==n)throw UO("Wrong length or index");return n},FO=Array,DO=Math.abs,qO=Math.pow,BO=Math.floor,zO=Math.log,WO=Math.LN2,$O={pack:function(e,t,n){var r,i,a,o=FO(n),s=8*n-t-1,u=(1<<s)-1,c=u>>1,l=23===t?qO(2,-24)-qO(2,-77):0,f=e<0||0===e&&1/e<0?1:0,d=0;for((e=DO(e))!=e||e===1/0?(i=e!=e?1:0,r=u):(r=BO(zO(e)/WO),e*(a=qO(2,-r))<1&&(r--,a*=2),(e+=r+c>=1?l/a:l*qO(2,1-c))*a>=2&&(r++,a/=2),r+c>=u?(i=0,r=u):r+c>=1?(i=(e*a-1)*qO(2,t),r+=c):(i=e*qO(2,c-1)*qO(2,t),r=0));t>=8;)o[d++]=255&i,i/=256,t-=8;for(r=r<<t|i,s+=t;s>0;)o[d++]=255&r,r/=256,s-=8;return o[--d]|=128*f,o},unpack:function(e,t){var n,r=e.length,i=8*r-t-1,a=(1<<i)-1,o=a>>1,s=i-7,u=r-1,c=e[u--],l=127&c;for(c>>=7;s>0;)l=256*l+e[u--],s-=8;for(n=l&(1<<-s)-1,l>>=-s,s+=t;s>0;)n=256*n+e[u--],s-=8;if(0===l)l=1-o;else{if(l===a)return n?NaN:c?-1/0:1/0;n+=qO(2,t),l-=o}return(c?-1:1)*n*qO(2,l-t)}},KO=Be,HO=ur,GO=pr,VO=function(e){for(var t=KO(this),n=GO(t),r=arguments.length,i=HO(r>1?arguments[1]:void 0,n),a=r>2?arguments[2]:void 0,o=void 0===a?n:HO(a,n);o>i;)t[i++]=e;return t},YO=i,JO=C,QO=s,XO=jO,ZO=on,eE=Xt,tE=L_,nE=o,rE=Ec,iE=ir,aE=fr,oE=NO,sE=$O,uE=dv,cE=gc,lE=Zn.f,fE=jt.f,dE=VO,pE=Za,hE=oi,vE=ZO.PROPER,yE=ZO.CONFIGURABLE,mE=Ln.get,gE=Ln.set,bE="ArrayBuffer",wE="DataView",kE="Wrong index",xE=YO.ArrayBuffer,_E=xE,SE=_E&&_E.prototype,OE=YO.DataView,EE=OE&&OE.prototype,TE=Object.prototype,RE=YO.Array,IE=YO.RangeError,CE=JO(dE),PE=JO([].reverse),AE=sE.pack,jE=sE.unpack,ME=function(e){return[255&e]},LE=function(e){return[255&e,e>>8&255]},UE=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},NE=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},FE=function(e){return AE(e,23,4)},DE=function(e){return AE(e,52,8)},qE=function(e,t){fE(e.prototype,t,{get:function(){return mE(this)[t]}})},BE=function(e,t,n,r){var i=oE(n),a=mE(e);if(i+t>a.byteLength)throw IE(kE);var o=mE(a.buffer).bytes,s=i+a.byteOffset,u=pE(o,s,s+t);return r?u:PE(u)},zE=function(e,t,n,r,i,a){var o=oE(n),s=mE(e);if(o+t>s.byteLength)throw IE(kE);for(var u=mE(s.buffer).bytes,c=o+s.byteOffset,l=r(+i),f=0;f<t;f++)u[c+f]=l[a?f:t-f-1]};if(XO){var WE=vE&&xE.name!==bE;if(nE((function(){xE(1)}))&&nE((function(){new xE(-1)}))&&!nE((function(){return new xE,new xE(1.5),new xE(NaN),1!=xE.length||WE&&!yE})))WE&&yE&&eE(xE,"name",bE);else{(_E=function(e){return rE(this,SE),new xE(oE(e))}).prototype=SE;for(var $E,KE=lE(xE),HE=0;KE.length>HE;)($E=KE[HE++])in _E||eE(_E,$E,xE[$E]);SE.constructor=_E}cE&&uE(EE)!==TE&&cE(EE,TE);var GE=new OE(new _E(2)),VE=JO(EE.setInt8);GE.setInt8(0,2147483648),GE.setInt8(1,2147483649),!GE.getInt8(0)&&GE.getInt8(1)||tE(EE,{setInt8:function(e,t){VE(this,e,t<<24>>24)},setUint8:function(e,t){VE(this,e,t<<24>>24)}},{unsafe:!0})}else SE=(_E=function(e){rE(this,SE);var t=oE(e);gE(this,{bytes:CE(RE(t),0),byteLength:t}),QO||(this.byteLength=t)}).prototype,EE=(OE=function(e,t,n){rE(this,EE),rE(e,SE);var r=mE(e).byteLength,i=iE(t);if(i<0||i>r)throw IE("Wrong offset");if(i+(n=void 0===n?r-i:aE(n))>r)throw IE("Wrong length");gE(this,{buffer:e,byteLength:n,byteOffset:i}),QO||(this.buffer=e,this.byteLength=n,this.byteOffset=i)}).prototype,QO&&(qE(_E,"byteLength"),qE(OE,"buffer"),qE(OE,"byteLength"),qE(OE,"byteOffset")),tE(EE,{getInt8:function(e){return BE(this,1,e)[0]<<24>>24},getUint8:function(e){return BE(this,1,e)[0]},getInt16:function(e){var t=BE(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=BE(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return NE(BE(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return NE(BE(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return jE(BE(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return jE(BE(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){zE(this,1,e,ME,t)},setUint8:function(e,t){zE(this,1,e,ME,t)},setInt16:function(e,t){zE(this,2,e,LE,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){zE(this,2,e,LE,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){zE(this,4,e,UE,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){zE(this,4,e,UE,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){zE(this,4,e,FE,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){zE(this,8,e,DE,t,arguments.length>2?arguments[2]:void 0)}});hE(_E,bE),hE(OE,wE);var YE={ArrayBuffer:_E,DataView:OE},JE=_c,QE="ArrayBuffer",XE=YE.ArrayBuffer;ni({global:!0,constructor:!0,forced:i.ArrayBuffer!==XE},{ArrayBuffer:XE}),JE(QE);var ZE={exports:{}};!function(e,n){(function(){var r={function:!0,object:!0}["undefined"==typeof window?"undefined":Xu(window)]&&window||this,i=n,a=e&&!e.nodeType&&e,o=i&&a&&"object"==Xu(t)&&t;!o||o.global!==o&&o.window!==o&&o.self!==o||(r=o);var s=Math.pow(2,53)-1,u=/\bOpera/,c=Object.prototype,l=c.hasOwnProperty,f=c.toString;function d(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function p(e){return e=g(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:d(e)}function h(e,t){for(var n in e)l.call(e,n)&&t(e[n],n,e)}function v(e){return null==e?d(e):f.call(e).slice(8,-1)}function y(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function m(e,t){var n=null;return function(e,t){var n=-1,r=e?e.length:0;if("number"==typeof r&&r>-1&&r<=s)for(;++n<r;)t(e[n],n,e);else h(e,t)}(e,(function(r,i){n=t(n,r,i,e)})),n}function g(e){return String(e).replace(/^ +| +$/g,"")}var b=function e(t){var n=r,i=t&&"object"==Xu(t)&&"String"!=v(t);i&&(n=t,t=null);var a=n.navigator||{},o=a.userAgent||"";t||(t=o);var s,c,l=i?!!a.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(f.toString()),d="Object",b=i?d:"ScriptBridgingProxyObject",w=i?d:"Environment",k=i&&n.java?"JavaPackage":v(n.java),x=i?d:"RuntimeObject",_=/\bJava/.test(k)&&n.java,S=_&&v(n.environment)==w,O=_?"a":"α",E=_?"b":"β",T=n.document||{},R=n.operamini||n.opera,I=u.test(I=i&&R?R["[[Class]]"]:v(R))?I:R=null,C=t,P=[],A=null,j=t==o,M=j&&R&&"function"==typeof R.version&&R.version(),L=m([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],(function(e,n){return e||RegExp("\\b"+(n.pattern||y(n))+"\\b","i").exec(t)&&(n.label||n)})),U=function(e){return m(e,(function(e,n){return e||RegExp("\\b"+(n.pattern||y(n))+"\\b","i").exec(t)&&(n.label||n)}))}(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),N=q([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),F=function(e){return m(e,(function(e,n,r){return e||(n[N]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(N)]||RegExp("\\b"+y(r)+"(?:\\b|\\w*\\d)","i").exec(t))&&r}))}({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),D=function(e){return m(e,(function(e,n){var r=n.pattern||y(n);return!e&&(e=RegExp("\\b"+r+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,n){var r={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])&&(e="Windows "+r),e=String(e),t&&n&&(e=e.replace(RegExp(t,"i"),n)),p(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}(e,r,n.label||n)),e}))}(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function q(e){return m(e,(function(e,n){var r=n.pattern||y(n);return!e&&(e=RegExp("\\b"+r+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+r+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+r+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(n.label&&!RegExp(r,"i").test(n.label)?n.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),n=n.label||n,e=p(e[0].replace(RegExp(r,"i"),n).replace(RegExp("; *(?:"+n+"[_-])?","i")," ").replace(RegExp("("+n+")[-_.]?(\\w)","i"),"$1 $2"))),e}))}function B(e){return m(e,(function(e,n){return e||(RegExp(n+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if(L&&(L=[L]),/\bAndroid\b/.test(D)&&!N&&(s=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(N=g(s[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),F&&!N?N=q([F]):F&&N&&(N=N.replace(RegExp("^("+y(F)+")[-_.\\s]","i"),F+" ").replace(RegExp("^("+y(F)+")[-_.]?(\\w)","i"),F+" $2")),(s=/\bGoogle TV\b/.exec(N))&&(N=s[0]),/\bSimulator\b/i.test(t)&&(N=(N?N+" ":"")+"Simulator"),"Opera Mini"==U&&/\bOPiOS\b/.test(t)&&P.push("running in Turbo/Uncompressed mode"),"IE"==U&&/\blike iPhone OS\b/.test(t)?(F=(s=e(t.replace(/like iPhone OS/,""))).manufacturer,N=s.product):/^iP/.test(N)?(U||(U="Safari"),D="iOS"+((s=/ OS ([\d_]+)/i.exec(t))?" "+s[1].replace(/_/g,"."):"")):"Konqueror"==U&&/^Linux\b/i.test(D)?D="Kubuntu":F&&"Google"!=F&&(/Chrome/.test(U)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(N))||/\bAndroid\b/.test(D)&&/^Chrome/.test(U)&&/\bVersion\//i.test(t)?(U="Android Browser",D=/\bAndroid\b/.test(D)?D:"Android"):"Silk"==U?(/\bMobi/i.test(t)||(D="Android",P.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&P.unshift("accelerated")):"UC Browser"==U&&/\bUCWEB\b/.test(t)?P.push("speed mode"):"PaleMoon"==U&&(s=/\bFirefox\/([\d.]+)\b/.exec(t))?P.push("identifying as Firefox "+s[1]):"Firefox"==U&&(s=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(D||(D="Firefox OS"),N||(N=s[1])):!U||(s=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(U))?(U&&!N&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(s+"/")+8))&&(U=null),(s=N||F||D)&&(N||F||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(D))&&(U=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(D)?D:s)+" Browser")):"Electron"==U&&(s=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&P.push("Chromium "+s),M||(M=B(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",y(U),"(?:Firefox|Minefield|NetFront)"])),(s=("iCab"==L&&parseFloat(M)>3?"WebKit":/\bOpera\b/.test(U)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(L)&&"WebKit"||!L&&/\bMSIE\b/i.test(t)&&("Mac OS"==D?"Tasman":"Trident")||"WebKit"==L&&/\bPlayStation\b(?! Vita\b)/i.test(U)&&"NetFront")&&(L=[s]),"IE"==U&&(s=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(U+=" Mobile",D="Windows Phone "+(/\+$/.test(s)?s:s+".x"),P.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(U="IE Mobile",D="Windows Phone 8.x",P.unshift("desktop mode"),M||(M=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=U&&"Trident"==L&&(s=/\brv:([\d.]+)/.exec(t))&&(U&&P.push("identifying as "+U+(M?" "+M:"")),U="IE",M=s[1]),j){if(function(e,t){var n=null!=e?Xu(e[t]):"number";return!(/^(?:boolean|number|string|undefined)$/.test(n)||"object"==n&&!e[t])}(n,"global"))if(_&&(C=(s=_.lang.System).getProperty("os.arch"),D=D||s.getProperty("os.name")+" "+s.getProperty("os.version")),S){try{M=n.require("ringo/engine").version.join("."),U="RingoJS"}catch(e){(s=n.system)&&s.global.system==n.system&&(U="Narwhal",D||(D=s[0].os||null))}U||(U="Rhino")}else"object"==Xu(n.process)&&!n.process.browser&&(s=n.process)&&("object"==Xu(s.versions)&&("string"==typeof s.versions.electron?(P.push("Node "+s.versions.node),U="Electron",M=s.versions.electron):"string"==typeof s.versions.nw&&(P.push("Chromium "+M,"Node "+s.versions.node),U="NW.js",M=s.versions.nw)),U||(U="Node.js",C=s.arch,D=s.platform,M=(M=/[\d.]+/.exec(s.version))?M[0]:null));else v(s=n.runtime)==b?(U="Adobe AIR",D=s.flash.system.Capabilities.os):v(s=n.phantom)==x?(U="PhantomJS",M=(s=s.version||null)&&s.major+"."+s.minor+"."+s.patch):"number"==typeof T.documentMode&&(s=/\bTrident\/(\d+)/i.exec(t))?(M=[M,T.documentMode],(s=+s[1]+4)!=M[1]&&(P.push("IE "+M[1]+" mode"),L&&(L[1]=""),M[1]=s),M="IE"==U?String(M[1].toFixed(1)):M[0]):"number"==typeof T.documentMode&&/^(?:Chrome|Firefox)\b/.test(U)&&(P.push("masking as "+U+" "+M),U="IE",M="11.0",L=["Trident"],D="Windows");D=D&&p(D)}if(M&&(s=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(M)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(j&&a.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(A=/b/i.test(s)?"beta":"alpha",M=M.replace(RegExp(s+"\\+?$"),"")+("beta"==A?E:O)+(/\d+\+?/.exec(s)||"")),"Fennec"==U||"Firefox"==U&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(D))U="Firefox Mobile";else if("Maxthon"==U&&M)M=M.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(N))"Xbox 360"==N&&(D=null),"Xbox 360"==N&&/\bIEMobile\b/.test(t)&&P.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(U)&&(!U||N||/Browser|Mobi/.test(U))||"Windows CE"!=D&&!/Mobi/i.test(t))if("IE"==U&&j)try{null===n.external&&P.unshift("platform preview")}catch(e){P.unshift("embedded")}else(/\bBlackBerry\b/.test(N)||/\bBB10\b/.test(t))&&(s=(RegExp(N.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||M)?(D=((s=[s,/BB10/.test(t)])[1]?(N=null,F="BlackBerry"):"Device Software")+" "+s[0],M=null):this!=h&&"Wii"!=N&&(j&&R||/Opera/.test(U)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==U&&/\bOS X (?:\d+\.){2,}/.test(D)||"IE"==U&&(D&&!/^Win/.test(D)&&M>5.5||/\bWindows XP\b/.test(D)&&M>8||8==M&&!/\bTrident\b/.test(t)))&&!u.test(s=e.call(h,t.replace(u,"")+";"))&&s.name&&(s="ing as "+s.name+((s=s.version)?" "+s:""),u.test(U)?(/\bIE\b/.test(s)&&"Mac OS"==D&&(D=null),s="identify"+s):(s="mask"+s,U=I?p(I.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(s)&&(D=null),j||(M=null)),L=["Presto"],P.push(s));else U+=" Mobile";(s=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(s=[parseFloat(s.replace(/\.(\d)$/,".0$1")),s],"Safari"==U&&"+"==s[1].slice(-1)?(U="WebKit Nightly",A="alpha",M=s[1].slice(0,-1)):M!=s[1]&&M!=(s[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(M=null),s[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==s[0]&&537.36==s[2]&&parseFloat(s[1])>=28&&"WebKit"==L&&(L=["Blink"]),j&&(l||s[1])?(L&&(L[1]="like Chrome"),s=s[1]||((s=s[0])<530?1:s<532?2:s<532.05?3:s<533?4:s<534.03?5:s<534.07?6:s<534.1?7:s<534.13?8:s<534.16?9:s<534.24?10:s<534.3?11:s<535.01?12:s<535.02?"13+":s<535.07?15:s<535.11?16:s<535.19?17:s<536.05?18:s<536.1?19:s<537.01?20:s<537.11?"21+":s<537.13?23:s<537.18?24:s<537.24?25:s<537.36?26:"Blink"!=L?"27":"28")):(L&&(L[1]="like Safari"),s=(s=s[0])<400?1:s<500?2:s<526?3:s<533?4:s<534?"4+":s<535?5:s<537?6:s<538?7:s<601?8:s<602?9:s<604?10:s<606?11:s<608?12:"12"),L&&(L[1]+=" "+(s+="number"==typeof s?".x":/[.+]/.test(s)?"":"+")),"Safari"==U&&(!M||parseInt(M)>45)?M=s:"Chrome"==U&&/\bHeadlessChrome/i.test(t)&&P.unshift("headless")),"Opera"==U&&(s=/\bzbov|zvav$/.exec(D))?(U+=" ",P.unshift("desktop mode"),"zvav"==s?(U+="Mini",M=null):U+="Mobile",D=D.replace(RegExp(" *"+s+"$"),"")):"Safari"==U&&/\bChrome\b/.exec(L&&L[1])?(P.unshift("desktop mode"),U="Chrome Mobile",M=null,/\bOS X\b/.test(D)?(F="Apple",D="iOS 4.3+"):D=null):/\bSRWare Iron\b/.test(U)&&!M&&(M=B("Chrome")),M&&0==M.indexOf(s=/[\d.]+$/.exec(D))&&t.indexOf("/"+s+"-")>-1&&(D=g(D.replace(s,""))),D&&-1!=D.indexOf(U)&&!RegExp(U+" OS").test(D)&&(D=D.replace(RegExp(" *"+y(U)+" *"),"")),L&&!/\b(?:Avant|Nook)\b/.test(U)&&(/Browser|Lunascape|Maxthon/.test(U)||"Safari"!=U&&/^iOS/.test(D)&&/\bSafari\b/.test(L[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(U)&&L[1])&&(s=L[L.length-1])&&P.push(s),P.length&&(P=["("+P.join("; ")+")"]),F&&N&&N.indexOf(F)<0&&P.push("on "+F),N&&P.push((/^on /.test(P[P.length-1])?"":"on ")+N),D&&(s=/ ([\d.+]+)$/.exec(D),c=s&&"/"==D.charAt(D.length-s[0].length-1),D={architecture:32,family:s&&!c?D.replace(s[0],""):D,version:s?s[1]:null,toString:function(){var e=this.version;return this.family+(e&&!c?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(s=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(C))&&!/\bi686\b/i.test(C)?(D&&(D.architecture=64,D.family=D.family.replace(RegExp(" *"+s),"")),U&&(/\bWOW64\b/i.test(t)||j&&/\w(?:86|32)$/.test(a.cpuClass||a.platform)&&!/\bWin64; x64\b/i.test(t))&&P.unshift("32-bit")):D&&/^OS X/.test(D.family)&&"Chrome"==U&&parseFloat(M)>=39&&(D.architecture=64),t||(t=null);var z={};return z.description=t,z.layout=L&&L[0],z.manufacturer=F,z.name=U,z.prerelease=A,z.product=N,z.ua=t,z.version=U&&M,z.os=D||{architecture:null,family:null,version:null,toString:function(){return"null"}},z.parse=e,z.toString=function(){return this.description||""},z.version&&P.unshift(M),z.name&&P.unshift(U),D&&U&&(D!=String(D).split(" ")[0]||D!=U.split(" ")[0]&&!N)&&P.push(N?"("+D+")":"on "+D),P.length&&(z.description=P.join(" ")),z}();i&&a?h(b,(function(e,t){i[t]=e})):r.platform=b}).call(t)}(ZE,ZE.exports);var eT={},tT=Symbol("@ts-pattern/matcher"),nT="@ts-pattern/anonymous-select-key",rT=function(e){return Boolean(e&&"object"==Xu(e))},iT=function(e){return e&&!!e[tT]},aT=function e(t,n,r){if(rT(t)){if(iT(t)){var i=t[tT]().match(n),a=i.matched,o=i.selections;return a&&o&&Object.keys(o).forEach((function(e){return r(e,o[e])})),a}if(!rT(n))return!1;if(Array.isArray(t))return!!Array.isArray(n)&&t.length===n.length&&t.every((function(t,i){return e(t,n[i],r)}));if(t instanceof Map)return n instanceof Map&&Array.from(t.keys()).every((function(i){return e(t.get(i),n.get(i),r)}));if(t instanceof Set){if(!(n instanceof Set))return!1;if(0===t.size)return 0===n.size;if(1===t.size){var s=Array.from(t.values())[0];return iT(s)?Array.from(n.values()).every((function(t){return e(s,t,r)})):n.has(s)}return Array.from(t.values()).every((function(e){return n.has(e)}))}return Object.keys(t).every((function(i){var a,o=t[i];return(i in n||iT(a=o)&&"optional"===a[tT]().matcherType)&&e(o,n[i],r)}))}return Object.is(n,t)},oT=function e(t){var n,r,i;return rT(t)?iT(t)?null!=(n=null==(r=(i=t[tT]()).getSelectionKeys)?void 0:r.call(i))?n:[]:Array.isArray(t)?sT(t,e):sT(Object.values(t),e):[]},sT=function(e,t){return e.reduce((function(e,n){return e.concat(t(n))}),[])};function uT(e){var t;return(t={})[tT]=function(){return{match:function(t){var n={},r=function(e,t){n[e]=t};return void 0===t?(oT(e).forEach((function(e){return r(e,void 0)})),{matched:!0,selections:n}):{matched:aT(e,t,r),selections:n}},getSelectionKeys:function(){return oT(e)},matcherType:"optional"}},t}function cT(e){var t;return(t={})[tT]=function(){return{match:function(t){if(!Array.isArray(t))return{matched:!1};var n={};if(0===t.length)return oT(e).forEach((function(e){n[e]=[]})),{matched:!0,selections:n};var r=function(e,t){n[e]=(n[e]||[]).concat([t])};return{matched:t.every((function(t){return aT(e,t,r)})),selections:n}},getSelectionKeys:function(){return oT(e)}}},t}function lT(){var e,t=[].slice.call(arguments);return(e={})[tT]=function(){return{match:function(e){var n={},r=function(e,t){n[e]=t};return{matched:t.every((function(t){return aT(t,e,r)})),selections:n}},getSelectionKeys:function(){return sT(t,oT)},matcherType:"and"}},e}function fT(){var e,t=[].slice.call(arguments);return(e={})[tT]=function(){return{match:function(e){var n={},r=function(e,t){n[e]=t};return sT(t,oT).forEach((function(e){return r(e,void 0)})),{matched:t.some((function(t){return aT(t,e,r)})),selections:n}},getSelectionKeys:function(){return sT(t,oT)},matcherType:"or"}},e}function dT(e){var t;return(t={})[tT]=function(){return{match:function(t){return{matched:!aT(e,t,(function(){}))}},getSelectionKeys:function(){return[]},matcherType:"not"}},t}function pT(e){var t;return(t={})[tT]=function(){return{match:function(t){return{matched:Boolean(e(t))}}}},t}function hT(){var e,t=[].slice.call(arguments),n="string"==typeof t[0]?t[0]:void 0,r=2===t.length?t[1]:"string"==typeof t[0]?void 0:t[0];return(e={})[tT]=function(){return{match:function(e){var t,i=((t={})[null!=n?n:nT]=e,t);return{matched:void 0===r||aT(r,e,(function(e,t){i[e]=t})),selections:i}},getSelectionKeys:function(){return[null!=n?n:nT].concat(void 0===r?[]:oT(r))}}},e}var vT=pT((function(e){return!0})),yT=vT,mT=pT((function(e){return"string"==typeof e})),gT=pT((function(e){return"number"==typeof e})),bT=pT((function(e){return"boolean"==typeof e})),wT=pT((function(e){return"bigint"==typeof e})),kT=pT((function(e){return"symbol"==Xu(e)})),xT=pT((function(e){return null==e})),_T={__proto__:null,optional:uT,array:cT,intersection:lT,union:fT,not:dT,when:pT,select:hT,any:vT,_:yT,string:mT,number:gT,boolean:bT,bigint:wT,symbol:kT,nullish:xT,instanceOf:function(e){return pT(function(e){return function(t){return t instanceof e}}(e))},typed:function(){return{array:cT,optional:uT,intersection:lT,union:fT,not:dT,select:hT,when:pT}}},ST=function(){function e(e,t){this.value=void 0,this.cases=void 0,this.value=e,this.cases=t}var t=e.prototype;return t.with=function(){var t=[].slice.call(arguments),n=t[t.length-1],r=[t[0]],i=[];return 3===t.length&&"function"==typeof t[1]?(r.push(t[0]),i.push(t[1])):t.length>2&&r.push.apply(r,t.slice(1,t.length-1)),new e(this.value,this.cases.concat([{match:function(e){var t={},n=Boolean(r.some((function(n){return aT(n,e,(function(e,n){t[e]=n}))}))&&i.every((function(t){return t(e)})));return{matched:n,value:n&&Object.keys(t).length?nT in t?t[nT]:t:e}},handler:n}]))},t.when=function(t,n){return new e(this.value,this.cases.concat([{match:function(e){return{matched:Boolean(t(e)),value:e}},handler:n}]))},t.otherwise=function(t){return new e(this.value,this.cases.concat([{match:function(e){return{matched:!0,value:e}},handler:t}])).run()},t.exhaustive=function(){return this.run()},t.run=function(){for(var e=this.value,t=void 0,n=0;n<this.cases.length;n++){var r=this.cases[n],i=r.match(this.value);if(i.matched){e=i.value,t=r.handler;break}}if(!t){var a;try{a=JSON.stringify(this.value)}catch(e){a=this.value}throw new Error("Pattern matching error: no pattern matches value "+a)}return t(e,this.value)},e}();eT.P=_T,eT.Pattern=_T,eT.isMatching=function(){var e=[].slice.call(arguments);if(1===e.length){var t=e[0];return function(e){return aT(t,e,(function(){}))}}if(2===e.length){var n=e,r=n[0],i=n[1];return aT(r,i,(function(){}))}throw new Error("isMatching wasn't given the right number of arguments: expected 1 or 2, received "+e.length+".")},eT.match=function(e){return new ST(e,[])};var OT=ni,ET=Fl,TT=o,RT=Z,IT=H,CT=Pc,PT=hp,AT=Xn,jT=ET&&ET.prototype;if(OT({target:"Promise",proto:!0,real:!0,forced:!!ET&&TT((function(){jT.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=CT(this,RT("Promise")),n=IT(e);return this.then(n?function(n){return PT(t,e()).then((function(){return n}))}:e,n?function(n){return PT(t,e()).then((function(){throw n}))}:e)}}),IT(ET)){var MT=RT("Promise").prototype.finally;jT.finally!==MT&&AT(jT,"finally",MT,{unsafe:!0})}function LT(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function UT(e,t,n){return UT=LT()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&Ju(i,n.prototype),i},UT.apply(null,arguments)}function NT(e){var t="function"==typeof Map?new Map:void 0;return NT=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return UT(e,arguments,ec(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Ju(r,e)},NT(e)}var FT={},DT="[a-fA-F\\d:]",qT=function(e){return e&&e.includeBoundaries?"(?:(?<=\\s|^)(?=".concat(DT,")|(?<=").concat(DT,")(?=\\s|$))"):""},BT="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",zT="[a-fA-F\\d]{1,4}",WT="\n(?:\n(?:".concat(zT,":){7}(?:").concat(zT,"|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:").concat(zT,":){6}(?:").concat(BT,"|:").concat(zT,"|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:").concat(zT,":){5}(?::").concat(BT,"|(?::").concat(zT,"){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:").concat(zT,":){4}(?:(?::").concat(zT,"){0,1}:").concat(BT,"|(?::").concat(zT,"){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:").concat(zT,":){3}(?:(?::").concat(zT,"){0,2}:").concat(BT,"|(?::").concat(zT,"){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:").concat(zT,":){2}(?:(?::").concat(zT,"){0,3}:").concat(BT,"|(?::").concat(zT,"){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:").concat(zT,":){1}(?:(?::").concat(zT,"){0,4}:").concat(BT,"|(?::").concat(zT,"){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::").concat(zT,"){0,5}:").concat(BT,"|(?::").concat(zT,"){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n").replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),$T=new RegExp("(?:^".concat(BT,"$)|(?:^").concat(WT,"$)")),KT=new RegExp("^".concat(BT,"$")),HT=new RegExp("^".concat(WT,"$")),GT=function(e){return e&&e.exact?$T:new RegExp("(?:".concat(qT(e)).concat(BT).concat(qT(e),")|(?:").concat(qT(e)).concat(WT).concat(qT(e),")"),"g")};GT.v4=function(e){return e&&e.exact?KT:new RegExp("".concat(qT(e)).concat(BT).concat(qT(e)),"g")},GT.v6=function(e){return e&&e.exact?HT:new RegExp("".concat(qT(e)).concat(WT).concat(qT(e)),"g")};var VT=GT,YT=function(e){return VT({exact:!0}).test(e)};function JT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function QT(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?JT(Object(n),!0).forEach((function(t){ic(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):JT(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function XT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ZT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ZT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function ZT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function eR(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}YT.v4=function(e){return VT.v4({exact:!0}).test(e)},YT.v6=function(e){return VT.v6({exact:!0}).test(e)},YT.version=function(e){return YT(e)?YT.v4(e)?4:6:void 0};var tR=YT,nR=function(e){Qu(n,e);var t=eR(n);function n(){var e;return rc(this,n),(e=t.call(this,"Request was cancelled")).name="CancelError",e}return nc(n,[{key:"isCanceled",get:function(){return!0}}]),n}(NT(Error)),rR={timeout:5e3},iR={v4:["https://ipv4.icanhazip.com/","https://api.ipify.org/"],v6:["https://ipv6.icanhazip.com/","https://api6.ipify.org/"]},aR=function(e,t,n){var r,i=new XMLHttpRequest,a=new Promise((function(a,o){r=o,i.addEventListener("error",o,{once:!0}),i.addEventListener("timeout",o,{once:!0}),i.addEventListener("load",(function(){var e=i.responseText.trim();e&&tR[n](e)?a(e):o()}),{once:!0}),i.open("GET",e),i.timeout=t.timeout,i.send()}));return a.cancel=function(){i.abort(),r(new nR)},a},oR=function(e,t){var n,r=Vu(lh.mark((function r(){var i,a,o,s,u;return lh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:i=[].concat.apply(iR[e],t.fallbackUrls||[]),a=XT(i),r.prev=2,a.s();case 4:if((o=a.n()).done){r.next=20;break}return s=o.value,r.prev=6,n=aR(s,t,e),r.next=10,n;case 10:return u=r.sent,r.abrupt("return",u);case 14:if(r.prev=14,r.t0=r.catch(6),!(r.t0 instanceof nR)){r.next=18;break}throw r.t0;case 18:r.next=4;break;case 20:r.next=25;break;case 22:r.prev=22,r.t1=r.catch(2),a.e(r.t1);case 25:return r.prev=25,a.f(),r.finish(25);case 28:throw new Error("Couldn't find your IP");case 29:case"end":return r.stop()}}),r,null,[[2,22,25,28],[6,14]])})))();return r.cancel=function(){n.cancel()},r};function sR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function uR(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?sR(Object(n),!0).forEach((function(t){ic(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sR(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}FT.v4=function(e){return oR("v4",QT(QT({},rR),e))},FT.v6=function(e){return oR("v6",QT(QT({},rR),e))};var cR,lR=FT,fR=function(){var e=Vu(lh.mark((function e(t){var n;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=uR({timeout:5e3,ipVersion:4},t),!navigator||navigator.onLine){e.next=3;break}return e.abrupt("return",!1);case 3:return n=4===t.ipVersion?"v4":"v6",e.prev=4,e.next=7,lR[n](t);case 7:return e.abrupt("return",!0);case 10:return e.prev=10,e.t0=e.catch(4),e.abrupt("return",!1);case 13:case"end":return e.stop()}}),e,null,[[4,10]])})));return function(t){return e.apply(this,arguments)}}(),dR=fR,pR=Y,hR=T,vR=ot("match"),yR=function(e){var t;return pR(e)&&(void 0!==(t=e[vR])?!!t:"RegExp"==hR(e))},mR=yR,gR=TypeError,bR=function(e){if(mR(e))throw gR("The method doesn't accept regular expressions");return e},wR=ot("match"),kR=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[wR]=!1,"/./"[e](t)}catch(e){}}return!1},xR=ni,_R=C,SR=a.f,OR=fr,ER=za,TR=bR,RR=D,IR=kR,CR=_R("".startsWith),PR=_R("".slice),AR=Math.min,jR=IR("startsWith");xR({target:"String",proto:!0,forced:!!(jR||(cR=SR(String.prototype,"startsWith"),!cR||cR.writable))&&!jR},{startsWith:function(e){var t=ER(RR(this));TR(e);var n=OR(AR(arguments.length>1?arguments[1]:void 0,t.length)),r=ER(e);return CR?CR(t,r,n):PR(t,n,n+r.length)===r}});var MR="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",LR={nanoid:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,t="",n=e;n--;)t+=MR[64*Math.random()|0];return t},customAlphabet:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:21;return function(){for(var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t,r="",i=n;i--;)r+=e[Math.random()*e.length|0];return r}}};function UR(e){return function(e){if(Array.isArray(e))return Kx(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Hx(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var NR={};function FR(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return DR(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return DR(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function DR(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function qR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function BR(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qR(Object(n),!0).forEach((function(t){ic(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qR(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Type=e.TypeBuilder=e.Modifier=e.Hint=e.Kind=void 0,e.Kind=Symbol.for("TypeBox.Kind"),e.Hint=Symbol.for("TypeBox.Hint"),e.Modifier=Symbol.for("TypeBox.Modifier");var t=0,n=function(){function n(){rc(this,n)}return nc(n,[{key:"ReadonlyOptional",value:function(t){return BR(ic({},e.Modifier,"ReadonlyOptional"),t)}},{key:"Readonly",value:function(t){return BR(ic({},e.Modifier,"Readonly"),t)}},{key:"Optional",value:function(t){return BR(ic({},e.Modifier,"Optional"),t)}},{key:"Any",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(BR(BR({},t),{},ic({},e.Kind,"Any")))}},{key:"Array",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.Create(BR(BR({},r),{},(ic(n={},e.Kind,"Array"),ic(n,"type","array"),ic(n,"items",t),n)))}},{key:"Boolean",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(BR(BR({},n),{},(ic(t={},e.Kind,"Boolean"),ic(t,"type","boolean"),t)))}},{key:"ConstructorParameters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.Tuple(UR(e.parameters),BR({},t))}},{key:"Constructor",value:function(t,n){var r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("Tuple"===t[e.Kind]){var a,o=void 0===t.items?[]:t.items;return this.Create(BR(BR({},i),{},(ic(a={},e.Kind,"Constructor"),ic(a,"type","constructor"),ic(a,"parameters",o),ic(a,"returns",n),a)))}if(globalThis.Array.isArray(t))return this.Create(BR(BR({},i),{},(ic(r={},e.Kind,"Constructor"),ic(r,"type","constructor"),ic(r,"parameters",t),ic(r,"returns",n),r)));throw new Error("TypeBuilder.Constructor: Invalid parameters")}},{key:"Enum",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=Object.keys(t).filter((function(e){return isNaN(e)})).map((function(e){return t[e]})),a=i.map((function(t){var n,r;return"string"==typeof t?(ic(n={},e.Kind,"Literal"),ic(n,"type","string"),ic(n,"const",t),n):(ic(r={},e.Kind,"Literal"),ic(r,"type","number"),ic(r,"const",t),r)}));return this.Create(BR(BR({},r),{},(ic(n={},e.Kind,"Union"),ic(n,e.Hint,"Enum"),ic(n,"anyOf",a),n)))}},{key:"Function",value:function(t,n){var r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("Tuple"===t[e.Kind]){var a,o=void 0===t.items?[]:t.items;return this.Create(BR(BR({},i),{},(ic(a={},e.Kind,"Function"),ic(a,"type","function"),ic(a,"parameters",o),ic(a,"returns",n),a)))}if(globalThis.Array.isArray(t))return this.Create(BR(BR({},i),{},(ic(r={},e.Kind,"Function"),ic(r,"type","function"),ic(r,"parameters",t),ic(r,"returns",n),r)));throw new Error("TypeBuilder.Function: Invalid parameters")}},{key:"InstanceType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return BR(BR({},t),this.Clone(e.returns))}},{key:"Integer",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(BR(BR({},n),{},(ic(t={},e.Kind,"Integer"),ic(t,"type","integer"),t)))}},{key:"Intersect",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=function(t){return t[e.Modifier]&&"Optional"===t[e.Modifier]||"ReadonlyOptional"===t[e.Modifier]},a=new Set,o=new Set,s=FR(t);try{for(s.s();!(n=s.n()).done;)for(var u=n.value,c=0,l=Object.entries(u.properties);c<l.length;c++){var f=Gx(l[c],2),d=f[0],p=f[1];i(p)&&o.add(d)}}catch(e){s.e(e)}finally{s.f()}var h,v=FR(t);try{for(v.s();!(h=v.n()).done;)for(var y=h.value,m=0,g=Object.keys(y.properties);m<g.length;m++){var b=g[m];o.has(b)||a.add(b)}}catch(e){v.e(e)}finally{v.f()}var w,k,x,_={},S=FR(t);try{for(S.s();!(w=S.n()).done;)for(var O=w.value,E=0,T=Object.entries(O.properties);E<T.length;E++){var R,I=Gx(T[E],2),C=I[0],P=I[1];_[C]=void 0===_[C]?P:(ic(R={},e.Kind,"Union"),ic(R,"anyOf",[_[C],BR({},P)]),R)}}catch(e){S.e(e)}finally{S.f()}return a.size>0?this.Create(BR(BR({},r),{},(ic(k={},e.Kind,"Object"),ic(k,"type","object"),ic(k,"properties",_),ic(k,"required",UR(a)),k))):this.Create(BR(BR({},r),{},(ic(x={},e.Kind,"Object"),ic(x,"type","object"),ic(x,"properties",_),x)))}},{key:"KeyOf",value:function(t){var n,r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=Object.keys(t.properties).map((function(t){var n;return r.Create(BR(BR({},i),{},(ic(n={},e.Kind,"Literal"),ic(n,"type","string"),ic(n,"const",t),n)))}));return this.Create(BR(BR({},i),{},(ic(n={},e.Kind,"Union"),ic(n,e.Hint,"KeyOf"),ic(n,"anyOf",a),n)))}},{key:"Literal",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.Create(BR(BR({},r),{},(ic(n={},e.Kind,"Literal"),ic(n,"const",t),ic(n,"type",Xu(t)),n)))}},{key:"Never",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(BR(BR({},n),{},(ic(t={},e.Kind,"Never"),ic(t,"allOf",[{type:"boolean",const:!1},{type:"boolean",const:!0}]),t)))}},{key:"Null",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(BR(BR({},n),{},(ic(t={},e.Kind,"Null"),ic(t,"type","null"),t)))}},{key:"Number",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(BR(BR({},n),{},(ic(t={},e.Kind,"Number"),ic(t,"type","number"),t)))}},{key:"Object",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(t){var n,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=Object.keys(t),o=a.filter((function(n){var r=t[n][e.Modifier];return r&&("Optional"===r||"ReadonlyOptional"===r)})),s=a.filter((function(e){return!o.includes(e)}));return s.length>0?this.Create(BR(BR({},i),{},(ic(n={},e.Kind,"Object"),ic(n,"type","object"),ic(n,"properties",t),ic(n,"required",s),n))):this.Create(BR(BR({},i),{},(ic(r={},e.Kind,"Object"),ic(r,"type","object"),ic(r,"properties",t),r)))}))},{key:"Omit",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i="Union"===n[e.Kind]?n.anyOf.map((function(e){return e.const})):n,a=BR(BR(BR({},this.Clone(t)),r),{},ic({},e.Hint,"Omit"));a.required&&(a.required=a.required.filter((function(e){return!i.includes(e)})),0===a.required.length&&delete a.required);for(var o=0,s=Object.keys(a.properties);o<s.length;o++){var u=s[o];i.includes(u)&&delete a.properties[u]}return this.Create(a)}},{key:"Parameters",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.Type.Tuple(t.parameters,BR({},n))}},{key:"Partial",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=BR(BR(BR({},this.Clone(t)),n),{},ic({},e.Hint,"Partial"));delete r.required;for(var i=0,a=Object.keys(r.properties);i<a.length;i++){var o=a[i],s=r.properties[o],u=s[e.Modifier];switch(u){case"ReadonlyOptional":case"Readonly":s[e.Modifier]="ReadonlyOptional";break;default:s[e.Modifier]="Optional"}}return this.Create(r)}},{key:"Pick",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i="Union"===n[e.Kind]?n.anyOf.map((function(e){return e.const})):n,a=BR(BR(BR({},this.Clone(t)),r),{},ic({},e.Hint,"Pick"));a.required&&(a.required=a.required.filter((function(e){return i.includes(e)})),0===a.required.length&&delete a.required);for(var o=0,s=Object.keys(a.properties);o<s.length;o++){var u=s[o];i.includes(u)||delete a.properties[u]}return this.Create(a)}},{key:"Promise",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.Create(BR(BR({},r),{},(ic(n={},e.Kind,"Promise"),ic(n,"type","promise"),ic(n,"item",t),n)))}},{key:"Record",value:function(t,n){var r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("Union"===t[e.Kind])return this.Object(t.anyOf.reduce((function(e,t){return BR(BR({},e),{},ic({},t.const,n))}),{}),BR(BR({},i),{},ic({},e.Hint,"Record")));var a="Number"===t[e.Kind]?"^(0|[1-9][0-9]*)$":"String"===t[e.Kind]&&t.pattern?t.pattern:"^.*$";return this.Create(BR(BR({},i),{},(ic(r={},e.Kind,"Record"),ic(r,"type","object"),ic(r,"patternProperties",ic({},a,n)),ic(r,"additionalProperties",!1),r)))}},{key:"Recursive",value:function(n){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};void 0===i.$id&&(i.$id="T".concat(t++));var a=n((ic(r={},e.Kind,"Self"),ic(r,"$ref","".concat(i.$id)),r));return a.$id=i.$id,this.Create(BR(BR({},i),a))}},{key:"Ref",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0===t.$id)throw Error("TypeBuilder.Ref: Referenced schema must specify an $id");return this.Create(BR(BR({},r),{},(ic(n={},e.Kind,"Ref"),ic(n,"$ref",t.$id),n)))}},{key:"RegEx",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.Create(BR(BR({},r),{},(ic(n={},e.Kind,"String"),ic(n,"type","string"),ic(n,"pattern",t.source),n)))}},{key:"Required",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=BR(BR(BR({},this.Clone(t)),n),{},ic({},e.Hint,"Required"));r.required=Object.keys(r.properties);for(var i=0,a=Object.keys(r.properties);i<a.length;i++){var o=a[i],s=r.properties[o],u=s[e.Modifier];switch(u){case"ReadonlyOptional":case"Readonly":s[e.Modifier]="Readonly";break;default:delete s[e.Modifier]}}return this.Create(r)}},{key:"ReturnType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return BR(BR({},t),this.Clone(e.returns))}},{key:"Strict",value:function(e){return JSON.parse(JSON.stringify(e))}},{key:"String",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(BR(BR({},n),{},(ic(t={},e.Kind,"String"),ic(t,"type","string"),t)))}},{key:"Tuple",value:function(t){var n,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=!1,o=t.length,s=t.length,u=t.length>0?BR(BR({},i),{},(ic(n={},e.Kind,"Tuple"),ic(n,"type","array"),ic(n,"items",t),ic(n,"additionalItems",a),ic(n,"minItems",o),ic(n,"maxItems",s),n)):BR(BR({},i),{},(ic(r={},e.Kind,"Tuple"),ic(r,"type","array"),ic(r,"minItems",o),ic(r,"maxItems",s),r));return this.Create(u)}},{key:"Undefined",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(BR(BR({},n),{},(ic(t={},e.Kind,"Undefined"),ic(t,"type","object"),ic(t,"specialized","Undefined"),t)))}},{key:"Union",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return 0===t.length?e.Type.Never(BR({},r)):this.Create(BR(BR({},r),{},(ic(n={},e.Kind,"Union"),ic(n,"anyOf",t),n)))}},{key:"Uint8Array",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(BR(BR({},n),{},(ic(t={},e.Kind,"Uint8Array"),ic(t,"type","object"),ic(t,"specialized","Uint8Array"),t)))}},{key:"Unknown",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(BR(BR({},t),{},ic({},e.Kind,"Unknown")))}},{key:"Unsafe",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(BR(BR({},t),{},ic({},e.Kind,t[e.Kind]||"Unsafe")))}},{key:"Void",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(BR(BR({},n),{},(ic(t={},e.Kind,"Void"),ic(t,"type","null"),t)))}},{key:"Create",value:function(e){return e}},{key:"Clone",value:function(e){var t,n=this;return"object"!==Xu(t=e)||null===t||Array.isArray(t)?function(e){return"object"===Xu(e)&&null!==e&&Array.isArray(e)}(e)?e.map((function(e){return n.Clone(e)})):e:Object.keys(e).reduce((function(t,r){return BR(BR({},t),{},ic({},r,n.Clone(e[r])))}),Object.getOwnPropertySymbols(e).reduce((function(t,r){return BR(BR({},t),{},ic({},r,n.Clone(e[r])))}),{}))}}]),n}();e.TypeBuilder=n,e.Type=new n}(NR);var zR={},WR={},$R={},KR={},HR={};function GR(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return VR(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return VR(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function VR(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function YR(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}!function(e){var t,n;Object.defineProperty(e,"__esModule",{value:!0}),e.Format=void 0,t=e.Format||(e.Format={}),n=new Map,t.Clear=function(){return n.clear()},t.Has=function(e){return n.has(e)},t.Set=function(e,t){n.set(e,t)},t.Get=function(e){return n.get(e)}}(HR),function(e){var n=t&&t.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=t&&t.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),r(HR,e)}(KR),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueErrors=e.ValueErrorsUnknownTypeError=e.ValueErrorType=void 0;var t,n=NR,r=KR;!function(e){e[e.Array=0]="Array",e[e.ArrayMinItems=1]="ArrayMinItems",e[e.ArrayMaxItems=2]="ArrayMaxItems",e[e.ArrayUniqueItems=3]="ArrayUniqueItems",e[e.Boolean=4]="Boolean",e[e.Function=5]="Function",e[e.Integer=6]="Integer",e[e.IntegerMultipleOf=7]="IntegerMultipleOf",e[e.IntegerExclusiveMinimum=8]="IntegerExclusiveMinimum",e[e.IntegerExclusiveMaximum=9]="IntegerExclusiveMaximum",e[e.IntegerMinimum=10]="IntegerMinimum",e[e.IntegerMaximum=11]="IntegerMaximum",e[e.Literal=12]="Literal",e[e.Never=13]="Never",e[e.Null=14]="Null",e[e.Number=15]="Number",e[e.NumberMultipleOf=16]="NumberMultipleOf",e[e.NumberExclusiveMinimum=17]="NumberExclusiveMinimum",e[e.NumberExclusiveMaximum=18]="NumberExclusiveMaximum",e[e.NumberMinumum=19]="NumberMinumum",e[e.NumberMaximum=20]="NumberMaximum",e[e.Object=21]="Object",e[e.ObjectMinProperties=22]="ObjectMinProperties",e[e.ObjectMaxProperties=23]="ObjectMaxProperties",e[e.ObjectAdditionalProperties=24]="ObjectAdditionalProperties",e[e.Promise=25]="Promise",e[e.RecordKeyNumeric=26]="RecordKeyNumeric",e[e.RecordKeyString=27]="RecordKeyString",e[e.String=28]="String",e[e.StringMinLength=29]="StringMinLength",e[e.StringMaxLength=30]="StringMaxLength",e[e.StringPattern=31]="StringPattern",e[e.StringFormatUnknown=32]="StringFormatUnknown",e[e.StringFormat=33]="StringFormat",e[e.TupleZeroLength=34]="TupleZeroLength",e[e.TupleLength=35]="TupleLength",e[e.Undefined=36]="Undefined",e[e.Union=37]="Union",e[e.Uint8Array=38]="Uint8Array",e[e.Uint8ArrayMinByteLength=39]="Uint8ArrayMinByteLength",e[e.Uint8ArrayMaxByteLength=40]="Uint8ArrayMaxByteLength",e[e.Void=41]="Void"}(t=e.ValueErrorType||(e.ValueErrorType={}));var i=function(e){Qu(n,e);var t=YR(n);function n(e){var r;return rc(this,n),(r=t.call(this,"ValueErrors: Unknown type")).schema=e,r}return nc(n)}(NT(Error));e.ValueErrorsUnknownTypeError=i,function(e){var a=lh.mark(I),o=lh.mark(C),s=lh.mark(P),u=lh.mark(A),c=lh.mark(j),l=lh.mark(M),f=lh.mark(L),d=lh.mark(U),p=lh.mark(N),h=lh.mark(F),v=lh.mark(D),y=lh.mark(q),m=lh.mark(B),g=lh.mark(z),b=lh.mark(W),w=lh.mark($),k=lh.mark(K),x=lh.mark(H),_=lh.mark(G),S=lh.mark(V),O=lh.mark(Y),E=lh.mark(J),T=lh.mark(Q),R=lh.mark(X);function I(e,t,n,r){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),a)}function C(e,n,r,i){var a;return lh.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(globalThis.Array.isArray(i)){o.next=4;break}return o.next=3,{type:t.Array,schema:e,path:r,value:i,message:"Expected array"};case 3:return o.abrupt("return",o.sent);case 4:if(void 0===e.minItems||i.length>=e.minItems){o.next=7;break}return o.next=7,{type:t.ArrayMinItems,schema:e,path:r,value:i,message:"Expected array length to be greater or equal to ".concat(e.minItems)};case 7:if(void 0===e.maxItems||i.length<=e.maxItems){o.next=10;break}return o.next=10,{type:t.ArrayMinItems,schema:e,path:r,value:i,message:"Expected array length to be less or equal to ".concat(e.maxItems)};case 10:if(!0!==e.uniqueItems||new Set(i).size===i.length){o.next=13;break}return o.next=13,{type:t.ArrayUniqueItems,schema:e,path:r,value:i,message:"Expected array elements to be unique"};case 13:a=0;case 14:if(!(a<i.length)){o.next=19;break}return o.delegateYield(Q(e.items,n,"".concat(r,"/").concat(a),i[a]),"t0",16);case 16:a++,o.next=14;break;case 19:case"end":return o.stop()}}),o)}function P(e,n,r,i){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("boolean"==typeof i){n.next=4;break}return n.next=3,{type:t.Boolean,schema:e,path:r,value:i,message:"Expected boolean"};case 3:return n.abrupt("return",n.sent);case 4:case"end":return n.stop()}}),s)}function A(e,t,n,r){return lh.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(Q(e.returns,t,n,r.prototype),"t0",1);case 1:case"end":return i.stop()}}),u)}function j(e,n,r,i){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("function"==typeof i){n.next=4;break}return n.next=3,{type:t.Function,schema:e,path:r,value:i,message:"Expected function"};case 3:return n.abrupt("return",n.sent);case 4:case"end":return n.stop()}}),c)}function M(e,n,r,i){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("number"==typeof i){n.next=4;break}return n.next=3,{type:t.Number,schema:e,path:r,value:i,message:"Expected number"};case 3:return n.abrupt("return",n.sent);case 4:if(globalThis.Number.isInteger(i)){n.next=7;break}return n.next=7,{type:t.Integer,schema:e,path:r,value:i,message:"Expected integer"};case 7:if(!e.multipleOf||i%e.multipleOf==0){n.next=10;break}return n.next=10,{type:t.IntegerMultipleOf,schema:e,path:r,value:i,message:"Expected integer to be a multiple of ".concat(e.multipleOf)};case 10:if(!e.exclusiveMinimum||i>e.exclusiveMinimum){n.next=13;break}return n.next=13,{type:t.IntegerExclusiveMinimum,schema:e,path:r,value:i,message:"Expected integer to be greater than ".concat(e.exclusiveMinimum)};case 13:if(!e.exclusiveMaximum||i<e.exclusiveMaximum){n.next=16;break}return n.next=16,{type:t.IntegerExclusiveMaximum,schema:e,path:r,value:i,message:"Expected integer to be less than ".concat(e.exclusiveMaximum)};case 16:if(!e.minimum||i>=e.minimum){n.next=19;break}return n.next=19,{type:t.IntegerMinimum,schema:e,path:r,value:i,message:"Expected integer to be greater or equal to ".concat(e.minimum)};case 19:if(!e.maximum||i<=e.maximum){n.next=22;break}return n.next=22,{type:t.IntegerMaximum,schema:e,path:r,value:i,message:"Expected integer to be less or equal to ".concat(e.maximum)};case 22:case"end":return n.stop()}}),l)}function L(e,n,r,i){var a;return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(i===e.const){n.next=5;break}return a="string"==typeof e.const?"'".concat(e.const,"'"):e.const,n.next=4,{type:t.Literal,schema:e,path:r,value:i,message:"Expected ".concat(a)};case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),f)}function U(e,n,r,i){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,{type:t.Never,schema:e,path:r,value:i,message:"Value cannot be validated"};case 2:case"end":return n.stop()}}),d)}function N(e,n,r,i){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===i){n.next=4;break}return n.next=3,{type:t.Null,schema:e,path:r,value:i,message:"Expected null"};case 3:return n.abrupt("return",n.sent);case 4:case"end":return n.stop()}}),p)}function F(e,n,r,i){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("number"==typeof i){n.next=4;break}return n.next=3,{type:t.Number,schema:e,path:r,value:i,message:"Expected number"};case 3:return n.abrupt("return",n.sent);case 4:if(!e.multipleOf||i%e.multipleOf==0){n.next=7;break}return n.next=7,{type:t.NumberMultipleOf,schema:e,path:r,value:i,message:"Expected number to be a multiple of ".concat(e.multipleOf)};case 7:if(!e.exclusiveMinimum||i>e.exclusiveMinimum){n.next=10;break}return n.next=10,{type:t.NumberExclusiveMinimum,schema:e,path:r,value:i,message:"Expected number to be greater than ".concat(e.exclusiveMinimum)};case 10:if(!e.exclusiveMaximum||i<e.exclusiveMaximum){n.next=13;break}return n.next=13,{type:t.NumberExclusiveMaximum,schema:e,path:r,value:i,message:"Expected number to be less than ".concat(e.exclusiveMaximum)};case 13:if(!e.minimum||i>=e.minimum){n.next=16;break}return n.next=16,{type:t.NumberMaximum,schema:e,path:r,value:i,message:"Expected number to be greater or equal to ".concat(e.minimum)};case 16:if(!e.maximum||i<=e.maximum){n.next=19;break}return n.next=19,{type:t.NumberMinumum,schema:e,path:r,value:i,message:"Expected number to be less or equal to ".concat(e.maximum)};case 19:case"end":return n.stop()}}),h)}function D(e,n,r,i){var a,o,s,u,c,l,f,d;return lh.wrap((function(p){for(;;)switch(p.prev=p.next){case 0:if("object"===Xu(i)&&null!==i&&!globalThis.Array.isArray(i)){p.next=4;break}return p.next=3,{type:t.Object,schema:e,path:r,value:i,message:"Expected object"};case 3:return p.abrupt("return",p.sent);case 4:if(void 0===e.minProperties||globalThis.Object.keys(i).length>=e.minProperties){p.next=7;break}return p.next=7,{type:t.ObjectMinProperties,schema:e,path:r,value:i,message:"Expected object to have at least ".concat(e.minProperties," properties")};case 7:if(void 0===e.maxProperties||globalThis.Object.keys(i).length<=e.maxProperties){p.next=10;break}return p.next=10,{type:t.ObjectMaxProperties,schema:e,path:r,value:i,message:"Expected object to have less than ".concat(e.minProperties," properties")};case 10:if(a=globalThis.Object.keys(e.properties),!1!==e.additionalProperties){p.next=30;break}o=GR(globalThis.Object.keys(i)),p.prev=13,o.s();case 15:if((s=o.n()).done){p.next=22;break}if(u=s.value,a.includes(u)){p.next=20;break}return p.next=20,{type:t.ObjectAdditionalProperties,schema:e,path:"".concat(r,"/").concat(u),value:i[u],message:"Unexpected property"};case 20:p.next=15;break;case 22:p.next=27;break;case 24:p.prev=24,p.t0=p.catch(13),o.e(p.t0);case 27:return p.prev=27,o.f(),p.finish(27);case 30:c=GR(a),p.prev=31,c.s();case 33:if((l=c.n()).done){p.next=44;break}if(f=l.value,d=e.properties[f],!e.required||!e.required.includes(f)){p.next=40;break}return p.delegateYield(Q(d,n,"".concat(r,"/").concat(f),i[f]),"t1",38);case 38:p.next=42;break;case 40:if(void 0===i[f]){p.next=42;break}return p.delegateYield(Q(d,n,"".concat(r,"/").concat(f),i[f]),"t2",42);case 42:p.next=33;break;case 44:p.next=49;break;case 46:p.prev=46,p.t3=p.catch(31),c.e(p.t3);case 49:return p.prev=49,c.f(),p.finish(49);case 52:case"end":return p.stop()}}),v,null,[[13,24,27,30],[31,46,49,52]])}function q(e,n,r,i){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("object"===Xu(i)&&"function"==typeof i.then){n.next=3;break}return n.next=3,{type:t.Promise,schema:e,path:r,value:i,message:"Expected Promise"};case 3:case"end":return n.stop()}}),y)}function B(e,n,r,i){var a,o,s,u,c,l,f,d,p,h,v,y;return lh.wrap((function(m){for(;;)switch(m.prev=m.next){case 0:if("object"===Xu(i)&&null!==i&&!globalThis.Array.isArray(i)){m.next=4;break}return m.next=3,{type:t.Object,schema:e,path:r,value:i,message:"Expected object"};case 3:return m.abrupt("return",m.sent);case 4:if(a=Gx(globalThis.Object.entries(e.patternProperties)[0],2),o=a[0],s=a[1],u=new RegExp(o),globalThis.Object.keys(i).every((function(e){return u.test(e)}))){m.next=13;break}return l=(c="^(0|[1-9][0-9]*)$"===o)?t.RecordKeyNumeric:t.RecordKeyString,f=c?"Expected all object property keys to be numeric":"Expected all object property keys to be strings",m.next=12,{type:l,schema:e,path:r,value:i,message:f};case 12:return m.abrupt("return",m.sent);case 13:d=GR(globalThis.Object.entries(i)),m.prev=14,d.s();case 16:if((p=d.n()).done){m.next=21;break}return h=Gx(p.value,2),v=h[0],y=h[1],m.delegateYield(Q(s,n,"".concat(r,"/").concat(v),y),"t0",19);case 19:m.next=16;break;case 21:m.next=26;break;case 23:m.prev=23,m.t1=m.catch(14),d.e(m.t1);case 26:return m.prev=26,d.f(),m.finish(26);case 29:case"end":return m.stop()}}),m,null,[[14,23,26,29]])}function z(e,t,n,r){var i;return lh.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(void 0!==(i=t.find((function(t){return t.$id===e.$ref})))){a.next=3;break}throw new Error("ValueErrors.Ref: Cannot find schema with $id '".concat(e.$ref,"'."));case 3:return a.delegateYield(Q(i,t,n,r),"t0",4);case 4:case"end":return a.stop()}}),g)}function W(e,t,n,r){var i;return lh.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(void 0!==(i=t.find((function(t){return t.$id===e.$ref})))){a.next=3;break}throw new Error("ValueErrors.Self: Cannot find schema with $id '".concat(e.$ref,"'."));case 3:return a.delegateYield(Q(i,t,n,r),"t0",4);case 4:case"end":return a.stop()}}),b)}function $(e,n,i,a){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("string"==typeof a){n.next=4;break}return n.next=3,{type:t.String,schema:e,path:i,value:a,message:"Expected string"};case 3:return n.abrupt("return",n.sent);case 4:if(void 0===e.minLength||a.length>=e.minLength){n.next=7;break}return n.next=7,{type:t.StringMinLength,schema:e,path:i,value:a,message:"Expected string length greater or equal to ".concat(e.minLength)};case 7:if(void 0===e.maxLength||a.length<=e.maxLength){n.next=10;break}return n.next=10,{type:t.StringMaxLength,schema:e,path:i,value:a,message:"Expected string length less or equal to ".concat(e.maxLength)};case 10:if(void 0===e.pattern){n.next=15;break}if(new RegExp(e.pattern).test(a)){n.next=15;break}return n.next=15,{type:t.StringPattern,schema:e,path:i,value:a,message:"Expected string to match pattern ".concat(e.pattern)};case 15:if(void 0===e.format){n.next=25;break}if(r.Format.Has(e.format)){n.next=21;break}return n.next=19,{type:t.StringFormatUnknown,schema:e,path:i,value:a,message:"Unknown string format '".concat(e.format,"'")};case 19:n.next=25;break;case 21:if(r.Format.Get(e.format)(a)){n.next=25;break}return n.next=25,{type:t.StringFormat,schema:e,path:i,value:a,message:"Expected string to match format '".concat(e.format,"'")};case 25:case"end":return n.stop()}}),w)}function K(e,n,r,i){var a;return lh.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(globalThis.Array.isArray(i)){o.next=4;break}return o.next=3,{type:t.Array,schema:e,path:r,value:i,message:"Expected Array"};case 3:return o.abrupt("return",o.sent);case 4:if(void 0!==e.items||0===i.length){o.next=8;break}return o.next=7,{type:t.TupleZeroLength,schema:e,path:r,value:i,message:"Expected tuple to have 0 elements"};case 7:return o.abrupt("return",o.sent);case 8:if(i.length===e.maxItems){o.next=11;break}return o.next=11,{type:t.TupleLength,schema:e,path:r,value:i,message:"Expected tuple to have ".concat(e.maxItems," elements")};case 11:if(e.items){o.next=13;break}return o.abrupt("return");case 13:a=0;case 14:if(!(a<e.items.length)){o.next=19;break}return o.delegateYield(Q(e.items[a],n,"".concat(r,"/").concat(a),i[a]),"t0",16);case 16:a++,o.next=14;break;case 19:case"end":return o.stop()}}),k)}function H(e,n,r,i){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(void 0===i){n.next=3;break}return n.next=3,{type:t.Undefined,schema:e,path:r,value:i,message:"Expected undefined"};case 3:case"end":return n.stop()}}),x)}function G(e,n,r,i){var a,o,s,u,c,l,f,d;return lh.wrap((function(p){for(;;)switch(p.prev=p.next){case 0:a=[],o=GR(e.anyOf),p.prev=2,o.s();case 4:if((s=o.n()).done){p.next=12;break}if(u=s.value,0!==(c=UR(Q(u,n,r,i))).length){p.next=9;break}return p.abrupt("return");case 9:a.push.apply(a,UR(c));case 10:p.next=4;break;case 12:p.next=17;break;case 14:p.prev=14,p.t0=p.catch(2),o.e(p.t0);case 17:return p.prev=17,o.f(),p.finish(17);case 20:l=0,f=a;case 21:if(!(l<f.length)){p.next=28;break}return d=f[l],p.next=25,d;case 25:l++,p.next=21;break;case 28:if(!(a.length>0)){p.next=31;break}return p.next=31,{type:t.Union,schema:e,path:r,value:i,message:"Expected value of union"};case 31:case"end":return p.stop()}}),_,null,[[2,14,17,20]])}function V(e,n,r,i){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(i instanceof globalThis.Uint8Array){n.next=4;break}return n.next=3,{type:t.Uint8Array,schema:e,path:r,value:i,message:"Expected Uint8Array"};case 3:return n.abrupt("return",n.sent);case 4:if(!e.maxByteLength||i.length<=e.maxByteLength){n.next=7;break}return n.next=7,{type:t.Uint8ArrayMaxByteLength,schema:e,path:r,value:i,message:"Expected Uint8Array to have a byte length less or equal to ".concat(e.maxByteLength)};case 7:if(!e.minByteLength||i.length>=e.minByteLength){n.next=10;break}return n.next=10,{type:t.Uint8ArrayMinByteLength,schema:e,path:r,value:i,message:"Expected Uint8Array to have a byte length greater or equal to ".concat(e.maxByteLength)};case 10:case"end":return n.stop()}}),S)}function Y(e,t,n,r){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),O)}function J(e,n,r,i){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===i){n.next=4;break}return n.next=3,{type:t.Void,schema:e,path:r,value:i,message:"Expected null"};case 3:return n.abrupt("return",n.sent);case 4:case"end":return n.stop()}}),E)}function Q(e,t,r,a){var o,s;return lh.wrap((function(u){for(;;)switch(u.prev=u.next){case 0:o=void 0===e.$id?t:[e].concat(UR(t)),s=e,u.t0=s[n.Kind],u.next="Any"===u.t0?5:"Array"===u.t0?7:"Boolean"===u.t0?9:"Constructor"===u.t0?11:"Function"===u.t0?13:"Integer"===u.t0?15:"Literal"===u.t0?17:"Never"===u.t0?19:"Null"===u.t0?21:"Number"===u.t0?23:"Object"===u.t0?25:"Promise"===u.t0?27:"Record"===u.t0?29:"Ref"===u.t0?31:"Self"===u.t0?33:"String"===u.t0?35:"Tuple"===u.t0?37:"Undefined"===u.t0?39:"Union"===u.t0?41:"Uint8Array"===u.t0?43:"Unknown"===u.t0?45:"Void"===u.t0?47:49;break;case 5:return u.delegateYield(I(),"t1",6);case 6:return u.abrupt("return",u.t1);case 7:return u.delegateYield(C(s,o,r,a),"t2",8);case 8:return u.abrupt("return",u.t2);case 9:return u.delegateYield(P(s,0,r,a),"t3",10);case 10:return u.abrupt("return",u.t3);case 11:return u.delegateYield(A(s,o,r,a),"t4",12);case 12:return u.abrupt("return",u.t4);case 13:return u.delegateYield(j(s,0,r,a),"t5",14);case 14:return u.abrupt("return",u.t5);case 15:return u.delegateYield(M(s,0,r,a),"t6",16);case 16:return u.abrupt("return",u.t6);case 17:return u.delegateYield(L(s,0,r,a),"t7",18);case 18:return u.abrupt("return",u.t7);case 19:return u.delegateYield(U(s,0,r,a),"t8",20);case 20:return u.abrupt("return",u.t8);case 21:return u.delegateYield(N(s,0,r,a),"t9",22);case 22:return u.abrupt("return",u.t9);case 23:return u.delegateYield(F(s,0,r,a),"t10",24);case 24:return u.abrupt("return",u.t10);case 25:return u.delegateYield(D(s,o,r,a),"t11",26);case 26:return u.abrupt("return",u.t11);case 27:return u.delegateYield(q(s,0,r,a),"t12",28);case 28:return u.abrupt("return",u.t12);case 29:return u.delegateYield(B(s,o,r,a),"t13",30);case 30:return u.abrupt("return",u.t13);case 31:return u.delegateYield(z(s,o,r,a),"t14",32);case 32:return u.abrupt("return",u.t14);case 33:return u.delegateYield(W(s,o,r,a),"t15",34);case 34:return u.abrupt("return",u.t15);case 35:return u.delegateYield($(s,0,r,a),"t16",36);case 36:return u.abrupt("return",u.t16);case 37:return u.delegateYield(K(s,o,r,a),"t17",38);case 38:return u.abrupt("return",u.t17);case 39:return u.delegateYield(H(s,0,r,a),"t18",40);case 40:return u.abrupt("return",u.t18);case 41:return u.delegateYield(G(s,o,r,a),"t19",42);case 42:return u.abrupt("return",u.t19);case 43:return u.delegateYield(V(s,0,r,a),"t20",44);case 44:return u.abrupt("return",u.t20);case 45:return u.delegateYield(Y(),"t21",46);case 46:return u.abrupt("return",u.t21);case 47:return u.delegateYield(J(s,0,r,a),"t22",48);case 48:return u.abrupt("return",u.t22);case 49:throw new i(e);case 50:case"end":return u.stop()}}),T)}function X(e,t,n){return lh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(Q(e,t,"",n),"t0",1);case 1:case"end":return r.stop()}}),R)}e.Errors=X}(e.ValueErrors||(e.ValueErrors={}))}($R),function(e){var n=t&&t.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=t&&t.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),r($R,e)}(WR);var JR={},QR={},XR={};function ZR(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return eI(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eI(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function eI(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function tI(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}function nI(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return rI(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rI(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function rI(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function iI(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TypeGuard=e.TypeGuardInvalidTypeError=void 0;var t=NR,n=function(e){Qu(n,e);var t=tI(n);function n(e){var r;return rc(this,n),(r=t.call(this,"TypeGuard: Invalid type")).schema=e,r}return nc(n)}(NT(Error));e.TypeGuardInvalidTypeError=n,function(e){function r(e){return"object"===Xu(e)&&null!==e&&!Array.isArray(e)}function i(e){return"object"===Xu(e)&&null!==e&&Array.isArray(e)}function a(e){try{return new RegExp(e),!0}catch(e){return!1}}function o(e){if("string"!=typeof e)return!1;for(var t=0;t<e.length;t++){var n=e.charCodeAt(t);if(n>=7&&n<=13||27===n||127===n)return!1}return!0}function s(e){return"string"==typeof e}function u(e){return"number"==typeof e}function c(e){return"boolean"==typeof e}function l(e){return void 0===e||void 0!==e&&u(e)}function f(e){return void 0===e||void 0!==e&&c(e)}function d(e){return void 0===e||void 0!==e&&s(e)}function p(e){return r(e)&&"Any"===e[t.Kind]&&d(e.$id)}function h(e){return r(e)&&"Array"===e[t.Kind]&&"array"===e.type&&d(e.$id)&&L(e.items)&&l(e.minItems)&&l(e.maxItems)&&f(e.uniqueItems)}function v(e){return r(e)&&"Boolean"===e[t.Kind]&&"boolean"===e.type&&d(e.$id)}function y(e){if(!(r(e)&&"Constructor"===e[t.Kind]&&"constructor"===e.type&&d(e.$id)&&i(e.parameters)&&L(e.returns)))return!1;var n,a=ZR(e.parameters);try{for(a.s();!(n=a.n()).done;){if(!L(n.value))return!1}}catch(e){a.e(e)}finally{a.f()}return!0}function m(e){if(!(r(e)&&"Function"===e[t.Kind]&&"function"===e.type&&d(e.$id)&&i(e.parameters)&&L(e.returns)))return!1;var n,a=ZR(e.parameters);try{for(a.s();!(n=a.n()).done;){if(!L(n.value))return!1}}catch(e){a.e(e)}finally{a.f()}return!0}function g(e){return r(e)&&"Integer"===e[t.Kind]&&"integer"===e.type&&d(e.$id)&&l(e.multipleOf)&&l(e.minimum)&&l(e.maximum)&&l(e.exclusiveMinimum)&&l(e.exclusiveMaximum)}function b(e){return r(e)&&"Literal"===e[t.Kind]&&d(e.$id)&&(s(e.const)||u(e.const)||c(e.const))}function w(e){return r(e)&&"Never"===e[t.Kind]&&i(e.allOf)&&2===e.allOf.length&&r(e.allOf[0])&&s(e.allOf[0].type)&&"boolean"===e.allOf[0].type&&!1===e.allOf[0].const&&r(e.allOf[1])&&s(e.allOf[1].type)&&"boolean"===e.allOf[1].type&&!0===e.allOf[1].const}function k(e){return r(e)&&"Null"===e[t.Kind]&&"null"===e.type&&d(e.$id)}function x(e){return r(e)&&"Number"===e[t.Kind]&&"number"===e.type&&d(e.$id)&&l(e.multipleOf)&&l(e.minimum)&&l(e.maximum)&&l(e.exclusiveMinimum)&&l(e.exclusiveMaximum)}function _(e){if(!(r(e)&&"Object"===e[t.Kind]&&"object"===e.type&&d(e.$id)&&r(e.properties)&&f(e.additionalProperties)&&l(e.minProperties)&&l(e.maxProperties)))return!1;for(var n=0,i=Object.entries(e.properties);n<i.length;n++){var a=Gx(i[n],2),s=a[0],u=a[1];if(!o(s))return!1;if(!L(u))return!1}return!0}function S(e){return r(e)&&"Promise"===e[t.Kind]&&"promise"===e.type&&d(e.$id)&&L(e.item)}function O(e){if(!(r(e)&&"Record"===e[t.Kind]&&"object"===e.type&&d(e.$id)&&!1===e.additionalProperties&&r(e.patternProperties)))return!1;var n=Object.keys(e.patternProperties);return 1===n.length&&(!!a(n[0])&&!!L(e.patternProperties[n[0]]))}function E(e){return r(e)&&"Self"===e[t.Kind]&&d(e.$id)&&s(e.$ref)}function T(e){return r(e)&&"Ref"===e[t.Kind]&&d(e.$id)&&s(e.$ref)}function R(e){return r(e)&&"String"===e[t.Kind]&&"string"===e.type&&d(e.$id)&&l(e.minLength)&&l(e.maxLength)&&(void 0===(n=e.pattern)||void 0!==n&&s(n)&&o(n)&&a(n))&&function(e){return void 0===e||void 0!==e&&s(e)&&o(e)}(e.format);var n}function I(e){if(!(r(e)&&"Tuple"===e[t.Kind]&&"array"===e.type&&d(e.$id)&&u(e.minItems)&&u(e.maxItems)&&e.minItems===e.maxItems))return!1;if(void 0===e.items&&void 0===e.additionalItems&&0===e.minItems)return!0;if(!i(e.items))return!1;var n,a=ZR(e.items);try{for(a.s();!(n=a.n()).done;){if(!L(n.value))return!1}}catch(e){a.e(e)}finally{a.f()}return!0}function C(e){return r(e)&&"Undefined"===e[t.Kind]&&"object"===e.type&&d(e.$id)&&"Undefined"===e.specialized}function P(e){if(!(r(e)&&"Union"===e[t.Kind]&&i(e.anyOf)&&d(e.$id)))return!1;var n,a=ZR(e.anyOf);try{for(a.s();!(n=a.n()).done;){if(!L(n.value))return!1}}catch(e){a.e(e)}finally{a.f()}return!0}function A(e){return r(e)&&"Uint8Array"===e[t.Kind]&&"object"===e.type&&d(e.$id)&&"Uint8Array"===e.specialized&&l(e.minByteLength)&&l(e.maxByteLength)}function j(e){return r(e)&&"Unknown"===e[t.Kind]&&d(e.$id)}function M(e){return r(e)&&"Void"===e[t.Kind]&&"null"===e.type&&d(e.$id)}function L(e){return p(e)||h(e)||v(e)||y(e)||m(e)||g(e)||b(e)||w(e)||k(e)||x(e)||_(e)||S(e)||O(e)||E(e)||T(e)||R(e)||I(e)||C(e)||P(e)||A(e)||j(e)||M(e)}e.TAny=p,e.TArray=h,e.TBoolean=v,e.TConstructor=y,e.TFunction=m,e.TInteger=g,e.TLiteral=b,e.TNever=w,e.TNull=k,e.TNumber=x,e.TObject=_,e.TPromise=S,e.TRecord=O,e.TSelf=E,e.TRef=T,e.TString=R,e.TTuple=I,e.TUndefined=C,e.TUnion=P,e.TUint8Array=A,e.TUnknown=j,e.TVoid=M,e.TSchema=L,e.Assert=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!L(e))throw new n(e);var r,i=ZR(t);try{for(i.s();!(r=i.n()).done;){var a=r.value;if(!L(a))throw new n(a)}}catch(e){i.e(e)}finally{i.f()}}}(e.TypeGuard||(e.TypeGuard={}))}(XR),function(e){var n=t&&t.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=t&&t.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),r(XR,e)}(QR),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TypeCompiler=e.TypeCompilerUnknownTypeError=e.Property=e.TypeCheck=void 0;var t,n=WR,r=QR,i=KR,a=NR,o=function(){function e(t,n,r,i){rc(this,e),this.schema=t,this.references=n,this.checkFunc=r,this.code=i}return nc(e,[{key:"Code",value:function(){return this.code}},{key:"Errors",value:function(e){return n.ValueErrors.Errors(this.schema,this.references,e)}},{key:"Check",value:function(e){return this.checkFunc(e)}}]),e}();e.TypeCheck=o,function(e){function t(e){return 36===e}function n(e){return 95===e}function r(e){return e>=48&&e<=57}function i(e){return e>=65&&e<=90||e>=97&&e<=122}e.Check=function(e){if(0===e.length)return!1;var a=e.charCodeAt(0);if(!(t(a)||n(a)||i(a)))return!1;for(var o=1;o<e.length;o++){var s=e.charCodeAt(o);if(!(t(s)||n(s)||i(s)||r(s)))return!1}return!0}}(t=e.Property||(e.Property={}));var s=function(e){Qu(n,e);var t=iI(n);function n(e){var r;return rc(this,n),(r=t.call(this,"TypeCompiler: Unknown type")).schema=e,r}return nc(n)}(NT(Error));e.TypeCompilerUnknownTypeError=s,function(e){var n=lh.mark(C),u=lh.mark(P),c=lh.mark(A),l=lh.mark(j),f=lh.mark(M),d=lh.mark(L),p=lh.mark(U),h=lh.mark(N),v=lh.mark(F),y=lh.mark(D),m=lh.mark(q),g=lh.mark(B),b=lh.mark(z),w=lh.mark(W),k=lh.mark($),x=lh.mark(K),_=lh.mark(H),S=lh.mark(G),O=lh.mark(V),E=lh.mark(Y),T=lh.mark(J),R=lh.mark(Q),I=lh.mark(X);function C(e,t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(true)";case 2:case"end":return e.stop()}}),n)}function P(e,t){var n;return lh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=ie(e.items,"value"),void 0===e.minItems){r.next=4;break}return r.next=4,"(".concat(t,".length >= ").concat(e.minItems,")");case 4:if(void 0===e.maxItems){r.next=7;break}return r.next=7,"(".concat(t,".length <= ").concat(e.maxItems,")");case 7:if(void 0===e.uniqueItems){r.next=10;break}return r.next=10,"(new Set(".concat(t,").size === ").concat(t,".length)");case 10:return r.next=12,"(Array.isArray(".concat(t,") && ").concat(t,".every(value => ").concat(n,"))");case 12:case"end":return r.stop()}}),u)}function A(e,t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(typeof ".concat(t," === 'boolean')");case 2:case"end":return e.stop()}}),c)}function j(e,t){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(X(e.returns,"".concat(t,".prototype")),"t0",1);case 1:case"end":return n.stop()}}),l)}function M(e,t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(typeof ".concat(t," === 'function')");case 2:case"end":return e.stop()}}),f)}function L(e,t){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,"(typeof ".concat(t," === 'number' && Number.isInteger(").concat(t,"))");case 2:if(void 0===e.multipleOf){n.next=5;break}return n.next=5,"(".concat(t," % ").concat(e.multipleOf," === 0)");case 5:if(void 0===e.exclusiveMinimum){n.next=8;break}return n.next=8,"(".concat(t," > ").concat(e.exclusiveMinimum,")");case 8:if(void 0===e.exclusiveMaximum){n.next=11;break}return n.next=11,"(".concat(t," < ").concat(e.exclusiveMaximum,")");case 11:if(void 0===e.minimum){n.next=14;break}return n.next=14,"(".concat(t," >= ").concat(e.minimum,")");case 14:if(void 0===e.maximum){n.next=17;break}return n.next=17,"(".concat(t," <= ").concat(e.maximum,")");case 17:case"end":return n.stop()}}),d)}function U(e,t){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("number"!=typeof e.const&&"boolean"!=typeof e.const){n.next=5;break}return n.next=3,"(".concat(t," === ").concat(e.const,")");case 3:n.next=7;break;case 5:return n.next=7,"(".concat(t," === '").concat(e.const,"')");case 7:case"end":return n.stop()}}),p)}function N(e,t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(false)";case 2:case"end":return e.stop()}}),h)}function F(e,t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(".concat(t," === null)");case 2:case"end":return e.stop()}}),v)}function D(e,t){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,"(typeof ".concat(t," === 'number')");case 2:if(void 0===e.multipleOf){n.next=5;break}return n.next=5,"(".concat(t," % ").concat(e.multipleOf," === 0)");case 5:if(void 0===e.exclusiveMinimum){n.next=8;break}return n.next=8,"(".concat(t," > ").concat(e.exclusiveMinimum,")");case 8:if(void 0===e.exclusiveMaximum){n.next=11;break}return n.next=11,"(".concat(t," < ").concat(e.exclusiveMaximum,")");case 11:if(void 0===e.minimum){n.next=14;break}return n.next=14,"(".concat(t," >= ").concat(e.minimum,")");case 14:if(void 0===e.maximum){n.next=17;break}return n.next=17,"(".concat(t," <= ").concat(e.maximum,")");case 17:case"end":return n.stop()}}),y)}function q(e,n){var r,i,a,o,s,u,c,l;return lh.wrap((function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,"(typeof ".concat(n," === 'object' && ").concat(n," !== null && !Array.isArray(").concat(n,"))");case 2:if(void 0===e.minProperties){f.next=5;break}return f.next=5,"(Object.keys(".concat(n,").length >= ").concat(e.minProperties,")");case 5:if(void 0===e.maxProperties){f.next=8;break}return f.next=8,"(Object.keys(".concat(n,").length <= ").concat(e.maxProperties,")");case 8:if(r=globalThis.Object.keys(e.properties),!1!==e.additionalProperties){f.next=18;break}if(!e.required||e.required.length!==r.length){f.next=15;break}return f.next=13,"(Object.keys(".concat(n,").length === ").concat(r.length,")");case 13:f.next=18;break;case 15:return i="[".concat(r.map((function(e){return"'".concat(e,"'")})).join(", "),"]"),f.next=18,"(Object.keys(".concat(n,").every(key => ").concat(i,".includes(key)))");case 18:a=nI(r),f.prev=19,a.s();case 21:if((o=a.n()).done){f.next=34;break}if(s=o.value,u=t.Check(s)?"".concat(n,".").concat(s):"".concat(n,"['").concat(s,"']"),c=e.properties[s],!e.required||!e.required.includes(s)){f.next=29;break}return f.delegateYield(X(c,u),"t0",27);case 27:f.next=32;break;case 29:return l=ie(c,u),f.next=32,"(".concat(u," === undefined ? true : (").concat(l,"))");case 32:f.next=21;break;case 34:f.next=39;break;case 36:f.prev=36,f.t1=f.catch(19),a.e(f.t1);case 39:return f.prev=39,a.f(),f.finish(39);case 42:case"end":return f.stop()}}),m,null,[[19,36,39,42]])}function B(e,t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(typeof value === 'object' && typeof ".concat(t,".then === 'function')");case 2:case"end":return e.stop()}}),g)}function z(e,t){var n,r,i,a,o;return lh.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,"(typeof ".concat(t," === 'object' && ").concat(t," !== null && !Array.isArray(").concat(t,"))");case 2:return n=Gx(globalThis.Object.entries(e.patternProperties)[0],2),r=n[0],i=n[1],a=se("new RegExp(/".concat(r,"/)")),s.next=6,"(Object.keys(".concat(t,").every(key => ").concat(a,".test(key)))");case 6:return o=ie(i,"value"),s.next=9,"(Object.values(".concat(t,").every(value => ").concat(o,"))");case 9:case"end":return s.stop()}}),b)}function W(e,t){var n;return lh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!te.has(e.$ref)){r.next=4;break}return r.next=3,"(".concat(ae(e.$ref),"(").concat(t,"))");case 3:return r.abrupt("return",r.sent);case 4:if(Z.has(e.$ref)){r.next=6;break}throw Error("TypeCompiler.Ref: Cannot de-reference schema with $id '".concat(e.$ref,"'"));case 6:return n=Z.get(e.$ref),r.delegateYield(X(n,t),"t0",8);case 8:case"end":return r.stop()}}),w)}function $(e,t){var n;return lh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=ae(e.$ref),r.next=3,"(".concat(n,"(").concat(t,"))");case 3:case"end":return r.stop()}}),k)}function K(e,t){var n;return lh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,"(typeof ".concat(t," === 'string')");case 2:if(void 0===e.minLength){r.next=5;break}return r.next=5,"(".concat(t,".length >= ").concat(e.minLength,")");case 5:if(void 0===e.maxLength){r.next=8;break}return r.next=8,"(".concat(t,".length <= ").concat(e.maxLength,")");case 8:if(void 0===e.pattern){r.next=12;break}return n=se("new RegExp(/".concat(e.pattern,"/);")),r.next=12,"(".concat(n,".test(").concat(t,"))");case 12:if(void 0===e.format){r.next=15;break}return r.next=15,"(format('".concat(e.format,"', ").concat(t,"))");case 15:case"end":return r.stop()}}),x)}function H(e,t){var n,r;return lh.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,"(Array.isArray(".concat(t,"))");case 2:if(void 0!==e.items){i.next=6;break}return i.next=5,"(".concat(t,".length === 0)");case 5:return i.abrupt("return",i.sent);case 6:return i.next=8,"(".concat(t,".length === ").concat(e.maxItems,")");case 8:n=0;case 9:if(!(n<e.items.length)){i.next=16;break}return r=ie(e.items[n],"".concat(t,"[").concat(n,"]")),i.next=13,"(".concat(r,")");case 13:n++,i.next=9;break;case 16:case"end":return i.stop()}}),_)}function G(e,t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(".concat(t," === undefined)");case 2:case"end":return e.stop()}}),S)}function V(e,t){var n;return lh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=e.anyOf.map((function(e){return ie(e,t)})),r.next=3,"(".concat(n.join(" || "),")");case 3:case"end":return r.stop()}}),O)}function Y(e,t){return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,"(".concat(t," instanceof Uint8Array)");case 2:if(!e.maxByteLength){n.next=5;break}return n.next=5,"(".concat(t,".length <= ").concat(e.maxByteLength,")");case 5:if(!e.minByteLength){n.next=8;break}return n.next=8,"(".concat(t,".length >= ").concat(e.minByteLength,")");case 8:case"end":return n.stop()}}),E)}function J(e,t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(true)";case 2:case"end":return e.stop()}}),T)}function Q(e,t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(".concat(t," === null)");case 2:case"end":return e.stop()}}),R)}function X(e,t){var n,r,i;return lh.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(!e.$id||te.has(e.$id)){o.next=8;break}return te.add(e.$id),n=ae(e.$id),r=oe(n,e,"value"),u=r,ee.add(u),o.next=7,"(".concat(n,"(").concat(t,"))");case 7:return o.abrupt("return");case 8:i=e,o.t0=i[a.Kind],o.next="Any"===o.t0?12:"Array"===o.t0?14:"Boolean"===o.t0?16:"Constructor"===o.t0?18:"Function"===o.t0?20:"Integer"===o.t0?22:"Literal"===o.t0?24:"Never"===o.t0?26:"Null"===o.t0?28:"Number"===o.t0?30:"Object"===o.t0?32:"Promise"===o.t0?34:"Record"===o.t0?36:"Ref"===o.t0?38:"Self"===o.t0?40:"String"===o.t0?42:"Tuple"===o.t0?44:"Undefined"===o.t0?46:"Union"===o.t0?48:"Uint8Array"===o.t0?50:"Unknown"===o.t0?52:"Void"===o.t0?54:56;break;case 12:return o.delegateYield(C(),"t1",13);case 13:return o.abrupt("return",o.t1);case 14:return o.delegateYield(P(i,t),"t2",15);case 15:return o.abrupt("return",o.t2);case 16:return o.delegateYield(A(0,t),"t3",17);case 17:return o.abrupt("return",o.t3);case 18:return o.delegateYield(j(i,t),"t4",19);case 19:return o.abrupt("return",o.t4);case 20:return o.delegateYield(M(0,t),"t5",21);case 21:return o.abrupt("return",o.t5);case 22:return o.delegateYield(L(i,t),"t6",23);case 23:return o.abrupt("return",o.t6);case 24:return o.delegateYield(U(i,t),"t7",25);case 25:return o.abrupt("return",o.t7);case 26:return o.delegateYield(N(),"t8",27);case 27:return o.abrupt("return",o.t8);case 28:return o.delegateYield(F(0,t),"t9",29);case 29:return o.abrupt("return",o.t9);case 30:return o.delegateYield(D(i,t),"t10",31);case 31:return o.abrupt("return",o.t10);case 32:return o.delegateYield(q(i,t),"t11",33);case 33:return o.abrupt("return",o.t11);case 34:return o.delegateYield(B(0,t),"t12",35);case 35:return o.abrupt("return",o.t12);case 36:return o.delegateYield(z(i,t),"t13",37);case 37:return o.abrupt("return",o.t13);case 38:return o.delegateYield(W(i,t),"t14",39);case 39:return o.abrupt("return",o.t14);case 40:return o.delegateYield($(i,t),"t15",41);case 41:return o.abrupt("return",o.t15);case 42:return o.delegateYield(K(i,t),"t16",43);case 43:return o.abrupt("return",o.t16);case 44:return o.delegateYield(H(i,t),"t17",45);case 45:return o.abrupt("return",o.t17);case 46:return o.delegateYield(G(0,t),"t18",47);case 47:return o.abrupt("return",o.t18);case 48:return o.delegateYield(V(i,t),"t19",49);case 49:return o.abrupt("return",o.t19);case 50:return o.delegateYield(Y(i,t),"t20",51);case 51:return o.abrupt("return",o.t20);case 52:return o.delegateYield(J(),"t21",53);case 53:return o.abrupt("return",o.t21);case 54:return o.delegateYield(Q(0,t),"t22",55);case 55:return o.abrupt("return",o.t22);case 56:throw new s(e);case 57:case"end":return o.stop()}var u}),I)}var Z=new Map,ee=new Set,te=new Set;function ne(){Z.clear(),ee.clear(),te.clear()}function re(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=nI(t);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(!r.$id)throw new Error("TypeCompiler: Referenced schemas must specify an $id.");if(Z.has(r.$id))throw new Error("TypeCompiler: Duplicate schema $id found for '".concat(r.$id,"'"));Z.set(r.$id,r)}}catch(e){n.e(e)}finally{n.f()}}function ie(e,t){return UR(X(e,t)).join(" && ")}function ae(e){return"check_".concat(e.replace(/-/g,"_"))}function oe(e,t,n){var r=UR(X(t,n)).map((function(e){return" ".concat(e)})).join(" &&\n");return"function ".concat(e,"(value) {\n return (\n").concat(r,"\n )\n}")}function se(e){var t="local_".concat(ee.size);return ee.add("const ".concat(t," = ").concat(e)),t}function ue(){return UR(ee.values())}function ce(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];ne(),re(t);var n=oe("check",e,"value"),r=ue();return"".concat(r.join("\n"),"\nreturn ").concat(n)}e.Compile=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];r.TypeGuard.Assert(e,t);var n=ce(e,t),a=globalThis.Function("format",n),s=a((function(e,t){return!!i.Format.Has(e)&&i.Format.Get(e)(t)}));return new o(e,t,s,n)}}(e.TypeCompiler||(e.TypeCompiler={}))}(JR),function(e){var n=t&&t.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=t&&t.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.ValueErrorType=void 0;var i=WR;Object.defineProperty(e,"ValueErrorType",{enumerable:!0,get:function(){return i.ValueErrorType}}),r(JR,e)}(zR);var aI=o,oI=ot("iterator"),sI=!aI((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[oI]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host})),uI=Zt.exports,cI=jt,lI=s,fI=C,dI=f,pI=o,hI=ra,vI=Rr,yI=d,mI=Be,gI=L,bI=Object.assign,wI=Object.defineProperty,kI=fI([].concat),xI=!bI||pI((function(){if(lI&&1!==bI({b:1},bI(wI({},"a",{enumerable:!0,get:function(){wI(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach((function(e){t[e]=e})),7!=bI({},e)[n]||hI(bI({},t)).join("")!=r}))?function(e,t){for(var n=mI(e),r=arguments.length,i=1,a=vI.f,o=yI.f;r>i;)for(var s,u=gI(arguments[i++]),c=a?kI(hI(u),a(u)):hI(u),l=c.length,f=0;l>f;)s=c[f++],lI&&!dI(o,u,s)||(n[s]=u[s]);return n}:bI,_I=C,SI=2147483647,OI=/[^\0-\u007E]/,EI=/[.\u3002\uFF0E\uFF61]/g,TI="Overflow: input needs wider integers to process",RI=RangeError,II=_I(EI.exec),CI=Math.floor,PI=String.fromCharCode,AI=_I("".charCodeAt),jI=_I([].join),MI=_I([].push),LI=_I("".replace),UI=_I("".split),NI=_I("".toLowerCase),FI=function(e){return e+22+75*(e<26)},DI=function(e,t,n){var r=0;for(e=n?CI(e/700):e>>1,e+=CI(e/t);e>455;)e=CI(e/35),r+=36;return CI(r+36*e/(e+38))},qI=function(e){var t=[];e=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=AI(e,n++);if(i>=55296&&i<=56319&&n<r){var a=AI(e,n++);56320==(64512&a)?MI(t,((1023&i)<<10)+(1023&a)+65536):(MI(t,i),n--)}else MI(t,i)}return t}(e);var n,r,i=e.length,a=128,o=0,s=72;for(n=0;n<e.length;n++)(r=e[n])<128&&MI(t,PI(r));var u=t.length,c=u;for(u&&MI(t,"-");c<i;){var l=SI;for(n=0;n<e.length;n++)(r=e[n])>=a&&r<l&&(l=r);var f=c+1;if(l-a>CI((SI-o)/f))throw RI(TI);for(o+=(l-a)*f,a=l,n=0;n<e.length;n++){if((r=e[n])<a&&++o>SI)throw RI(TI);if(r==a){for(var d=o,p=36;;){var h=p<=s?1:p>=s+26?26:p-s;if(d<h)break;var v=d-h,y=36-h;MI(t,PI(FI(h+v%y))),d=CI(v/y),p+=36}MI(t,PI(FI(d))),s=DI(o,f,c==u),o=0,c++}}o++,a++}return jI(t,"")},BI=Za,zI=Math.floor,WI=function(e,t){var n=e.length,r=zI(n/2);return n<8?$I(e,t):KI(e,WI(BI(e,0,r),t),WI(BI(e,r),t),t)},$I=function(e,t){for(var n,r,i=e.length,a=1;a<i;){for(r=a,n=e[a];r&&t(e[r-1],n)>0;)e[r]=e[--r];r!==a++&&(e[r]=n)}return e},KI=function(e,t,n,r){for(var i=t.length,a=n.length,o=0,s=0;o<i||s<a;)e[o+s]=o<i&&s<a?r(t[o],n[s])<=0?t[o++]:n[s++]:o<i?t[o++]:n[s++];return e},HI=WI,GI=ni,VI=i,YI=f,JI=C,QI=s,XI=sI,ZI=Xn,eC=L_,tC=oi,nC=Rv,rC=Ln,iC=Ec,aC=H,oC=$e,sC=wo,uC=Li,cC=Ft,lC=Y,fC=za,dC=_a,pC=g,hC=bd,vC=dd,yC=jc,mC=HI,gC=ot("iterator"),bC="URLSearchParams",wC="URLSearchParamsIterator",kC=rC.set,xC=rC.getterFor(bC),_C=rC.getterFor(wC),SC=Object.getOwnPropertyDescriptor,OC=function(e){if(!QI)return VI[e];var t=SC(VI,e);return t&&t.value},EC=OC("fetch"),TC=OC("Request"),RC=OC("Headers"),IC=TC&&TC.prototype,CC=RC&&RC.prototype,PC=VI.RegExp,AC=VI.TypeError,jC=VI.decodeURIComponent,MC=VI.encodeURIComponent,LC=JI("".charAt),UC=JI([].join),NC=JI([].push),FC=JI("".replace),DC=JI([].shift),qC=JI([].splice),BC=JI("".split),zC=JI("".slice),WC=/\+/g,$C=Array(4),KC=function(e){return $C[e-1]||($C[e-1]=PC("((?:%[\\da-f]{2}){"+e+"})","gi"))},HC=function(e){try{return jC(e)}catch(t){return e}},GC=function(e){var t=FC(e,WC," "),n=4;try{return jC(t)}catch(e){for(;n;)t=FC(t,KC(n--),HC);return t}},VC=/[!'()~]|%20/g,YC={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},JC=function(e){return YC[e]},QC=function(e){return FC(MC(e),VC,JC)},XC=nC((function(e,t){kC(this,{type:wC,iterator:hC(xC(e).entries),kind:t})}),"Iterator",(function(){var e=_C(this),t=e.kind,n=e.iterator.next(),r=n.value;return n.done||(n.value="keys"===t?r.key:"values"===t?r.value:[r.key,r.value]),n}),!0),ZC=function(e){this.entries=[],this.url=null,void 0!==e&&(lC(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===LC(e,0)?zC(e,1):e:fC(e)))};ZC.prototype={type:bC,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,i,a,o,s,u=vC(e);if(u)for(n=(t=hC(e,u)).next;!(r=YI(n,t)).done;){if(a=(i=hC(cC(r.value))).next,(o=YI(a,i)).done||(s=YI(a,i)).done||!YI(a,i).done)throw AC("Expected sequence with length 2");NC(this.entries,{key:fC(o.value),value:fC(s.value)})}else for(var c in e)oC(e,c)&&NC(this.entries,{key:c,value:fC(e[c])})},parseQuery:function(e){if(e)for(var t,n,r=BC(e,"&"),i=0;i<r.length;)(t=r[i++]).length&&(n=BC(t,"="),NC(this.entries,{key:GC(DC(n)),value:GC(UC(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],r=0;r<t.length;)e=t[r++],NC(n,QC(e.key)+"="+QC(e.value));return UC(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var eP=function(){iC(this,tP);var e=arguments.length>0?arguments[0]:void 0;kC(this,new ZC(e))},tP=eP.prototype;if(eC(tP,{append:function(e,t){yC(arguments.length,2);var n=xC(this);NC(n.entries,{key:fC(e),value:fC(t)}),n.updateURL()},delete:function(e){yC(arguments.length,1);for(var t=xC(this),n=t.entries,r=fC(e),i=0;i<n.length;)n[i].key===r?qC(n,i,1):i++;t.updateURL()},get:function(e){yC(arguments.length,1);for(var t=xC(this).entries,n=fC(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){yC(arguments.length,1);for(var t=xC(this).entries,n=fC(e),r=[],i=0;i<t.length;i++)t[i].key===n&&NC(r,t[i].value);return r},has:function(e){yC(arguments.length,1);for(var t=xC(this).entries,n=fC(e),r=0;r<t.length;)if(t[r++].key===n)return!0;return!1},set:function(e,t){yC(arguments.length,1);for(var n,r=xC(this),i=r.entries,a=!1,o=fC(e),s=fC(t),u=0;u<i.length;u++)(n=i[u]).key===o&&(a?qC(i,u--,1):(a=!0,n.value=s));a||NC(i,{key:o,value:s}),r.updateURL()},sort:function(){var e=xC(this);mC(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,n=xC(this).entries,r=sC(e,arguments.length>1?arguments[1]:void 0),i=0;i<n.length;)r((t=n[i++]).value,t.key,this)},keys:function(){return new XC(this,"keys")},values:function(){return new XC(this,"values")},entries:function(){return new XC(this,"entries")}},{enumerable:!0}),ZI(tP,gC,tP.entries,{name:"entries"}),ZI(tP,"toString",(function(){return xC(this).serialize()}),{enumerable:!0}),tC(eP,bC),GI({global:!0,constructor:!0,forced:!XI},{URLSearchParams:eP}),!XI&&aC(RC)){var nP=JI(CC.has),rP=JI(CC.set),iP=function(e){if(lC(e)){var t,n=e.body;if(uC(n)===bC)return t=e.headers?new RC(e.headers):new RC,nP(t,"content-type")||rP(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),dC(e,{body:pC(0,fC(n)),headers:pC(0,t)})}return e};if(aC(EC)&&GI({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return EC(e,arguments.length>1?iP(arguments[1]):{})}}),aC(TC)){var aP=function(e){return iC(this,IC),new TC(e,arguments.length>1?iP(arguments[1]):{})};IC.constructor=aP,aP.prototype=IC,GI({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:aP})}}var oP,sP=ni,uP=s,cP=sI,lP=i,fP=wo,dP=C,pP=Xn,hP=function(e,t,n){return n.get&&uI(n.get,t,{getter:!0}),n.set&&uI(n.set,t,{setter:!0}),cI.f(e,t,n)},vP=Ec,yP=$e,mP=xI,gP=$h,bP=Za,wP=rv.codeAt,kP=function(e){var t,n,r=[],i=UI(LI(NI(e),EI,"."),".");for(t=0;t<i.length;t++)n=i[t],MI(r,II(OI,n)?"xn--"+qI(n):n);return jI(r,".")},xP=za,_P=oi,SP=jc,OP={URLSearchParams:eP,getState:xC},EP=Ln,TP=EP.set,RP=EP.getterFor("URL"),IP=OP.URLSearchParams,CP=OP.getState,PP=lP.URL,AP=lP.TypeError,jP=lP.parseInt,MP=Math.floor,LP=Math.pow,UP=dP("".charAt),NP=dP(/./.exec),FP=dP([].join),DP=dP(1..toString),qP=dP([].pop),BP=dP([].push),zP=dP("".replace),WP=dP([].shift),$P=dP("".split),KP=dP("".slice),HP=dP("".toLowerCase),GP=dP([].unshift),VP="Invalid scheme",YP="Invalid host",JP="Invalid port",QP=/[a-z]/i,XP=/[\d+-.a-z]/i,ZP=/\d/,eA=/^0x/i,tA=/^[0-7]+$/,nA=/^\d+$/,rA=/^[\da-f]+$/i,iA=/[\0\t\n\r #%/:<>?@[\\\]^|]/,aA=/[\0\t\n\r #/:<>?@[\\\]^|]/,oA=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,sA=/[\t\n\r]/g,uA=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)GP(t,e%256),e=MP(e/256);return FP(t,".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,a=0;a<8;a++)0!==e[a]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=a),++i);return i>n&&(t=r,n=i),t}(e),n=0;n<8;n++)i&&0===e[n]||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=DP(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},cA={},lA=mP({},cA,{" ":1,'"':1,"<":1,">":1,"`":1}),fA=mP({},lA,{"#":1,"?":1,"{":1,"}":1}),dA=mP({},fA,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),pA=function(e,t){var n=wP(e,0);return n>32&&n<127&&!yP(t,e)?e:encodeURIComponent(e)},hA={ftp:21,file:null,http:80,https:443,ws:80,wss:443},vA=function(e,t){var n;return 2==e.length&&NP(QP,UP(e,0))&&(":"==(n=UP(e,1))||!t&&"|"==n)},yA=function(e){var t;return e.length>1&&vA(KP(e,0,2))&&(2==e.length||"/"===(t=UP(e,2))||"\\"===t||"?"===t||"#"===t)},mA=function(e){return"."===e||"%2e"===HP(e)},gA={},bA={},wA={},kA={},xA={},_A={},SA={},OA={},EA={},TA={},RA={},IA={},CA={},PA={},AA={},jA={},MA={},LA={},UA={},NA={},FA={},DA=function(e,t,n){var r,i,a,o=xP(e);if(t){if(i=this.parse(o))throw AP(i);this.searchParams=null}else{if(void 0!==n&&(r=new DA(n,!0)),i=this.parse(o,null,r))throw AP(i);(a=CP(new IP)).bindURL(this),this.searchParams=a}};DA.prototype={type:"URL",parse:function(e,t,n){var r,i,a,o,s,u=this,c=t||gA,l=0,f="",d=!1,p=!1,h=!1;for(e=xP(e),t||(u.scheme="",u.username="",u.password="",u.host=null,u.port=null,u.path=[],u.query=null,u.fragment=null,u.cannotBeABaseURL=!1,e=zP(e,oA,"")),e=zP(e,sA,""),r=gP(e);l<=r.length;){switch(i=r[l],c){case gA:if(!i||!NP(QP,i)){if(t)return VP;c=wA;continue}f+=HP(i),c=bA;break;case bA:if(i&&(NP(XP,i)||"+"==i||"-"==i||"."==i))f+=HP(i);else{if(":"!=i){if(t)return VP;f="",c=wA,l=0;continue}if(t&&(u.isSpecial()!=yP(hA,f)||"file"==f&&(u.includesCredentials()||null!==u.port)||"file"==u.scheme&&!u.host))return;if(u.scheme=f,t)return void(u.isSpecial()&&hA[u.scheme]==u.port&&(u.port=null));f="","file"==u.scheme?c=PA:u.isSpecial()&&n&&n.scheme==u.scheme?c=kA:u.isSpecial()?c=OA:"/"==r[l+1]?(c=xA,l++):(u.cannotBeABaseURL=!0,BP(u.path,""),c=UA)}break;case wA:if(!n||n.cannotBeABaseURL&&"#"!=i)return VP;if(n.cannotBeABaseURL&&"#"==i){u.scheme=n.scheme,u.path=bP(n.path),u.query=n.query,u.fragment="",u.cannotBeABaseURL=!0,c=FA;break}c="file"==n.scheme?PA:_A;continue;case kA:if("/"!=i||"/"!=r[l+1]){c=_A;continue}c=EA,l++;break;case xA:if("/"==i){c=TA;break}c=LA;continue;case _A:if(u.scheme=n.scheme,i==oP)u.username=n.username,u.password=n.password,u.host=n.host,u.port=n.port,u.path=bP(n.path),u.query=n.query;else if("/"==i||"\\"==i&&u.isSpecial())c=SA;else if("?"==i)u.username=n.username,u.password=n.password,u.host=n.host,u.port=n.port,u.path=bP(n.path),u.query="",c=NA;else{if("#"!=i){u.username=n.username,u.password=n.password,u.host=n.host,u.port=n.port,u.path=bP(n.path),u.path.length--,c=LA;continue}u.username=n.username,u.password=n.password,u.host=n.host,u.port=n.port,u.path=bP(n.path),u.query=n.query,u.fragment="",c=FA}break;case SA:if(!u.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){u.username=n.username,u.password=n.password,u.host=n.host,u.port=n.port,c=LA;continue}c=TA}else c=EA;break;case OA:if(c=EA,"/"!=i||"/"!=UP(f,l+1))continue;l++;break;case EA:if("/"!=i&&"\\"!=i){c=TA;continue}break;case TA:if("@"==i){d&&(f="%40"+f),d=!0,a=gP(f);for(var v=0;v<a.length;v++){var y=a[v];if(":"!=y||h){var m=pA(y,dA);h?u.password+=m:u.username+=m}else h=!0}f=""}else if(i==oP||"/"==i||"?"==i||"#"==i||"\\"==i&&u.isSpecial()){if(d&&""==f)return"Invalid authority";l-=gP(f).length+1,f="",c=RA}else f+=i;break;case RA:case IA:if(t&&"file"==u.scheme){c=jA;continue}if(":"!=i||p){if(i==oP||"/"==i||"?"==i||"#"==i||"\\"==i&&u.isSpecial()){if(u.isSpecial()&&""==f)return YP;if(t&&""==f&&(u.includesCredentials()||null!==u.port))return;if(o=u.parseHost(f))return o;if(f="",c=MA,t)return;continue}"["==i?p=!0:"]"==i&&(p=!1),f+=i}else{if(""==f)return YP;if(o=u.parseHost(f))return o;if(f="",c=CA,t==IA)return}break;case CA:if(!NP(ZP,i)){if(i==oP||"/"==i||"?"==i||"#"==i||"\\"==i&&u.isSpecial()||t){if(""!=f){var g=jP(f,10);if(g>65535)return JP;u.port=u.isSpecial()&&g===hA[u.scheme]?null:g,f=""}if(t)return;c=MA;continue}return JP}f+=i;break;case PA:if(u.scheme="file","/"==i||"\\"==i)c=AA;else{if(!n||"file"!=n.scheme){c=LA;continue}if(i==oP)u.host=n.host,u.path=bP(n.path),u.query=n.query;else if("?"==i)u.host=n.host,u.path=bP(n.path),u.query="",c=NA;else{if("#"!=i){yA(FP(bP(r,l),""))||(u.host=n.host,u.path=bP(n.path),u.shortenPath()),c=LA;continue}u.host=n.host,u.path=bP(n.path),u.query=n.query,u.fragment="",c=FA}}break;case AA:if("/"==i||"\\"==i){c=jA;break}n&&"file"==n.scheme&&!yA(FP(bP(r,l),""))&&(vA(n.path[0],!0)?BP(u.path,n.path[0]):u.host=n.host),c=LA;continue;case jA:if(i==oP||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&vA(f))c=LA;else if(""==f){if(u.host="",t)return;c=MA}else{if(o=u.parseHost(f))return o;if("localhost"==u.host&&(u.host=""),t)return;f="",c=MA}continue}f+=i;break;case MA:if(u.isSpecial()){if(c=LA,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=oP&&(c=LA,"/"!=i))continue}else u.fragment="",c=FA;else u.query="",c=NA;break;case LA:if(i==oP||"/"==i||"\\"==i&&u.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=HP(s=f))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(u.shortenPath(),"/"==i||"\\"==i&&u.isSpecial()||BP(u.path,"")):mA(f)?"/"==i||"\\"==i&&u.isSpecial()||BP(u.path,""):("file"==u.scheme&&!u.path.length&&vA(f)&&(u.host&&(u.host=""),f=UP(f,0)+":"),BP(u.path,f)),f="","file"==u.scheme&&(i==oP||"?"==i||"#"==i))for(;u.path.length>1&&""===u.path[0];)WP(u.path);"?"==i?(u.query="",c=NA):"#"==i&&(u.fragment="",c=FA)}else f+=pA(i,fA);break;case UA:"?"==i?(u.query="",c=NA):"#"==i?(u.fragment="",c=FA):i!=oP&&(u.path[0]+=pA(i,cA));break;case NA:t||"#"!=i?i!=oP&&("'"==i&&u.isSpecial()?u.query+="%27":u.query+="#"==i?"%23":pA(i,cA)):(u.fragment="",c=FA);break;case FA:i!=oP&&(u.fragment+=pA(i,lA))}l++}},parseHost:function(e){var t,n,r;if("["==UP(e,0)){if("]"!=UP(e,e.length-1))return YP;if(t=function(e){var t,n,r,i,a,o,s,u=[0,0,0,0,0,0,0,0],c=0,l=null,f=0,d=function(){return UP(e,f)};if(":"==d()){if(":"!=UP(e,1))return;f+=2,l=++c}for(;d();){if(8==c)return;if(":"!=d()){for(t=n=0;n<4&&NP(rA,d());)t=16*t+jP(d(),16),f++,n++;if("."==d()){if(0==n)return;if(f-=n,c>6)return;for(r=0;d();){if(i=null,r>0){if(!("."==d()&&r<4))return;f++}if(!NP(ZP,d()))return;for(;NP(ZP,d());){if(a=jP(d(),10),null===i)i=a;else{if(0==i)return;i=10*i+a}if(i>255)return;f++}u[c]=256*u[c]+i,2!=++r&&4!=r||c++}if(4!=r)return;break}if(":"==d()){if(f++,!d())return}else if(d())return;u[c++]=t}else{if(null!==l)return;f++,l=++c}}if(null!==l)for(o=c-l,c=7;0!=c&&o>0;)s=u[c],u[c--]=u[l+o-1],u[l+--o]=s;else if(8!=c)return;return u}(KP(e,1,-1)),!t)return YP;this.host=t}else if(this.isSpecial()){if(e=kP(e),NP(iA,e))return YP;if(t=function(e){var t,n,r,i,a,o,s,u=$P(e,".");if(u.length&&""==u[u.length-1]&&u.length--,(t=u.length)>4)return e;for(n=[],r=0;r<t;r++){if(""==(i=u[r]))return e;if(a=10,i.length>1&&"0"==UP(i,0)&&(a=NP(eA,i)?16:8,i=KP(i,8==a?1:2)),""===i)o=0;else{if(!NP(10==a?nA:8==a?tA:rA,i))return e;o=jP(i,a)}BP(n,o)}for(r=0;r<t;r++)if(o=n[r],r==t-1){if(o>=LP(256,5-t))return null}else if(o>255)return null;for(s=qP(n),r=0;r<n.length;r++)s+=n[r]*LP(256,3-r);return s}(e),null===t)return YP;this.host=t}else{if(NP(aA,e))return YP;for(t="",n=gP(e),r=0;r<n.length;r++)t+=pA(n[r],cA);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return yP(hA,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&vA(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,r=e.password,i=e.host,a=e.port,o=e.path,s=e.query,u=e.fragment,c=t+":";return null!==i?(c+="//",e.includesCredentials()&&(c+=n+(r?":"+r:"")+"@"),c+=uA(i),null!==a&&(c+=":"+a)):"file"==t&&(c+="//"),c+=e.cannotBeABaseURL?o[0]:o.length?"/"+FP(o,"/"):"",null!==s&&(c+="?"+s),null!==u&&(c+="#"+u),c},setHref:function(e){var t=this.parse(e);if(t)throw AP(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new qA(e.path[0]).origin}catch(e){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+uA(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(xP(e)+":",gA)},getUsername:function(){return this.username},setUsername:function(e){var t=gP(xP(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=pA(t[n],dA)}},getPassword:function(){return this.password},setPassword:function(e){var t=gP(xP(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=pA(t[n],dA)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?uA(e):uA(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,RA)},getHostname:function(){var e=this.host;return null===e?"":uA(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,IA)},getPort:function(){var e=this.port;return null===e?"":xP(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=xP(e))?this.port=null:this.parse(e,CA))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+FP(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,MA))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=xP(e))?this.query=null:("?"==UP(e,0)&&(e=KP(e,1)),this.query="",this.parse(e,NA)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=xP(e))?("#"==UP(e,0)&&(e=KP(e,1)),this.fragment="",this.parse(e,FA)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var qA=function(e){var t=vP(this,BA),n=SP(arguments.length,1)>1?arguments[1]:void 0,r=TP(t,new DA(e,!1,n));uP||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},BA=qA.prototype,zA=function(e,t){return{get:function(){return RP(this)[e]()},set:t&&function(e){return RP(this)[t](e)},configurable:!0,enumerable:!0}};if(uP&&(hP(BA,"href",zA("serialize","setHref")),hP(BA,"origin",zA("getOrigin")),hP(BA,"protocol",zA("getProtocol","setProtocol")),hP(BA,"username",zA("getUsername","setUsername")),hP(BA,"password",zA("getPassword","setPassword")),hP(BA,"host",zA("getHost","setHost")),hP(BA,"hostname",zA("getHostname","setHostname")),hP(BA,"port",zA("getPort","setPort")),hP(BA,"pathname",zA("getPathname","setPathname")),hP(BA,"search",zA("getSearch","setSearch")),hP(BA,"searchParams",zA("getSearchParams")),hP(BA,"hash",zA("getHash","setHash"))),pP(BA,"toJSON",(function(){return RP(this).serialize()}),{enumerable:!0}),pP(BA,"toString",(function(){return RP(this).serialize()}),{enumerable:!0}),PP){var WA=PP.createObjectURL,$A=PP.revokeObjectURL;WA&&pP(qA,"createObjectURL",fP(WA,PP)),$A&&pP(qA,"revokeObjectURL",fP($A,PP))}_P(qA,"URL"),sP({global:!0,constructor:!0,forced:!cP,sham:!uP},{URL:qA});var KA={},HA={},GA=t&&t.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(HA,"__esModule",{value:!0}),HA.StateMachine=void 0;var VA=function(){function e(e){var t,n,r=this;if(this._configuration={},this._listeners=new Set,this._scopeStack=[],"function"!=typeof e)throw new Error("The StateMachine constructor expects a callback as the first argument");if(this._scopeStack.unshift("config"),e({initialState:function(e){r._checkConfigScope(),r._currentState=e},state:function(e,t){r._checkConfigScope();var n={on:{}};r._scopeStack.unshift("state"),t({onEnter:function(e){r._checkStateScope("onEnter"),n.onEnter=e},onExit:function(e){r._checkStateScope("onExit"),n.onExit=e},on:function(e,t){r._checkStateScope("on"),n.on[e]=t}}),r._scopeStack.shift(),r._configuration[e]=n}}),this._scopeStack.shift(),void 0===this._currentState)throw new Error("No initial state provided");if(0===Object.keys(this._configuration).length)throw new Error("No state definition was provided");null===(n=null===(t=this._configuration[this._currentState.type])||void 0===t?void 0:t.onEnter)||void 0===n||n.call(t,{state:this._currentState})}return e.prototype.transition=function(e){var t,n,r,i,a,o=this._configuration[this._currentState.type];if(o){var s=o.on[e.type];if(s){var u=s({state:this._currentState,event:e,transitionTo:function(e,t){return{state:e,sideEffect:null!=t?t:null}},dontTransition:function(e){return{state:null,sideEffect:null!=e?e:null}}}),c=u.state,l=u.sideEffect,f=this._currentState;null!==c&&(null===(r=o.onExit)||void 0===r||r.call(o,{state:this._currentState}),this._currentState=c,null===(a=null===(i=this._configuration[c.type])||void 0===i?void 0:i.onEnter)||void 0===a||a.call(i,{state:c}));try{for(var d=GA(this._listeners),p=d.next();!p.done;p=d.next()){(0,p.value)(f,null!=c?c:f,e)}}catch(e){t={error:e}}finally{try{p&&!p.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}l&&setTimeout((function(){null==l||l()}),0)}}},e.prototype.subscribe=function(e){var t=this;return this._listeners.add(e),e(null,this._currentState,null),function(){t._listeners.delete(e)}},Object.defineProperty(e.prototype,"state",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),e.prototype._checkConfigScope=function(){if("config"!==this._scopeStack[0])throw new Error("Call to `initialState` is allowed only from within the config callback, but not inside a state callback")},e.prototype._checkStateScope=function(e){if("state"!==this._scopeStack[0])throw new Error("Call to `".concat(e,"` is allowed only from within a state callback"))},e}();HA.StateMachine=VA,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.StateMachine=void 0;var t=HA;Object.defineProperty(e,"StateMachine",{enumerable:!0,get:function(){return t.StateMachine}})}(KA),function(e){var t=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Object.defineProperty(e,"__esModule",{value:!0});var n=Dw.exports,r=DS.exports,i=$w.exports,a=Ww.exports,o=Vw.exports,s=Kw.exports,u=Gw.exports,c=Yw.exports,l=sx.exports,f=qS,d=BS,p=ix,h=jw.exports,v=ZE.exports,y=eT,m=dR,g=LR,b=NR,w=zR,k=KA;function x(e){return e&&"object"===Xu(e)&&"default"in e?e:{default:e}}function _(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var S,O=x(NS.exports),E=x(n),T=x(r),R=x(i),I=x(a),C=x(o),P=x(s),A=x(u),j=x(c),M=x(l),L=x(f),U=x(h),N=_(v),F=x(m),D=function(){function e(t,n){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;R.default(this,e),M.default(this,"message",void 0),M.default(this,"_onFinished",void 0),M.default(this,"_timer",void 0),M.default(this,"_deferredResponse",new d.Deferred),this.message=t,this._onFinished=i,this._timer=setTimeout((function(){var e;if(!r._deferredResponse.isDone){var t=new d.ErrorInfo("timeout","Request timeout: ".concat(r.message.id));r._deferredResponse.reject(new d.TwilioError(t)),null===(e=r._onFinished)||void 0===e||e.call(r,r)}}),n)}return I.default(e,[{key:"complete",value:function(e){var t;this._deferredResponse.isDone||(clearTimeout(this._timer),this._deferredResponse.resolve(e),null===(t=this._onFinished)||void 0===t||t.call(this,this))}},{key:"cancel",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new d.ErrorInfo("cancelled","Request has been cancelled");this._deferredResponse.isDone||(clearTimeout(this._timer),this._deferredResponse.reject(new d.TwilioError(t)),null===(e=this._onFinished)||void 0===e||e.call(this,this))}},{key:"promise",get:function(){return this._deferredResponse.promise}}]),e}(),q=new d.Logger("twilsock","Twilsock"),B=new TextEncoder,z=new TextDecoder;function W(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return $(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function K(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=j.default(e);if(t){var i=j.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return A.default(this,n)}}var H=null!==(S=t.WebSocket)&&void 0!==S?S:{},G=function(e){P.default(n,e);var t=K(n);function n(){var e;R.default(this,n);for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return e=t.call.apply(t,[this].concat(i)),M.default(C.default(e),"_webSocket",null),M.default(C.default(e),"_state","disconnected"),M.default(C.default(e),"_listeners",[]),e}return I.default(n,[{key:"connect",value:function(e){var t=this;if(q.info("Call to Transport.connect(".concat(e,")")),"disconnected"===this._state){this._state="connecting";try{this._webSocket=new H(e)}catch(e){return q.error("Error in Transport.connect:",e),void this._doDisconnect(new d.ErrorInfo("unknown","Error in Transport.connect"))}this._webSocket.binaryType="arraybuffer",this._subscribeToEvent("open",(function(){q.info('WebSocket "open" event'),t._state="connected",t.emit("connected")})),this._subscribeToEvent("error",(function(e){q.info('WebSocket "error" event:',e),t._doDisconnect(new d.ErrorInfo("unknown","Failed to connect WebSocket"))})),this._subscribeToEvent("close",(function(e){q.info('WebSocket "close" event:',e),t._doDisconnect(new d.ErrorInfo("transportDisconnected",'WebSocket "close" event received'))})),this._subscribeToEvent("message",(function(e){q.info('WebSocket "message" event:',z.decode(e.data));var n=e.data;n instanceof ArrayBuffer&&t.emit("messageReceived",n)}))}else q.warn('Cannot connect in state "'.concat(this._state,'". Ignored.'))}},{key:"sendMessage",value:function(e){q.info("Call to Transport.sendMessage(".concat(z.decode(e),")"));var t=new Error("Transport is not ready. Call `connect()` first");if(null===this._webSocket)throw t;try{this._webSocket.send(e)}catch(e){throw t}}},{key:"disconnect",value:function(e){this._doDisconnect(new d.ErrorInfo("transportDisconnected","Transport.Disconnect called: ".concat(e)))}},{key:"_doDisconnect",value:function(e){var t;(q.info("Call to Transport.doDisconnect(".concat(e,"): ").concat(this._state)),"disconnected"!==this._state)&&(this._state="disconnected",null===(t=this._webSocket)||void 0===t||t.close(),this._unsubscribeFromListeners(),this.emit("disconnected",e))}},{key:"_subscribeToEvent",value:function(e,t){var n;null===(n=this._webSocket)||void 0===n||n.addEventListener(e,t),this._listeners.push([e,t])}},{key:"_unsubscribeFromListeners",value:function(){var e,t=W(this._listeners);try{for(t.s();!(e=t.n()).done;){var n,r=U.default(e.value,2),i=r[0],a=r[1];null===(n=this._webSocket)||void 0===n||n.removeEventListener(i,a)}}catch(e){t.e(e)}finally{t.f()}this._listeners=[]}}]),n}(p.ReplayEventEmitter);function V(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var Y=function(e){var t,n,r,i,a,o,s,u;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?V(Object(n),!0).forEach((function(t){M.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):V(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({env:null!==(t=N.name)&&void 0!==t?t:"unknown",envv:null!==(n=N.version)&&void 0!==n?n:"unknown",os:null!==(r=null===(i=N.os)||void 0===i?void 0:i.family)&&void 0!==r?r:"unknown",osv:null!==(a=null===(o=N.os)||void 0===o?void 0:o.version)&&void 0!==a?a:"unknown",osa:String(null!==(s=null===(u=N.os)||void 0===u?void 0:u.architecture)&&void 0!==s?s:"unknown"),sdk:"js-default"},e)},J=I.default((function e(t,n,r){var i,a,o,s,u,c,l,f,d,p;R.default(this,e),M.default(this,"retryPolicy",void 0),M.default(this,"url",void 0),M.default(this,"activeGrant",void 0),M.default(this,"logLevel",void 0),M.default(this,"clientMetadata",void 0),M.default(this,"tweaks",void 0),M.default(this,"token",void 0),M.default(this,"continuationToken",void 0),M.default(this,"initRegistrations",void 0);var h=null!==(i=r.region)&&void 0!==i?i:"us1",v="wss://tsock.".concat(h,".twilio.com/v3/wsconnect"),y=null!==(a=null!==(o=r.twilsock)&&void 0!==o?o:r.Twilsock)&&void 0!==a?a:{};this.token=t,this.continuationToken=null!==(s=r.continuationToken)&&void 0!==s?s:null,this.activeGrant=n,this.url=null!==(u=y.uri)&&void 0!==u?u:v,this.logLevel=null!==(c=r.logLevel)&&void 0!==c?c:"error",this.retryPolicy=null!==(l=r.retryPolicy)&&void 0!==l?l:{min:1e3,max:12e4,randomness:.2},this.clientMetadata=Y(null!==(f=r.clientMetadata)&&void 0!==f?f:{}),this.clientMetadata.ver="0.13.1",this.initRegistrations=null!==(d=r.initRegistrations)&&void 0!==d?d:null,this.tweaks=null!==(p=r.tweaks)&&void 0!==p?p:null}));function Q(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=j.default(e);if(t){var i=j.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return A.default(this,n)}}var X=function(e){P.default(r,e);var n=Q(r);function r(){var e;R.default(this,r);for(var t=arguments.length,i=new Array(t),a=0;a<t;a++)i[a]=arguments[a];return e=n.call.apply(n,[this].concat(i)),M.default(C.default(e),"_timer",null),M.default(C.default(e),"_isNetworkAvailable",!0),e}return I.default(r,[{key:"isNetworkAvailable",get:function(){return this._isNetworkAvailable}},{key:"start",value:function(){null===this._timer&&(this.emit("changed",this._isNetworkAvailable),this._checkConnectivity())}},{key:"stop",value:function(){var e;null!==this._timer&&("number"==typeof(e=this._timer)&&"function"==typeof t.clearTimeout?t.clearTimeout(e):function(e){e&&"function"==typeof e.close&&e.close()}(e),this._timer=null)}},{key:"_checkConnectivity",value:function(){var e=this,t=this._isNetworkAvailable;F.default().then((function(t){e._isNetworkAvailable=t})).catch((function(t){q.warn("Error on checking connectivity",t),e._isNetworkAvailable=!1})).finally((function(){t!==e._isNetworkAvailable&&e.emit("changed",e._isNetworkAvailable),e._timer=setTimeout((function(){e._checkConnectivity()}),5e3)}))}}]),r}(p.ReplayEventEmitter),Z=b.Type.Union([b.Type.Literal("init"),b.Type.Literal("update"),b.Type.Literal("ping"),b.Type.Literal("close"),b.Type.Literal("notification"),b.Type.Literal("message"),b.Type.Literal("reply"),b.Type.Literal("client_update")]),ee=b.Type.Object({method:Z,id:b.Type.String(),payload_size:b.Type.Optional(b.Type.Number()),payload_type:b.Type.Optional(b.Type.String())}),te=w.TypeCompiler.Compile(ee);function ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function re(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ne(Object(n),!0).forEach((function(t){M.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ne(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ie="TWILSOCK V3.0",ae=g.customAlphabet("1234567890abcdef",32),Message=function(){function Message(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"RQ".concat(ae());R.default(this,Message),M.default(this,"method",void 0),M.default(this,"headers",void 0),M.default(this,"payloadType",void 0),M.default(this,"payload",void 0),M.default(this,"id",void 0),this.method=e,this.headers=t,this.payloadType=n,this.payload=r,this.id=i}return I.default(Message,[{key:"encode",value:function(){var e,t={method:this.method,id:this.id};""!==this.payload&&(t.payload_size=B.encode(this.payload).length,t.payload_type=this.payloadType);var n=JSON.stringify(re(re({},null!==(e=this.headers)&&void 0!==e?e:{}),t)),r=B.encode(n).length,i=""===this.payload?"":"\r\n";return B.encode("".concat(ie," ").concat(r,"\r\n").concat(n,"\r\n").concat(this.payload).concat(i))}}],[{key:"parse",value:function(e){var t,n=z.decode(e);if(!n.startsWith(ie))throw new Error("Invalid Twilsock prefix");var r=n.split("\r\n"),i=U.default(r,3),a=i[0],o=i[1],s=i[2],u=Number(a.split(" ")[2]);if(o.length!==u)throw new Error("Invalid header size: expected ".concat(u,", got ").concat(o.length));var c=JSON.parse(o);if(!te.Check(c))throw new Error("Invalid headers received");var l=null!==(t=c.payload_type)&&void 0!==t?t:"";return new Message(c.method,c,l,s,c.id)}}]),Message}(),oe=I.default((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"ers",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];R.default(this,e),M.default(this,"product",void 0),M.default(this,"type",void 0),M.default(this,"notification_protocol_version",void 0),M.default(this,"message_types",void 0),this.product=t,this.type=n,this.notification_protocol_version=r,this.message_types=i,Object.freeze(i)})),se=b.Type.Object({code:b.Type.Number(),status:b.Type.String(),errorCode:b.Type.Optional(b.Type.Number())}),ue=b.Type.Object({status:se,http_status:b.Type.Optional(se),continuation_token:b.Type.Optional(b.Type.String()),http_headers:b.Type.Optional(b.Type.Record(b.Type.String(),b.Type.String()))}),ce=w.TypeCompiler.Compile(ue),le=b.Type.Object({backoff_policy:b.Type.Optional(b.Type.Object({reconnect_min_ms:b.Type.Optional(b.Type.Number()),reconnect_max_ms:b.Type.Optional(b.Type.Number())}))}),fe=w.TypeCompiler.Compile(le);function de(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=j.default(e);if(t){var i=j.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return A.default(this,n)}}var pe=function(e){P.default(n,e);var t=de(n);function n(e,r,i,a){var o,s,u,c,l,f;if(R.default(this,n),c=t.call(this,"reply",r,i,a,e),M.default(C.default(c),"replyHeaders",void 0),M.default(C.default(c),"replyPayload",void 0),!ce.Check(r))throw new Error("Invalid reply headers passed");c.replyHeaders={status:r.status,httpStatus:null!==(o=r.http_status)&&void 0!==o?o:{code:200,status:"ok"},continuationToken:null!==(s=r.continuation_token)&&void 0!==s?s:"",httpHeaders:null!==(u=r.http_headers)&&void 0!==u?u:{}};try{var d,p,h=JSON.parse(a);if(fe.Check(h))l=null===(d=h.backoff_policy)||void 0===d?void 0:d.reconnect_min_ms,f=null===(p=h.backoff_policy)||void 0===p?void 0:p.reconnect_max_ms}catch(e){}finally{var v,y;c.replyPayload={backoffPolicy:{reconnectMinMs:null!==(v=l)&&void 0!==v?v:1e3,reconnectMaxMs:null!==(y=f)&&void 0!==y?y:2e3}}}return c}return I.default(n)}(Message),he=I.default((function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;R.default(this,e),M.default(this,"capabilities",void 0),M.default(this,"token",void 0),M.default(this,"continuation_token",void 0),M.default(this,"registrations",void 0),M.default(this,"tweaks",void 0),M.default(this,"metadata",void 0),this.capabilities=t,this.token=n,this.continuation_token=r,this.registrations=i,this.tweaks=a,this.metadata=o,Object.freeze(i),Object.freeze(a),Object.freeze(o)}));function ve(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ye(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ve(Object(n),!0).forEach((function(t){M.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ve(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var me=function(){function e(t,n,r,i,a){R.default(this,e),M.default(this,"host",void 0),M.default(this,"path",void 0),M.default(this,"method",void 0),M.default(this,"params",void 0),M.default(this,"headers",void 0),this.host=t,this.path=n,this.method=r,this.params=i,this.headers=a,Object.freeze(i),Object.freeze(a)}return I.default(e,null,[{key:"from",value:function(t){var n=new URL(t.url),r=E.default(new URLSearchParams(n.searchParams).entries()).reduce((function(e,t){var n=U.default(t,2),r=n[0],i=n[1];return ye(ye({},e),{},M.default({},r,i))}),{});return new e(n.host,n.pathname,t.method,r,t.headers)}}]),e}(),ge=I.default((function e(t,n){R.default(this,e),M.default(this,"active_grant",void 0),M.default(this,"http_request",void 0),this.active_grant=t,this.http_request=n,Object.freeze(n)})),be=b.Type.Object({status:se}),we=w.TypeCompiler.Compile(be);function ke(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=j.default(e);if(t){var i=j.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return A.default(this,n)}}var xe=function(e){P.default(n,e);var t=ke(n);function n(e,r,i,a){var o;if(R.default(this,n),o=t.call(this,"close",r,i,a,e),M.default(C.default(o),"status",void 0),!we.Check(r))throw new Error("Invalid close headers passed");return o.status=r.status,o}return I.default(n)}(Message),_e=b.Type.Object({client_update_type:b.Type.Optional(b.Type.String())}),Se=w.TypeCompiler.Compile(_e);function Oe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=j.default(e);if(t){var i=j.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return A.default(this,n)}}var Ee=function(e){P.default(n,e);var t=Oe(n);function n(e,r,i,a){var o,s;if(R.default(this,n),s=t.call(this,"client_update",r,i,a,e),M.default(C.default(s),"clientUpdateType",void 0),!Se.Check(r))throw new Error("Invalid client update headers passed");return s.clientUpdateType=null!==(o=r.client_update_type)&&void 0!==o?o:"",s}return I.default(n)}(Message),Te=b.Type.Object({message_type:b.Type.Optional(b.Type.String())}),Re=w.TypeCompiler.Compile(Te);function Ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=j.default(e);if(t){var i=j.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return A.default(this,n)}}var Ce=function(e){P.default(n,e);var t=Ie(n);function n(e,r,i,a){var o,s;if(R.default(this,n),s=t.call(this,"notification",r,i,a,e),M.default(C.default(s),"messageType",void 0),!Re.Check(r))throw new Error("Invalid notification headers passed");return s.messageType=null!==(o=r.message_type)&&void 0!==o?o:"",s}return I.default(n)}(Message),Pe=I.default((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:6e4;R.default(this,e),M.default(this,"url",void 0),M.default(this,"method",void 0),M.default(this,"headers",void 0),M.default(this,"payload",void 0),M.default(this,"grant",void 0),M.default(this,"timeout",void 0),this.url=t,this.method=n,this.headers=r,this.payload=i,this.grant=a,this.timeout=o,Object.freeze(r)})),Ae=I.default((function e(t,n,r,i){R.default(this,e),M.default(this,"statusCode",void 0),M.default(this,"status",void 0),M.default(this,"headers",void 0),M.default(this,"payload",void 0),this.statusCode=t,this.status=n,this.headers=r,this.payload=i,Object.freeze(r)}));function je(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Me(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Me(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Me(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Le(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=j.default(e);if(t){var i=j.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return A.default(this,n)}}var Ue={code:200,status:"Ok"},Ne={code:400,status:"Bad Request"},Fe=20104,De=function(e,t){return new d.ErrorInfo(t,e.status,e.code,e.errorCode)},qe=function(e){P.default(n,e);var t=Le(n);function n(e,r){var i,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};R.default(this,n),i=t.call(this),M.default(C.default(i),"lastError",null),M.default(C.default(i),"_config",void 0),M.default(C.default(i),"_fsm",void 0),M.default(C.default(i),"_pendingRequests",new Map),M.default(C.default(i),"_sentRequests",new Map),M.default(C.default(i),"_connectivityMonitor",new X),M.default(C.default(i),"_failedReconnectionAttempts",0),M.default(C.default(i),"_webSocket",null),M.default(C.default(i),"_watchdogTimer",null),i._config=new J(e,r,a),a.logLevel&&q.setLevel(a.logLevel);var o=function(e){var t=e.event;return(0,e.dontTransition)((function(){i._handleMessageReceived(t.message)}))},s=function(e){return(0,e.transitionTo)({type:"disconnected",errorInfo:new d.ErrorInfo("unknown","Disconnect called")})},u=function(e){var t=e.event;return(0,e.transitionTo)({type:"waitAndReconnect"},(function(){i.emit("nonFatalError",t.errorInfo)}))},c=function(e){return(0,e.transitionTo)({type:"waitAndReconnect"},(function(){i.emit("nonFatalError",new d.ErrorInfo("networkBecameUnreachable","Network became unreachable"))}))},l=function(e){var t=e.event;return(0,e.transitionTo)({type:"disconnected",errorInfo:t.errorInfo},(function(){i.emit("fatalError",t.errorInfo)}))};return i._fsm=new k.StateMachine((function(e){var t=e.initialState,n=e.state;t({type:"disconnected",errorInfo:new d.ErrorInfo("unknown","Twilsock created")}),n("disconnected",(function(e){var t=e.onEnter,n=e.onExit,r=e.on;t((function(e){var t=e.state;i._failedReconnectionAttempts=0,i._connectivityMonitor.stop(),i._failAllSentRequests(t.errorInfo),i._failAllPendingRequests(t.errorInfo),i._disconnectWebSocket(),i.emit("disconnected",t.errorInfo.message)})),n((function(){i._connectivityMonitor.start()})),r("connect",(function(e){return(0,e.transitionTo)({type:"connecting"})})),r("updateToken",(function(e){var t=e.event,n=e.transitionTo;return i._config.token=t.token,t.request.cancel(),n({type:"connecting"})})),r("sendRequest",(function(e){var t=e.event,n=e.dontTransition,r=new d.ErrorInfo("transportDisconnected","Cannot send request in the disconnected state");return t.request.cancel(r),n()}))})),n("connecting",(function(e){var t=e.onEnter,n=e.on;t((function(){i._connectWebSocket(),i.emit("connecting")})),n("updateToken",(function(e){var t=e.event,n=e.dontTransition,r=new d.ErrorInfo("tokenUpdatedLocally");return i._config.token=t.token,t.request.cancel(r),n()})),n("sendRequest",(function(e){var t=e.event,n=e.dontTransition;return i._addPendingRequest(t.request),n()})),n("transportConnected",(function(e){return(0,e.transitionTo)({type:"initializing"})})),n("disconnect",(function(e){return s(e)})),n("networkBecameUnreachable",(function(e){return c(e)})),n("nonFatalError",(function(e){return u(e)})),n("fatalError",(function(e){return l(e)}))})),n("initializing",(function(e){var t,n=e.onEnter,r=e.onExit,a=e.on;n((function(){(t=i._createInitRequest(5e3)).promise.then((function(){q.debug("Init message received"),i._fsm.transition({type:"initMessageReceived"})})).catch((function(e){e instanceof d.ErrorInfo&&"timeout"===e.reason&&i._onTimeout()})),i._sendRequest(t)})),r((function(){t.cancel()})),a("timeout",(function(e){return(0,e.transitionTo)({type:"waitAndReconnect"},(function(){var e=new d.ErrorInfo("timeout");i.emit("nonFatalError",e)}))})),a("updateToken",(function(e){var t=e.event,n=e.dontTransition;return i._config.token=t.token,i._addPendingRequest(t.request),n()})),a("sendRequest",(function(e){var t=e.event,n=e.dontTransition;return i._addPendingRequest(t.request),n()})),a("initMessageReceived",(function(e){return(0,e.transitionTo)({type:"connected"})})),a("tooManyRequests",(function(e){var t=e.event;return(0,e.transitionTo)({type:"waitAndReconnect",waitTime:t.waitTime},(function(){var e=new d.ErrorInfo("tooManyRequests");i.emit("nonFatalError",e)}))})),a("messageReceived",(function(e){return o(e)})),a("disconnect",(function(e){return s(e)})),a("networkBecameUnreachable",(function(e){return c(e)})),a("nonFatalError",(function(e){return u(e)})),a("fatalError",(function(e){return l(e)}))})),n("connected",(function(e){var t=e.onEnter,n=e.onExit,r=e.on;t((function(){i._failedReconnectionAttempts=0,i._startWatchdogTimer(),i._sendAllPendingRequests(),i.emit("connected")})),n((function(){i._cancelWatchdogTimer()})),r("updateToken",(function(e){var t=e.event,n=e.dontTransition;return i._config.token=t.token,i._sendRequest(t.request),n()})),r("sendRequest",(function(e){var t=e.event,n=e.dontTransition;return i._sendRequest(t.request),n()})),r("tooManyRequests",(function(e){var t=e.event;return(0,e.transitionTo)({type:"throttling",waitTime:t.waitTime},(function(){var e=new d.ErrorInfo("tooManyRequests");i.emit("nonFatalError",e)}))})),r("messageReceived",(function(e){return o(e)})),r("disconnect",(function(e){return s(e)})),r("networkBecameUnreachable",(function(e){return c(e)})),r("nonFatalError",(function(e){return u(e)})),r("fatalError",(function(e){return l(e)}))})),n("waitAndReconnect",(function(e){var t=e.onEnter,n=e.onExit,r=e.on,a=null;t((function(e){var t,n=null!==(t=e.state.waitTime)&&void 0!==t?t:i._calculateDefaultWaitTime();q.debug("Started the reconnection timer for ".concat(n," ms"));var r=new d.ErrorInfo("transportDisconnected","Transport disconnected, started the reconnection timer...");i._failAllSentRequests(r),i._disconnectWebSocket(),i._connectivityMonitor.isNetworkAvailable&&(a=setTimeout((function(){i._onTimeout()}),n)),i._failedReconnectionAttempts++,i.emit("disconnected","Wait and reconnect")})),n((function(){null!==a&&(clearTimeout(a),a=null)})),r("timeout",(function(e){return(0,e.transitionTo)({type:"connecting"})})),r("connect",(function(e){return(0,e.transitionTo)({type:"connecting"})})),r("updateToken",(function(e){var t=e.event,n=e.dontTransition;i._config.token=t.token;var r=new d.ErrorInfo("tokenUpdatedLocally");return t.request.cancel(r),n()})),r("sendRequest",(function(e){var t=e.event,n=e.dontTransition;return i._addPendingRequest(t.request),n()})),r("networkBecameReachable",(function(e){var t=e.transitionTo;return i._failedReconnectionAttempts=0,t({type:"connecting"})})),r("networkBecameUnreachable",(function(e){var t=e.dontTransition;return null!==a&&(clearTimeout(a),a=null),t()})),r("disconnect",(function(e){return s(e)}))})),n("throttling",(function(e){var t,n=e.onEnter,r=e.onExit,a=e.on;n((function(e){var n=e.state;t=setTimeout((function(){i._onTimeout()}),n.waitTime)})),r((function(){clearTimeout(t)})),a("timeout",(function(e){return(0,e.transitionTo)({type:"connected"})})),a("updateToken",(function(e){var t=e.event,n=e.dontTransition;return i._config.token=t.token,i._addPendingRequest(t.request),n()})),a("sendRequest",(function(e){var t=e.event,n=e.dontTransition;return i._addPendingRequest(t.request),n()})),a("messageReceived",(function(e){return o(e)})),a("disconnect",(function(e){return s(e)})),a("networkBecameUnreachable",(function(e){return c(e)})),a("nonFatalError",(function(e){return u(e)})),a("fatalError",(function(e){return l(e)}))}))})),i._fsm.subscribe((function(e,t,n){null!==e&&null!==n?q.debug("FSM transition ".concat(n.type,": ").concat(e.type," -> ").concat(t.type)):q.debug("FSM initiated: ".concat(t.type))})),i._connectivityMonitor.on("changed",(function(e){q.debug('ConnectivityMonitor "changed" event: '.concat(e)),i._fsm.transition({type:e?"networkBecameReachable":"networkBecameUnreachable"})})),i}return I.default(n,[{key:"connect",value:function(){q.debug("Call to TwilsockClient.connect"),this._fsm.transition({type:"connect"})}},{key:"disconnect",value:function(){q.debug("Call to TwilsockClient.disconnect"),this._fsm.transition({type:"disconnect"})}},{key:"get",value:function(e){var t=e.url,n=e.headers,r=e.grant,i=e.typeCheck,a=new Pe(t,"GET",n,"",r);return this._sendHttpRequest(a,i)}},{key:"post",value:function(e){var t,n=e.url,r=e.headers,i=e.body,a=e.grant,o=e.typeCheck;i=null!==(t=i)&&void 0!==t?t:"";var s=new Pe(n,"POST",r,"string"==typeof i?i:JSON.stringify(i),a);return this._sendHttpRequest(s,o)}},{key:"put",value:function(e){var t,n=e.url,r=e.headers,i=e.body,a=e.grant,o=e.typeCheck;i=null!==(t=i)&&void 0!==t?t:"";var s=new Pe(n,"PUT",r,"string"==typeof i?i:JSON.stringify(i),a);return this._sendHttpRequest(s,o)}},{key:"delete",value:function(e){var t,n=e.url,r=e.headers,i=e.body,a=e.grant,o=e.typeCheck;i=null!==(t=i)&&void 0!==t?t:"";var s=new Pe(n,"DELETE",r,"string"==typeof i?i:JSON.stringify(i),a);return this._sendHttpRequest(s,o)}},{key:"updateToken",value:function(e){var t=this;return new d.CancellablePromise(function(){var n=T.default(L.default.mark((function n(r,i,a){var o;return L.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return q.debug("Call to TwilsockClient.updateToken:",e),o=t._createUpdateTokenRequest(e),t._fsm.transition({type:"updateToken",token:e,request:o}),a((function(){q.debug("Update token request has been cancelled by the user"),o.cancel()})),n.prev=4,n.next=7,o.promise;case 7:n.next=16;break;case 9:if(n.prev=9,n.t0=n.catch(4),!(n.t0 instanceof d.TwilioError&&"tokenUpdatedLocally"===n.t0.errorInfo.reason)){n.next=15;break}return q.debug("Token was updated locally"),r(),n.abrupt("return");case 15:i(n.t0);case 16:q.debug("Token was updated remotely"),r();case 18:case"end":return n.stop()}}),n,null,[[4,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"populateInitRegistrations",value:function(e){var t=E.default(e.values());q.debug("Call to TwilsockClient.populateInitRegistrations:",t.join(", ")),this._config.initRegistrations=[new oe(this._config.activeGrant,"ers",4,t)]}},{key:"_sendHttpRequest",value:function(e,t){var n=this;return new d.CancellablePromise(function(){var r=T.default(L.default.mark((function r(i,a,o){var s,u,c;return L.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return q.debug("Call to TwilsockClient.sendRequest:",JSON.stringify(e)),s=n._createUpstreamRequest(e),n._fsm.transition({type:"sendRequest",request:s}),o((function(){q.debug("Request ".concat(s.message.id," has been cancelled by the user")),s.cancel()})),r.prev=4,r.next=7,s.promise;case 7:u=r.sent,r.next=14;break;case 10:return r.prev=10,r.t0=r.catch(4),a(r.t0),r.abrupt("return");case 14:if(u instanceof pe){r.next=17;break}return a(new Error("Expected instance of ReplyMessage")),r.abrupt("return");case 17:if(!t){r.next=31;break}if(r.prev=18,c=JSON.parse(u.payload),t.Check(c)){r.next=23;break}return a(new Error("Payload doesn't match the provided schema")),r.abrupt("return");case 23:return i(new Ae(u.replyHeaders.httpStatus.code,u.replyHeaders.httpStatus.status,u.replyHeaders.httpHeaders,c)),r.abrupt("return");case 27:return r.prev=27,r.t1=r.catch(18),a(r.t1),r.abrupt("return");case 31:i(new Ae(u.replyHeaders.httpStatus.code,u.replyHeaders.httpStatus.status,u.replyHeaders.httpHeaders,u.payload));case 32:case"end":return r.stop()}}),r,null,[[4,10],[18,27]])})));return function(e,t,n){return r.apply(this,arguments)}}())}},{key:"_failAllPendingRequests",value:function(e){var t,n=je(this._pendingRequests.values());try{for(n.s();!(t=n.n()).done;){t.value.cancel(e)}}catch(e){n.e(e)}finally{n.f()}this._pendingRequests.clear()}},{key:"_failAllSentRequests",value:function(e){var t,n=je(this._sentRequests.values());try{for(n.s();!(t=n.n()).done;){t.value.cancel(e)}}catch(e){n.e(e)}finally{n.f()}this._sentRequests.clear()}},{key:"_sendAllPendingRequests",value:function(){var e,t=je(this._pendingRequests.values());try{for(t.s();!(e=t.n()).done;){var n=e.value;this._sendRequest(n)}}catch(e){t.e(e)}finally{t.f()}this._pendingRequests.clear()}},{key:"_addPendingRequest",value:function(e){this._pendingRequests.set(e.message.id,e)}},{key:"_calculateDefaultWaitTime",value:function(){var e=1e3*Math.pow(2,this._failedReconnectionAttempts)+Math.floor(1e3*Math.random())-1e3;return Math.min(e,45e3)}},{key:"_connectWebSocket",value:function(){var e=this;if(q.debug("Call to TwilsockClient._connectWebSocket"),null!==this._webSocket)throw new Error("Websocket already exists");this._webSocket=new G,this._webSocket.on("connected",(function(){q.debug('TwilsockTransport "connected" event'),e._fsm.transition({type:"transportConnected"})})),this._webSocket.on("disconnected",(function(t){e._fsm.transition({type:"nonFatalError",errorInfo:t})})),this._webSocket.on("messageReceived",(function(t){var n;e._restartWatchdogTimer();try{n=Message.parse(t)}catch(t){q.warn("Error while parsing an incoming message",t);var r=new d.ErrorInfo("cannotParse");return void e._fsm.transition({type:"fatalError",errorInfo:r})}e._fsm.transition({type:"messageReceived",message:n})})),this._webSocket.connect(this._config.url)}},{key:"_disconnectWebSocket",value:function(){var e;q.debug("Call to TwilsockClient._disconnectWebSocket"),null===(e=this._webSocket)||void 0===e||e.disconnect("TwilsockClient._disconnectWebSocket called"),this._webSocket=null}},{key:"_startWatchdogTimer",value:function(){var e=this;if(null!==this._watchdogTimer)throw new Error("The watchdog time is already running");this._watchdogTimer=setTimeout((function(){q.warn("Watchdog timeout"),e._fsm.transition({type:"nonFatalError",errorInfo:new d.ErrorInfo("timeout","Watchdog timeout")})}),43e3)}},{key:"_createInitRequest",value:function(e){var t=this,n=new he(["client_update"],this._config.token,this._config.continuationToken,this._config.initRegistrations,this._config.tweaks,this._config.clientMetadata),r=new Message("init",n);return new D(r,e,(function(e){t._onRequestFinished(e)}))}},{key:"_createUpdateTokenRequest",value:function(e){var t=this,n=new Message("update",{token:e});return new D(n,6e4,(function(e){t._onRequestFinished(e)}))}},{key:"_createUpstreamRequest",value:function(e){var t,n,r=this,i=new ge(null!==(t=e.grant)&&void 0!==t?t:this._config.activeGrant,me.from(e)),a=new Message("message",i,null!==(n=e.headers["Content-Type"])&&void 0!==n?n:"application/json",e.payload);return new D(a,e.timeout,(function(e){r._onRequestFinished(e)}))}},{key:"_onRequestFinished",value:function(e){this._pendingRequests.delete(e.message.id),this._sentRequests.delete(e.message.id)}},{key:"_onTimeout",value:function(){q.debug("Call to TwilsockClient._onTimeout"),this._fsm.transition({type:"timeout"})}},{key:"_cancelWatchdogTimer",value:function(){if(null===this._watchdogTimer)throw new Error("The watchdog time is not running");clearTimeout(this._watchdogTimer),this._watchdogTimer=null}},{key:"_restartWatchdogTimer",value:function(){null!==this._watchdogTimer&&(this._cancelWatchdogTimer(),this._startWatchdogTimer())}},{key:"_handleMessageReceived",value:function(e){var t=this,n=[e.id,e.headers,e.payloadType,e.payload];y.match(e.method).with("reply",(function(){t._handleReplyMessage(O.default(pe,n))})).with("close",(function(){t._handleCloseMessage(O.default(xe,n))})).with("client_update",(function(){t._handleClientUpdateMessage(O.default(Ee,n))})).with("notification",(function(){t._handleNotificationMessage(O.default(Ce,n))})).with("ping",(function(){t._sendMessageReply(e,Ue)})).otherwise((function(e){q.warn('Skipped a message with an unexpected method "'.concat(e,'"'))}))}},{key:"_handleReplyMessage",value:function(e){var t=this,n=this._sentRequests.get(e.id);if(n){var r=e.replyHeaders.status;if(r.code<200||r.code>=300){var i=y.match(r).with({errorCode:Fe},(function(){return De(r,"tokenExpired")})).with({code:401},(function(){return De(r,"unauthorized")})).with({code:429},(function(){return De(r,"tooManyRequests")})).otherwise((function(){return De(r,"unknown")}));return n.cancel(i),r.errorCode===Fe&&(q.warn("Received a token expired reply"),this.emit("tokenExpired")),void y.match(r.code).with(401,(function(){t._fsm.transition({type:"fatalError",errorInfo:i})})).with(429,(function(){var n=e.replyPayload.backoffPolicy,r=n.reconnectMinMs,i=n.reconnectMaxMs,a=Math.floor(Math.random()*(i-r)+r);t._fsm.transition({type:"tooManyRequests",waitTime:a})})).otherwise((function(){t._fsm.transition({type:"nonFatalError",errorInfo:i})}))}var a=e.replyHeaders.continuationToken;void 0!==a&&(this._config.continuationToken=a),n.complete(e)}else q.warn("Skipped a reply to an unknown request: ".concat(e.id))}},{key:"_handleCloseMessage",value:function(e){var t=this;q.debug("Server has initiated the process of closing the connection: ".concat(e.payload)),this._sendMessageReply(e,Ue);var n=De(e.status,"closeMessageReceived");if(308===e.status.code&&51232===e.status.errorCode)return q.debug("Token with a different instanceSid"),void this._fsm.transition({type:"fatalError",errorInfo:n});var r=e.status.code;y.match(r).with(308,(function(){q.debug("Offloading to another instance"),t._fsm.transition({type:"nonFatalError",errorInfo:n})})).with(401,406,410,417,(function(){q.debug("Server closed connection due to a fatal error: ".concat(n));var r=y.match(e.status).with({code:410},{errorCode:Fe},(function(){return De(e.status,"tokenExpired")})).with({code:401},(function(){return De(e.status,"unauthorized")})).otherwise((function(){return n}));t._fsm.transition({type:"fatalError",errorInfo:r})})).otherwise((function(){q.warn("Unexpected close message ".concat(n)),t._fsm.transition({type:"nonFatalError",errorInfo:n})}))}},{key:"_handleClientUpdateMessage",value:function(e){this._sendMessageReply(e,Ue),"token_about_to_expire"!==e.clientUpdateType?q.warn("Ignoring an unknown client update ".concat(e.clientUpdateType)):this.emit("tokenAboutToExpire")}},{key:"_handleNotificationMessage",value:function(e){if(""===e.payload)return q.warn("Skipped a notification message with no payload: ".concat(e.id)),void this._sendMessageReply(e,Ne,"Notification message must carry data");this._sendMessageReply(e,Ue),""!==e.messageType?this.emit("targetedMessageReceived",e.messageType,e.payload):this.emit("messageReceived",e.payload)}},{key:"_sendMessageReply",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(null!==this._webSocket){var r=new Message("reply",{status:t},""!==n?"text/plain":"",n,e.id);this._webSocket.sendMessage(r.encode())}}},{key:"_sendRequest",value:function(e){if(null===this._webSocket)throw new Error("WebSocket not initialized");this._webSocket.sendMessage(e.message.encode()),this._sentRequests.set(e.message.id,e)}}]),n}(p.ReplayEventEmitter);Object.defineProperty(e,"CancellablePromise",{enumerable:!0,get:function(){return d.CancellablePromise}}),Object.defineProperty(e,"CancellationError",{enumerable:!0,get:function(){return d.CancellationError}}),Object.defineProperty(e,"ErrorInfo",{enumerable:!0,get:function(){return d.ErrorInfo}}),e.InitRegistration=oe,e.TwilsockClient=qe}(US);var YA={},JA=f,QA=$e,XA=ee,ZA=$m,ej=RegExp.prototype,tj=on.PROPER,nj=Xn,rj=Ft,ij=za,aj=o,oj=function(e){var t=e.flags;return void 0!==t||"flags"in ej||QA(e,"flags")||!XA(ej,e)?t:JA(ZA,e)},sj="toString",uj=RegExp.prototype.toString,cj=aj((function(){return"/a/b"!=uj.call({source:"a",flags:"b"})})),lj=tj&&uj.name!=sj;(cj||lj)&&nj(RegExp.prototype,sj,(function(){var e=rj(this);return"/"+ij(e.source)+"/"+ij(oj(e))}),{unsafe:!0});var fj=xI;ni({target:"Object",stat:!0,arity:2,forced:Object.assign!==fj},{assign:fj}),j_("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),J_),function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=DS.exports,n=$w.exports,r=Ww.exports,i=Vw.exports,a=Kw.exports,o=Gw.exports,s=Yw.exports,u=sx.exports,c=qS,l=Sw.exports,f=US,d=Q_,p=jw.exports,h=Dw.exports,v=sy.exports,y=VS,m=Mb;function g(e){return e&&"object"===Xu(e)&&"default"in e?e:{default:e}}function b(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var w=g(t),k=g(n),x=g(r),_=g(i),S=g(a),O=g(o),E=g(s),T=g(u),R=g(c),I=g(l),C=g(p),P=g(h),A=b(v);function j(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":I.default(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function M(e,t){if("object"===("undefined"==typeof Reflect?"undefined":I.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function L(){}function U(){U.init.call(this)}function N(e){return void 0===e._maxListeners?U.defaultMaxListeners:e._maxListeners}function F(e,t,n){if(t)e.call(n);else for(var r=e.length,i=H(e,r),a=0;a<r;++a)i[a].call(n)}function D(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=H(e,i),o=0;o<i;++o)a[o].call(n,r)}function q(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=H(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function B(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=H(e,o),u=0;u<o;++u)s[u].call(n,r,i,a)}function z(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=H(e,i),o=0;o<i;++o)a[o].apply(n,r)}function W(e,t,n,r){var i,a,o;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new L,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=N(e))&&i>0&&o.length>i){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=o.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(s)}}else o=a[t]=n,++e._eventsCount;return e}function $(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function K(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function H(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}L.prototype=Object.create(null),U.EventEmitter=U,U.usingDomains=!1,U.prototype.domain=void 0,U.prototype._events=void 0,U.prototype._maxListeners=void 0,U.defaultMaxListeners=10,U.init=function(){this.domain=null,U.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new L,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},U.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},U.prototype.getMaxListeners=function(){return N(this)},U.prototype.emit=function(e){var t,n,r,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:F(n,l,this);break;case 2:D(n,l,this,arguments[1]);break;case 3:q(n,l,this,arguments[1],arguments[2]);break;case 4:B(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];z(n,l,this,i)}return!0},U.prototype.addListener=function(e,t){return W(this,e,t,!1)},U.prototype.on=U.prototype.addListener,U.prototype.prependListener=function(e,t){return W(this,e,t,!0)},U.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,$(this,e,t)),this},U.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,$(this,e,t)),this},U.prototype.removeListener=function(e,t){var n,r,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new L:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new L,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},U.prototype.off=function(e,t){return this.removeListener(e,t)},U.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new L,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new L:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),a=0;a<i.length;++a)"removeListener"!==(r=i[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new L,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},U.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},U.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):K.call(e,t)},U.prototype.listenerCount=K,U.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var G=A.getLogger("twilio-notificatiions");function V(e,t){return["".concat((new Date).toISOString()," Twilio.Notifications ").concat(e,":")].concat(Array.from(t))}var Y=function(){function e(){k.default(this,e)}return x.default(e,[{key:"setLevel",value:function(e){G.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];G.trace.apply(null,V("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];G.debug.apply(null,V("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];G.info.apply(null,V("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];G.warn.apply(null,V("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];G.error.apply(null,V("E",t))}}]),e}(),J=new Y;function Q(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return O.default(this,n)}}var X=x.default((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;k.default(this,e),T.default(this,"token",void 0),T.default(this,"notificationId",void 0),T.default(this,"messageTypes",void 0),this.token=t,this.notificationId=n,this.messageTypes=r}));function Z(e,t){var n=new Set;return e.notificationId!==t.notificationId&&n.add("notificationId"),e.token!==t.token&&n.add("token"),function(e,t){return[].concat(P.default(P.default(e).filter((function(e){return!t.has(e)}))),P.default(P.default(t).filter((function(t){return!e.has(t)}))))}(e.messageTypes,t.messageTypes).length>0&&n.add("messageType"),[n.size>0,n]}var ee=function(e){S.default(r,e);var t,n=Q(r);function r(e){var t;return k.default(this,r),t=n.call(this),T.default(_.default(t),"channelType",void 0),T.default(_.default(t),"desiredState",new X),T.default(_.default(t),"currentState",new X),T.default(_.default(t),"_hasActiveAttempt",!1),t.channelType=e,t}return x.default(r,[{key:"setNotificationId",value:function(e){this.desiredState.notificationId=e}},{key:"isActive",value:function(){return""!==this.desiredState.notificationId}},{key:"subscribe",value:function(e){this.desiredState.messageTypes.has(e)?J.debug("message type '".concat(e,"' for channel ").concat(this.channelType," is already registered")):this.desiredState.messageTypes.add(e)}},{key:"unsubscribe",value:function(e){this.desiredState.messageTypes.has(e)&&this.desiredState.messageTypes.delete(e)}},{key:"updateToken",value:function(e){this.desiredState.token=e}},{key:"commitChanges",value:(t=w.default(R.default.mark((function e(){var t,n,r,i,a,o;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._hasActiveAttempt){e.next=3;break}throw J.error("One registration attempt is already in progress"),new Error("One registration attempt is already in progress");case 3:if(t=Z(this.desiredState,this.currentState),n=C.default(t,2),r=n[0],i=n[1],r){e.next=6;break}return e.abrupt("return");case 6:if(this.currentState.notificationId||i.delete("notificationId"),J.trace("Persisting ".concat(this.channelType," registration"),i,this.desiredState),e.prev=8,this._hasActiveAttempt=!0,(a=new X).token=this.desiredState.token,a.notificationId=this.desiredState.notificationId,a.messageTypes=new Set(this.desiredState.messageTypes),!(a.messageTypes.size>0)){e.next=24;break}return e.next=17,this.updateRegistration(a,i);case 17:o=e.sent,this.currentState.token=o.token,this.currentState.notificationId=o.notificationId,this.currentState.messageTypes=new Set(o.messageTypes),this.emit("stateChanged",this.channelType,"registered",this.currentState),e.next=30;break;case 24:return e.next=26,this.removeRegistration();case 26:this.currentState.token=a.token,this.currentState.notificationId=a.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged",this.channelType,"unregistered",this.currentState);case 30:e.next=35;break;case 32:throw e.prev=32,e.t0=e.catch(8),e.t0;case 35:return e.prev=35,this._hasActiveAttempt=!1,e.finish(35);case 38:case"end":return e.stop()}}),e,this,[[8,32,35,38]])}))),function(){return t.apply(this,arguments)})}]),r}(U);function te(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return O.default(this,n)}}var ne={min:2e3,max:12e4,randomness:.2},re=function(e){S.default(a,e);var t,n,r,i=te(a);function a(e,t,n,r){var o;return k.default(this,a),o=i.call(this,e),T.default(_.default(o),"context",void 0),T.default(_.default(o),"twilsock",void 0),T.default(_.default(o),"registrarUrl",void 0),T.default(_.default(o),"registrationId",null),o.context=t,o.twilsock=n,o.registrarUrl=r,o}return x.default(a,[{key:"updateRegistration",value:(r=w.default(R.default.mark((function e(t,n){var r,i,a,o,s,u=this;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.has("notificationId")){e.next=3;break}return e.next=3,this.removeRegistration();case 3:if(t.notificationId&&t.notificationId.length){e.next=6;break}throw J.error("No push notification ID for registration"),new Error("No push notification ID for registration");case 6:return J.trace("Registering",this.channelType,t),r={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:Array.from(t.messageTypes),data:{registration_id:t.notificationId}},i=this.context.productId,a="".concat(this.registrarUrl,"?productId=").concat(i),o={"Content-Type":"application/json"},J.trace("Creating registration for channel ".concat(this.channelType)),e.prev=12,e.t0=JSON,e.next=16,new d.AsyncRetrier(ne).run((function(){return u.twilsock.post({url:a,headers:o,body:r,grant:i})}));case 16:e.t1=e.sent.payload,s=e.t0.parse.call(e.t0,e.t1),this.registrationId=s.id,J.debug("Registration created: ",s),e.next=26;break;case 22:throw e.prev=22,e.t2=e.catch(12),J.error("Registration failed: ",e.t2),e.t2;case 26:return e.abrupt("return",t);case 27:case"end":return e.stop()}}),e,this,[[12,22]])}))),function(e,t){return r.apply(this,arguments)})},{key:"removeRegistration",value:(n=w.default(R.default.mark((function e(){var t,n,r,i=this;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.registrationId){e.next=2;break}return e.abrupt("return");case 2:return t=this.context.productId,n="".concat(this.registrarUrl,"/").concat(this.registrationId,"?productId=").concat(t),r={"Content-Type":"application/json"},J.trace("Removing registration for ".concat(this.channelType)),e.prev=6,e.next=9,new d.AsyncRetrier(Object.assign(ne,{maxAttemptsCount:3})).run((function(){return i.twilsock.delete({url:n,headers:r,grant:t})}));case 9:this.registrationId=null,this.currentState.notificationId="",J.debug("Registration removed for ".concat(this.channelType)),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(6),J.error("Failed to remove registration ",this.channelType,e.t0),e.t0;case 18:case"end":return e.stop()}}),e,this,[[6,14]])}))),function(){return n.apply(this,arguments)})},{key:"sendDeviceRemoveRequest",value:(t=w.default(R.default.mark((function e(t){var n,r,i,a,o=this;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(""!==t){e.next=2;break}throw new Error("Empty registration ID");case 2:return n=this.context.productId,r="".concat(this.registrarUrl,"?productId=").concat(n),i={"Content-Type":"application/json"},a={binding_type:this.channelType,address:t},e.prev=6,J.trace("Removing old registrations for ".concat(this.channelType)),e.next=10,new d.AsyncRetrier(Object.assign(ne,{maxAttemptsCount:3})).run((function(){return o.twilsock.delete({url:r,headers:i,body:a,grant:n})}));case 10:this.registrationId=null,this.currentState.notificationId="",J.debug("Registration removed for ".concat(this.channelType)),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(6),J.error("Failed to remove registration ",this.channelType,e.t0),e.t0;case 19:case"end":return e.stop()}}),e,this,[[6,15]])}))),function(e){return t.apply(this,arguments)})}]),a}(ee);function ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return O.default(this,n)}}var ae,oe=function(e){S.default(a,e);var t,n,r,i=ie(a);function a(e,t,n){var r;return k.default(this,a),r=i.call(this,"twilsock"),T.default(_.default(r),"productId",void 0),T.default(_.default(r),"platform",void 0),T.default(_.default(r),"twilsock",void 0),T.default(_.default(r),"contextId",y.nanoid()),r.productId=e,r.platform=t,r.twilsock=n,r}return x.default(a,[{key:"updateRegistration",value:(r=w.default(R.default.mark((function e(t,n){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.has("messageType")){e.next=2;break}return e.abrupt("return",t);case 2:Array.from(t.messageTypes),this.productId,this.platform,e.prev=4,e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(4),J.error("Failed to update twilsock notification context: ".concat(e.t0)),e.t0;case 11:return e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this,[[4,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"removeRegistration",value:(n=w.default(R.default.mark((function e(){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,e.next=7;break;case 3:throw e.prev=3,e.t0=e.catch(0),J.error("Failed to remove twilsock notification context: ".concat(e.t0)),e.t0;case 7:case"end":return e.stop()}}),e,null,[[0,3]])}))),function(){return n.apply(this,arguments)})},{key:"sendDeviceRemoveRequest",value:(t=w.default(R.default.mark((function e(t){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),a}(ee);function se(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return O.default(this,n)}}var ue=m.literal("apn","fcm","twilsock");e.Notifications=ae=function(e){S.default(Client,e);var t,n,r,i=se(Client);function Client(e){var t,n,r,a,o,s,u,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};k.default(this,Client),u=i.call(this),T.default(_.default(u),"twilsock",void 0),T.default(_.default(u),"connectors",void 0),c.logLevel=null!==(t=c.logLevel)&&void 0!==t?t:"error",J.setLevel(c.logLevel);var l=null!==(n=c.productId)&&void 0!==n?n:"notifications",d=!c.twilsockClient,p=c.twilsockClient=null!==(r=c.twilsockClient)&&void 0!==r?r:new f.TwilsockClient(e,l,c),h=null!==(a=c.notifications)&&void 0!==a?a:{},v=null!==(o=null!==(s=h.region)&&void 0!==s?s:c.region)&&void 0!==o?o:"us1",y="https://ers.".concat(v,".twilio.com/v1/registrations"),m=h.ersUrl||y;u.connectors=new Map;var g=ae._detectPlatform();return u.connectors.set("apn",new re("apn",{protocolVersion:4,productId:l,platform:g},p,m)),u.connectors.set("fcm",new re("fcm",{protocolVersion:3,productId:l,platform:g},p,m)),u.connectors.set("twilsock",new oe(l,g,p)),p.on("connecting",(function(){return u.emit("transportState","connecting")})),p.on("connected",(function(){return u.emit("transportState","connected")})),p.on("disconnected",(function(){return u.emit("transportState","disconnected")})),u._connector("twilsock").on("stateChanged",(function(e,t,n){return u.emit("stateChanged",e,t,n)})),u._connector("apn").on("stateChanged",(function(e,t,n){return u.emit("stateChanged",e,t,n)})),u._connector("fcm").on("stateChanged",(function(e,t,n){return u.emit("stateChanged",e,t,n)})),p.on("targetedMessageReceived",(function(e,t){return u._routeMessage(e,t)})),u.updateToken(e),d&&(p.connect(),u.twilsock=p),u}return x.default(Client,[{key:"shutdown",value:(r=w.default(R.default.mark((function e(){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectors.clear(),!this.twilsock){e.next=4;break}return e.next=4,this.twilsock.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"setPushRegistrationId",value:function(e,t){J.debug("Set ".concat(e," push registration id '").concat(t,"'")),this._connector(e).setNotificationId(t)}},{key:"subscribe",value:function(e,t){J.debug("Add ".concat(e," subscriptions for message type ").concat(t)),this._connector(e).subscribe(t)}},{key:"unsubscribe",value:function(e,t){J.debug("Remove ".concat(e," subscriptions for message type ").concat(t)),this._connector(e).unsubscribe(t)}},{key:"updateToken",value:function(e){this.connectors.forEach((function(t){return t.updateToken(e)}))}},{key:"commitChanges",value:(n=w.default(R.default.mark((function e(){var t;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],this.connectors.forEach((function(e){e.isActive()&&t.push(e.commitChanges())})),e.next=4,Promise.all(t);case 4:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"removeRegistrations",value:(t=w.default(R.default.mark((function e(t,n){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._connector(t).sendDeviceRemoveRequest(n);case 2:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"handlePushNotification",value:function(e){return{messageType:e.twi_message_type,payload:e.payload}}},{key:"_routeMessage",value:function(e,t){J.debug("Notification message arrived: ",e,t),this.emit("message",e,t)}},{key:"_connector",value:function(e){var t=this.connectors.get(e);if(!t)throw new Error("Unknown channel type: ".concat(e));return t}}],[{key:"_detectPlatform",value:function(){var e="";return"undefined"!=typeof navigator?(e="unknown",void 0!==navigator.product&&(e=navigator.product),void 0!==navigator.userAgent&&(e=navigator.userAgent)):e="web",e.substring(0,128)}}]),Client}(U),j([m.validateTypes(ue,m.nonEmptyString),M("design:type",Function),M("design:paramtypes",[String,String]),M("design:returntype",void 0)],e.Notifications.prototype,"setPushRegistrationId",null),j([m.validateTypes(ue,m.nonEmptyString),M("design:type",Function),M("design:paramtypes",[String,String]),M("design:returntype",void 0)],e.Notifications.prototype,"subscribe",null),j([m.validateTypes(ue,m.nonEmptyString),M("design:type",Function),M("design:paramtypes",[String,String]),M("design:returntype",void 0)],e.Notifications.prototype,"unsubscribe",null),j([m.validateTypes(m.nonEmptyString),M("design:type",Function),M("design:paramtypes",[String]),M("design:returntype",void 0)],e.Notifications.prototype,"updateToken",null),j([m.validateTypesAsync(ue,m.nonEmptyString),M("design:type",Function),M("design:paramtypes",[String,String]),M("design:returntype",Promise)],e.Notifications.prototype,"removeRegistrations",null),e.Notifications=ae=j([m.validateConstructorTypes(m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),M("design:paramtypes",[String,Object])],e.Notifications)}(YA);var dj={},pj=f,hj=Ft,vj=U,yj=fr,mj=za,gj=D,bj=Ee,wj=Mg,kj=Yg;Ag("match",(function(e,t,n){return[function(t){var n=gj(this),r=vj(t)?void 0:bj(t,e);return r?pj(r,t,n):new RegExp(t)[e](mj(n))},function(e){var r=hj(this),i=mj(e),a=n(t,r,i);if(a.done)return a.value;if(!r.global)return kj(r,i);var o=r.unicode;r.lastIndex=0;for(var s,u=[],c=0;null!==(s=kj(r,i));){var l=mj(s[0]);u[c]=l,""===l&&(r.lastIndex=wj(i,yj(r.lastIndex),o)),c++}return 0===c?null:u}]}));var xj={exports:{}},_j="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(_j){var Sj=new Uint8Array(16);xj.exports=function(){return _j(Sj),Sj}}else{var Oj=new Array(16);xj.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),Oj[t]=e>>>((3&t)<<3)&255;return Oj}}for(var Ej=[],Tj=0;Tj<256;++Tj)Ej[Tj]=(Tj+256).toString(16).substr(1);var Rj,Ij,Cj=function(e,t){var n=t||0,r=Ej;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")},Pj=xj.exports,Aj=Cj,jj=0,Mj=0;var Lj=function(e,t,n){var r=t&&n||0,i=t||[],a=(e=e||{}).node||Rj,o=void 0!==e.clockseq?e.clockseq:Ij;if(null==a||null==o){var s=Pj();null==a&&(a=Rj=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==o&&(o=Ij=16383&(s[6]<<8|s[7]))}var u=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:Mj+1,l=u-jj+(c-Mj)/1e4;if(l<0&&void 0===e.clockseq&&(o=o+1&16383),(l<0||u>jj)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");jj=u,Mj=c,Ij=o;var f=(1e4*(268435455&(u+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var d=u/4294967296*1e4&268435455;i[r++]=d>>>8&255,i[r++]=255&d,i[r++]=d>>>24&15|16,i[r++]=d>>>16&255,i[r++]=o>>>8|128,i[r++]=255&o;for(var p=0;p<6;++p)i[r+p]=a[p];return t||Aj(i)},Uj=xj.exports,Nj=Cj;var Fj=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||Uj)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var a=0;a<16;++a)t[r+a]=i[a];return t||Nj(i)},Dj=Lj,qj=Fj,Bj=qj;Bj.v1=Dj,Bj.v4=qj;var zj=Bj;Object.defineProperty(dj,"__esModule",{value:!0});var Wj=DS.exports,$j=$w.exports,Kj=Ww.exports,Hj=Vw.exports,Gj=Kw.exports,Vj=Gw.exports,Yj=Yw.exports,Jj=sx.exports,Qj=qS,Xj=Sw.exports,Zj=Mb,eM=US,tM=zS.exports,nM=sy.exports,rM=jw.exports,iM=Q_,aM=zj,oM=ax.exports,sM=ix,uM=ZE.exports;function cM(e){return e&&"object"===Xu(e)&&"default"in e?e:{default:e}}function lM(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var fM=cM(Wj),dM=cM($j),pM=cM(Kj),hM=cM(Hj),vM=cM(Gj),yM=cM(Vj),mM=cM(Yj),gM=cM(Jj),bM=cM(Qj),wM=cM(Xj),kM=cM(tM),xM=lM(nM),_M=cM(rM),SM=lM(aM),OM=cM(oM),EM=lM(uM);function TM(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":wM.default(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function RM(e,t){if("object"===("undefined"==typeof Reflect?"undefined":wM.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var IM=function(){function e(t){dM.default(this,e),this.base=t,this.args=new Array,this.paths=new Array}return pM.default(e,[{key:"pathSegment",value:function(e){return this.paths.push(encodeURIComponent(e)),this}},{key:"queryParam",value:function(e,t){return void 0!==t&&this.args.push(encodeURIComponent(e)+"="+encodeURIComponent(t)),this}},{key:"build",value:function(){var e=this.base;return this.paths.length&&(e+="/"+this.paths.join("/")),this.args.length&&(e+="?"+this.args.join("&")),e}}]),e}();function CM(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mM.default(e);if(t){var i=mM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return yM.default(this,n)}}var SyncError=function(e){vM.default(SyncError,e);var t=CM(SyncError);function SyncError(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return dM.default(this,SyncError),(n=t.call(this)).name=n.constructor.name,n.message="".concat(e," (status: ").concat(r,", code: ").concat(i,")"),n.status=r,n.code=i,n}return pM.default(SyncError)}(kM.default(Error)),PM=function(e){vM.default(n,e);var t=CM(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3?arguments[3]:void 0;return dM.default(this,n),(r=t.call(this,e,i,a)).body=o,r}return pM.default(n)}(SyncError);function AM(e){return JSON.parse(JSON.stringify(e))}function jM(e){if(!(void 0===e||MM(e)))throw new SyncError("Invalid pageSize parameter. Expected a positive integer, was '".concat(e,"'."),400,20007)}function MM(e){return function(e){return!isNaN(parseInt(e))&&isFinite(e)}(e)&&e>0}var LM=xM.getLogger("twilio-sync");function UM(e,t){return["".concat((new Date).toISOString()," Sync ").concat(e,":")].concat(Array.from(t))}var NM=function(e){LM.setLevel(e)},FM=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];LM.trace.apply(null,UM("T",t))},DM=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];LM.debug.apply(null,UM("D",t))},qM=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];LM.warn.apply(null,UM("W",t))},BM=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];LM.error.apply(null,UM("E",t))},zM="/v4/Subscriptions",WM="/v3/Maps",$M="/v3/Lists",KM="/v3/Documents",HM="/v3/Streams",GM="/v3/Insights";function VM(e,t,n){return e&&void 0!==e[t]?e[t]:n}var YM=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};dM.default(this,e);var n=t.region||"us1",r="https://cds.".concat(n,".twilio.com"),i=t.cdsUri||r;this.settings={subscriptionsUri:i+zM,documentsUri:i+KM,listsUri:i+$M,mapsUri:i+WM,streamsUri:i+HM,insightsUri:i+GM,sessionStorageEnabled:VM(t.Sync,"enableSessionStorage",!0),productId:t.productId}}return pM.default(e,[{key:"subscriptionsUri",get:function(){return this.settings.subscriptionsUri}},{key:"documentsUri",get:function(){return this.settings.documentsUri}},{key:"listsUri",get:function(){return this.settings.listsUri}},{key:"mapsUri",get:function(){return this.settings.mapsUri}},{key:"streamsUri",get:function(){return this.settings.streamsUri}},{key:"insightsUri",get:function(){return this.settings.insightsUri}},{key:"backoffConfig",get:function(){return this.settings.backoffConfig||{}}},{key:"sessionStorageEnabled",get:function(){return this.settings.sessionStorageEnabled}},{key:"productId",get:function(){return this.settings.productId}}]),e}();function JM(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return QM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return QM(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function QM(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var XM=function(){function e(t){dM.default(this,e),this.localObject=t,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return pM.default(e,[{key:"sid",get:function(){return this.localObject.sid}},{key:"type",get:function(){return this.localObject.type}},{key:"lastEventId",get:function(){return this.localObject.lastEventId}},{key:"indexName",get:function(){return this.localObject.indexName}},{key:"queryString",get:function(){return this.localObject.queryString}},{key:"isEstablished",get:function(){return this.established}},{key:"update",value:function(e,t){this.localObject._update(e,t)}},{key:"updatePending",value:function(e,t){this.pendingAction=e,this.pendingCorrelationId=t}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(e){this.rejectedWithError=e.error,this.updatePending(null,null),this.localObject.reportFailure(new SyncError("Failed to subscribe on service events: ".concat(e.error.message),e.error.status,e.error.code))}},{key:"complete",value:function(e){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(e)}},{key:"setSubscriptionState",value:function(e){this.localObject._setSubscriptionState(e)}}]),e}(),ZM=function(){function e(t){var n=this;dM.default(this,e),gM.default(this,"isConnected",!1),gM.default(this,"maxBatchSize",100),gM.default(this,"subscriptionTtlTimer",null),gM.default(this,"pendingPokeReason",null),this.services=t,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;this.backoff=iM.Backoff.exponential(Object.assign({randomisationFactor:.2,initialDelay:100,maxDelay:12e4},this.services.config.backoffConfig)),this.backoff.on("ready",(function(){var e=n.getSubscriptionUpdateBatch(),t=e.action,r=e.subscriptions;t?n.applyNewSubscriptionUpdateBatch(t,r):(n.backoff.reset(),DM("All subscriptions resolved."))}))}var t;return pM.default(e,[{key:"getSubscriptionUpdateBatch",value:function(){function e(e,t,n,r){var i,a=[],o=JM(e);try{for(o.s();!(i=o.n()).done;){var s=_M.default(i.value,2),u=s[0],c=s[1];if(!t.get(u)&&n!==c.pendingAction&&!c.rejectedWithError&&(a.push(c),r&&a.length>=r))break}}catch(e){o.e(e)}finally{o.f()}return a}var t=e(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(t.length>0)return{action:"establish",subscriptions:t};var n=e(this.persisted,this.subscriptions,"cancel",this.maxBatchSize);return n.length>0?{action:"cancel",subscriptions:n}:{action:null,subscriptions:null}}},{key:"persist",value:function(){this.backoff.backoff()}},{key:"applyNewSubscriptionUpdateBatch",value:(t=fM.default(bM.default.mark((function e(t,n){var r,i,a,o,s,u,c,l,f,d,p,h,v=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isConnected){e.next=4;break}return DM("Twilsock connection (required for subscription) not ready; waiting…"),this.backoff.reset(),e.abrupt("return");case 4:n=this.processLocalActions(t,n),r=(new Date).getTime(),i=JM(n);try{for(i.s();!(a=i.n()).done;)o=a.value,this.recordActionAttemptOn(o,t,r)}catch(e){i.e(e)}finally{i.f()}return s=this.pendingPokeReason,this.pendingPokeReason=null,e.prev=10,e.next=13,this.request(t,r,s,n);case 13:u=e.sent,c=u.body.max_batch_size,!isNaN(parseInt(c))&&isFinite(c)&&c>0&&(this.maxBatchSize=c),this.subscriptionTtlTimer||(l=u.body.ttl_in_s,!isNaN(parseFloat(l))&&isFinite(l)&&l>0&&(this.subscriptionTtlTimer=setTimeout((function(){return v.onSubscriptionTtlElapsed()}),1e3*l))),"establish"===t&&(f=u.body.estimated_delivery_in_ms,!isNaN(parseFloat(f))&&isFinite(f)&&f>0?setTimeout((function(){return v.verifyPokeDelivery(r,f,n)}),f):BM("Invalid timeout: ".concat(f)),n.filter((function(e){return e.pendingCorrelationId===r})).forEach((function(e){return e.setSubscriptionState("response_in_flight")}))),this.backoff.reset(),e.next=26;break;case 21:e.prev=21,e.t0=e.catch(10),d=JM(n);try{for(d.s();!(p=d.n()).done;)h=p.value,this.recordActionFailureOn(h,t)}catch(e){d.e(e)}finally{d.f()}e.t0 instanceof eM.TransportUnavailableError?(DM("Twilsock connection (required for subscription) not ready (c:".concat(r,"); waiting…")),this.backoff.reset()):(DM("Failed an attempt to ".concat(t," subscriptions (c:").concat(r,"); retrying"),e.t0),this.persist());case 26:case"end":return e.stop()}}),e,this,[[10,21]])}))),function(e,n){return t.apply(this,arguments)})},{key:"verifyPokeDelivery",value:function(e,t,n){var r=this,i=this.latestPokeResponseArrivalTimestampByCorrelationId.get(e),a=i?(new Date).getTime()-i:t;a>=t?(n.filter((function(t){return t.pendingCorrelationId===e})).forEach((function(e){e.updatePending(null,null),e.retryCount++,r.persisted.delete(e.sid)})),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(e)):setTimeout((function(){return r.verifyPokeDelivery(e,t,n)}),t-a)}},{key:"processLocalActions",value:function(e,t){return"cancel"===e?t.filter((function(e){return!e.rejectedWithError})):t}},{key:"recordActionAttemptOn",value:function(e,t,n){if(e.setSubscriptionState("request_in_flight"),"establish"===t)this.persisted.set(e.sid,e),e.updatePending(t,n);else{var r=this.persisted.get(e.sid);r&&r.updatePending(t,n)}}},{key:"recordActionFailureOn",value:function(e,t){e.setSubscriptionState("none"),e.updatePending(null,null),"establish"===t&&this.persisted.delete(e.sid)}},{key:"request",value:function(e,t,n,r){var i=r.map((function(t){return{object_sid:t.sid,object_type:t.type,last_event_id:"establish"===e?t.lastEventId:void 0,index_name:"establish"===e?t.indexName:void 0,query_string:"establish"===e?t.queryString:void 0}})),a=r.filter((function(e){return e.retryCount>0})).length;DM("Attempting '".concat(e,"' request (c:").concat(t,"):"),i);var o={event_protocol_version:4,action:e,correlation_id:t,retried_requests:a,ttl_in_s:-1,requests:i};return"ttl"===n&&(o.reason=n),this.services.network.post(this.services.config.subscriptionsUri,o)}},{key:"add",value:function(e,t){DM("Establishing intent to subscribe to ".concat(e));var n=this.subscriptions.get(e);n&&t&&n.lastEventId===t.lastEventId||(this.persisted.delete(e),this.subscriptions.set(e,new XM(t)),this.persist())}},{key:"remove",value:function(e){DM("Establishing intent to unsubscribe from ".concat(e)),this.subscriptions.delete(e)&&this.persist()}},{key:"acceptMessage",value:function(e,t){FM("Subscriptions received",e);var n=e.event_type,r=void 0!==e.events?e.events:[e.event],i=e.correlation_id;i&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(i,(new Date).getTime());var a,o=JM(r);try{for(o.s();!(a=o.n()).done;){var s=a.value,u=void 0;switch(e.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(s,i);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(s,i);break;case"subscription_failed":this.applySubscriptionFailedMessage(s,i);break;case(u=n.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:var c=void 0;switch(u[0]){case"map_":c=s.map_sid;break;case"list_":c=s.list_sid;break;case"document_":c=s.document_sid;break;case"stream_":c=s.stream_sid;break;case"live_query_":c=s.query_id,t=!1,!0===e.strictly_ordered&&(t=!0);break;default:c=void 0}this.applyEventToSubscribedEntity(c,s,n,t);break;default:DM("Dropping unknown message type ".concat(n))}}}catch(e){o.e(e)}finally{o.f()}}},{key:"applySubscriptionEstablishedMessage",value:function(e,t){var n=e.object_sid,r=this.persisted.get(e.object_sid);r&&r.pendingCorrelationId===t?"interrupted"===e.replay_status?(DM("Event Replay for subscription to ".concat(n," (c:").concat(t,") interrupted; continuing eagerly.")),r.updatePending(null,null),this.persisted.delete(r.sid),this.backoff.reset()):"completed"===e.replay_status&&(DM("Event Replay for subscription to ".concat(n," (c:").concat(t,") completed. Subscription is ready.")),r.complete(e.last_event_id),this.persisted.set(e.object_sid,r),r.setSubscriptionState("established"),this.backoff.reset()):DM("Late message for ".concat(e.object_sid," (c:").concat(t,") dropped.")),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(e,t){var n=this.persisted.get(e.object_sid);n&&n.pendingCorrelationId===t?(n.updatePending(null,null),n.setSubscriptionState("none"),this.persisted.delete(e.object_sid)):DM("Late message for ".concat(e.object_sid," (c:").concat(t,") dropped.")),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(e,t){var n=e.object_sid,r=this.subscriptions.get(n),i=this.persisted.get(n);r&&i?i.pendingCorrelationId===t&&(BM("Failed to subscribe on ".concat(i.sid),e.error),i.markAsFailed(e),i.setSubscriptionState("none")):!r&&i&&(this.persisted.delete(n),i.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(e,t,n,r){if(e){var i;r=r||(i=this.persisted.get(e))&&i.isEstablished;var a=this.subscriptions.get(e);a?(t.type=n,a.update(t,r)):DM("Message dropped for SID '".concat(e,"', for which there is no subscription."))}}},{key:"onConnectionStateChanged",value:function(e){this.isConnected=e,e&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(e){DM("Triggering event replay for all subscriptions, reason=".concat(e)),this.pendingPokeReason=e,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var t,n=[],r=JM(this.persisted.values());try{for(r.s();!(t=r.n()).done;){var i=t.value;i.reset(),i.rejectedWithError&&n.push(i)}}catch(e){r.e(e)}finally{r.f()}this.persisted.clear();for(var a=0,o=n;a<o.length;a++){var s=o[a];this.persisted.set(s.sid,s)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),e}();function eL(e){if(e.body&&e.body.message)return e.body.message;switch(e.status){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function tL(e){return e.body?e.body.code:0}function nL(e){return 409===e.status?new PM(eL(e),e.status,tL(e),e.body):e.status?new SyncError(eL(e),e.status,tL(e)):e instanceof eM.TransportUnavailableError?e:new SyncError(e.message,0,0)}var rL=function(){function e(t,n,r){dM.default(this,e),this.clientInfo=t,this.config=n,this.transport=r}return pM.default(e,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+SM.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return Object.assign({min:4e3,max:6e4,maxAttemptsTime:9e4,randomness:.2},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new Promise((function(r,i){var a=[502,503,504];n&&a.push(429);var o=new iM.Retrier(t.backoffConfig());o.on("attempt",(function(){e().then((function(e){return o.succeeded(e)})).catch((function(e){if(a.includes(e.status)){var t=parseInt(e.headers?e.headers["Retry-After"]:null);o.failed(nL(e),isNaN(t)?null:1e3*t)}else"Twilsock disconnected"===e.message?o.failed(nL(e)):(o.removeAllListeners(),o.cancel(),i(nL(e)))}))})),o.on("succeeded",(function(e){r(e)})),o.on("cancelled",(function(e){return i(nL(e))})),o.on("failed",(function(e){return i(nL(e))})),o.start()}))}},{key:"get",value:function(e){var t=this,n=this.createHeaders();return DM("GET",e,"ID:",n["Twilio-Request-Id"]),this.executeWithRetry((function(){return t.transport.get(e,n,t.config.productId)}),!0)}},{key:"post",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=this.createHeaders();return null!=n&&(a["If-Match"]=n),DM("POST",e,"ID:",a["Twilio-Request-Id"]),this.executeWithRetry((function(){return r.transport.post(e,a,t,r.config.productId)}),i)}},{key:"put",value:function(e,t,n){var r=this,i=this.createHeaders();return null!=n&&(i["If-Match"]=n),DM("PUT",e,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry((function(){return r.transport.put(e,i,t,r.config.productId)}),!1)}},{key:"delete",value:function(e){var t=this,n=this.createHeaders();return DM("DELETE",e,"ID:",n["Twilio-Request-Id"]),this.executeWithRetry((function(){return t.transport.delete(e,n,t.config.productId)}),!1)}}]),e}(),iL=function(){function e(t,n){dM.default(this,e),this.config=t,this.storageId=null;try{this.storage=n||sessionStorage}catch(e){}}return pM.default(e,[{key:"storageKey",value:function(e,t){return"".concat(this.storageId,"::").concat(e,"::").concat(t)}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}},{key:"updateStorageId",value:function(e){this.storageId=e}},{key:"store",value:function(e,t,n){return this.isReady?this._store(this.storageKey(e,t),n):null}},{key:"read",value:function(e,t){return this.isReady?this._read(this.storageKey(e,t)):null}},{key:"remove",value:function(e,t,n){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(e,t)),n&&this.storage.removeItem(this.storageKey(e,n))}catch(e){}}},{key:"update",value:function(e,t,n,r){if(!this.isReady)return null;this._apply(this.storageKey(e,t),r),n&&this._apply(this.storageKey(e,n),r)}},{key:"_store",value:function(e,t){try{this.storage.setItem(e,JSON.stringify(t))}catch(e){}}},{key:"_read",value:function(e){try{var t=this.storage.getItem(e);if(t)return JSON.parse(t)}catch(e){}return null}},{key:"_apply",value:function(e,t){var n=this._read(e);if(!n)return!1;this._store(e,Object.assign(n,t))}}]),e}();function aL(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return oL(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return oL(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function oL(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var sL=function(){function e(t,n){dM.default(this,e),this.services=t,this.removalHandler=n,this.subscriptionState="none",this._attachedListeners=new Map}return pM.default(e,[{key:"_advanceLastEventId",value:function(e,t){}},{key:"reportFailure",value:function(e){404===e.status?this.onRemoved(!1):this.broadcastEventToListeners("failure",e)}},{key:"_subscribe",value:function(){this.services.router._subscribe(this.sid,this)}},{key:"_unsubscribe",value:function(){this.services.router._unsubscribe(this.sid)}},{key:"_setSubscriptionState",value:function(e){this.subscriptionState=e,this.broadcastEventToListeners("_subscriptionStateChanged",e)}},{key:"close",value:function(){this._unsubscribe(),null!=this.removalHandler&&this.removalHandler(this.type,this.sid,this.uniqueName)}},{key:"attach",value:function(e){var t=e.listenerUuid;this._attachedListeners.get(t)||(this._attachedListeners.size||this._subscribe(),this._attachedListeners.set(t,e))}},{key:"detach",value:function(e){this._attachedListeners.delete(e),this._attachedListeners.size||this.close()}},{key:"broadcastEventToListeners",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i,a=aL(this._attachedListeners.values());try{for(a.s();!(i=a.n()).done;){var o=i.value;o.emit.apply(o,[e].concat(n))}}catch(e){a.e(e)}finally{a.f()}}}]),e}(),uL=function(){function e(t){dM.default(this,e),gM.default(this,"queuedRequests",[]),gM.default(this,"isRequestInFlight",!1),this.inputMergingFunction=t}return pM.default(e,[{key:"add",value:function(e,t){var n=this,r=new Promise((function(r,i){return n.queuedRequests.push({input:e,requestFunction:t,resolve:r,reject:i})}));return this.wakeupQueue(),r}},{key:"squashAndAdd",value:function(e,t){var n,r=this.queuedRequests;this.queuedRequests=[],r.length>0?(n=r.map((function(e){return e.input})).reduce(this.inputMergingFunction),n=this.inputMergingFunction(n,e)):n=e;var i=this.add(n,t);return r.forEach((function(e){return i.then(e.resolve,e.reject)})),i}},{key:"isEmpty",value:function(){return 0===this.queuedRequests.length&&!this.isRequestInFlight}},{key:"wakeupQueue",value:function(){var e=this;if(0!==this.queuedRequests.length&&!this.isRequestInFlight){var t=this.queuedRequests.shift();this.isRequestInFlight=!0,t.requestFunction(t.input).then(t.resolve,t.reject).then((function(t){e.isRequestInFlight=!1,e.wakeupQueue()}))}}}]),e}(),cL=function(){function e(t){dM.default(this,e),gM.default(this,"queueByNamespaceKey",new Map),this.inputReducer=t}var t,n,r;return pM.default(e,[{key:"add",value:(r=fM.default(bM.default.mark((function e(t,n,r){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.invokeQueueMethod(t,(function(e){return e.add(n,r)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"squashAndAdd",value:(n=fM.default(bM.default.mark((function e(t,n,r){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.invokeQueueMethod(t,(function(e){return e.squashAndAdd(n,r)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"invokeQueueMethod",value:(t=fM.default(bM.default.mark((function e(t,n){var r,i;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queueByNamespaceKey.has(t)||this.queueByNamespaceKey.set(t,new uL(this.inputReducer)),r=this.queueByNamespaceKey.get(t),i=n(r),this.queueByNamespaceKey.get(t).isEmpty()&&this.queueByNamespaceKey.delete(t),e.abrupt("return",i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})}]),e}();function lL(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mM.default(e);if(t){var i=mM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return yM.default(this,n)}}var fL=function(e){vM.default(n,e);var t=lL(n);function n(){var e;return dM.default(this,n),(e=t.call(this)).closed=!1,e.uuid=aM.v4(),e}return pM.default(n,[{key:"listenerUuid",get:function(){return this.uuid}},{key:"close",value:function(){this.removeAllListeners(),this.closed=!0}},{key:"ensureNotClosed",value:function(){if(this.closed)throw new Error("Invalid operation on closed object")}}]),n}(sM.ReplayEventEmitter);function dL(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mM.default(e);if(t){var i=mM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return yM.default(this,n)}}var pL=function(e){vM.default(f,e);var t,n,r,i,a,o,s,u,c,l=dL(f);function f(e,t,n){var r;dM.default(this,f),r=l.call(this,e,n),gM.default(hM.default(r),"isDeleted",!1);return r.updateMergingQueue=new uL((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.descriptor=t,r.descriptor.data=r.descriptor.data||{},r.descriptor.date_updated=new Date(r.descriptor.date_updated),r}return pM.default(f,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"document"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"_update",value:function(e){switch(e.date_created=new Date(e.date_created),e.type){case"document_updated":if(e.id<=this.lastEventId){FM("Document update skipped, current:",this.lastEventId,", remote:",e.id);break}var t=void 0!==this.descriptor.data?AM(this.descriptor.data):null;this.descriptor.last_event_id=e.id,this.descriptor.revision=e.document_revision,this.descriptor.date_updated=e.date_created,this.descriptor.data=e.document_data,this.broadcastEventToListeners("updated",{data:e.document_data,isLocal:!1,previousData:t}),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:e.id,revision:e.document_revision,date_updated:e.date_created,data:e.document_data});break;case"document_removed":this.onRemoved(!1)}}},{key:"set",value:(c=fM.default(bM.default.mark((function e(t,n){var r,i=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n||{},e.abrupt("return",this.updateMergingQueue.squashAndAdd(r,(function(e){return i._setUnconditionally(t,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"mutate",value:(u=fM.default(bM.default.mark((function e(t,n){var r,i=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n||{},e.abrupt("return",this.updateMergingQueue.add(r,(function(e){return i._setWithIfMatch(t,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"update",value:(s=fM.default(bM.default.mark((function e(t,n){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate((function(e){return Object.assign(e,t)}),n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"setTtl",value:(o=fM.default(bM.default.mark((function e(t){var n;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._postUpdateToServer({ttl:t});case 2:n=e.sent,this.descriptor.date_expires=n.date_expires;case 4:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_setUnconditionally",value:(a=fM.default(bM.default.mark((function e(t,n){var r;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._postUpdateToServer({data:t,revision:void 0,ttl:n});case 2:return r=e.sent,this._handleSuccessfulUpdateResult(r),e.abrupt("return",this.descriptor.data);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"_setWithIfMatch",value:(i=fM.default(bM.default.mark((function e(t,n){var r,i,a;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t(AM(this.descriptor.data)))){e.next=22;break}return i=this.revision,e.prev=3,e.next=6,this._postUpdateToServer({data:r,revision:i,ttl:n});case 6:return a=e.sent,this._handleSuccessfulUpdateResult(a),e.abrupt("return",this.descriptor.data);case 11:if(e.prev=11,e.t0=e.catch(3),412!==e.t0.status){e.next=19;break}return e.next=16,this._softSync();case 16:return e.abrupt("return",this._setWithIfMatch(t));case 19:throw e.t0;case 20:e.next=23;break;case 22:return e.abrupt("return",this.descriptor.data);case 23:case"end":return e.stop()}}),e,this,[[3,11]])}))),function(e,t){return i.apply(this,arguments)})},{key:"_handleSuccessfulUpdateResult",value:function(e){if(!(e.last_event_id<=this.descriptor.last_event_id)){var t=void 0!==this.descriptor.data?AM(this.descriptor.data):null;this.descriptor.revision=e.revision,this.descriptor.data=e.data,this.descriptor.last_event_id=e.last_event_id,this.descriptor.date_expires=e.date_expires,this.descriptor.date_updated=new Date(e.date_updated),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:e.last_event_id,revision:e.revision,date_updated:e.date_updated,data:e.data}),this.broadcastEventToListeners("updated",{data:this.descriptor.data,isLocal:!0,previousData:t})}}},{key:"_postUpdateToServer",value:(r=fM.default(bM.default.mark((function e(t){var n,r,i;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isDeleted){e.next=17;break}return n={data:t.data},void 0!==t.ttl&&(n.ttl=t.ttl),r=t.revision,e.prev=4,e.next=7,this.services.network.post(this.uri,n,r);case 7:return i=e.sent,e.abrupt("return",{revision:i.body.revision,data:t.data,last_event_id:i.body.last_event_id,date_updated:i.body.date_updated,date_expires:i.body.date_expires});case 11:throw e.prev=11,e.t0=e.catch(4),404===e.t0.status&&this.onRemoved(!1),e.t0;case 15:e.next=18;break;case 17:return e.abrupt("return",Promise.reject(new SyncError("The Document has been removed",404,54100)));case 18:case"end":return e.stop()}}),e,this,[[4,11]])}))),function(e){return r.apply(this,arguments)})},{key:"_softSync",value:(n=fM.default(bM.default.mark((function e(){var t=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.services.network.get(this.uri).then((function(e){var n={type:"document_updated",id:e.body.last_event_id,document_revision:e.body.revision,document_data:e.body.data,date_created:e.body.date_updated};return t._update(n),t})).catch((function(e){404===e.status?t.onRemoved(!1):BM("Can't get updates for ".concat(t.sid,":"),e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"onRemoved",value:function(e){if(!this.isDeleted){var t=void 0!==this.descriptor.data?AM(this.descriptor.data):null;this.isDeleted=!0,this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e,previousData:t})}}},{key:"removeDocument",value:(t=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isDeleted){e.next=6;break}return e.next=3,this.services.network.delete(this.uri);case 3:this.onRemoved(!0),e.next=7;break;case 6:return e.abrupt("return",Promise.reject(new SyncError("The Document has been removed",404,54100)));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}],[{key:"type",get:function(){return"document"}}]),f}(sL),hL=function(e){vM.default(s,e);var t,n,r,i,a,o=dL(s);function s(e){var t;return dM.default(this,s),(t=o.call(this)).syncDocumentImpl=e,t.syncDocumentImpl.attach(hM.default(t)),t}return pM.default(s,[{key:"uri",get:function(){return this.syncDocumentImpl.uri}},{key:"revision",get:function(){return this.syncDocumentImpl.revision}},{key:"lastEventId",get:function(){return this.syncDocumentImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncDocumentImpl.dateExpires}},{key:"type",get:function(){return pL.type}},{key:"sid",get:function(){return this.syncDocumentImpl.sid}},{key:"data",get:function(){return this.syncDocumentImpl.data}},{key:"dateUpdated",get:function(){return this.syncDocumentImpl.dateUpdated}},{key:"uniqueName",get:function(){return this.syncDocumentImpl.uniqueName}},{key:"set",value:(a=fM.default(bM.default.mark((function e(t,n){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.set(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"mutate",value:(i=fM.default(bM.default.mark((function e(t,n){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.mutate(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"update",value:(r=fM.default(bM.default.mark((function e(t,n){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.update(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setTtl",value:(n=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"removeDocument",value:(t=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.removeDocument());case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){OM.default(mM.default(s.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return pL.type}}]),s}(fL);gM.default(hL,"removed","removed"),gM.default(hL,"updated","updated"),TM([Zj.validateTypesAsync(Zj.pureObject,["undefined",Zj.objectSchema("document metadata",{ttl:[Zj.nonNegativeInteger,"undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[Object,Object]),RM("design:returntype",Promise)],hL.prototype,"set",null),TM([Zj.validateTypesAsync("function",["undefined",Zj.objectSchema("document metadata",{ttl:[Zj.nonNegativeInteger,"undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[Function,Object]),RM("design:returntype",Promise)],hL.prototype,"mutate",null),TM([Zj.validateTypesAsync(Zj.pureObject,["undefined",Zj.objectSchema("document metadata",{ttl:[Zj.nonNegativeInteger,"undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[Object,Object]),RM("design:returntype",Promise)],hL.prototype,"update",null),TM([Zj.validateTypesAsync(Zj.nonNegativeInteger),RM("design:type",Function),RM("design:paramtypes",[Number]),RM("design:returntype",Promise)],hL.prototype,"setTtl",null);var vL=function(){function e(t){dM.default(this,e),this.descriptor=t}return pM.default(e,[{key:"uri",get:function(){return this.descriptor.uri}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.lastEventId}},{key:"dateUpdated",get:function(){return this.descriptor.dateUpdated}},{key:"dateExpires",get:function(){return this.descriptor.dateExpires}},{key:"index",get:function(){return this.descriptor.index}},{key:"data",get:function(){return this.descriptor.data}},{key:"update",value:function(e,t,n,r){return this.descriptor.lastEventId=e,this.descriptor.revision=t,this.descriptor.data=n,this.descriptor.dateUpdated=r,this}},{key:"updateDateExpires",value:function(e){this.descriptor.dateExpires=e}}]),e}(),Paginator=function(){function Paginator(e,t,n,r){dM.default(this,Paginator),this.prevToken=n,this.nextToken=r,this.items=e,this.source=t}var e,t;return pM.default(Paginator,[{key:"hasNextPage",get:function(){return!!this.nextToken}},{key:"hasPrevPage",get:function(){return!!this.prevToken}},{key:"nextPage",value:(t=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasNextPage){e.next=2;break}throw new Error("No next page");case 2:return e.abrupt("return",this.source(this.nextToken));case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"prevPage",value:(e=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasPrevPage){e.next=2;break}throw new Error("No previous page");case 2:return e.abrupt("return",this.source(this.prevToken));case 3:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]),Paginator}();function yL(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return mL(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mL(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function mL(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var gL=function(){function e(t,n){dM.default(this,e),this.balanceFactor=0,this.key=t,this.value=n,this.parent=null,this.left=null,this.right=null}return pM.default(e,[{key:"isRoot",get:function(){return null===this.parent}},{key:"isLeaf",get:function(){return null===this.left&&null===this.right}},{key:"isLeftChild",get:function(){return this.parent.left===this}},{key:"update",value:function(e){this.value=e}},{key:"replace",value:function(e,t){e&&(this.left===t?this.left=t:this.right===t&&(this.right=t))}}]),e}(),bL=function(e){function t(e,n){dM.default(this,t),this.isLessThan=e||function(e,t){return e<t},this.isEqual=n||function(e,t){return e===t},this.root=null,this.count=null}return pM.default(t,[{key:"size",get:function(){return this.count}},{key:"clear",value:function(){this.root=null,this.count=0}},{key:"set",value:function(e,t){var n=this.getNode(e);n?n.update(t):this.insert(e,t)}},{key:"insert",value:function(e,t){var n=new gL(e,t);if(this.count++,this.root){for(var r=this.root;;)if(this.isLessThan(e,r.key)){if(!r.left){r.left=n;break}r=r.left}else{if(!r.right){r.right=n;break}r=r.right}for(n.parent=r,r=n;r.parent;){var i=r.parent,a=i.balanceFactor;if(r.isLeftChild?i.balanceFactor++:i.balanceFactor--,Math.abs(i.balanceFactor)<Math.abs(a))break;if(i.balanceFactor<-1||i.balanceFactor>1){this.rebalance(i);break}r=i}}else this.root=n}},{key:"get",value:function(e){for(var t=this.root;t;){if(this.isEqual(e,t.key))return t.value;t=this.isLessThan(e,t.key)?t.left:t.right}return null}},{key:"delete",value:function(e){var t=this.getNode(e);if(!t||t.key!==e)return null;var n=t.parent,r=t.left,i=t.right;if(!!r!=!!i){var a=r||i;n||a?n&&!a?this.root=a:(n.replace(t,null),this.rebalance(n)):this.root=null}else{for(var o=t.left;o.right;)o=o.right;if(t.left===o)t.isRoot?(this.root=o,o.parent=null):(t.isLeftChild?t.parent.left=o:t.parent.right=o,o.parent=t.parent),o.right=t.right,o.right.parent=o,o.balanceFactor=t.balanceFactor,t={parent:o,isLeftChild:!0};else{var s=o.parent,u=o.left;s.right=u,u&&(u.parent=s),t.isRoot?(this.root=o,o.parent=null):(t.isLeftChild?t.parent.left=o:t.parent.right=o,o.parent=t.parent),o.right=t.right,o.right.parent=o,o.left=t.left,o.left.parent=o,o.balanceFactor=t.balanceFactor,t={parent:s,isLeftChild:!1}}}for(this.count--;t.parent;){var c=t.parent,l=c.balanceFactor;if(t.isLeftChild?c.balanceFactor-=1:c.balanceFactor+=1,Math.abs(c.balanceFactor)>Math.abs(l)){if(!(c.balanceFactor<-1||c.balanceFactor>1))break;if(this.rebalance(c),0!==c.parent.balanceFactor)break;t=c.parent}else t=c}return null}},{key:"getNode",value:function(e){for(var t=this.root;t;){if(this.isEqual(e,t.key))return t;t=this.isLessThan(e,t.key)?t.left:t.right}return null}},{key:"rebalance",value:function(e){e.balanceFactor<0?e.right.balanceFactor>0?(this.rotateRight(e.right),this.rotateLeft(e)):this.rotateLeft(e):e.balanceFactor>0&&(e.left.balanceFactor<0?(this.rotateLeft(e.left),this.rotateRight(e)):this.rotateRight(e))}},{key:"rotateLeft",value:function(e){var t=e.right;e.right=t.left,null!==t.left&&(t.left.parent=e),t.parent=e.parent,null===t.parent?this.root=t:e.isLeftChild?t.parent.left=t:t.parent.right=t,t.left=e,e.parent=t,e.balanceFactor=e.balanceFactor+1-Math.min(t.balanceFactor,0),t.balanceFactor=t.balanceFactor+1-Math.max(e.balanceFactor,0)}},{key:"rotateRight",value:function(e){var t=e.left;e.left=t.right,null!==t.right&&(t.right.parent=e),t.parent=e.parent,null===t.parent?this.root=t:e.isLeftChild?t.parent.left=t:t.parent.right=t,t.right=e,e.parent=t,e.balanceFactor=e.balanceFactor-1-Math.min(t.balanceFactor,0),t.balanceFactor=t.balanceFactor-1-Math.max(e.balanceFactor,0)}},{key:e,value:bM.default.mark((function e(){var t,n,r;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=yL(this.getIterator()),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=n.value,e.next=7,r;case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[1,11,14,17]])}))},{key:"getIterator",value:bM.default.mark((function e(){var t,n,r,i=arguments;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i.length>0&&void 0!==i[0]?i[0]:null,n=this.root;case 2:if(!n){e.next=8;break}if(!this.isEqual(t,n.key)&&(null!==t||n.left)){e.next=5;break}return e.abrupt("break",8);case 5:n=this.isLessThan(t,n.key)||null===t?n.left:n.right,e.next=2;break;case 8:if(n){e.next=10;break}return e.abrupt("return",null);case 10:r=!0;case 11:if(!r){e.next=29;break}return e.next=14,[n.key,n.value];case 14:if(r=!1,!n.right){e.next=21;break}for(n=n.right;n.left;)n=n.left;r=!0,e.next=27;break;case 21:if(!n.parent){e.next=26;break}r=n.parent.left===n,n=n.parent,e.next=27;break;case 26:return e.abrupt("break",37);case 27:e.next=35;break;case 29:if(!n.parent){e.next=34;break}r=n.parent.left===n,n=n.parent,e.next=35;break;case 34:return e.abrupt("break",37);case 35:e.next=11;break;case 37:return e.abrupt("return",null);case 38:case"end":return e.stop()}}),e,this)}))},{key:"getReverseIterator",value:bM.default.mark((function e(){var t,n,r,i=arguments;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i.length>0&&void 0!==i[0]?i[0]:null,n=this.root;case 2:if(!n){e.next=8;break}if(!this.isEqual(t,n.key)&&(null!==t||n.right)){e.next=5;break}return e.abrupt("break",8);case 5:n=this.isLessThan(t,n.key)&&null!==t?n.left:n.right,e.next=2;break;case 8:if(n){e.next=10;break}return e.abrupt("return",null);case 10:r=!0;case 11:if(!r){e.next=29;break}return e.next=14,[n.key,n.value];case 14:if(r=!1,!n.left){e.next=21;break}for(n=n.left;n.right;)n=n.right;r=!0,e.next=27;break;case 21:if(!n.parent){e.next=26;break}r=n.parent.right===n,n=n.parent,e.next=27;break;case 26:return e.abrupt("break",37);case 27:e.next=35;break;case 29:if(!n.parent){e.next=34;break}r=n.parent.right===n,n=n.parent,e.next=35;break;case 34:return e.abrupt("break",37);case 35:e.next=11;break;case 37:return e.abrupt("return",null);case 38:case"end":return e.stop()}}),e,this)}))}]),t}(Symbol.iterator);function wL(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return kL(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kL(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function kL(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var xL=function(){function e(t,n){dM.default(this,e),this.value=t,this.revision=n||0}return pM.default(e,[{key:"isValid",get:function(){return!0}}]),e}(),_L=function(){function e(t){dM.default(this,e),this.revision=t}return pM.default(e,[{key:"isValid",get:function(){return!1}}]),e}(),SL=function(){function e(){dM.default(this,e),this.items=new bL}return pM.default(e,[{key:"store",value:function(e,t,n){var r=this.items.get(e);return r&&r.revision>n?r.isValid?r.value:null:(this.items.set(e,new xL(t,n)),t)}},{key:"delete",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.items.get(e);(!r||r.revision<t||r&&!0===n)&&this.items.set(e,new _L(t))}},{key:"isKnown",value:function(e,t){var n=this.items.get(e);return n&&n.revision>=t}},{key:"get",value:function(e){var t=this.items.get(e);return t&&t.isValid?t.value:null}},{key:"has",value:function(e){var t=this.items.get(e);return t&&t.isValid}},{key:"forEach",value:function(e){if(this.items){var t,n=wL(this.items);try{for(n.s();!(t=n.n()).done;){var r=_M.default(t.value,2),i=r[0],a=r[1];a.isValid&&e(i,a.value)}}catch(e){n.e(e)}finally{n.f()}}}}]),e}();function OL(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mM.default(e);if(t){var i=mM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return yM.default(this,n)}}var EL=function(e){vM.default(y,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v=OL(y);function y(e,t,n){var r;dM.default(this,y);return(r=v.call(this,e,n)).updateMergingQueue=new cL((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.cache=new SL,r.descriptor=t,r.descriptor.date_updated=new Date(r.descriptor.date_updated),r}return pM.default(y,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"list"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"_addOrUpdateItemOnServer",value:(h=fM.default(bM.default.mark((function e(t,n,r,i){var a,o;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a={data:n},void 0!==i&&(a.ttl=i),e.next=4,this.services.network.post(t,a,r);case 4:return(o=e.sent).body.data=n,o.body.date_updated=new Date(o.body.date_updated),e.abrupt("return",o.body);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n,r){return h.apply(this,arguments)})},{key:"push",value:(p=fM.default(bM.default.mark((function e(t,n){var r,i,a;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=(n||{}).ttl,e.next=3,this._addOrUpdateItemOnServer(this.links.items,t,void 0,r);case 3:return i=e.sent,a=Number(i.index),this._handleItemMutated(a,i.url,i.last_event_id,i.revision,t,i.date_updated,i.date_expires,!0,!1),e.abrupt("return",this.cache.get(a));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"set",value:(d=fM.default(bM.default.mark((function e(t,n,r){var i,a=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.squashAndAdd(t,i,(function(e){return a._updateItemUnconditionally(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return d.apply(this,arguments)})},{key:"_updateItemUnconditionally",value:(f=fM.default(bM.default.mark((function e(t,n,r){var i,a;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return i=e.sent,e.next=5,this._addOrUpdateItemOnServer(i.uri,n,void 0,r);case 5:return a=e.sent,this._handleItemMutated(t,a.url,a.last_event_id,a.revision,a.data,a.date_updated,a.date_expires,!1,!1),e.abrupt("return",this.cache.get(t));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return f.apply(this,arguments)})},{key:"_updateItemWithIfMatch",value:(l=fM.default(bM.default.mark((function e(t,n,r){var i,a,o,s;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:if(i=e.sent,!(a=n(AM(i.data)))){e.next=25;break}return o=i.revision,e.prev=6,e.next=9,this._addOrUpdateItemOnServer(i.uri,a,o,r);case 9:return s=e.sent,this._handleItemMutated(t,s.url,s.last_event_id,s.revision,s.data,s.date_updated,s.date_expires,!1,!1),e.abrupt("return",this.cache.get(t));case 14:if(e.prev=14,e.t0=e.catch(6),412!==e.t0.status){e.next=22;break}return e.next=19,this._getItemFromServer(t);case 19:return e.abrupt("return",this._updateItemWithIfMatch(t,n,r));case 22:throw e.t0;case 23:e.next=26;break;case 25:return e.abrupt("return",i);case 26:case"end":return e.stop()}}),e,this,[[6,14]])}))),function(e,t,n){return l.apply(this,arguments)})},{key:"mutate",value:(c=fM.default(bM.default.mark((function e(t,n,r){var i,a=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.add(t,i,(function(e){return a._updateItemWithIfMatch(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return c.apply(this,arguments)})},{key:"update",value:(u=fM.default(bM.default.mark((function e(t,n,r){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate(t,(function(e){return Object.assign(e,n)}),r));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return u.apply(this,arguments)})},{key:"remove",value:(s=fM.default(bM.default.mark((function e(t){var n,r,i;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return n=e.sent,r=AM(n.data),e.next=6,this.services.network.delete(n.uri);case 6:i=e.sent,this._handleItemRemoved(t,i.body.last_event_id,r,new Date(i.body.date_updated),!1);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"get",value:function(){var e=fM.default(bM.default.mark((function e(t){var n;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.cache.get(t))){e.next=5;break}return e.abrupt("return",n);case 5:return e.abrupt("return",this._getItemFromServer(t));case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"_getItemFromServer",value:(o=fM.default(bM.default.mark((function e(t){var n;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.queryItems({index:t});case 2:if(!((n=e.sent).items.length<1)){e.next=7;break}throw new SyncError("No item with index ".concat(t," found"),404,54151);case 7:return e.abrupt("return",n.items[0]);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"queryItems",value:function(){var e=fM.default(bM.default.mark((function e(t){var n,r,i,a,o=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},n=new IM(this.links.items).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Index",t.index).queryParam("PageToken",t.pageToken).queryParam("Order",t.order).build(),e.next=4,this.services.network.get(n);case 4:return r=e.sent,i=r.body.items.map((function(e){return e.date_updated=new Date(e.date_updated),o.cache.get(e.index)?o._handleItemMutated(e.index,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0):o.cache.store(Number(e.index),new vL({index:Number(e.index),uri:e.url,revision:e.revision,lastEventId:e.last_event_id,dateUpdated:e.date_updated,dateExpires:e.date_expires,data:e.data}),e.last_event_id),o.cache.get(e.index)})),a=r.body.meta,e.abrupt("return",new Paginator(i,(function(e){return o.queryItems({pageToken:e})}),a.previous_token,a.next_token));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:(a=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jM((t=t||{}).pageSize),t.limit=t.pageSize||t.limit||50,t.order=t.order||"asc",e.abrupt("return",this.queryItems(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getContext",value:(i=fM.default(bM.default.mark((function e(){var t;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.context){e.next=5;break}return e.next=3,this.services.network.get(this.links.context);case 3:t=e.sent,this._updateContextIfRequired(t.body.data,t.body.last_event_id);case 5:return e.abrupt("return",this.context);case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"setTtl",value:(r=fM.default(bM.default.mark((function e(t){var n,r;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={ttl:t},e.next=4,this.services.network.post(this.uri,n);case 4:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),404===e.t0.status&&this.onRemoved(!1),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=fM.default(bM.default.mark((function e(t,n){var r,i,a;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return r=e.sent,i={ttl:n},e.next=6,this.services.network.post(r.uri,i);case 6:a=e.sent,r.updateDateExpires(a.body.date_expires);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeList",value:(t=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}},{key:"shouldIgnoreEvent",value:function(e,t){return this.cache.isKnown(e,t)}},{key:"_update",value:function(e,t){var n=Number(e.item_index);switch(e.date_created=new Date(e.date_created),e.type){case"list_item_added":case"list_item_updated":this._handleItemMutated(n,e.item_url,e.id,e.item_revision,e.item_data,e.date_created,void 0,"list_item_added"===e.type,!0);break;case"list_item_removed":this._handleItemRemoved(n,e.id,e.item_data,e.date_created,!0);break;case"list_context_updated":this._handleContextUpdate(e.context_data,e.id,e.date_created);break;case"list_removed":this.onRemoved(!1)}t&&this._advanceLastEventId(e.id,e.list_revision)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e,t&&(this.descriptor.revision=t))}},{key:"_updateRootDateUpdated",value:function(e){(!this.descriptor.date_updated||e.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=e,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:e}))}},{key:"_handleItemMutated",value:function(e,t,n,r,i,a,o,s,u){if(this.shouldIgnoreEvent(e,n))FM("Item ".concat(e," update skipped, current: ").concat(this.lastEventId,", remote: ").concat(n));else{this._updateRootDateUpdated(a);var c=this.cache.get(e);if(!c){var l=new vL({index:e,uri:t,lastEventId:n,revision:r,data:i,dateUpdated:a,dateExpires:o});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,s)}var f=AM(c.data);c.update(n,r,i,a),this.cache.store(e,c,n),void 0!==o&&c.updateDateExpires(o),this.emitItemMutationEvent(c,u,!1,f)}}},{key:"emitItemMutationEvent",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=n?"itemAdded":"itemUpdated",a={item:e,isLocal:!t};n||(a.previousItemData=r),this.broadcastEventToListeners(i,a)}},{key:"_handleItemRemoved",value:function(e,t,n,r,i){this._updateRootDateUpdated(r),this.cache.delete(e,t),this.broadcastEventToListeners("itemRemoved",{index:e,isLocal:!i,previousItemData:n})}},{key:"_handleContextUpdate",value:function(e,t,n){this._updateRootDateUpdated(n),this._updateContextIfRequired(e,t)&&this.broadcastEventToListeners("contextUpdated",{context:e,isLocal:!1})}},{key:"_updateContextIfRequired",value:function(e,t){return!this.contextEventId||t>this.contextEventId?(this.context=e,this.contextEventId=t,!0):(FM("Context update skipped, current:",this.lastEventId,", remote:",t),!1)}}],[{key:"type",get:function(){return"list"}}]),y}(sL),TL=function(e){vM.default(p,e);var t,n,r,i,a,o,s,u,c,l,f,d=OL(p);function p(e){var t;return dM.default(this,p),(t=d.call(this)).syncListImpl=e,t.syncListImpl.attach(hM.default(t)),t}return pM.default(p,[{key:"uri",get:function(){return this.syncListImpl.uri}},{key:"revision",get:function(){return this.syncListImpl.revision}},{key:"lastEventId",get:function(){return this.syncListImpl.lastEventId}},{key:"links",get:function(){return this.syncListImpl.links}},{key:"dateExpires",get:function(){return this.syncListImpl.dateExpires}},{key:"type",get:function(){return EL.type}},{key:"sid",get:function(){return this.syncListImpl.sid}},{key:"uniqueName",get:function(){return this.syncListImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncListImpl.dateUpdated}},{key:"push",value:(f=fM.default(bM.default.mark((function e(t,n){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.push(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"set",value:(l=fM.default(bM.default.mark((function e(t,n,r){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.set(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return l.apply(this,arguments)})},{key:"mutate",value:(c=fM.default(bM.default.mark((function e(t,n,r){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.mutate(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return c.apply(this,arguments)})},{key:"update",value:(u=fM.default(bM.default.mark((function e(t,n,r){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.update(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return u.apply(this,arguments)})},{key:"remove",value:(s=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.remove(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"get",value:(o=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.get(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getContext",value:(a=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.getContext());case 2:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getItems",value:(i=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.getItems(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setTtl",value:(r=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=fM.default(bM.default.mark((function e(t,n){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.setItemTtl(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeList",value:(t=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.removeList());case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){OM.default(mM.default(p.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return EL.type}}]),p}(fL);gM.default(TL,"itemAdded","itemAdded"),gM.default(TL,"itemUpdated","itemUpdated"),gM.default(TL,"itemRemoved","itemRemoved"),gM.default(TL,"removed","removed"),TM([Zj.validateTypesAsync(Zj.pureObject,["undefined",Zj.objectSchema("item metadata",{ttl:[Zj.nonNegativeInteger,"undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[Object,Object]),RM("design:returntype",Promise)],TL.prototype,"push",null),TM([Zj.validateTypesAsync(Zj.nonNegativeInteger,Zj.pureObject,["undefined",Zj.objectSchema("item metadata",{ttl:[Zj.nonNegativeInteger,"undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[Number,Object,Object]),RM("design:returntype",Promise)],TL.prototype,"set",null),TM([Zj.validateTypesAsync(Zj.nonNegativeInteger,"function",["undefined",Zj.objectSchema("item metadata",{ttl:[Zj.nonNegativeInteger,"undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[Number,Function,Object]),RM("design:returntype",Promise)],TL.prototype,"mutate",null),TM([Zj.validateTypesAsync(Zj.nonNegativeInteger,Zj.pureObject,["undefined",Zj.objectSchema("item metadata",{ttl:[Zj.nonNegativeInteger,"undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[Number,Object,Object]),RM("design:returntype",Promise)],TL.prototype,"update",null),TM([Zj.validateTypesAsync(Zj.nonNegativeInteger),RM("design:type",Function),RM("design:paramtypes",[Number]),RM("design:returntype",Promise)],TL.prototype,"remove",null),TM([Zj.validateTypesAsync(Zj.nonNegativeInteger),RM("design:type",Function),RM("design:paramtypes",[Number]),RM("design:returntype",Promise)],TL.prototype,"get",null),TM([Zj.validateTypesAsync(["undefined",Zj.objectSchema("query options",{from:[Zj.nonNegativeInteger,"undefined"],pageSize:[Zj.custom((function(e){return[MM(e),"a positive integer"]})),"undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[Object]),RM("design:returntype",Promise)],TL.prototype,"getItems",null),TM([Zj.validateTypesAsync(Zj.nonNegativeInteger),RM("design:type",Function),RM("design:paramtypes",[Number]),RM("design:returntype",Promise)],TL.prototype,"setTtl",null),TM([Zj.validateTypesAsync(Zj.nonNegativeInteger,Zj.nonNegativeInteger),RM("design:type",Function),RM("design:paramtypes",[Number,Number]),RM("design:returntype",Promise)],TL.prototype,"setItemTtl",null);var RL=function(){function e(t){dM.default(this,e),this.descriptor=t}return pM.default(e,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"key",get:function(){return this.descriptor.key}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"update",value:function(e,t,n,r){return this.descriptor.last_event_id=e,this.descriptor.revision=t,this.descriptor.data=n,this.descriptor.date_updated=r,this}},{key:"updateDateExpires",value:function(e){this.descriptor.date_expires=e}}]),e}();function IL(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mM.default(e);if(t){var i=mM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return yM.default(this,n)}}var CL=function(e){vM.default(h,e);var t,n,r,i,a,o,s,u,c,l,f,d,p=IL(h);function h(e,t,n){var r;dM.default(this,h);return(r=p.call(this,e,n)).updateMergingQueue=new cL((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.cache=new SL,r.descriptor=t,r.descriptor.date_updated=new Date(r.descriptor.date_updated),t.items&&t.items.forEach((function(e){e.date_updated=new Date(e.date_updated),r.cache.store(e.key,new RL(e),e.last_event_id)})),r}return pM.default(h,[{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"map"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"set",value:(d=fM.default(bM.default.mark((function e(t,n,r){var i,a=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.squashAndAdd(t,i,(function(e){return a._putItemUnconditionally(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return d.apply(this,arguments)})},{key:"get",value:function(){var e=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}throw new SyncError("SyncMapItem key may not be empty",400,54209);case 2:if(!this.cache.has(t)){e.next=6;break}return e.abrupt("return",this.cache.get(t));case 6:return e.abrupt("return",this._getItemFromServer(t));case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"_getItemFromServer",value:(f=fM.default(bM.default.mark((function e(t){var n;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.queryItems({key:t});case 2:if(!((n=e.sent).items.length<1)){e.next=7;break}throw new SyncError("The specified Map Item does not exist",404,54201);case 7:return e.abrupt("return",n.items[0]);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"mutate",value:(l=fM.default(bM.default.mark((function e(t,n,r){var i,a=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.add(t,i,(function(e){return a._putItemWithIfMatch(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return l.apply(this,arguments)})},{key:"update",value:(c=fM.default(bM.default.mark((function e(t,n,r){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate(t,(function(e){return Object.assign(e,n)}),r));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return c.apply(this,arguments)})},{key:"_putItemUnconditionally",value:(u=fM.default(bM.default.mark((function e(t,n,r){var i,a;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._putItemToServer(t,n,void 0,r);case 2:return i=e.sent,a=i.item,this._handleItemMutated(a.key,a.url,a.last_event_id,a.revision,a.data,a.date_updated,a.date_expires,i.added,!1),e.abrupt("return",this.cache.get(a.key));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return u.apply(this,arguments)})},{key:"_putItemWithIfMatch",value:(s=fM.default(bM.default.mark((function e(t,n,r){var i,a,o,s,u;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t).catch((function(e){if(404===e.status)return new RL({key:t,data:{},last_event_id:-1,revision:"-1",url:null,date_updated:null,date_expires:null});throw e}));case 2:if(i=e.sent,!(a=n(AM(i.data)))){e.next=26;break}return o=i.revision,e.prev=6,e.next=9,this._putItemToServer(t,a,o,r);case 9:return s=e.sent,u=s.item,this._handleItemMutated(u.key,u.url,u.last_event_id,u.revision,u.data,u.date_updated,u.date_expires,s.added,!1),e.abrupt("return",this.cache.get(u.key));case 15:if(e.prev=15,e.t0=e.catch(6),412!==e.t0.status){e.next=23;break}return e.next=20,this._getItemFromServer(t);case 20:return e.abrupt("return",this._putItemWithIfMatch(t,n,r));case 23:throw e.t0;case 24:e.next=27;break;case 26:return e.abrupt("return",i);case 27:case"end":return e.stop()}}),e,this,[[6,15]])}))),function(e,t,n){return s.apply(this,arguments)})},{key:"_putItemToServer",value:(o=fM.default(bM.default.mark((function e(t,n,r,i){var a,o,s,u,c;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new IM(this.links.items).pathSegment(t).build(),o={data:n},void 0!==i&&(o.ttl=i),e.prev=3,e.next=6,this.services.network.put(a,o,r);case 6:return s=e.sent,(u=s.body).data=n,u.date_updated=new Date(u.date_updated),c=201===s.status.code,e.abrupt("return",{added:c,item:u});case 14:throw e.prev=14,e.t0=e.catch(3),404===e.t0.status&&this.onRemoved(!1),e.t0;case 18:case"end":return e.stop()}}),e,this,[[3,14]])}))),function(e,t,n,r){return o.apply(this,arguments)})},{key:"remove",value:(a=fM.default(bM.default.mark((function e(t){var n,r,i;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return n=e.sent,r=AM(n.data),e.next=6,this.services.network.delete(n.uri);case 6:i=e.sent,this._handleItemRemoved(t,i.body.last_event_id,r,new Date(i.body.date_updated),!1);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"queryItems",value:function(){var e=fM.default(bM.default.mark((function e(t){var n,r,i,a,o=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},n=new IM(this.links.items).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Key",t.key).queryParam("PageToken",t.pageToken).queryParam("Order",t.order).build(),e.next=4,this.services.network.get(n);case 4:return r=e.sent,i=r.body.items.map((function(e){return e.date_updated=new Date(e.date_updated),o.cache.get(e.key)?o._handleItemMutated(e.key,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0):o.cache.store(e.key,new RL(e),e.last_event_id),o.cache.get(e.key)})),a=r.body.meta,e.abrupt("return",new Paginator(i,(function(e){return o.queryItems({pageToken:e})}),a.previous_token,a.next_token));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:(i=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jM((t=t||{}).pageSize),t.limit=t.pageSize||t.limit||50,t.order=t.order||"asc",e.abrupt("return",this.queryItems(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"shouldIgnoreEvent",value:function(e,t){return this.cache.isKnown(e,t)}},{key:"_update",value:function(e,t){switch(e.date_created=new Date(e.date_created),e.type){case"map_item_added":case"map_item_updated":this._handleItemMutated(e.item_key,e.item_url,e.id,e.item_revision,e.item_data,e.date_created,void 0,"map_item_added"===e.type,!0);break;case"map_item_removed":this._handleItemRemoved(e.item_key,e.id,e.item_data,e.date_created,!0);break;case"map_removed":this.onRemoved(!1)}t&&this._advanceLastEventId(e.id,e.map_revision)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e,t&&(this.descriptor.revision=t))}},{key:"_updateRootDateUpdated",value:function(e){(!this.descriptor.date_updated||e.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=e,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:e}))}},{key:"_handleItemMutated",value:function(e,t,n,r,i,a,o,s,u){if(this.shouldIgnoreEvent(e,n))FM("SyncMapItem ",e," update skipped, current:",this.lastEventId,", remote:",n);else{this._updateRootDateUpdated(a);var c=this.cache.get(e);if(!c){var l=new RL({key:e,url:t,last_event_id:n,revision:r,data:i,date_updated:a,date_expires:o});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,s)}var f=AM(c.data);c.update(n,r,i,a),this.cache.store(e,c,n),void 0!==o&&c.updateDateExpires(o),this.emitItemMutationEvent(c,u,!1,f)}}},{key:"emitItemMutationEvent",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=n?"itemAdded":"itemUpdated",a={item:e,isLocal:!t};n||(a.previousItemData=r),this.broadcastEventToListeners(i,a)}},{key:"_handleItemRemoved",value:function(e,t,n,r,i){this._updateRootDateUpdated(r),this.cache.delete(e,t),this.broadcastEventToListeners("itemRemoved",{key:e,isLocal:!i,previousItemData:n})}},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}},{key:"setTtl",value:(r=fM.default(bM.default.mark((function e(t){var n,r;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={ttl:t},e.next=4,this.services.network.post(this.uri,n);case 4:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),404===e.t0.status&&this.onRemoved(!1),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=fM.default(bM.default.mark((function e(t,n){var r,i,a;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return r=e.sent,i={ttl:n},e.next=6,this.services.network.post(r.uri,i);case 6:a=e.sent,r.updateDateExpires(a.body.date_expires);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeMap",value:(t=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}],[{key:"type",get:function(){return"map"}}]),h}(sL),PL=function(e){vM.default(f,e);var t,n,r,i,a,o,s,u,c,l=IL(f);function f(e){var t;return dM.default(this,f),(t=l.call(this)).syncMapImpl=e,t.syncMapImpl.attach(hM.default(t)),t}return pM.default(f,[{key:"uri",get:function(){return this.syncMapImpl.uri}},{key:"links",get:function(){return this.syncMapImpl.links}},{key:"revision",get:function(){return this.syncMapImpl.revision}},{key:"lastEventId",get:function(){return this.syncMapImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncMapImpl.dateExpires}},{key:"type",get:function(){return CL.type}},{key:"sid",get:function(){return this.syncMapImpl.sid}},{key:"uniqueName",get:function(){return this.syncMapImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncMapImpl.dateUpdated}},{key:"set",value:(c=fM.default(bM.default.mark((function e(t,n,r){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.set(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return c.apply(this,arguments)})},{key:"get",value:(u=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.get(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"mutate",value:(s=fM.default(bM.default.mark((function e(t,n,r){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.mutate(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return s.apply(this,arguments)})},{key:"update",value:(o=fM.default(bM.default.mark((function e(t,n,r){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.update(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return o.apply(this,arguments)})},{key:"remove",value:(a=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.remove(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getItems",value:(i=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.getItems(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setTtl",value:(r=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=fM.default(bM.default.mark((function e(t,n){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.setItemTtl(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeMap",value:(t=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.next=3,this.syncMapImpl.removeMap();case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){OM.default(mM.default(f.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return CL.type}}]),f}(fL);function AL(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mM.default(e);if(t){var i=mM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return yM.default(this,n)}}gM.default(PL,"itemAdded","itemAdded"),gM.default(PL,"itemUpdated","itemUpdated"),gM.default(PL,"itemRemoved","itemRemoved"),gM.default(PL,"removed","removed"),TM([Zj.validateTypesAsync("string",Zj.pureObject,["undefined",Zj.objectSchema("item metadata",{ttl:[Zj.nonNegativeInteger,"undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[String,Object,Object]),RM("design:returntype",Promise)],PL.prototype,"set",null),TM([Zj.validateTypesAsync("string"),RM("design:type",Function),RM("design:paramtypes",[String]),RM("design:returntype",Promise)],PL.prototype,"get",null),TM([Zj.validateTypesAsync("string","function",["undefined",Zj.objectSchema("item metadata",{ttl:[Zj.nonNegativeInteger,"undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[String,Function,Object]),RM("design:returntype",Promise)],PL.prototype,"mutate",null),TM([Zj.validateTypesAsync("string",Zj.pureObject,["undefined",Zj.objectSchema("item metadata",{ttl:[Zj.nonNegativeInteger,"undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[String,Object,Object]),RM("design:returntype",Promise)],PL.prototype,"update",null),TM([Zj.validateTypesAsync("string"),RM("design:type",Function),RM("design:paramtypes",[String]),RM("design:returntype",Promise)],PL.prototype,"remove",null),TM([Zj.validateTypesAsync(["undefined",Zj.objectSchema("query options",{from:["string","undefined"],pageSize:[Zj.custom((function(e){return[MM(e),"a positive integer"]})),"undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[Object]),RM("design:returntype",Promise)],PL.prototype,"getItems",null),TM([Zj.validateTypesAsync(Zj.nonNegativeInteger),RM("design:type",Function),RM("design:paramtypes",[Number]),RM("design:returntype",Promise)],PL.prototype,"setTtl",null),TM([Zj.validateTypesAsync("string",Zj.nonNegativeInteger),RM("design:type",Function),RM("design:paramtypes",[String,Number]),RM("design:returntype",Promise)],PL.prototype,"setItemTtl",null);var jL=function(e){vM.default(a,e);var t,n,r,i=AL(a);function a(e,t,n){var r;return dM.default(this,a),(r=i.call(this,e,n)).descriptor=t,r}return pM.default(a,[{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"stream"}},{key:"lastEventId",get:function(){return null}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"publishMessage",value:(r=fM.default(bM.default.mark((function e(t){var n,r,i,a;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={data:t},e.next=3,this.services.network.post(this.links.messages,n);case 3:return r=e.sent,i=r.body,a=this._handleMessagePublished(i.sid,t,!1),e.abrupt("return",a);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setTtl",value:(n=fM.default(bM.default.mark((function e(t){var n,r;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={ttl:t},e.next=4,this.services.network.post(this.uri,n);case 4:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),404===e.t0.status&&this.onRemoved(!1),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return n.apply(this,arguments)})},{key:"removeStream",value:(t=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_update",value:function(e){switch(e.type){case"stream_message_published":this._handleMessagePublished(e.message_sid,e.message_data,!0);break;case"stream_removed":this.onRemoved(!1)}}},{key:"_handleMessagePublished",value:function(e,t,n){var r={sid:e,data:t};return this.broadcastEventToListeners("messagePublished",{message:r,isLocal:!n}),r}},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}}],[{key:"type",get:function(){return"stream"}}]),a}(sL);TM([Zj.validateTypesAsync(Zj.pureObject),RM("design:type",Function),RM("design:paramtypes",[Object]),RM("design:returntype",Promise)],jL.prototype,"publishMessage",null),TM([Zj.validateTypesAsync(Zj.nonNegativeInteger),RM("design:type",Function),RM("design:paramtypes",[Number]),RM("design:returntype",Promise)],jL.prototype,"setTtl",null);var ML=function(e){vM.default(a,e);var t,n,r,i=AL(a);function a(e){var t;return dM.default(this,a),(t=i.call(this)).syncStreamImpl=e,t.syncStreamImpl.attach(hM.default(t)),t}return pM.default(a,[{key:"uri",get:function(){return this.syncStreamImpl.uri}},{key:"links",get:function(){return this.syncStreamImpl.links}},{key:"dateExpires",get:function(){return this.syncStreamImpl.dateExpires}},{key:"type",get:function(){return jL.type}},{key:"lastEventId",get:function(){return null}},{key:"sid",get:function(){return this.syncStreamImpl.sid}},{key:"uniqueName",get:function(){return this.syncStreamImpl.uniqueName}},{key:"publishMessage",value:(r=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.publishMessage(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setTtl",value:(n=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"removeStream",value:(t=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.removeStream());case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){OM.default(mM.default(a.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return jL.type}}]),a}(fL);gM.default(ML,"messagePublished","messagePublished"),gM.default(ML,"removed","removed"),TM([Zj.validateTypesAsync(Zj.pureObject),RM("design:type",Function),RM("design:paramtypes",[Object]),RM("design:returntype",Promise)],ML.prototype,"publishMessage",null),TM([Zj.validateTypesAsync(Zj.nonNegativeInteger),RM("design:type",Function),RM("design:paramtypes",[Number]),RM("design:returntype",Promise)],ML.prototype,"setTtl",null);var LL=pM.default((function e(t){dM.default(this,e),this.sdk="js",this.sdkVer=t,this.os=EM.os.family,this.osVer=EM.os.version,this.pl=EM.name,this.plVer=EM.version})),UL=function(){function e(){dM.default(this,e),this.names=new Map,this.entities=new Map}return pM.default(e,[{key:"store",value:function(e){var t=this.entities.get(e.sid);return t||(this.entities.set(e.sid,e),e.uniqueName&&this.names.set(e.type+"::"+e.uniqueName,e.sid),e)}},{key:"getResolved",value:function(e,t){var n=this.names.get(t+"::"+e);return n?this.entities.get(n):null}},{key:"get",value:function(e,t){return this.entities.get(e)||this.getResolved(e,t)||null}},{key:"remove",value:function(e){var t=this.entities.get(e);t&&(this.entities.delete(e),t.uniqueName&&this.names.delete(t.type+"::"+t.uniqueName))}}]),e}();function NL(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mM.default(e);if(t){var i=mM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return yM.default(this,n)}}var FL=pM.default((function e(){dM.default(this,e)})),DL=function(e){vM.default(n,e);var t=NL(n);function n(e,r,i,a){var o;return dM.default(this,n),(o=t.call(this,r,i)).descriptor=e,o.cache=new SL,a&&a.forEach((function(e){o.cache.store(e.key,{key:e.key,value:e.data},e.revision)})),o}return pM.default(n,[{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return null}},{key:"type",get:function(){return n.type}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"indexName",get:function(){return this.descriptor.indexName}},{key:"queryString",get:function(){return this.descriptor.queryExpression}},{key:"queryUri",get:function(){return this.descriptor.queryUri}},{key:"liveQueryDescriptor",get:function(){return this.descriptor}},{key:"onRemoved",value:function(){}},{key:"getItems",value:function(){var e={};return this.cache.forEach((function(t,n){e[t]=n.value})),e}},{key:"_update",value:function(e,t){switch(e.type){case"live_query_item_updated":this.handleItemMutated(e.item_key,e.item_data,e.item_revision);break;case"live_query_item_removed":this.handleItemRemoved(e.item_key,e.item_revision);break;case"live_query_updated":this.handleBatchUpdate(e.items)}t&&this._advanceLastEventId(e.last_event_id)}},{key:"handleItemMutated",value:function(e,t,n){if(this.shouldIgnoreEvent(e,n))FM("Item ".concat(e," update skipped, revision: ").concat(n));else{var r={key:e,value:t};this.cache.store(e,r,n),this.broadcastEventToListeners("itemUpdated",r)}}},{key:"handleItemRemoved",value:function(e,t){var n=null===t;this.shouldIgnoreEvent(e,t)?FM("Item ".concat(e," delete skipped, revision: ").concat(t)):(this.cache.delete(e,t,n),this.broadcastEventToListeners("itemRemoved",{key:e}))}},{key:"handleBatchUpdate",value:function(e){var t=this,n={};for(var r in null!=e&&e.forEach((function(e){n[e.key]={data:e.data,revision:e.revision}})),this.cache.forEach((function(e,r){var i=n[e];null!=i?t.handleItemMutated(e,i.data,i.revision):t.handleItemRemoved(e,null),delete n[e]})),n)this.handleItemMutated(r,n[r].data,n[r].revision)}},{key:"shouldIgnoreEvent",value:function(e,t){return null!=e&&null!=t&&this.cache.isKnown(e,t)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e)}}],[{key:"type",get:function(){return"live_query"}}]),n}(sL);function qL(e){return BL.apply(this,arguments)}function BL(){return BL=fM.default(bM.default.mark((function e(t){var n,r,i,a,o,s;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.network,r=t.queryString,i=t.uri,a=t.type,null!=r){e.next=3;break}throw new SyncError("Invalid query",400,54507);case 3:return o={query_string:r},a===zL.type&&(o.type=a),e.next=7,n.post(i,o,void 0,!0);case 7:return s=e.sent,e.abrupt("return",s.body);case 9:case"end":return e.stop()}}),e)}))),BL.apply(this,arguments)}var zL=function(e){vM.default(n,e);var t=NL(n);function n(e){var r;return dM.default(this,n),(r=t.call(this)).liveQueryImpl=e,r.liveQueryImpl.attach(hM.default(r)),r}return pM.default(n,[{key:"type",get:function(){return DL.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){OM.default(mM.default(n.prototype),"close",this).call(this),this.liveQueryImpl.detach(this.listenerUuid)}},{key:"getItems",value:function(){return this.ensureNotClosed(),this.liveQueryImpl.getItems()}}],[{key:"type",get:function(){return DL.type}}]),n}(fL);gM.default(zL,"itemUpdated","itemUpdated"),gM.default(zL,"itemRemoved","itemRemoved");var WL=function(e){vM.default(i,e);var t,n,r=NL(i);function i(e){var t;return dM.default(this,i),t=r.call(this),gM.default(hM.default(t),"queryExpression",null),gM.default(hM.default(t),"items",{}),Object.assign(hM.default(t),e),t.updateIndexName(e.indexName),t}return pM.default(i,[{key:"type",get:function(){return i.type}},{key:"search",value:(n=fM.default(bM.default.mark((function e(t){var n=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.items={},e.abrupt("return",qL({network:this.network,uri:this.queryUri,queryString:t}).then((function(e){n.queryExpression=t,e.items&&e.items.forEach((function(e){n.items[e.key]=e.data})),n.emit("searchResult",n.getItems())})).catch((function(e){throw BM("Error '".concat(e.message,"' while executing query '").concat(t,"'")),n.queryExpression=null,e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"subscribe",value:(t=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=this.queryExpression){e.next=2;break}return e.abrupt("return",Promise.reject(new SyncError("Invalid query",400,54507)));case 2:return e.abrupt("return",this.liveQueryCreator(this.indexName,this.queryExpression));case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getItems",value:function(){return this.items}},{key:"updateIndexName",value:function(e){this.indexName=e,this.queryUri=this.generateQueryUri(this.indexName)}},{key:"generateQueryUri",value:function(e){return new IM(this.insightsUri).pathSegment(e).pathSegment("Items").build()}}],[{key:"type",get:function(){return"instant_query"}}]),i}(sM.ReplayEventEmitter);gM.default(WL,"searchResult","searchResult"),TM([Zj.validateTypesAsync("string"),RM("design:type",Function),RM("design:paramtypes",[String]),RM("design:returntype",Promise)],WL.prototype,"search",null),TM([Zj.validateTypes(Zj.nonEmptyString),RM("design:type",Function),RM("design:paramtypes",[String]),RM("design:returntype",void 0)],WL.prototype,"updateIndexName",null);function $L(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mM.default(e);if(t){var i=mM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return yM.default(this,n)}}function KL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function HL(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?KL(Object(n),!0).forEach((function(t){gM.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):KL(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var GL="data_sync",VL="3.2.2";function YL(e){if(e){if("string"==typeof e)return{id:e,mode:"open_or_create"};var t=e.mode||(e.id?"open_or_create":"create_new");return HL(HL({},e),{},{mode:t})}return{mode:"create_new"}}var JL="com.twilio.rtd.cds.document",QL="com.twilio.rtd.cds.list",XL="com.twilio.rtd.cds.map",ZL="twilio.sync.event",Client=function(e){vM.default(Client,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v,y=$L(Client);function Client(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(dM.default(this,Client),n=y.call(this),!e)throw new Error("Sync library needs a valid Twilio token to be passed");r.hasOwnProperty("logLevel")?NM(r.logLevel):NM("silent");var i=r.productId=r.productId||GL;r.clientMetadata=r.clientMetadata||{},r.clientMetadata.hasOwnProperty("type")||(r.clientMetadata.type="sync"),r.clientMetadata.hasOwnProperty("sdk")||(r.clientMetadata.sdk="JS",r.clientMetadata.sdkv=VL);var a=!r.twilsockClient;if(!r.initRegistrations){var o=new eM.InitRegistration(i);Client.populateInitRegistrations(o),r.initRegistrations=[o]}var s=r.twilsockClient=null!==(t=r.twilsockClient)&&void 0!==t?t:new eM.Twilsock(e,i,r);s.on("tokenAboutToExpire",(function(){return n.emit("tokenAboutToExpire")})),s.on("tokenExpired",(function(){return n.emit("tokenExpired")})),s.on("connectionError",(function(e){return n.emit("connectionError",e)})),s.on("stateChanged",(function(e){n.emit("connectionStateChanged",e),n.services.subscriptions.onConnectionStateChanged("connected"===e)})),s.on("message",(function(e,t){return n._routeMessage(e,t)}));var u=new YM(r),c=new rL(new LL(VL),u,s),l=new iL(u);return n.services={config:u,twilsock:s,network:c,storage:l,router:hM.default(n),subscriptions:null},n.services.subscriptions=new ZM(n.services),n.entities=new UL,a&&s.connect(),n}return pM.default(Client,[{key:"_routeMessage",value:function(e,t){switch(FM("Notification type:",e,"content:",t),e){case JL:case QL:case XL:this.services.subscriptions.acceptMessage(t,!1);break;case ZL:this.services.subscriptions.acceptMessage(t,!0)}}},{key:"_subscribe",value:function(e,t){this.services.subscriptions.add(e,t)}},{key:"_unsubscribe",value:function(e){this.services.subscriptions.remove(e)}},{key:"connectionState",get:function(){return this.services.twilsock.state}},{key:"ensureReady",value:(v=fM.default(bM.default.mark((function e(){var t;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.services.config.sessionStorageEnabled){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,this.services.twilsock.storageId();case 5:t=e.sent,this.services.storage.updateStorageId(t.id),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),qM("Failed to initialize storage",e.t0);case 12:case"end":return e.stop()}}),e,this,[[2,9]])}))),function(){return v.apply(this,arguments)})},{key:"storeRootInSessionCache",value:function(e,t,n){if(this.services.config.sessionStorageEnabled&&t){var r=AM(n);e!==TL.type&&e!==PL.type||(r.last_event_id=null,delete r.items),this.services.storage.store(e,t,r)}}},{key:"readRootFromSessionCache",value:function(e,t){return this.services.config.sessionStorageEnabled&&t?this.services.storage.read(e,t):null}},{key:"_get",value:(h=fM.default(bM.default.mark((function e(t,n){var r,i,a,o=arguments;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=o.length>2&&void 0!==o[2]&&o[2],n){e.next=3;break}throw new SyncError("Cannot get entity without id",404);case 3:return i=new IM(t).pathSegment(n).queryParam("Include",r?"items":void 0).build(),e.next=6,this.services.network.get(i);case 6:return a=e.sent,e.abrupt("return",a.body);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"_createDocument",value:function(e,t,n){var r={unique_name:e,data:t||{}};return void 0!==n&&(r.ttl=n),this.services.network.post(this.services.config.documentsUri,r).then((function(e){return e.body.data=r.data,e.body}))}},{key:"_getDocument",value:(p=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(hL.type,t)||this._get(this.services.config.documentsUri,t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"_createList",value:function(e,t,n,r){var i={unique_name:e,purpose:t,context:n};return void 0!==r&&(i.ttl=r),this.services.network.post(this.services.config.listsUri,i).then((function(e){return e.body}))}},{key:"_getList",value:(d=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(TL.type,t)||this._get(this.services.config.listsUri,t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"_createMap",value:function(e,t){var n={unique_name:e};return void 0!==t&&(n.ttl=t),this.services.network.post(this.services.config.mapsUri,n).then((function(e){return e.body}))}},{key:"_getMap",value:(f=fM.default(bM.default.mark((function e(t){var n,r=arguments;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.length>1&&void 0!==r[1]&&r[1],e.abrupt("return",this.readRootFromSessionCache(PL.type,t)||this._get(this.services.config.mapsUri,t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"_getStream",value:(l=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(ML.type,t)||this._get(this.services.config.streamsUri,t,!1));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"_createStream",value:(c=fM.default(bM.default.mark((function e(t,n){var r,i;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={unique_name:t},void 0!==n&&(r.ttl=n),e.next=4,this.services.network.post(this.services.config.streamsUri,r);case 4:return i=e.sent,e.abrupt("return",i.body);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"_getLiveQuery",value:function(e){return this.readRootFromSessionCache(zL.type,e)}},{key:"getCached",value:function(e,t){return e&&this.entities.get(e,t)||null}},{key:"removeFromCacheAndSession",value:function(e,t,n){this.entities.remove(t),this.services.config.sessionStorageEnabled&&this.services.storage.remove(e,t,n)}},{key:"document",value:(u=fM.default(bM.default.mark((function e(t){var n,r,i,a,o=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=YL(t)).mode){e.next=9;break}return e.next=6,this._createDocument(n.id,n.data,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,hL.type))){e.next=14;break}return e.abrupt("return",new hL(i));case 14:return e.prev=14,e.next=17,this._getDocument(n.id);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createDocument(n.id,n.data,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.document(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(hL.type,n.id,r),a=new pL(this.services,r,(function(e,t,n){return o.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new hL(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return u.apply(this,arguments)})},{key:"map",value:(s=fM.default(bM.default.mark((function e(t){var n,r,i,a,o=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=YL(t)).mode){e.next=9;break}return e.next=6,this._createMap(n.id,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,PL.type))){e.next=14;break}return e.abrupt("return",new PL(i));case 14:return e.prev=14,e.next=17,this._getMap(n.id,n.includeItems);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createMap(n.id,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.map(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(PL.type,n.id,r),a=new CL(this.services,r,(function(e,t,n){return o.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new PL(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return s.apply(this,arguments)})},{key:"list",value:(o=fM.default(bM.default.mark((function e(t){var n,r,i,a,o=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=YL(t)).mode){e.next=9;break}return e.next=6,this._createList(n.id,n.purpose,n.context,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,TL.type))){e.next=14;break}return e.abrupt("return",new TL(i));case 14:return e.prev=14,e.next=17,this._getList(n.id);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createList(n.id,n.purpose,n.context,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.list(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(TL.type,n.id,r),a=new EL(this.services,r,(function(e,t,n){return o.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new TL(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return o.apply(this,arguments)})},{key:"stream",value:(a=fM.default(bM.default.mark((function e(t){var n,r,i,a,o,s=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=YL(t)).mode){e.next=9;break}return e.next=6,this._createStream(n.id,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,ML.type))){e.next=14;break}return e.abrupt("return",new ML(i));case 14:return e.prev=14,e.next=17,this._getStream(n.id);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createStream(n.id,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.stream(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(ML.type,n.id,r),a=function(e,t,n){return s.removeFromCacheAndSession(e,t,n)},o=new jL(this.services,r,a),o=this.entities.store(o),e.abrupt("return",new ML(o));case 44:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return a.apply(this,arguments)})},{key:"shutdown",value:(i=fM.default(bM.default.mark((function e(){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.subscriptions.shutdown();case 2:return e.next=4,this.services.twilsock.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"updateToken",value:(r=fM.default(bM.default.mark((function e(t){return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.services.twilsock.updateToken(t).catch((function(e){var t,n=null==e||null===(t=e.reply)||void 0===t?void 0:t.status;if(401===(null==n?void 0:n.code)&&"UNAUTHORIZED"===(null==n?void 0:n.status))throw new SyncError("Updated token was rejected by server",400,51130);throw e})));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"liveQuery",value:(n=fM.default(bM.default.mark((function e(t,n){var r,i,a,o,s,u=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:return r=new IM(this.services.config.insightsUri).pathSegment(t).pathSegment("Items").build(),e.next=5,qL({network:this.services.network,uri:r,queryString:n,type:zL.type});case 5:return i=e.sent,(a=this.getCached(i.query_id,zL.type))||((o=this._getLiveQuery(i.query_id))||(o={indexName:t,queryExpression:n,sid:i.query_id,queryUri:r,last_event_id:i.last_event_id}),s=function(e,t,n){return u.removeFromCacheAndSession(e,t,n)},a=new DL(o,this.services,s,i.items)),this.storeRootInSessionCache(zL.type,i.query_id,a.liveQueryDescriptor),a=this.entities.store(a),e.abrupt("return",new zL(a));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"instantQuery",value:(t=fM.default(bM.default.mark((function e(t){var n,r=this;return bM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:return n=function(e,t){return r.liveQuery(e,t)},e.abrupt("return",new WL({indexName:t,network:this.services.network,insightsUri:this.services.config.insightsUri,liveQueryCreator:n}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}],[{key:"populateInitRegistrations",value:function(e){e.populateInitRegistrations([ZL,JL,QL,XL])}},{key:"version",get:function(){return VL}}]),Client}(sM.ReplayEventEmitter);gM.default(Client,"connectionStateChanged","connectionStateChanged"),gM.default(Client,"connectionError","connectionError"),gM.default(Client,"tokenAboutToExpire","tokenAboutToExpire"),gM.default(Client,"tokenExpired","tokenExpired"),TM([Zj.validateTypesAsync(["undefined","string",Zj.objectSchema("open document options",{id:["string","undefined"],mode:[Zj.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Zj.nonNegativeInteger,"undefined"],data:[Zj.pureObject,"undefined",Zj.literal(null)]})]),RM("design:type",Function),RM("design:paramtypes",[Object]),RM("design:returntype",Promise)],Client.prototype,"document",null),TM([Zj.validateTypesAsync(["undefined","string",Zj.objectSchema("open map options",{id:["string","undefined"],mode:[Zj.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Zj.nonNegativeInteger,"undefined"],data:[Zj.pureObject,"undefined",Zj.literal(null)],includeItems:["boolean","undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[Object]),RM("design:returntype",Promise)],Client.prototype,"map",null),TM([Zj.validateTypesAsync(["undefined","string",Zj.objectSchema("open list options",{id:["string","undefined"],mode:[Zj.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Zj.nonNegativeInteger,"undefined"],data:[Zj.pureObject,"undefined",Zj.literal(null)],purpose:["string","undefined"],context:[Zj.pureObject,"undefined"],includeItems:["boolean","undefined"]})]),RM("design:type",Function),RM("design:paramtypes",[Object]),RM("design:returntype",Promise)],Client.prototype,"list",null),TM([Zj.validateTypesAsync(["undefined","string",Zj.objectSchema("open stream options",{id:["string","undefined"],mode:[Zj.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Zj.nonNegativeInteger,"undefined"],data:[Zj.pureObject,"undefined",Zj.literal(null)]})]),RM("design:type",Function),RM("design:paramtypes",[Object]),RM("design:returntype",Promise)],Client.prototype,"stream",null),TM([Zj.validateTypesAsync(Zj.nonEmptyString),RM("design:type",Function),RM("design:paramtypes",[String]),RM("design:returntype",Promise)],Client.prototype,"updateToken",null),TM([Zj.validateTypesAsync(Zj.nonEmptyString,"string"),RM("design:type",Function),RM("design:paramtypes",[String,String]),RM("design:returntype",Promise)],Client.prototype,"liveQuery",null),TM([Zj.validateTypesAsync(Zj.nonEmptyString),RM("design:type",Function),RM("design:paramtypes",[String]),RM("design:returntype",Promise)],Client.prototype,"instantQuery",null),dj.Client=Client,dj.InsightsItem=FL,dj.InstantQuery=WL,dj.LiveQuery=zL,dj.Paginator=Paginator;var eU=dj.SyncClient=Client;dj.SyncDocument=hL,dj.SyncList=TL,dj.SyncListItem=vL,dj.SyncMap=PL,dj.SyncMapItem=RL,dj.SyncStream=ML;var tU={},nU=_e,rU=Be,iU=L,aU=pr,oU=TypeError,sU=function(e){return function(t,n,r,i){nU(n);var a=rU(t),o=iU(a),s=aU(a),u=e?s-1:0,c=e?-1:1;if(r<2)for(;;){if(u in o){i=o[u],u+=c;break}if(u+=c,e?u<0:s<=u)throw oU("Reduce of empty array with no initial value")}for(;e?u>=0:s>u;u+=c)u in o&&(i=n(i,o[u],u,a));return i}},uU={left:sU(!1),right:sU(!0)},cU=uU.left,lU=ue,fU=fc;ni({target:"Array",proto:!0,forced:!Sp("reduce")||!fU&&lU>79&&lU<83},{reduce:function(e){var t=arguments.length;return cU(this,e,t,t>1?arguments[1]:void 0)}});var dU=pi,pU=f,hU=C,vU=Ag,yU=Ft,mU=U,gU=yR,bU=D,wU=Pc,kU=Mg,xU=fr,_U=za,SU=Ee,OU=Za,EU=Yg,TU=_g,RU=o,IU=Jm.UNSUPPORTED_Y,CU=4294967295,PU=Math.min,AU=[].push,jU=hU(/./.exec),MU=hU(AU),LU=hU("".slice),UU=!RU((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]}));function NU(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}vU("split",(function(e,t,n){var r;return r="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(e,n){var r=_U(bU(this)),i=void 0===n?CU:n>>>0;if(0===i)return[];if(void 0===e)return[r];if(!gU(e))return pU(t,r,e,i);for(var a,o,s,u=[],c=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),l=0,f=new RegExp(e.source,c+"g");(a=pU(TU,f,r))&&!((o=f.lastIndex)>l&&(MU(u,LU(r,l,a.index)),a.length>1&&a.index<r.length&&dU(AU,u,OU(a,1)),s=a[0].length,l=o,u.length>=i));)f.lastIndex===a.index&&f.lastIndex++;return l===r.length?!s&&jU(f,"")||MU(u,""):MU(u,LU(r,l)),u.length>i?OU(u,0,i):u}:"0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:pU(t,this,e,n)}:t,[function(t,n){var i=bU(this),a=mU(t)?void 0:SU(t,e);return a?pU(a,t,i,n):pU(r,_U(i),t,n)},function(e,i){var a=yU(this),o=_U(e),s=n(r,a,o,i,r!==t);if(s.done)return s.value;var u=wU(a,RegExp),c=a.unicode,l=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.unicode?"u":"")+(IU?"g":"y"),f=new u(IU?"^(?:"+a.source+")":a,l),d=void 0===i?CU:i>>>0;if(0===d)return[];if(0===o.length)return null===EU(f,o)?[o]:[];for(var p=0,h=0,v=[];h<o.length;){f.lastIndex=IU?0:h;var y,m=EU(f,IU?LU(o,h):o);if(null===m||(y=PU(xU(f.lastIndex+(IU?h:0)),o.length))===p)h=kU(o,h,c);else{if(MU(v,LU(o,p,h)),v.length===d)return v;for(var g=1;g<=m.length-1;g++)if(MU(v,m[g]),v.length===d)return v;h=p=y}}return MU(v,LU(o,p)),v}]}),!UU,IU),function(e){var t=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Object.defineProperty(e,"__esModule",{value:!0});var n=BS,r=DS.exports,i=sx.exports,a=qS,o=sy.exports,s=Q_,u=Mb;function c(e){return e&&"object"===Xu(e)&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var f=c(r),d=c(i),p=c(a),h=l(o);function v(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":Xu(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function y(e,t){if("object"===("undefined"==typeof Reflect?"undefined":Xu(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function m(e,t){return["".concat((new Date).toISOString()," MCS Client ").concat(e,":")].concat(Array.from(t))}var g=function(){function e(t){rc(this,e),d.default(this,"prefix",""),this.prefix=null!=t&&t.length>0?t+" ":""}return nc(e,[{key:"setLevel",value:function(e){h.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.trace.apply(null,m(this.prefix+"T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.debug.apply(null,m(this.prefix+"D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.info.apply(null,m(this.prefix+"I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.warn.apply(null,m(this.prefix+"W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.error.apply(null,m(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){h.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.trace.apply(null,m("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.debug.apply(null,m("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.info.apply(null,m("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.warn.apply(null,m("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.error.apply(null,m("E",t))}}]),e}(),b=function(e,t){return"".concat((n=e,n.startsWith("http")?"":function(e){return"https://mcs.".concat(null!=e?e:"us1",".twilio.com")}(t))).concat(e);var n},w=function(){function e(t,n,r,i){var a,o,s,u,c,l;rc(this,e),d.default(this,"token",void 0),d.default(this,"retryWhenThrottledOverride",void 0),d.default(this,"backoffConfigOverride",void 0),d.default(this,"mediaUrl",void 0),d.default(this,"mediaSetUrl",void 0),d.default(this,"region",void 0);var f=null!==(a=null!==(o=i.MCS)&&void 0!==o?o:i)&&void 0!==a?a:{};this.region=null!==(s=null!==(u=f.region)&&void 0!==u?u:i.region)&&void 0!==s?s:"us1",this.mediaUrl=b(n,this.region),this.mediaSetUrl=r?b(r):"".concat(this.mediaUrl,"Set"),this.token=t,this.retryWhenThrottledOverride=null===(c=f.retryWhenThrottledOverride)||void 0===c||c,this.backoffConfigOverride=null!==(l=f.backoffConfigOverride)&&void 0!==l?l:e.backoffConfigDefault}return nc(e,[{key:"updateToken",value:function(e){this.token=e}}],[{key:"backoffConfigDefault",get:function(){return{min:1e3,max:4e3,maxAttemptsCount:3}}},{key:"retryWhenThrottledDefault",get:function(){return true}}]),e}(),Media=function(){function Media(e,t,n){rc(this,Media),d.default(this,"state",void 0),d.default(this,"network",void 0),d.default(this,"config",void 0),this.config=e,this.network=t,this._update(n)}return nc(Media,[{key:"sid",get:function(){return this.state.sid}},{key:"serviceSid",get:function(){return this.state.serviceSid}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"fileName",get:function(){return this.state.filename}},{key:"filename",get:function(){return this.state.filename}},{key:"category",get:function(){return this.state.category}},{key:"getContentUrl",value:function(){var e=this;return new n.CancellablePromise(function(){var t=f.default(p.default.mark((function t(n,r,i){var a,o;return p.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.network.get("".concat(e.config.mediaUrl,"/").concat(e.sid)),i((function(){return a.cancel()})),t.prev=2,t.next=5,a;case 5:o=t.sent,e._update(o.body),n(e.state.contentDirectUrl),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),r(t.t0);case 13:case"end":return t.stop()}}),t,null,[[2,10]])})));return function(e,n,r){return t.apply(this,arguments)}}())}},{key:"_update",value:function(e){var t,n,r,i;this.state={sid:e.sid,serviceSid:e.service_sid,channelSid:e.channel_sid,messageSid:e.message_sid,dateCreated:e.date_created?new Date(e.date_created):null,dateUploadUpdated:e.date_upload_updated?new Date(e.date_upload_updated):null,dateUpdated:e.date_updated?new Date(e.date_updated):null,size:e.size,contentType:e.content_type,author:e.author,url:e.url,contentUrl:e.links.content,contentDirectUrl:null!==(t=e.links.content_direct_temporary)&&void 0!==t?t:null,filename:null!==(n=e.filename)&&void 0!==n?n:null,category:null!==(r=e.category)&&void 0!==r?r:"media",isMultipartUpstream:null!==(i=e.is_multipart_upstream)&&void 0!==i&&i}}}]),Media}(),k=function(e){Qu(n,e);var t=NU(n);function n(e,r,i,a,o){var s;return rc(this,n),s=t.call(this,e),d.default(Yu(s),"code",void 0),d.default(Yu(s),"body",void 0),d.default(Yu(s),"status",void 0),d.default(Yu(s),"headers",void 0),s.code=r,s.body=i,s.status=a,s.headers=o,s}return nc(n)}(NT(Error)),x=t.XMLHttpRequest||{};var _,S=function(){function e(){rc(this,e)}return nc(e,[{key:"get",value:function(t,n){return e.request("GET",t,n)}},{key:"post",value:function(t,n,r){return e.request("POST",t,n,r)}}],[{key:"request",value:function(e,t,r,i){return new n.CancellablePromise((function(n,a,o){var s=new x,u=!1;for(var c in o((function(){s.abort(),u=!0})),s.open(e,t,!0),s.onreadystatechange=function(){if(4===s.readyState&&!u){var e,t=(e=s.getAllResponseHeaders())?e.split("\r\n").map((function(e){return e.split(": ")})).filter((function(e){return 2===e.length&&e[1].length>0})).reduce((function(e,t){return e[t[0]]=t[1],e}),{}):{},r=function(e){var t=e.getResponseHeader("Content-Type");if(!t||0!==t.indexOf("application/json")||0===e.responseText.length)return e.responseText;try{return JSON.parse(e.responseText)}catch(t){return e.responseText}}(s);if(200<=s.status&&s.status<300)n({status:s.status,headers:t,body:r});else{var i,o,c=null!==(i=s.statusText)&&void 0!==i?i:"NONE";if("string"==typeof r)if(r&&1===r.split("\n",2).length)o=r;else{var l,f=null===(l=r.replace(/<.*?>/g,"").split(/\r\n/g).filter((function(e){return e.length}))[0])||void 0===l?void 0:l.split(" ");o=(null==f?void 0:f.length)>2?null==f?void 0:f.slice(1).join(" "):""}else o=JSON.stringify(r);var d="".concat(s.status,": [").concat(c,"] ").concat(o);a(new k(d,s.status,r,c,t))}}},r)s.setRequestHeader(c,r[c]),"Content-Type"===c&&"application/json"===r[c]&&(i=JSON.stringify(i));s.send(i)}))}}]),e}(),O=g.scope("Network"),E=function(){function e(t,n){rc(this,e),d.default(this,"config",void 0),d.default(this,"transport",void 0),this.config=t,this.transport=n}return nc(e,[{key:"backoffConfig",value:function(){return Object.assign(w.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var e,t;return null!==(e=null!==(t=this.config.retryWhenThrottledOverride)&&void 0!==t?t:w.retryWhenThrottledDefault)&&void 0!==e&&e}},{key:"executeWithRetry",value:function(e,t){var r=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(i,a,o){var u,c;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:u=new s.Retrier(r.backoffConfig()),c=[502,503,504],t&&c.push(429),o((function(){u.cancel(),u.removeAllListeners()})),u.on("attempt",f.default(p.default.mark((function t(){var n,r;return p.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n=e(),o((function(){n.cancel(),u.cancel(),u.removeAllListeners()})),t.next=5,n;case 5:r=t.sent,u.succeeded(r),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(0),c.indexOf(t.t0.status)>-1||"Twilsock disconnected"===t.t0.message?u.failed(t.t0):(u.removeAllListeners(),u.cancel(),a(t.t0));case 12:case"end":return t.stop()}}),t,null,[[0,9]])})))),u.on("succeeded",(function(e){i(e)})),u.on("cancelled",(function(e){return a(e)})),u.on("failed",(function(e){return a(e)})),u.start();case 9:case"end":return n.stop()}}),n)})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"get",value:function(e){var t=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(r,i,a){var o,s,u;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o={"X-Twilio-Token":t.config.token},s=t.executeWithRetry((function(){return t.transport.get(e,o)}),t.retryWhenThrottled()),O.trace("sending GET request to ",e," headers ",o),a((function(){return s.cancel()})),n.prev=4,n.next=7,s;case 7:u=n.sent,O.trace("response",u),r(u),n.next=16;break;case 12:n.prev=12,n.t0=n.catch(4),O.debug("get() error ".concat(n.t0)),i(n.t0);case 16:case"end":return n.stop()}}),n,null,[[4,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"post",value:function(e,r,i,a,o){var s=this,u={"X-Twilio-Token":this.config.token};"undefined"!=typeof FormData&&i instanceof FormData||!a||Object.assign(u,{"Content-Type":a});var c=new URL(e);return r&&c.searchParams.append("Category",r),o&&c.searchParams.append("Filename",o),new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(r,a,o){var l,f;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return l=s.transport.post(c.href,u,i),o((function(){return l.cancel()})),O.trace("sending POST request to ".concat(e," with headers ").concat(u)),n.prev=3,n.next=6,l;case 6:f=n.sent,n.next=17;break;case 9:if(n.prev=9,n.t0=n.catch(3),!(void 0===t.XMLHttpRequest&&i instanceof FormData)){n.next=14;break}return a(new TypeError("Posting FormData supported only with browser engine's FormData")),n.abrupt("return");case 14:return O.debug("post() error ".concat(n.t0)),a(n.t0),n.abrupt("return");case 17:O.trace("response",f),r(f);case 19:case"end":return n.stop()}}),n,null,[[3,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}}]),e}(),T=g.scope("");e.default=(_=function(){function Client(e,t,n){var r,i;rc(this,Client);var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};d.default(this,"transport",void 0),d.default(this,"options",void 0),d.default(this,"network",void 0),d.default(this,"config",void 0),this.options=a,this.options.logLevel=null!==(r=this.options.logLevel)&&void 0!==r?r:"silent",this.config=new w(e,t,n,this.options),T.setLevel(this.options.logLevel),this.options.transport=null!==(i=this.options.transport)&&void 0!==i?i:new S,this.transport=this.options.transport,this.network=new E(this.config,this.transport)}return nc(Client,[{key:"updateToken",value:function(e){T.info("updateToken"),this.config.updateToken(e)}},{key:"get",value:function(e){var t=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(r,i,a){var o,s;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=t.network.get("".concat(t.config.mediaUrl,"/").concat(e)),a((function(){return o.cancel()})),n.prev=2,n.next=5,o;case 5:s=n.sent,r(new Media(t.config,t.network,s.body)),n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),i(n.t0);case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"post",value:function(e,t,r,i){var a=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(o,s,u){var c,l;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return c=a.network.post(a.config.mediaUrl,null!=r?r:"media",t,e,i),u((function(){return c.cancel()})),n.prev=2,n.next=5,c;case 5:l=n.sent,o(new Media(a.config,a.network,l.body)),n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),s(n.t0);case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"postFormData",value:function(e,t){var r=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(i,a,o){var s,u;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s=r.network.post(r.config.mediaUrl,null!=t?t:"media",e),o((function(){return s.cancel()})),n.prev=2,n.next=5,s;case 5:u=n.sent,i(new Media(r.config,r.network,u.body)),n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),a(n.t0);case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"mediaSetGet",value:function(e){var t=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(r,i,a){var o,s,u,c;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o={command:"get",list:e.map((function(e){return{media_sid:e}}))},s=t.network.post("".concat(t.config.mediaSetUrl),null,o,"application/json"),a((function(){return s.cancel()})),n.prev=3,n.next=6,s;case 6:u=n.sent,c=u.body.map((function(e){if(200===e.code)return new Media(t.config,t.network,e.media_record);i("Failed to obtain detailed information about Media items (failed SID ".concat(e.media_record.sid,")"))})),r(c),n.next=14;break;case 11:n.prev=11,n.t0=n.catch(3),i(n.t0);case 14:case"end":return n.stop()}}),n,null,[[3,11]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"mediaSetGetContentUrls",value:function(e){var t=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(r,i,a){var o,s,u,c;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o={command:"get",list:e.map((function(e){return{media_sid:e}}))},s=t.network.post("".concat(t.config.mediaSetUrl),null,o,"application/json"),a((function(){return s.cancel()})),n.prev=3,n.next=6,s;case 6:u=n.sent,c=new Map,u.body.forEach((function(e){200===e.code?c.set(e.media_record.sid,e.media_record.links.content_direct_temporary):i("Failed to obtain detailed information about Media items (failed SID ".concat(e.media_record.sid,")"))})),r(c),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(3),i(n.t0);case 15:case"end":return n.stop()}}),n,null,[[3,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}}]),Client}(),d.default(_,"version","0.6.1"),_),v([u.validateTypes(u.nonEmptyString),y("design:type",Function),y("design:paramtypes",[String]),y("design:returntype",void 0)],e.default.prototype,"updateToken",null),v([u.validateTypesAsync(u.nonEmptyString),y("design:type",Function),y("design:paramtypes",[String]),y("design:returntype",n.CancellablePromise)],e.default.prototype,"get",null),e.default=v([u.validateConstructorTypes(u.nonEmptyString,u.nonEmptyString,[u.nonEmptyString,u.literal(null)],[u.pureObject,"undefined"]),y("design:paramtypes",[String,String,Object,Object])],e.default),Object.defineProperty(e,"CancellablePromise",{enumerable:!0,get:function(){return n.CancellablePromise}}),e.Client=e.default,e.McsClient=e.default,e.McsMedia=Media,e.Media=Media}(tU);var FU,DU,qU,BU={exports:{}},zU=jO,WU=s,$U=i,KU=H,HU=Y,GU=$e,VU=Li,YU=be,JU=Xt,QU=Xn,XU=jt.f,ZU=ee,eN=dv,tN=gc,nN=ot,rN=Ye,iN=Ln.enforce,aN=Ln.get,oN=$U.Int8Array,sN=oN&&oN.prototype,uN=$U.Uint8ClampedArray,cN=uN&&uN.prototype,lN=oN&&eN(oN),fN=sN&&eN(sN),dN=Object.prototype,pN=$U.TypeError,hN=nN("toStringTag"),vN=rN("TYPED_ARRAY_TAG"),yN="TypedArrayConstructor",mN=zU&&!!tN&&"Opera"!==VU($U.opera),gN=!1,bN={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},wN={BigInt64Array:8,BigUint64Array:8},kN=function(e){var t=eN(e);if(HU(t)){var n=aN(t);return n&&GU(n,yN)?n.TypedArrayConstructor:kN(t)}},xN=function(e){if(!HU(e))return!1;var t=VU(e);return GU(bN,t)||GU(wN,t)};for(FU in bN)(qU=(DU=$U[FU])&&DU.prototype)?iN(qU).TypedArrayConstructor=DU:mN=!1;for(FU in wN)(qU=(DU=$U[FU])&&DU.prototype)&&(iN(qU).TypedArrayConstructor=DU);if((!mN||!KU(lN)||lN===Function.prototype)&&(lN=function(){throw pN("Incorrect invocation")},mN))for(FU in bN)$U[FU]&&tN($U[FU],lN);if((!mN||!fN||fN===dN)&&(fN=lN.prototype,mN))for(FU in bN)$U[FU]&&tN($U[FU].prototype,fN);if(mN&&eN(cN)!==fN&&tN(cN,fN),WU&&!GU(fN,hN))for(FU in gN=!0,XU(fN,hN,{get:function(){return HU(this)?this[vN]:void 0}}),bN)$U[FU]&&JU($U[FU],vN,FU);var _N={NATIVE_ARRAY_BUFFER_VIEWS:mN,TYPED_ARRAY_TAG:gN&&vN,aTypedArray:function(e){if(xN(e))return e;throw pN("Target is not a typed array")},aTypedArrayConstructor:function(e){if(KU(e)&&(!tN||ZU(lN,e)))return e;throw pN(YU(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(WU){if(n)for(var i in bN){var a=$U[i];if(a&&GU(a.prototype,e))try{delete a.prototype[e]}catch(n){try{a.prototype[e]=t}catch(e){}}}fN[e]&&!n||QU(fN,e,n?t:mN&&sN[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(WU){if(tN){if(n)for(r in bN)if((i=$U[r])&&GU(i,e))try{delete i[e]}catch(e){}if(lN[e]&&!n)return;try{return QU(lN,e,n?t:mN&&lN[e]||t)}catch(e){}}for(r in bN)!(i=$U[r])||i[e]&&!n||QU(i,e,t)}},getTypedArrayConstructor:kN,isView:function(e){if(!HU(e))return!1;var t=VU(e);return"DataView"===t||GU(bN,t)||GU(wN,t)},isTypedArray:xN,TypedArray:lN,TypedArrayPrototype:fN},SN=i,ON=o,EN=zd,TN=_N.NATIVE_ARRAY_BUFFER_VIEWS,RN=SN.ArrayBuffer,IN=SN.Int8Array,CN=!TN||!ON((function(){IN(1)}))||!ON((function(){new IN(-1)}))||!EN((function(e){new IN,new IN(null),new IN(1.5),new IN(e)}),!0)||ON((function(){return 1!==new IN(new RN(2),1,void 0).length})),PN=ir,AN=RangeError,jN=function(e){var t=PN(e);if(t<0)throw AN("The argument can't be less than 0");return t},MN=RangeError,LN=function(e,t){var n=jN(e);if(n%t)throw MN("Wrong offset");return n},UN=Li,NN=C("".slice),FN=ht,DN=TypeError,qN=function(e){var t=FN(e,"number");if("number"==typeof t)throw DN("Can't convert number to bigint");return BigInt(t)},BN=wo,zN=f,WN=Zi,$N=Be,KN=pr,HN=bd,GN=dd,VN=od,YN=function(e){return"Big"===NN(UN(e),0,3)},JN=_N.aTypedArrayConstructor,QN=qN,XN=ni,ZN=i,eF=f,tF=s,nF=CN,rF=_N,iF=YE,aF=Ec,oF=g,sF=Xt,uF=ek,cF=fr,lF=NO,fF=LN,dF=mt,pF=$e,hF=Li,vF=Y,yF=me,mF=_a,gF=ee,bF=gc,wF=Zn.f,kF=function(e){var t,n,r,i,a,o,s,u,c=WN(this),l=$N(e),f=arguments.length,d=f>1?arguments[1]:void 0,p=void 0!==d,h=GN(l);if(h&&!VN(h))for(u=(s=HN(l,h)).next,l=[];!(o=zN(u,s)).done;)l.push(o.value);for(p&&f>2&&(d=BN(d,arguments[2])),n=KN(l),r=new(JN(c))(n),i=YN(r),t=0;n>t;t++)a=p?d(l[t],t):l[t],r[t]=i?QN(a):+a;return r},xF=No.forEach,_F=_c,SF=jt,OF=a,EF=rm,TF=Ln.get,RF=Ln.set,IF=Ln.enforce,CF=SF.f,PF=OF.f,AF=Math.round,jF=ZN.RangeError,MF=iF.ArrayBuffer,LF=MF.prototype,UF=iF.DataView,NF=rF.NATIVE_ARRAY_BUFFER_VIEWS,FF=rF.TYPED_ARRAY_TAG,DF=rF.TypedArray,qF=rF.TypedArrayPrototype,BF=rF.aTypedArrayConstructor,zF=rF.isTypedArray,WF="BYTES_PER_ELEMENT",$F="Wrong length",KF=function(e,t){BF(e);for(var n=0,r=t.length,i=new e(r);r>n;)i[n]=t[n++];return i},HF=function(e,t){CF(e,t,{get:function(){return TF(this)[t]}})},GF=function(e){var t;return gF(LF,e)||"ArrayBuffer"==(t=hF(e))||"SharedArrayBuffer"==t},VF=function(e,t){return zF(e)&&!yF(t)&&t in e&&uF(+t)&&t>=0},YF=function(e,t){return t=dF(t),VF(e,t)?oF(2,e[t]):PF(e,t)},JF=function(e,t,n){return t=dF(t),!(VF(e,t)&&vF(n)&&pF(n,"value"))||pF(n,"get")||pF(n,"set")||n.configurable||pF(n,"writable")&&!n.writable||pF(n,"enumerable")&&!n.enumerable?CF(e,t,n):(e[t]=n.value,e)};tF?(NF||(OF.f=YF,SF.f=JF,HF(qF,"buffer"),HF(qF,"byteOffset"),HF(qF,"byteLength"),HF(qF,"length")),XN({target:"Object",stat:!0,forced:!NF},{getOwnPropertyDescriptor:YF,defineProperty:JF}),BU.exports=function(e,t,n){var r=e.match(/\d+$/)[0]/8,i=e+(n?"Clamped":"")+"Array",a="get"+e,o="set"+e,s=ZN[i],u=s,c=u&&u.prototype,l={},f=function(e,t){CF(e,t,{get:function(){return function(e,t){var n=TF(e);return n.view[a](t*r+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var a=TF(e);n&&(i=(i=AF(i))<0?0:i>255?255:255&i),a.view[o](t*r+a.byteOffset,i,!0)}(this,t,e)},enumerable:!0})};NF?nF&&(u=t((function(e,t,n,i){return aF(e,c),EF(vF(t)?GF(t)?void 0!==i?new s(t,fF(n,r),i):void 0!==n?new s(t,fF(n,r)):new s(t):zF(t)?KF(u,t):eF(kF,u,t):new s(lF(t)),e,u)})),bF&&bF(u,DF),xF(wF(s),(function(e){e in u||sF(u,e,s[e])})),u.prototype=c):(u=t((function(e,t,n,i){aF(e,c);var a,o,s,l=0,d=0;if(vF(t)){if(!GF(t))return zF(t)?KF(u,t):eF(kF,u,t);a=t,d=fF(n,r);var p=t.byteLength;if(void 0===i){if(p%r)throw jF($F);if((o=p-d)<0)throw jF($F)}else if((o=cF(i)*r)+d>p)throw jF($F);s=o/r}else s=lF(t),a=new MF(o=s*r);for(RF(e,{buffer:a,byteOffset:d,byteLength:o,length:s,view:new UF(a)});l<s;)f(e,l++)})),bF&&bF(u,DF),c=u.prototype=mF(qF)),c.constructor!==u&&sF(c,"constructor",u),IF(c).TypedArrayConstructor=u,FF&&sF(c,FF,i);var d=u!=s;l[i]=u,XN({global:!0,constructor:!0,forced:d,sham:!NF},l),WF in u||sF(u,WF,r),WF in c||sF(c,WF,r),_F(i)}):BU.exports=function(){},(0,BU.exports)("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}));var QF=pr,XF=ir,ZF=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("at",(function(e){var t=ZF(this),n=QF(t),r=XF(e),i=r>=0?r:n+r;return i<0||i>=n?void 0:t[i]}));var eD=be,tD=TypeError,nD=function(e,t){if(!delete e[t])throw tD("Cannot delete property "+eD(t)+" of "+eD(e))},rD=Be,iD=ur,aD=pr,oD=nD,sD=Math.min,uD=[].copyWithin||function(e,t){var n=rD(this),r=aD(n),i=iD(e,r),a=iD(t,r),o=arguments.length>2?arguments[2]:void 0,s=sD((void 0===o?r:iD(o,r))-a,r-i),u=1;for(a<i&&i<a+s&&(u=-1,a+=s-1,i+=s-1);s-- >0;)a in n?n[i]=n[a]:oD(n,i),i+=u,a+=u;return n},cD=_N,lD=C(uD),fD=cD.aTypedArray;(0,cD.exportTypedArrayMethod)("copyWithin",(function(e,t){return lD(fD(this),e,t,arguments.length>2?arguments[2]:void 0)}));var dD=No.every,pD=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("every",(function(e){return dD(pD(this),e,arguments.length>1?arguments[1]:void 0)}));var hD=VO,vD=qN,yD=Li,mD=f,gD=o,bD=_N.aTypedArray,wD=_N.exportTypedArrayMethod,kD=C("".slice);wD("fill",(function(e){var t=arguments.length;bD(this);var n="Big"===kD(yD(this),0,3)?vD(e):+e;return mD(hD,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),gD((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})));var xD=pr,_D=Pc,SD=_N.aTypedArrayConstructor,OD=_N.getTypedArrayConstructor,ED=function(e){return SD(_D(e,OD(e)))},TD=function(e,t){for(var n=0,r=xD(t),i=new e(r);r>n;)i[n]=t[n++];return i},RD=ED,ID=No.filter,CD=function(e,t){return TD(RD(e),t)},PD=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("filter",(function(e){var t=ID(PD(this),e,arguments.length>1?arguments[1]:void 0);return CD(this,t)}));var AD=No.find,jD=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("find",(function(e){return AD(jD(this),e,arguments.length>1?arguments[1]:void 0)}));var MD=No.findIndex,LD=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("findIndex",(function(e){return MD(LD(this),e,arguments.length>1?arguments[1]:void 0)}));var UD=wo,ND=L,FD=Be,DD=pr,qD=function(e){var t=1==e;return function(n,r,i){for(var a,o=FD(n),s=ND(o),u=UD(r,i),c=DD(s);c-- >0;)if(u(a=s[c],c,o))switch(e){case 0:return a;case 1:return c}return t?-1:void 0}},BD={findLast:qD(0),findLastIndex:qD(1)},zD=BD.findLast,WD=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("findLast",(function(e){return zD(WD(this),e,arguments.length>1?arguments[1]:void 0)}));var $D=BD.findLastIndex,KD=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("findLastIndex",(function(e){return $D(KD(this),e,arguments.length>1?arguments[1]:void 0)}));var HD=No.forEach,GD=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("forEach",(function(e){HD(GD(this),e,arguments.length>1?arguments[1]:void 0)}));var VD=gr.includes,YD=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("includes",(function(e){return VD(YD(this),e,arguments.length>1?arguments[1]:void 0)}));var JD=gr.indexOf,QD=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("indexOf",(function(e){return JD(QD(this),e,arguments.length>1?arguments[1]:void 0)}));var XD=i,ZD=o,eq=C,tq=_N,nq=By,rq=ot("iterator"),iq=XD.Uint8Array,aq=eq(nq.values),oq=eq(nq.keys),sq=eq(nq.entries),uq=tq.aTypedArray,cq=tq.exportTypedArrayMethod,lq=iq&&iq.prototype,fq=!ZD((function(){lq[rq].call([1])})),dq=!!lq&&lq.values&&lq[rq]===lq.values&&"values"===lq.values.name,pq=function(){return aq(uq(this))};cq("entries",(function(){return sq(uq(this))}),fq),cq("keys",(function(){return oq(uq(this))}),fq),cq("values",pq,fq||!dq,{name:"values"}),cq(rq,pq,fq||!dq,{name:"values"});var hq=_N.aTypedArray,vq=_N.exportTypedArrayMethod,yq=C([].join);vq("join",(function(e){return yq(hq(this),e)}));var mq=pi,gq=z,bq=ir,wq=pr,kq=Sp,xq=Math.min,_q=[].lastIndexOf,Sq=!!_q&&1/[1].lastIndexOf(1,-0)<0,Oq=kq("lastIndexOf"),Eq=Sq||!Oq?function(e){if(Sq)return mq(_q,this,arguments)||0;var t=gq(this),n=wq(t),r=n-1;for(arguments.length>1&&(r=xq(r,bq(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:_q,Tq=pi,Rq=Eq,Iq=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("lastIndexOf",(function(e){var t=arguments.length;return Tq(Rq,Iq(this),t>1?[e,arguments[1]]:[e])}));var Cq=No.map,Pq=ED,Aq=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("map",(function(e){return Cq(Aq(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(Pq(e))(t)}))}));var jq=uU.left,Mq=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("reduce",(function(e){var t=arguments.length;return jq(Mq(this),e,t,t>1?arguments[1]:void 0)}));var Lq=uU.right,Uq=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("reduceRight",(function(e){var t=arguments.length;return Lq(Uq(this),e,t,t>1?arguments[1]:void 0)}));var Nq=_N.aTypedArray,Fq=_N.exportTypedArrayMethod,Dq=Math.floor;Fq("reverse",(function(){for(var e,t=this,n=Nq(t).length,r=Dq(n/2),i=0;i<r;)e=t[i],t[i++]=t[--n],t[n]=e;return t}));var qq=i,Bq=f,zq=_N,Wq=pr,$q=LN,Kq=Be,Hq=o,Gq=qq.RangeError,Vq=qq.Int8Array,Yq=Vq&&Vq.prototype,Jq=Yq&&Yq.set,Qq=zq.aTypedArray,Xq=zq.exportTypedArrayMethod,Zq=!Hq((function(){var e=new Uint8ClampedArray(2);return Bq(Jq,e,{length:1,0:3},1),3!==e[1]})),eB=Zq&&zq.NATIVE_ARRAY_BUFFER_VIEWS&&Hq((function(){var e=new Vq(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));Xq("set",(function(e){Qq(this);var t=$q(arguments.length>1?arguments[1]:void 0,1),n=Kq(e);if(Zq)return Bq(Jq,this,n,t);var r=this.length,i=Wq(n),a=0;if(i+t>r)throw Gq("Wrong length");for(;a<i;)this[t+a]=n[a++]}),!Zq||eB);var tB=ED,nB=hi,rB=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("slice",(function(e,t){for(var n=nB(rB(this),e,t),r=tB(this),i=0,a=n.length,o=new r(a);a>i;)o[i]=n[i++];return o}),o((function(){new Int8Array(1).slice()})));var iB=No.some,aB=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("some",(function(e){return iB(aB(this),e,arguments.length>1?arguments[1]:void 0)}));var oB=te.match(/firefox\/(\d+)/i),sB=!!oB&&+oB[1],uB=/MSIE|Trident/.test(te),cB=te.match(/AppleWebKit\/(\d+)\./),lB=!!cB&&+cB[1],fB=C,dB=o,pB=_e,hB=HI,vB=sB,yB=uB,mB=ue,gB=lB,bB=_N.aTypedArray,wB=_N.exportTypedArrayMethod,kB=i.Uint16Array,xB=kB&&fB(kB.prototype.sort),_B=!(!xB||dB((function(){xB(new kB(2),null)}))&&dB((function(){xB(new kB(2),{})}))),SB=!!xB&&!dB((function(){if(mB)return mB<74;if(vB)return vB<67;if(yB)return!0;if(gB)return gB<602;var e,t,n=new kB(516),r=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,r[e]=e-2*t+3;for(xB(n,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==r[e])return!0}));wB("sort",(function(e){return void 0!==e&&pB(e),SB?xB(this,e):hB(bB(this),function(e){return function(t,n){return void 0!==e?+e(t,n)||0:n!=n?-1:t!=t?1:0===t&&0===n?1/t>0&&1/n<0?1:-1:t>n}}(e))}),!SB||_B);var OB=fr,EB=ur,TB=ED,RB=_N.aTypedArray;(0,_N.exportTypedArrayMethod)("subarray",(function(e,t){var n=RB(this),r=n.length,i=EB(e,r);return new(TB(n))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,OB((void 0===t?r:EB(t,r))-i))}));var IB=pi,CB=_N,PB=o,AB=hi,jB=i.Int8Array,MB=CB.aTypedArray,LB=CB.exportTypedArrayMethod,UB=[].toLocaleString,NB=!!jB&&PB((function(){UB.call(new jB(1))}));LB("toLocaleString",(function(){return IB(UB,NB?AB(MB(this)):MB(this),AB(arguments))}),PB((function(){return[1,2].toLocaleString()!=new jB([1,2]).toLocaleString()}))||!PB((function(){jB.prototype.toLocaleString.call([1,2])})));var FB=_N.exportTypedArrayMethod,DB=o,qB=C,BB=i.Uint8Array,zB=BB&&BB.prototype||{},WB=[].toString,$B=qB([].join);DB((function(){WB.call({})}))&&(WB=function(){return $B(this)});var KB=zB.toString!=WB;function HB(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}FB("toString",WB,KB);var GB=dy.scope("Participant"),Participant=function(e){Qu(Participant,e);var t,n,r,i=HB(Participant);function Participant(e,t,n,r,a){var o,s,u;if(rc(this,Participant),ic(Yu(u=i.call(this)),"state",void 0),ic(Yu(u),"links",void 0),ic(Yu(u),"services",void 0),ic(Yu(u),"conversation",void 0),u.conversation=n,u.links=r,u.services=a,u.state={attributes:Ab(e.attributes,"Retrieved malformed attributes from the server for participant: "+t,GB),dateCreated:e.dateCreated?Pb(e.dateCreated):null,dateUpdated:e.dateCreated?Pb(e.dateUpdated):null,sid:t,typingTimeout:null,isTyping:!1,identity:e.identity,roleSid:null!==(o=e.roleSid)&&void 0!==o?o:"",lastReadMessageIndex:Number.isInteger(e.lastConsumedMessageIndex)?e.lastConsumedMessageIndex:null,lastReadTimestamp:e.lastConsumptionTimestamp?Pb(e.lastConsumptionTimestamp):null,type:e.type||"chat",userInfo:e.userInfo,bindings:null!==(s=e.bindings)&&void 0!==s?s:{}},!e.identity&&!e.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return u}return nc(Participant,[{key:"sid",get:function(){return this.state.sid}},{key:"attributes",get:function(){return this.state.attributes}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"identity",get:function(){return this.state.identity}},{key:"isTyping",get:function(){return this.state.isTyping}},{key:"lastReadMessageIndex",get:function(){return this.state.lastReadMessageIndex}},{key:"lastReadTimestamp",get:function(){return this.state.lastReadTimestamp}},{key:"roleSid",get:function(){return this.state.roleSid}},{key:"type",get:function(){return this.state.type}},{key:"bindings",get:function(){var e;return null!==(e=this.state.bindings)&&void 0!==e?e:{}}},{key:"_startTyping",value:function(e){var t=this;return this.state.typingTimeout&&clearTimeout(this.state.typingTimeout),this.state.isTyping=!0,this.emit("typingStarted",this),this.conversation.emit("typingStarted",this),this.state.typingTimeout=Number(setTimeout((function(){return t._endTyping()}),e)),this}},{key:"_endTyping",value:function(){this.state.typingTimeout&&(this.state.isTyping=!1,this.emit("typingEnded",this),this.conversation.emit("typingEnded",this),clearInterval(this.state.typingTimeout),this.state.typingTimeout=null)}},{key:"_update",value:function(e){var t=[],n=Ab(e.attributes,"Retrieved malformed attributes from the server for participant: "+this.state.sid,GB);e.attributes&&!zx(this.state.attributes,n)&&(this.state.attributes=n,t.push("attributes"));var r=Pb(e.dateUpdated);e.dateUpdated&&(null==r?void 0:r.getTime())!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=r,t.push("dateUpdated"));var i=Pb(e.dateCreated);if(e.dateCreated&&(null==i?void 0:i.getTime())!==(this.state.dateCreated&&this.state.dateCreated.getTime())&&(this.state.dateCreated=i,t.push("dateCreated")),e.roleSid&&this.state.roleSid!==e.roleSid&&(this.state.roleSid=e.roleSid,t.push("roleSid")),!Number.isInteger(e.lastConsumedMessageIndex)&&null!==e.lastConsumedMessageIndex||this.state.lastReadMessageIndex===e.lastConsumedMessageIndex||(this.state.lastReadMessageIndex=e.lastConsumedMessageIndex,t.push("lastReadMessageIndex")),e.lastConsumptionTimestamp){var a=new Date(e.lastConsumptionTimestamp);this.state.lastReadTimestamp&&this.state.lastReadTimestamp.getTime()===a.getTime()||(this.state.lastReadTimestamp=a,t.push("lastReadTimestamp"))}return e.bindings&&!zx(this.state.bindings,e.bindings)&&(this.state.bindings=e.bindings,t.push("bindings")),t.length>0&&this.emit("updated",{participant:this,updateReasons:t}),this}},{key:"getUser",value:(r=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("chat"==this.type){e.next=2;break}throw new Error("Getting User is not supported for this Participant type: "+this.type);case 2:return e.abrupt("return",this.services.users.getUser(this.state.identity,this.state.userInfo));case 3:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"remove",value:(n=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.conversation.removeParticipant(this));case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"updateAttributes",value:(t=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(t)});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),Participant}(qx);function VB(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}ic(Participant,"typingStarted","typingStarted"),ic(Participant,"typingEnded","typingEnded"),ic(Participant,"updated","updated"),dh([tx(nx),ph("design:type",Function),ph("design:paramtypes",[Object]),ph("design:returntype",Promise)],Participant.prototype,"updateAttributes",null);var YB=dy.scope("Participants"),JB=function(e){Qu(l,e);var t,n,r,i,a,o,s,u,c=VB(l);function l(e,t,n,r,i){var a;return rc(this,l),ic(Yu(a=c.call(this)),"configuration",void 0),ic(Yu(a),"services",void 0),ic(Yu(a),"links",void 0),ic(Yu(a),"rosterEntityPromise",null),ic(Yu(a),"conversation",void 0),ic(Yu(a),"participants",void 0),a.conversation=e,a.participants=t,a.links=n,a.configuration=r,a.services=i,a}return nc(l,[{key:"unsubscribe",value:(u=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.rosterEntityPromise){e.next=6;break}return e.next=3,this.rosterEntityPromise;case 3:e.sent.close(),this.rosterEntityPromise=null;case 6:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"subscribe",value:function(e){var t=this,n="string"==typeof e?this.services.syncClient.map({id:e,mode:"open_existing"}):Promise.resolve(e);return this.rosterEntityPromise=this.rosterEntityPromise||n.then((function(e){e.on("itemAdded",(function(e){YB.debug(t.conversation.sid+" itemAdded: "+e.item.key),t.upsertParticipant(e.item.key,e.item.data).then((function(e){t.emit("participantJoined",e)}))})),e.on("itemRemoved",(function(e){YB.debug(t.conversation.sid+" itemRemoved: "+e.key);var n=e.key;if(t.participants.has(n)){var r=t.participants.get(n);t.participants.delete(n),r&&t.emit("participantLeft",r)}})),e.on("itemUpdated",(function(e){YB.debug(t.conversation.sid+" itemUpdated: "+e.item.key),t.upsertParticipant(e.item.key,e.item.data)}));var n=[];return e.getItems().then((function e(r){return r.items.forEach((function(e){n.push(t.upsertParticipant(e.key,e.data))})),r.hasNextPage?r.nextPage().then(e):null})).then((function(){return Promise.all(n)})).then((function(){return e}))})).catch((function(e){throw t.rosterEntityPromise=null,"disconnected"!=t.services.syncClient.connectionState&&YB.error("Failed to get roster object for conversation",t.conversation.sid,e),YB.debug("ERROR: Failed to get roster object for conversation",t.conversation.sid,e),e}))}},{key:"upsertParticipantFromResponse",value:(s=Vu(lh.mark((function e(t){var n,r,i,a,o,s,u,c;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.sid,i=t.attributes,a=t.date_created,o=t.date_updated,s=t.identity,u=t.role_sid,c=t.messaging_binding,e.next=3,this.upsertParticipant(r,{attributes:i,dateCreated:new Date(a),dateUpdated:new Date(o),identity:s,roleSid:u,lastConsumedMessageIndex:null,lastConsumptionTimestamp:null,type:null!==(n=null==c?void 0:c.type)&&void 0!==n?n:"chat"});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"upsertParticipant",value:(o=Vu(lh.mark((function e(t,n){var r,i,a=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.participants.get(t))){e.next=3;break}return e.abrupt("return",r._update(n));case 3:return i={self:"".concat(this.links.participants,"/").concat(t)},r=new Participant(n,t,this.conversation,i,this.services),this.participants.set(t,r),r.on("updated",(function(e){return a.emit("participantUpdated",e)})),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getParticipants",value:(a=Vu(lh.mark((function e(){var t=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then((function(){var e=[];return t.participants.forEach((function(t){return e.push(t)})),e})):[]);case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getParticipantBySid",value:(i=Vu(lh.mark((function e(t){var n=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then((function(){var e=n.participants.get(t);if(!e)throw new Error("Participant with SID "+t+" was not found");return e})):null);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getParticipantByIdentity",value:(r=Vu(lh.mark((function e(t){var n,r=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null,e.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then((function(){if(r.participants.forEach((function(e){e.identity===t&&(n=e)})),!n)throw new Error("Participant with identity "+t+" was not found");return n})):null);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"add",value:(n=Vu(lh.mark((function e(t,n){var r;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.participants,{identity:t,attributes:void 0!==n?JSON.stringify(n):void 0});case 2:return r=e.sent,e.next=5,this.upsertParticipantFromResponse(r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"addNonChatParticipant",value:(t=Vu(lh.mark((function e(t,n){var r,i,a,o,s,u=arguments;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=u.length>2&&void 0!==u[2]?u[2]:{},o=u.length>3&&void 0!==u[3]?u[3]:{},e.next=4,this.services.commandExecutor.mutateResource("post",this.links.participants,{attributes:void 0!==a?JSON.stringify(a):void 0,messaging_binding:{address:n,proxy_address:t,name:null==o||null===(r=o.email)||void 0===r?void 0:r.name,level:null==o||null===(i=o.email)||void 0===i?void 0:i.level}});case 4:return s=e.sent,e.next=7,this.upsertParticipantFromResponse(s);case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"remove",value:function(e){return this.services.commandExecutor.mutateResource("delete","".concat(this.links.participants,"/").concat(e))}}]),l}(qx),QB=ni,XB=C,ZB=_e,ez=Be,tz=pr,nz=nD,rz=za,iz=o,az=HI,oz=Sp,sz=sB,uz=uB,cz=ue,lz=lB,fz=[],dz=XB(fz.sort),pz=XB(fz.push),hz=iz((function(){fz.sort(void 0)})),vz=iz((function(){fz.sort(null)})),yz=oz("sort"),mz=!iz((function(){if(cz)return cz<70;if(!(sz&&sz>3)){if(uz)return!0;if(lz)return lz<603;var e,t,n,r,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(r=0;r<47;r++)fz.push({k:t+r,v:n})}for(fz.sort((function(e,t){return t.v-e.v})),r=0;r<fz.length;r++)t=fz[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));QB({target:"Array",proto:!0,forced:hz||!vz||!yz||!mz},{sort:function(e){void 0!==e&&ZB(e);var t=ez(this);if(mz)return void 0===e?dz(t):dz(t,e);var n,r,i=[],a=tz(t);for(r=0;r<a;r++)r in t&&pz(i,t[r]);for(az(i,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:rz(t)>rz(n)?1:-1}}(e)),n=tz(i),r=0;r<n;)t[r]=i[r++];for(;r<a;)nz(t,r++);return t}});var gz=ni,bz=bR,wz=D,kz=za,xz=kR,_z=C("".indexOf);gz({target:"String",proto:!0,forced:!xz("includes")},{includes:function(e){return!!~_z(kz(wz(this)),kz(bz(e)),arguments.length>1?arguments[1]:void 0)}});var Media=function(){function Media(e,t){rc(this,Media),ic(this,"state",void 0),ic(this,"services",void 0),ic(this,"mcsMedia",null),this.services=t,e instanceof tU.McsMedia&&(this.mcsMedia=e),this.state={sid:e.sid,category:e.category,filename:e.filename,contentType:e.contentType,size:e.size}}return nc(Media,[{key:"sid",get:function(){return this.state.sid}},{key:"filename",get:function(){return this.state.filename}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"category",get:function(){return this.state.category}},{key:"getContentTemporaryUrl",value:function(){var e=this;return new tU.CancellablePromise(function(){var t=Vu(lh.mark((function t(n,r,i){var a,o,s,u;return lh.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=e._fetchMcsMedia(),s=null===(a=e.mcsMedia)||void 0===a?void 0:a.getContentUrl(),i((function(){o.cancel(),s&&s.cancel()})),t.prev=3,e.mcsMedia){t.next=9;break}return t.next=7,o;case 7:u=t.sent,s=u.getContentUrl();case 9:if(t.t0=n,!s){t.next=16;break}return t.next=13,s;case 13:t.t1=t.sent,t.next=17;break;case 16:t.t1=null;case 17:t.t2=t.t1,(0,t.t0)(t.t2),t.next=24;break;case 21:t.prev=21,t.t3=t.catch(3),r(t.t3);case 24:case"end":return t.stop()}}),t,null,[[3,21]])})));return function(e,n,r){return t.apply(this,arguments)}}())}},{key:"_fetchMcsMedia",value:function(){var e=this;return new tU.CancellablePromise(function(){var t=Vu(lh.mark((function t(n,r,i){var a;return lh.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.services.mcsClient.get(e.state.sid),!e.services.mcsClient){t.next=14;break}return i((function(){return a.cancel()})),t.prev=3,t.next=6,a;case 6:e.mcsMedia=t.sent,n(e.mcsMedia),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(3),r(t.t0);case 13:return t.abrupt("return");case 14:r(new Error("Media Content Service is unavailable"));case 15:case"end":return t.stop()}}),t,null,[[3,10]])})));return function(e,n,r){return t.apply(this,arguments)}}())}}]),Media}(),AggregatedDeliveryReceipt=function(){function AggregatedDeliveryReceipt(e){rc(this,AggregatedDeliveryReceipt),ic(this,"state",void 0),this.state=e}return nc(AggregatedDeliveryReceipt,[{key:"total",get:function(){return this.state.total}},{key:"sent",get:function(){return this.state.sent}},{key:"delivered",get:function(){return this.state.delivered}},{key:"read",get:function(){return this.state.read}},{key:"undelivered",get:function(){return this.state.undelivered}},{key:"failed",get:function(){return this.state.failed}},{key:"_update",value:function(e){this.state=e}},{key:"_isEquals",value:function(e){var t=this.total===e.total,n=this.sent===e.sent,r=this.delivered===e.delivered,i=this.read===e.read,a=this.undelivered===e.undelivered,o=this.failed===e.failed;return t&&n&&r&&i&&a&&o}}]),AggregatedDeliveryReceipt}(),Sz=function(){function e(t,n,r,i){rc(this,e),ic(this,"state",void 0),this.state={prevToken:r,nextToken:i,source:n,items:t}}return nc(e,[{key:"hasNextPage",get:function(){return!!this.state.nextToken}},{key:"hasPrevPage",get:function(){return!!this.state.prevToken}},{key:"items",get:function(){return this.state.items}},{key:"nextPage",value:function(){return this.hasNextPage?this.state.source(this.state.nextToken):Promise.reject(new Error("No next page"))}},{key:"prevPage",value:function(){return this.hasPrevPage?this.state.source(this.state.prevToken):Promise.reject(new Error("No previous page"))}}]),e}(),DetailedDeliveryReceipt=nc((function DetailedDeliveryReceipt(e){rc(this,DetailedDeliveryReceipt),ic(this,"sid",void 0),ic(this,"messageSid",void 0),ic(this,"conversationSid",void 0),ic(this,"channelMessageSid",void 0),ic(this,"participantSid",void 0),ic(this,"status",void 0),ic(this,"errorCode",void 0),ic(this,"dateCreated",void 0),ic(this,"dateUpdated",void 0),this.sid=e.sid,this.messageSid=e.message_sid,this.conversationSid=e.conversation_sid,this.channelMessageSid=e.channel_message_sid,this.participantSid=e.participant_sid,this.status=e.status||"queued",this.errorCode=e.error_code||0,this.dateCreated=e.date_created,this.dateUpdated=e.date_updated}));function Oz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ez(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Oz(Object(n),!0).forEach((function(t){ic(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Oz(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Tz(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}var Rz=dy.scope("Message"),Message=function(e){Qu(Message,e);var t,n,r,i,a,o,s=Tz(Message);function Message(e,t,n,r,i,a){var o,u,c,l,f;return rc(this,Message),ic(Yu(f=s.call(this)),"conversation",void 0),ic(Yu(f),"links",void 0),ic(Yu(f),"configuration",void 0),ic(Yu(f),"services",void 0),ic(Yu(f),"state",void 0),f.conversation=n,f.links=r,f.configuration=i,f.services=a,f.state={sid:t.sid,index:e,author:t.author,subject:t.subject,body:null!==(o=t.text)&&void 0!==o?o:null,timestamp:t.timestamp?new Date(t.timestamp):null,dateUpdated:t.dateUpdated?new Date(t.dateUpdated):null,lastUpdatedBy:null!==(u=t.lastUpdatedBy)&&void 0!==u?u:null,attributes:Ab(t.attributes,"Got malformed attributes for the message ".concat(t.sid),Rz),type:null!==(c=t.type)&&void 0!==c?c:"text",media:"media"===t.type&&t.media?new Media(t.media,f.services):null,medias:"media"===t.type&&t.medias?t.medias.map((function(e){return new Media(e,f.services)})):"media"===t.type&&t.media&&!t.medias?[new Media(Ez(Ez({},t.media),{},{category:"media"}),f.services)]:null,participantSid:null!==(l=t.memberSid)&&void 0!==l?l:null,aggregatedDeliveryReceipt:t.delivery?new AggregatedDeliveryReceipt(t.delivery):null},f}return nc(Message,[{key:"sid",get:function(){return this.state.sid}},{key:"author",get:function(){return this.state.author}},{key:"subject",get:function(){return this.state.subject}},{key:"body",get:function(){return this.state.body}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"index",get:function(){return this.state.index}},{key:"lastUpdatedBy",get:function(){return this.state.lastUpdatedBy}},{key:"dateCreated",get:function(){return this.state.timestamp}},{key:"attributes",get:function(){return this.state.attributes}},{key:"type",get:function(){return this.state.type}},{key:"media",get:function(){return this.state.media}},{key:"attachedMedia",get:function(){return this.getMediaByCategories(["media"])}},{key:"participantSid",get:function(){return this.state.participantSid}},{key:"aggregatedDeliveryReceipt",get:function(){return this.state.aggregatedDeliveryReceipt}},{key:"getMediaByCategories",value:function(e){var t;return(null!==(t=this.state.medias)&&void 0!==t?t:[]).filter((function(t){return e.includes(t.category)}))}},{key:"getEmailBody",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"text/plain";return null!==(e=null===(t=this.getMediaByCategories(["body"]))||void 0===t?void 0:t.filter((function(e){return e.contentType==n})).shift())&&void 0!==e?e:null}},{key:"getEmailHistory",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"text/plain";return null!==(e=null===(t=this.getMediaByCategories(["history"]))||void 0===t?void 0:t.filter((function(e){return e.contentType==n})).shift())&&void 0!==e?e:null}},{key:"_update",value:function(e){var t=[];!e.text&&"string"!=typeof e.text||e.text===this.state.body||(this.state.body=e.text,t.push("body")),e.subject&&e.subject!==this.state.subject&&(this.state.subject=e.subject,t.push("subject")),e.lastUpdatedBy&&e.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=e.lastUpdatedBy,t.push("lastUpdatedBy")),e.author&&e.author!==this.state.author&&(this.state.author=e.author,t.push("author")),e.dateUpdated&&new Date(e.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(e.dateUpdated),t.push("dateUpdated")),e.timestamp&&new Date(e.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(e.timestamp),t.push("dateCreated"));var n=Ab(e.attributes,"Got malformed attributes for the message ".concat(this.sid),Rz);zx(this.state.attributes,n)||(this.state.attributes=n,t.push("attributes"));var r=e.delivery,i=this.state.aggregatedDeliveryReceipt;!!(r&&r.total&&r.delivered&&r.failed&&r.read&&r.sent&&r.undelivered)&&(i?i._isEquals(r)||(i._update(r),t.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new AggregatedDeliveryReceipt(r),t.push("deliveryReceipt"))),t.length>0&&this.emit("updated",{message:this,updateReasons:t})}},{key:"getParticipant",value:(o=Vu(lh.mark((function e(){var t,n,r=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=null,!this.state.participantSid){e.next=5;break}return e.next=4,this.conversation.getParticipantBySid(this.state.participantSid).catch((function(){return Rz.debug('Participant with sid "'.concat(r.participantSid,'" not found for message ').concat(r.sid)),null}));case 4:t=e.sent;case 5:if(t||!this.state.author){e.next=9;break}return e.next=8,this.conversation.getParticipantByIdentity(this.state.author).catch((function(){return Rz.debug('Participant with identity "'.concat(r.author,'" not found for message ').concat(r.sid)),null}));case 8:t=e.sent;case 9:if(!t){e.next=11;break}return e.abrupt("return",t);case 11:throw n="Participant with ",this.state.participantSid&&(n+="SID '"+this.state.participantSid+"' "),this.state.author&&(this.state.participantSid&&(n+="or "),n+="identity '"+this.state.author+"' "),"Participant with "===n&&(n="Participant "),n+="was not found",new Error(n);case 17:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"getDetailedDeliveryReceipts",value:(a=Vu(lh.mark((function e(){var t,n;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getDetailedDeliveryReceiptsPaginator();case 2:t=e.sent,n=t.items;case 4:if(!t.hasNextPage){e.next=11;break}return e.next=7,t.nextPage();case 7:t=e.sent,n=[].concat(UR(n),UR(t.items)),e.next=4;break;case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"remove",value:(i=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("delete",this.links.self);case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"updateBody",value:(r=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{body:t});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"updateAttributes",value:(n=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:void 0!==t?JSON.stringify(t):void 0});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"getTemporaryContentUrlsForMedia",value:function(e){var t=e.map((function(e){return e.sid}));return this.getTemporaryContentUrlsForMediaSids(t)}},{key:"getTemporaryContentUrlsForMediaSids",value:function(e){var t=this;return new tU.CancellablePromise(function(){var n=Vu(lh.mark((function n(r,i,a){var o,s;return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o=t.services.mcsClient.mediaSetGetContentUrls(null!=e?e:[]),t.services.mcsClient&&e){n.next=4;break}return i(new Error("Media Content Service is unavailable")),n.abrupt("return");case 4:return a((function(){o.cancel()})),n.prev=5,n.next=8,o;case 8:s=n.sent,r(s),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(5),i(n.t0);case 15:case"end":return n.stop()}}),n,null,[[5,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForAttachedMedia",value:function(){var e,t=this.attachedMedia,n=null!==(e=null==t?void 0:t.map((function(e){return e.sid})))&&void 0!==e?e:[];return this.getTemporaryContentUrlsForMediaSids(n)}},{key:"_getDetailedDeliveryReceiptsPaginator",value:(t=Vu(lh.mark((function e(t){var n,r,i,a=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.configuration.links.messagesReceipts.replace("%s",this.conversation.sid).replace("%s",this.sid),r=new jb(n).arg("PageToken",null==t?void 0:t.pageToken).arg("PageSize",null==t?void 0:t.pageSize).build(),e.next=4,this.services.network.get(r);case 4:return i=e.sent,e.abrupt("return",new Sz(i.body.delivery_receipts.map((function(e){return new DetailedDeliveryReceipt(e)})),(function(e,t){return a._getDetailedDeliveryReceiptsPaginator({pageToken:e,pageSize:t})}),i.body.meta.previous_token,i.body.meta.next_token));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),Message}(qx);function Iz(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Cz(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Cz(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Cz(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Pz(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}ic(Message,"updated","updated"),dh([ex([Yk,"undefined"]),ph("design:type",Function),ph("design:paramtypes",[Object]),ph("design:returntype",Media)],Message.prototype,"getEmailBody",null),dh([ex([Yk,"undefined"]),ph("design:type",Function),ph("design:paramtypes",[Object]),ph("design:returntype",Media)],Message.prototype,"getEmailHistory",null),dh([tx("string"),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],Message.prototype,"updateBody",null),dh([tx(nx),ph("design:type",Function),ph("design:paramtypes",[Object]),ph("design:returntype",Promise)],Message.prototype,"updateAttributes",null),dh([tx(Vk("media",Media)),ph("design:type",Function),ph("design:paramtypes",[Array]),ph("design:returntype",tU.CancellablePromise)],Message.prototype,"getTemporaryContentUrlsForMedia",null),dh([tx(Vk("strings","string")),ph("design:type",Function),ph("design:paramtypes",[Array]),ph("design:returntype",tU.CancellablePromise)],Message.prototype,"getTemporaryContentUrlsForMediaSids",null);var Az=dy.scope("Messages"),jz=function(e){Qu(u,e);var t,n,r,i,a,o,s=Pz(u);function u(e,t,n){var r;return rc(this,u),ic(Yu(r=s.call(this)),"conversation",void 0),ic(Yu(r),"configuration",void 0),ic(Yu(r),"services",void 0),ic(Yu(r),"messagesByIndex",void 0),ic(Yu(r),"messagesListPromise",void 0),r.conversation=e,r.configuration=t,r.services=n,r.messagesByIndex=new Map,r.messagesListPromise=null,r}return nc(u,[{key:"subscribe",value:(o=Vu(lh.mark((function e(t){var n,r=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.messagesListPromise){e.next=2;break}return e.abrupt("return",this.messagesListPromise);case 2:return this.messagesListPromise="string"==typeof t?this.services.syncClient.list({id:t,mode:"open_existing"}):Promise.resolve(t),e.prev=3,e.next=6,this.messagesListPromise;case 6:return(n=e.sent).on("itemAdded",(function(e){Az.debug("".concat(r.conversation.sid," itemAdded: ").concat(e.item.index)),r._upsertMessage(e.item.index,e.item.data)})),n.on("itemRemoved",(function(e){Az.debug("#{this.conversation.sid} itemRemoved: ".concat(e.index));var t=e.index;if(r.messagesByIndex.has(t)){var n=r.messagesByIndex.get(t);if(!n)return;r.messagesByIndex.delete(n.index),n.removeAllListeners("updated"),r.emit("messageRemoved",n)}})),n.on("itemUpdated",(function(e){Az.debug("".concat(r.conversation.sid," itemUpdated: ").concat(e.item.index));var t=r.messagesByIndex.get(e.item.index);t&&t._update(e.item.data)})),e.abrupt("return",n);case 13:throw e.prev=13,e.t0=e.catch(3),this.messagesListPromise=null,"disconnected"!==this.services.syncClient.connectionState&&Az.error("Failed to get messages object for conversation",this.conversation.sid,e.t0),Az.debug("ERROR: Failed to get messages object for conversation",this.conversation.sid,e.t0),e.t0;case 19:case"end":return e.stop()}}),e,this,[[3,13]])}))),function(e){return o.apply(this,arguments)})},{key:"unsubscribe",value:(a=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.messagesListPromise){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.messagesListPromise;case 4:e.sent.close(),this.messagesListPromise=null;case 7:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"sendV2",value:function(e){var t=this;return Az.debug("Sending message V2",e.mediaContent,e.attributes,e.emailOptions),new tU.CancellablePromise(function(){var n=Vu(lh.mark((function n(r,i,a){var o,s,u,c,l,f,d,p,h,v,y,m;return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:s=[],u=[],a((function(){u.forEach((function(e){return e.cancel()}))})),c=Iz(e.mediaContent),n.prev=4,c.s();case 6:if((l=c.n()).done){n.next=25;break}return f=Gx(l.value,2),d=f[0],p=f[1],n.prev=8,Az.debug("Adding media to a message as ".concat(p instanceof FormData?"FormData":"SendMediaOptions"),p),y=p instanceof FormData?t.services.mcsClient.postFormData(p,d):t.services.mcsClient.post(null!==(h=p.contentType)&&void 0!==h?h:"",null!==(v=p.media)&&void 0!==v?v:"",d,p.filename),u.push(y),n.t0=s,n.next=15,y;case 15:n.t1=n.sent,n.t0.push.call(n.t0,n.t1),n.next=23;break;case 19:return n.prev=19,n.t2=n.catch(8),i(n.t2),n.abrupt("return");case 23:n.next=6;break;case 25:n.next=30;break;case 27:n.prev=27,n.t3=n.catch(4),c.e(n.t3);case 30:return n.prev=30,c.f(),n.finish(30);case 33:return m=t.services.commandExecutor.mutateResource("post",t.conversation._links.messages,{body:e.text,subject:null===(o=e.emailOptions)||void 0===o?void 0:o.subject,media_sids:s.map((function(e){return e.sid})),attributes:void 0!==e.attributes?JSON.stringify(e.attributes):void 0}),n.prev=34,n.t4=r,n.next=38,m;case 38:n.t5=n.sent,(0,n.t4)(n.t5),n.next=45;break;case 42:n.prev=42,n.t6=n.catch(34),i(n.t6);case 45:case"end":return n.stop()}}),n,null,[[4,27,30,33],[8,19],[34,42]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"send",value:(i=Vu(lh.mark((function e(t){var n,r,i=arguments;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:{},r=i.length>2?i[2]:void 0,Az.debug("Sending text message",t,n,r),e.abrupt("return",this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{body:null!=t?t:"",attributes:void 0!==n?JSON.stringify(n):void 0,subject:null==r?void 0:r.subject}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendMedia",value:(r=Vu(lh.mark((function e(t){var n,r,i,a,o,s=arguments;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=s.length>1&&void 0!==s[1]?s[1]:{},a=s.length>2?s[2]:void 0,Az.debug("Sending media message",t,i,a),Az.debug("Sending media message as ".concat(t instanceof FormData?"FormData":"SendMediaOptions"),t,i),!(t instanceof FormData)){e.next=10;break}return e.next=7,this.services.mcsClient.postFormData(t);case 7:e.t0=e.sent,e.next=13;break;case 10:return e.next=12,this.services.mcsClient.post(null!==(n=t.contentType)&&void 0!==n?n:"",null!==(r=t.media)&&void 0!==r?r:"","media",t.filename);case 12:e.t0=e.sent;case 13:return o=e.t0,e.next=16,this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{media_sids:[o.sid],attributes:void 0!==i?JSON.stringify(i):void 0});case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getMessages",value:(n=Vu(lh.mark((function e(t,n){var r,i=arguments;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>2&&void 0!==i[2]?i[2]:"backwards",e.abrupt("return",this._getMessages(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_wrapPaginator",value:function(e,t,n){var r=this,i="desc"===e,a=function(){return t.nextPage().then((function(t){return r._wrapPaginator(e,t,n)}))},o=function(){return t.prevPage().then((function(t){return r._wrapPaginator(e,t,n)}))};return n(t.items).then((function(e){return{items:e.sort((function(e,t){return e.index-t.index})),hasPrevPage:i?t.hasNextPage:t.hasPrevPage,hasNextPage:i?t.hasPrevPage:t.hasNextPage,prevPage:i?a:o,nextPage:i?o:a}}))}},{key:"_upsertMessage",value:function(e,t){var n=this,r=this.messagesByIndex.get(e);if(r)return Az.debug("Attempted to upsert a message, but it is already known and therefore ignored",this.conversation.sid),r;var i={self:"".concat(this.conversation._links.messages,"/").concat(t.sid),conversation:this.conversation._links.self,messages_receipts:"".concat(this.conversation._links.messages,"/").concat(t.sid,"/Receipts")},a=new Message(e,t,this.conversation,i,this.configuration,this.services);return this.messagesByIndex.set(a.index,a),a.on("updated",(function(e){return n.emit("messageUpdated",e)})),this.emit("messageAdded",a),a}},{key:"_getMessages",value:(t=Vu(lh.mark((function e(){var t,n,r,i,a,o,s=this,u=arguments;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:30,n=u.length>1&&void 0!==u[1]?u[1]:"end",r=u.length>2&&void 0!==u[2]?u[2]:"forward",i="backwards"===r?"desc":"asc",e.next=6,this.messagesListPromise;case 6:return a=e.sent,e.next=9,null==a?void 0:a.getItems({from:"end"!==n?n:void 0,pageSize:t,order:i,limit:t});case 9:return o=e.sent,e.next=12,this._wrapPaginator(i,o,(function(e){return Promise.all(e.map((function(e){return s._upsertMessage(e.index,e.data)})))}));case 12:return e.abrupt("return",e.sent);case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),u}(qx),Mz=function(){function e(t){rc(this,e),ic(this,"messagesEntity",void 0),ic(this,"text",void 0),ic(this,"attributes",{}),ic(this,"mediaContent",[]),ic(this,"emailOptions",{}),this.messagesEntity=t}return nc(e,[{key:"send",value:function(){var e=this;return new tU.CancellablePromise(function(){var t=Vu(lh.mark((function t(n,r,i){var a,o;return lh.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.messagesEntity.sendV2(e),i((function(){return a.cancel()})),t.prev=2,t.next=5,a;case 5:o=t.sent,n(Cb(o.index)),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),r(t.t0);case 12:case"end":return t.stop()}}),t,null,[[2,9]])})));return function(e,n,r){return t.apply(this,arguments)}}())}}]),e}(),Lz=function(){function e(t,n){rc(this,e),ic(this,"limits",void 0),ic(this,"message",void 0),ic(this,"emailBodies",void 0),ic(this,"emailHistories",void 0),this.limits=t,this.message=new Mz(n),this.emailBodies=new Map,this.emailHistories=new Map}return nc(e,[{key:"setBody",value:function(e){return this.message.text=e,this}},{key:"setSubject",value:function(e){return this.message.emailOptions.subject=e,this}},{key:"setAttributes",value:function(e){return this.message.attributes=e,this}},{key:"setEmailBody",value:function(e,t){return this.emailBodies.set(e,t),this}},{key:"setEmailHistory",value:function(e,t){return this.emailHistories.set(e,t),this}},{key:"addMedia",value:function(e){if("undefined"==typeof FormData&&e instanceof FormData)throw new Error("Could not add FormData content whilst not in a browser");if(!(e instanceof FormData)){var t=e;if(!t.contentType||!t.media)throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media")}return this.message.mediaContent.push(["media",e]),this}},{key:"build",value:function(){var e=this;if(this.emailBodies.forEach((function(t,n){if(!e.limits.emailBodiesAllowedContentTypes.includes(n))throw new Error("Unsupported email body content type ".concat(n))})),this.emailHistories.forEach((function(t,n){if(!e.limits.emailHistoriesAllowedContentTypes.includes(n))throw new Error("Unsupported email history content type ".concat(n))})),this.emailBodies.size>this.limits.emailBodiesAllowedContentTypes.length)throw new Error("Too many email bodies attached to the message (".concat(this.emailBodies.size," > ").concat(this.limits.emailBodiesAllowedContentTypes.length,")"));if(this.emailHistories.size>this.limits.emailHistoriesAllowedContentTypes.length)throw new Error("Too many email histories attached to the message (".concat(this.emailHistories.size," > ").concat(this.limits.emailHistoriesAllowedContentTypes.length,")"));if(this.message.mediaContent.length>this.limits.mediaAttachmentsCountLimit)throw new Error("Too many media attachments in the message (".concat(this.message.mediaContent.length," > ").concat(this.limits.mediaAttachmentsCountLimit,")"));return this.emailBodies.forEach((function(t){e.message.mediaContent.push(["body",t])})),this.emailHistories.forEach((function(t){e.message.mediaContent.push(["history",t])})),this.message}},{key:"buildAndSend",value:function(){return this.build().send()}},{key:"getPayloadContentType",value:function(e){return"undefined"!=typeof FormData&&e instanceof FormData?e.get("Content-Type"):e.contentType}}]),e}();function Uz(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Nz(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Nz(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Nz(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Fz(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}var Dz={lastMessage:"lastMessage",attributes:"attributes",createdBy:"createdBy",dateCreated:"dateCreated",dateUpdated:"dateUpdated",friendlyName:"friendlyName",lastConsumedMessageIndex:"lastConsumedMessageIndex",notificationLevel:"notificationLevel",sid:"sid",status:"status",uniqueName:"uniqueName",state:"state",bindings:"bindings"},Conversation=function(e){Qu(Conversation,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v,y,m,g,b,w,k,x,_,S,O,E,T,R,I=Fz(Conversation);function Conversation(e,t,n,r,i){var a,o,s;rc(this,Conversation),ic(Yu(s=I.call(this)),"sid",void 0),ic(Yu(s),"_links",void 0),ic(Yu(s),"_participants",void 0),ic(Yu(s),"_configuration",void 0),ic(Yu(s),"_services",void 0),ic(Yu(s),"_internalState",void 0),ic(Yu(s),"_entityName",void 0),ic(Yu(s),"_messagesEntity",void 0),ic(Yu(s),"_messagesList",void 0),ic(Yu(s),"_participantsEntity",void 0),ic(Yu(s),"_participantsMap",void 0),ic(Yu(s),"_dataSource",void 0),ic(Yu(s),"_entityPromise",void 0),ic(Yu(s),"_entity",void 0),s.sid=t,s._links=n,s._configuration=r,s._services=i,s._entityName=e.channel,s._internalState={uniqueName:e.uniqueName||null,status:"notParticipating",attributes:null!==(a=e.attributes)&&void 0!==a?a:{},createdBy:e.createdBy,dateCreated:Pb(e.dateCreated),dateUpdated:Pb(e.dateUpdated),friendlyName:e.friendlyName||null,lastReadMessageIndex:Number.isInteger(e.lastConsumedMessageIndex)?e.lastConsumedMessageIndex:null,bindings:null!==(o=e.bindings)&&void 0!==o?o:{}},e.notificationLevel&&(s._internalState.notificationLevel=e.notificationLevel);var u={participants:s._links.participants};return s._participants=new Map,s._participantsEntity=new JB(Yu(s),s._participants,u,s._configuration,s._services),s._participantsEntity.on("participantJoined",(function(e){return s.emit("participantJoined",e)})),s._participantsEntity.on("participantLeft",(function(e){return s.emit("participantLeft",e)})),s._participantsEntity.on("participantUpdated",(function(e){return s.emit("participantUpdated",e)})),s._messagesEntity=new jz(Yu(s),r,i),s._messagesEntity.on("messageAdded",(function(e){return s._onMessageAdded(e)})),s._messagesEntity.on("messageUpdated",(function(e){return s.emit("messageUpdated",e)})),s._messagesEntity.on("messageRemoved",(function(e){return s.emit("messageRemoved",e)})),s}return nc(Conversation,[{key:"uniqueName",get:function(){return this._internalState.uniqueName}},{key:"status",get:function(){return this._internalState.status}},{key:"friendlyName",get:function(){return this._internalState.friendlyName}},{key:"dateUpdated",get:function(){return this._internalState.dateUpdated}},{key:"dateCreated",get:function(){return this._internalState.dateCreated}},{key:"createdBy",get:function(){var e;return null!==(e=this._internalState.createdBy)&&void 0!==e?e:""}},{key:"attributes",get:function(){return this._internalState.attributes}},{key:"lastReadMessageIndex",get:function(){return this._internalState.lastReadMessageIndex}},{key:"lastMessage",get:function(){var e;return null!==(e=this._internalState.lastMessage)&&void 0!==e?e:void 0}},{key:"notificationLevel",get:function(){var e;return null!==(e=this._internalState.notificationLevel)&&void 0!==e?e:"default"}},{key:"bindings",get:function(){return this._internalState.bindings}},{key:"limits",get:function(){return this._configuration.limits}},{key:"state",get:function(){return this._internalState.state}},{key:"_statusSource",get:function(){return this._dataSource}},{key:"add",value:(R=Vu(lh.mark((function e(t,n){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._participantsEntity.add(t,null!=n?n:{}));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"addNonChatParticipant",value:(T=Vu(lh.mark((function e(t,n){var r,i,a=arguments;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>2&&void 0!==a[2]?a[2]:{},i=a.length>3&&void 0!==a[3]?a[3]:{},e.abrupt("return",this._participantsEntity.addNonChatParticipant(t,n,null!=r?r:{},null!=i?i:{}));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return T.apply(this,arguments)})},{key:"advanceLastReadMessageIndex",value:(E=Vu(lh.mark((function e(t){var n;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:if(!(t<(null!==(n=this.lastReadMessageIndex)&&void 0!==n?n:0))){e.next=6;break}return e.next=5,this._setLastReadMessageIndex(this.lastReadMessageIndex);case 5:case 8:return e.abrupt("return",e.sent);case 6:return e.next=8,this._setLastReadMessageIndex(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"delete",value:(O=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("delete",this._links.self);case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(){return O.apply(this,arguments)})},{key:"getAttributes",value:(S=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribe();case 2:return e.abrupt("return",this.attributes);case 3:case"end":return e.stop()}}),e,this)}))),function(){return S.apply(this,arguments)})},{key:"getMessages",value:(_=Vu(lh.mark((function e(t,n,r){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this._messagesEntity.getMessages(t,n,r));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return _.apply(this,arguments)})},{key:"getParticipants",value:(x=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this._participantsEntity.getParticipants());case 3:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"getParticipantsCount",value:(k=Vu(lh.mark((function e(){var t,n,r;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new jb(this._configuration.links.conversations).path(this.sid).build(),e.next=3,this._services.network.get(n);case 3:return r=e.sent,e.abrupt("return",null!==(t=r.body.participants_count)&&void 0!==t?t:0);case 5:case"end":return e.stop()}}),e,this)}))),function(){return k.apply(this,arguments)})},{key:"getParticipantBySid",value:(w=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._participantsEntity.getParticipantBySid(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"getParticipantByIdentity",value:(b=Vu(lh.mark((function e(){var t,n=arguments;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:"",e.abrupt("return",this._participantsEntity.getParticipantByIdentity(null!=t?t:""));case 2:case"end":return e.stop()}}),e,this)}))),function(){return b.apply(this,arguments)})},{key:"getMessagesCount",value:(g=Vu(lh.mark((function e(){var t,n,r;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new jb(this._configuration.links.conversations).path(this.sid).build(),e.next=3,this._services.network.get(n);case 3:return r=e.sent,e.abrupt("return",null!==(t=r.body.messages_count)&&void 0!==t?t:0);case 5:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"getUnreadMessagesCount",value:(m=Vu(lh.mark((function e(){var t,n,r;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new jb(this._configuration.links.myConversations).path(this.sid).build(),e.next=3,this._services.network.get(t);case 3:if((n=e.sent).body.conversation_sid===this.sid){e.next=6;break}throw new Error("Conversation was not found in the user conversations list");case 6:if("number"!=typeof(r=n.body.unread_messages_count)){e.next=9;break}return e.abrupt("return",r);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"join",value:(y=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post",this._links.participants,{identity:this._configuration.userIdentity});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"leave",value:(v=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("joined"!==this._internalState.status){e.next=3;break}return e.next=3,this._services.commandExecutor.mutateResource("delete","".concat(this._links.participants,"/").concat(this._configuration.userIdentity));case 3:return e.abrupt("return",this);case 4:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"removeParticipant",value:(h=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._participantsEntity.remove("string"==typeof t?t:t.sid);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"sendMessage",value:(p=Vu(lh.mark((function e(t,n,r){var i,a,o,s;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t&&null!==t){e.next=6;break}return e.next=3,this._messagesEntity.send(t,n,r);case 3:e.t0=e.sent,e.next=9;break;case 6:return e.next=8,this._messagesEntity.sendMedia(t,n,r);case 8:e.t0=e.sent;case 9:i=e.t0,a="string"==typeof t||null===t?"text":"media";try{o=JSON.parse(i.attributes)}catch(e){}return s={sid:i.sid,text:i.body,type:a,author:i.author,subject:i.subject,lastUpdatedBy:i.participant_sid,attributes:o,dateUpdated:i.date_updated,timestamp:i.date_created,memberSid:i.participant_sid,medias:Array.isArray(i.media)?i.media.map((function(e){return{sid:e.sid,size:Number(e.size),category:e.category,filename:e.filename,contentType:e.content_type}})):null,media:i.media&&"object"===Xu(i.media)&&!Array.isArray(i.media)?{sid:i.media.sid,size:Number(i.media.size),category:i.media.category,filename:i.media.filename,contentType:i.media.content_type}:null},e.abrupt("return",this._messagesEntity._upsertMessage(i.index,s));case 14:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return p.apply(this,arguments)})},{key:"prepareMessage",value:function(){return new Lz(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:(d=Vu(lh.mark((function e(){var t;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.next=4,this.getMessages(1);case 4:if(!((t=e.sent).items.length>0)){e.next=7;break}return e.abrupt("return",this.advanceLastReadMessageIndex(t.items[0].index));case 7:return e.abrupt("return",0);case 8:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"setAllMessagesUnread",value:(f=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.next=4,this._setLastReadMessageIndex(null);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"setUserNotificationLevel",value:(l=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{notification_level:t});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"typing",value:function(){return this._services.typingIndicator.send(this.sid)}},{key:"updateAttributes",value:(c=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post",this._links.self,{attributes:void 0!==t?JSON.stringify(t):void 0});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"updateFriendlyName",value:(u=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._internalState.friendlyName===t){e.next=3;break}return e.next=3,this._services.commandExecutor.mutateResource("post",this._links.self,{friendly_name:t});case 3:return e.abrupt("return",this);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"updateLastReadMessageIndex",value:(s=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this._setLastReadMessageIndex(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"updateUniqueName",value:(o=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._internalState.uniqueName===t){e.next=4;break}return t||(t=""),e.next=4,this._services.commandExecutor.mutateResource("post",this._links.self,{unique_name:t});case 4:return e.abrupt("return",this);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_subscribe",value:(a=Vu(lh.mark((function e(){var t=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._entityPromise){e.next=2;break}return e.abrupt("return",this._entityPromise);case 2:return this._entityPromise=this._services.syncClient.document({id:this._entityName,mode:"open_existing"}),e.prev=3,e.next=6,this._entityPromise;case 6:return this._entity=e.sent,this._entity.on("updated",(function(e){return t._update(e.data)})),this._entity.on("removed",(function(){return t.emit("removed",t)})),this._update(this._entity.data),e.abrupt("return",this._entity);case 13:throw e.prev=13,e.t0=e.catch(3),this._entity=null,this._entityPromise=null,"disconnected"!=this._services.syncClient.connectionState&&Conversation._logger.error("Failed to get conversation object",e.t0),Conversation._logger.debug("ERROR: Failed to get conversation object",e.t0),e.t0;case 20:case"end":return e.stop()}}),e,this,[[3,13]])}))),function(){return a.apply(this,arguments)})},{key:"_fetchStreams",value:(i=Vu(lh.mark((function e(){var t,n,r;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribe();case 2:return Conversation._logger.trace("_streamsAvailable, this.entity.data=",null===(t=this._entity)||void 0===t?void 0:t.data),r=null===(n=this._entity)||void 0===n?void 0:n.data,e.next=6,this._services.syncClient.list({id:r.messages,mode:"open_existing"});case 6:return this._messagesList=e.sent,e.next=9,this._services.syncClient.map({id:r.roster,mode:"open_existing"});case 9:this._participantsMap=e.sent;case 10:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_subscribeStreams",value:(r=Vu(lh.mark((function e(){var t,n,r,i,a,o,s;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._subscribe();case 3:return Conversation._logger.trace("_subscribeStreams, this.entity.data=",null===(t=this._entity)||void 0===t?void 0:t.data),a=null===(n=this._entity)||void 0===n?void 0:n.data,o=a.messages,s=a.roster,e.next=9,Promise.all([this._messagesEntity.subscribe(null!==(r=this._messagesList)&&void 0!==r?r:o),this._participantsEntity.subscribe(null!==(i=this._participantsMap)&&void 0!==i?i:s)]);case 9:e.next=16;break;case 11:throw e.prev=11,e.t0=e.catch(0),"disconnected"!==this._services.syncClient.connectionState&&Conversation._logger.error("Failed to subscribe on conversation objects",this.sid,e.t0),Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects",this.sid,e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,11]])}))),function(){return r.apply(this,arguments)})},{key:"_unsubscribe",value:(n=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._entity){e.next=5;break}return e.next=3,this._entity.close();case 3:this._entity=null,this._entityPromise=null;case 5:return e.abrupt("return",Promise.all([this._participantsEntity.unsubscribe(),this._messagesEntity.unsubscribe()]));case 6:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_setStatus",value:function(e,t){var n=this;this._dataSource=t,this._internalState.status!==e&&(this._internalState.status=e,"joined"!==e?this._entityPromise&&this._unsubscribe().catch((function(t){if(Conversation._logger.debug("ERROR while setting conversation status "+e,t),"disconnected"!==n._services.syncClient.connectionState)throw t})):this._subscribeStreams().catch((function(t){if(Conversation._logger.debug("ERROR while setting conversation status "+e,t),"disconnected"!==n._services.syncClient.connectionState)throw t})))}},{key:"_update",value:function(e){var t,n,r,i,a;Conversation._logger.trace("_update",e),Conversation.preprocessUpdate(e,this.sid);for(var o=new Set,s=0,u=Object.keys(e);s<u.length;s++){var c=u[s],l=Dz[c];if(l)switch(l){case Dz.status:if(!e.status||"unknown"===e.status||this._internalState.status===e.status)break;this._internalState.status=e.status,o.add(l);break;case Dz.attributes:if(zx(this._internalState.attributes,e.attributes))break;this._internalState.attributes=e.attributes,o.add(l);break;case Dz.lastConsumedMessageIndex:if(void 0===e.lastConsumedMessageIndex||e.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=e.lastConsumedMessageIndex,o.add("lastReadMessageIndex");break;case Dz.lastMessage:if(this._internalState.lastMessage&&!e.lastMessage){delete this._internalState.lastMessage,o.add(l);break}this._internalState.lastMessage=this._internalState.lastMessage||{},void 0!==(null===(t=e.lastMessage)||void 0===t?void 0:t.index)&&e.lastMessage.index!==this._internalState.lastMessage.index&&(this._internalState.lastMessage.index=e.lastMessage.index,o.add(l)),void 0!==(null===(n=e.lastMessage)||void 0===n?void 0:n.timestamp)&&(null===(r=this._internalState.lastMessage)||void 0===r||null===(i=r.dateCreated)||void 0===i?void 0:i.getTime())!==e.lastMessage.timestamp.getTime()&&(this._internalState.lastMessage.dateCreated=e.lastMessage.timestamp,o.add(l)),zx(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case Dz.state:var f=e.state||void 0;if(void 0!==f&&(f.dateUpdated=new Date(f.dateUpdated)),zx(this._internalState.state,f))break;this._internalState.state=f,o.add(l);break;case Dz.bindings:if(zx(this._internalState.bindings,e.bindings))break;this._internalState.bindings=e.bindings,o.add(l);break;default:var d=e[c]instanceof Date,p=d&&(null===(a=this._internalState[l])||void 0===a?void 0:a.getTime())===e[c].getTime(),h=!d&&this[l]===e[c];if(p||h)break;this._internalState[l]=e[c],o.add(l)}}o.size>0&&this.emit("updated",{conversation:this,updateReasons:UR(o)})}},{key:"_onMessageAdded",value:function(e){var t,n=Uz(this._participants.values());try{for(n.s();!(t=n.n()).done;){var r=t.value;if(r.identity===e.author){r._endTyping();break}}}catch(e){n.e(e)}finally{n.f()}this.emit("messageAdded",e)}},{key:"_setLastReadMessageIndex",value:(t=Vu(lh.mark((function e(t){var n;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{last_read_message_index:t});case 2:return n=e.sent,e.abrupt("return",n.unread_messages_count);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}],[{key:"preprocessUpdate",value:function(e,t){try{"string"==typeof e.attributes?e.attributes=JSON.parse(e.attributes):e.attributes&&JSON.stringify(e.attributes)}catch(n){Conversation._logger.warn("Retrieved malformed attributes from the server for conversation: "+t),e.attributes={}}try{e.dateCreated&&(e.dateCreated=new Date(e.dateCreated))}catch(n){Conversation._logger.warn("Retrieved malformed dateCreated from the server for conversation: "+t),delete e.dateCreated}try{e.dateUpdated&&(e.dateUpdated=new Date(e.dateUpdated))}catch(n){Conversation._logger.warn("Retrieved malformed dateUpdated from the server for conversation: "+t),delete e.dateUpdated}try{e.lastMessage&&e.lastMessage.timestamp&&(e.lastMessage.timestamp=new Date(e.lastMessage.timestamp))}catch(n){Conversation._logger.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+t),delete e.lastMessage.timestamp}}}]),Conversation}(qx);ic(Conversation,"participantJoined","participantJoined"),ic(Conversation,"participantLeft","participantLeft"),ic(Conversation,"participantUpdated","participantUpdated"),ic(Conversation,"messageAdded","messageAdded"),ic(Conversation,"messageRemoved","messageRemoved"),ic(Conversation,"messageUpdated","messageUpdated"),ic(Conversation,"typingEnded","typingEnded"),ic(Conversation,"typingStarted","typingStarted"),ic(Conversation,"updated","updated"),ic(Conversation,"removed","removed"),ic(Conversation,"_logger",dy.scope("Conversation")),dh([tx(Yk,rx),ph("design:type",Function),ph("design:paramtypes",[String,Object]),ph("design:returntype",Promise)],Conversation.prototype,"add",null),dh([tx(Yk,Yk,rx),ph("design:type",Function),ph("design:paramtypes",[String,String,Object,Object]),ph("design:returntype",Promise)],Conversation.prototype,"addNonChatParticipant",null),dh([tx(Jk),ph("design:type",Function),ph("design:paramtypes",[Number]),ph("design:returntype",Promise)],Conversation.prototype,"advanceLastReadMessageIndex",null),dh([tx(["undefined",Jk],["undefined",Jk],["undefined",Gk("backwards","forward")]),ph("design:type",Function),ph("design:paramtypes",[Number,Number,String]),ph("design:returntype",Promise)],Conversation.prototype,"getMessages",null),dh([tx(Yk),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],Conversation.prototype,"getParticipantBySid",null),dh([tx(Yk),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],Conversation.prototype,"getParticipantByIdentity",null),dh([tx([Yk,Participant]),ph("design:type",Function),ph("design:paramtypes",[Object]),ph("design:returntype",Promise)],Conversation.prototype,"removeParticipant",null),dh([tx(["string",FormData,Gk(null),Qk("media options",{contentType:Yk,media:Hk((function(e){var t="string"==typeof e&&e.length>0||e instanceof Uint8Array||e instanceof ArrayBuffer;return"function"==typeof Blob&&(t=t||e instanceof Blob),[t,"a non-empty string, an instance of Buffer or an instance of Blob"]}))})],rx,["undefined",Gk(null),Qk("email attributes",{subject:[Yk,"undefined"]})]),ph("design:type",Function),ph("design:paramtypes",[Object,Object,Object]),ph("design:returntype",Promise)],Conversation.prototype,"sendMessage",null),dh([tx(Gk("default","muted")),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],Conversation.prototype,"setUserNotificationLevel",null),dh([tx(nx),ph("design:type",Function),ph("design:paramtypes",[Object]),ph("design:returntype",Promise)],Conversation.prototype,"updateAttributes",null),dh([tx("string"),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],Conversation.prototype,"updateFriendlyName",null),dh([tx([Gk(null),Jk]),ph("design:type",Function),ph("design:paramtypes",[Number]),ph("design:returntype",Promise)],Conversation.prototype,"updateLastReadMessageIndex",null),dh([tx(["string",Gk(null)]),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],Conversation.prototype,"updateUniqueName",null);var qz=function(){function e(){var t=this;rc(this,e),ic(this,"_promise",void 0),ic(this,"_resolve",void 0),ic(this,"_reject",void 0),ic(this,"current",void 0),this._promise=new Promise((function(e,n){t._resolve=e,t._reject=n}))}return nc(e,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(e){this._resolve(e)}},{key:"set",value:function(e){this.current=e,this._resolve(e)}},{key:"fail",value:function(e){this._reject(e)}}]),e}();function Bz(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return zz(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return zz(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function zz(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Wz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wz(Object(n),!0).forEach((function(t){ic(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wz(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Kz(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}var Hz=dy.scope("Conversations"),Gz=function(e){Qu(p,e);var t,n,r,i,a,o,s,u,c,l,f,d=Kz(p);function p(e,t){var n;return rc(this,p),ic(Yu(n=d.call(this)),"conversations",new Map),ic(Yu(n),"myConversationsRead",new qz),ic(Yu(n),"configuration",void 0),ic(Yu(n),"services",void 0),ic(Yu(n),"tombstones",new Set),ic(Yu(n),"myConversationsFetched",!1),n.configuration=e,n.services=t,n}return nc(p,[{key:"addConversation",value:(f=Vu(lh.mark((function e(t){var n,r,i,a,o,s,u,c,l,f;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=void 0!==(null==t?void 0:t.attributes)?t.attributes:{},e.next=3,this.services.commandExecutor.mutateResource("post",this.configuration.links.conversations,{friendly_name:t.friendlyName,unique_name:t.uniqueName,attributes:void 0!==a?JSON.stringify(a):void 0});case 3:if(o=e.sent,s=null!==(n=o.sid)&&void 0!==n?n:null,u=null!==(r=null===(i=o.sync_objects)||void 0===i?void 0:i.conversation)&&void 0!==r?r:null,c=$z({self:o.url},o.links),!(l=this.conversations.get(s))){e.next=12;break}return e.next=11,l._subscribe();case 11:return e.abrupt("return",l);case 12:return f=new Conversation({channel:u,entityName:"",uniqueName:"",attributes:null,createdBy:"",friendlyName:"",lastConsumedMessageIndex:0,dateCreated:null,dateUpdated:null},s,c,this.configuration,this.services),this.conversations.set(f.sid,f),this._registerForEvents(f),e.next=17,f._subscribe();case 17:return this.emit("conversationAdded",f),e.abrupt("return",f);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"fetchConversations",value:(l=Vu(lh.mark((function e(){var t,n,r,i,a,o,s,u=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._getMap();case 3:return(t=e.sent).on("itemAdded",(function(e){Hz.debug("itemAdded: ".concat(e.item.key)),u._upsertConversation("sync",e.item.key,e.item.data)})),t.on("itemRemoved",(function(e){Hz.debug("itemRemoved: ".concat(e.key));var t=e.key;u.myConversationsFetched||u.tombstones.add(t);var n=u.conversations.get(t);n&&("joined"===n.status&&(n._setStatus("notParticipating","sync"),u.emit("conversationLeft",n)),u.conversations.delete(t),u.emit("conversationRemoved",n),n.emit("removed",n))})),t.on("itemUpdated",(function(e){Hz.debug("itemUpdated: ".concat(e.item.key)),u._upsertConversation("sync",e.item.key,e.item.data)})),e.next=9,this._fetchMyConversations();case 9:n=e.sent,r=[],i=Bz(n);try{for(i.s();!(a=i.n()).done;)o=a.value,r.push(this._upsertConversation("rest",o.channel_sid,o))}catch(e){i.e(e)}finally{i.f()}return this.myConversationsRead.set(!0),e.next=16,Promise.all(r);case 16:return this.myConversationsFetched=!0,this.tombstones.clear(),Hz.debug("The conversations list has been successfully fetched"),e.abrupt("return",this);case 22:throw e.prev=22,e.t0=e.catch(0),s="Failed to fetch the conversations list","disconnected"!==this.services.syncClient.connectionState&&Hz.error(s,e.t0),Hz.debug("ERROR: ".concat(s),e.t0),e.t0;case 28:case"end":return e.stop()}}),e,this,[[0,22]])}))),function(){return l.apply(this,arguments)})},{key:"getConversations",value:(c=Vu(lh.mark((function e(){var t,n,r=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getMap();case 2:return t=e.sent,e.next=5,t.getItems();case 5:return n=e.sent,e.abrupt("return",this._wrapPaginator(n,(function(e){return Promise.all(e.map((function(e){return r._upsertConversation("sync",e.key,e.data)})))})));case 7:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"getConversation",value:(u=Vu(lh.mark((function e(t){var n,r,i,a=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getMap();case 2:return n=e.sent,e.next=5,n.getItems({key:t});case 5:return r=e.sent,i=r.items.map((function(e){return a._upsertConversation("sync",e.key,e.data)})),e.abrupt("return",i.length>0?i[0]:null);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"getConversationByUniqueName",value:(s=Vu(lh.mark((function e(t){var n,r,i,a,o;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new jb(this.configuration.links.myConversations).path(t).build(),e.next=3,this.services.network.get(n);case 3:return r=e.sent,i=JSON.parse(r.payload),a=i.conversation_sid,o={entityName:null,lastConsumedMessageIndex:i.last_read_message_index,status:(null==i?void 0:i.status)||"unknown",friendlyName:i.friendly_name,dateUpdated:i.date_updated,dateCreated:i.date_created,uniqueName:i.unique_name,createdBy:i.created_by,attributes:i.attributes,channel:i.sync_objects.conversation,notificationLevel:null==i?void 0:i.notification_level,sid:a},e.abrupt("return",a?this._upsertConversation("sync",a,o):null);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"peekConversation",value:(o=Vu(lh.mark((function e(t){var n,r,i,a;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new jb(this.configuration.links.conversations).path(t).build(),e.next=3,this.services.network.get(n);case 3:return r=e.sent,i=r.body,a={entityName:null,status:(null==i?void 0:i.status)||"unknown",friendlyName:i.friendly_name,dateUpdated:i.date_updated,dateCreated:i.date_created,uniqueName:i.unique_name,createdBy:i.created_by,attributes:i.attributes,channel:"".concat(t,".channel"),sid:t},e.abrupt("return",this._upsertConversation("sync",t,a));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_getMap",value:(a=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.syncClient.map({id:this.configuration.myConversations,mode:"open_existing"});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_wrapPaginator",value:(i=Vu(lh.mark((function e(t,n){var r,i=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(t.items);case 2:return r=e.sent,e.abrupt("return",{items:r.filter((function(e){return null!==e})),hasNextPage:t.hasNextPage,hasPrevPage:t.hasPrevPage,nextPage:function(){return t.nextPage().then((function(e){return i._wrapPaginator(e,n)}))},prevPage:function(){return t.prevPage().then((function(e){return i._wrapPaginator(e,n)}))}});case 4:case"end":return e.stop()}}),e)}))),function(e,t){return i.apply(this,arguments)})},{key:"_updateConversation",value:(r=Vu(lh.mark((function e(t,n,r){var i,a,o;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=void 0!==n._statusSource&&t!==n._statusSource,a="rest"!==t||"sync"===n._statusSource,!i||!a||"sync"===t){e.next=5;break}return Hz.trace("upsertConversation: conversation is known from sync and came from REST, ignoring",{sid:n.sid,data:r.status,conversation:n.status}),e.abrupt("return");case 5:if("joined"!==r.status||"joined"===n.status){e.next=15;break}return n._setStatus("joined",t),o={},void 0!==r.notificationLevel&&(o.notificationLevel=r.notificationLevel),void 0!==r.lastConsumedMessageIndex&&(o.lastConsumedMessageIndex=r.lastConsumedMessageIndex),zx(o,{})||n._update(o),e.next=13,n._subscribe();case 13:return this.emit("conversationJoined",n),e.abrupt("return");case 15:if("notParticipating"!==r.status||"joined"!==n.status){e.next=22;break}return n._setStatus("notParticipating",t),n._update(r),e.next=20,n._subscribe();case 20:return this.emit("conversationLeft",n),e.abrupt("return");case 22:if("notParticipating"!==r.status){e.next=26;break}return e.next=25,n._subscribe();case 25:return e.abrupt("return");case 26:n._update(r);case 27:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"_upsertConversation",value:(n=Vu(lh.mark((function e(t,n,r){var i,a,o,s;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Hz.trace("upsertConversation called for ".concat(n),r),!(i=this.conversations.get(n))){e.next=9;break}return Hz.trace("upsertConversation: the conversation ".concat(i.sid," is known;")+"its status is known from the source ".concat(i._statusSource," ")+"and the update came from the source ".concat(t),i),e.next=6,this._updateConversation(t,i,r);case 6:return e.next=8,i._subscribe();case 8:return e.abrupt("return",i);case 9:if("rest"!==t||!this.tombstones.has(n)){e.next=12;break}return Hz.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring",n),e.abrupt("return",null);case 12:return Hz.trace("upsertConversation: creating a local conversation object with sid "+n,r),a="".concat(this.configuration.links.conversations,"/").concat(n),o={self:a,messages:"".concat(a,"/Messages"),participants:"".concat(a,"/Participants")},s=new Conversation(r,n,o,this.configuration,this.services),this.conversations.set(n,s),e.prev=17,e.next=20,s._subscribe();case 20:if("joined"!==r.status){e.next=23;break}return e.next=23,s._fetchStreams();case 23:e.next=32;break;case 25:if(e.prev=25,e.t0=e.catch(17),"SyncError"===e.t0.name){e.next=29;break}throw e.t0;case 29:return Hz.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring",n,e.t0),this.conversations.delete(n),e.abrupt("return",null);case 32:return this._registerForEvents(s),this.emit("conversationAdded",s),"joined"===r.status&&(s._setStatus("joined",t),this.emit("conversationJoined",s)),e.abrupt("return",s);case 36:case"end":return e.stop()}}),e,this,[[17,25]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"_fetchMyConversations",value:(t=Vu(lh.mark((function e(){var t,n,r,i,a,o;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],n=null;case 2:return i=new jb(this.configuration.links.myConversations),n&&i.arg("PageToken",n),e.next=6,this.services.network.get(i.build());case 6:a=e.sent,o=null===(r=a.body)||void 0===r?void 0:r.conversations.map((function(e){return{descriptor:e,channel_sid:e.conversation_sid,status:e.status,channel:e.sync_objects.conversation,messages:e.sync_objects.messages,roster:"".concat(e.conversation_sid,".roster"),lastConsumedMessageIndex:e.last_read_message_index,notificationLevel:e.notification_level}})),n=a.body.meta.next_token,t=[].concat(UR(t),UR(o));case 10:if(n){e.next=2;break}case 11:return e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_onConversationRemoved",value:function(e){var t=this.conversations.get(e);t&&(this.conversations.delete(e),this.emit("conversationRemoved",t))}},{key:"_registerForEvents",value:function(e){var t=this;e.on("removed",(function(){return t._onConversationRemoved(e.sid)})),e.on("updated",(function(e){return t.emit("conversationUpdated",e)})),e.on("participantJoined",(function(e){return t.emit("participantJoined",e)})),e.on("participantLeft",(function(e){return t.emit("participantLeft",e)})),e.on("participantUpdated",(function(e){return t.emit("participantUpdated",e)})),e.on("messageAdded",(function(e){return t.emit("messageAdded",e)})),e.on("messageUpdated",(function(e){return t.emit("messageUpdated",e)})),e.on("messageRemoved",(function(e){return t.emit("messageRemoved",e)})),e.on("typingStarted",(function(e){return t.emit("typingStarted",e)})),e.on("typingEnded",(function(e){return t.emit("typingEnded",e)}))}}]),p}(qx),Vz=ni,Yz=No.find,Jz=Iy,Qz="find",Xz=!0;Qz in[]&&Array(1).find((function(){Xz=!1})),Vz({target:"Array",proto:!0,forced:Xz},{find:function(e){return Yz(this,e,arguments.length>1?arguments[1]:void 0)}}),Jz(Qz);var Zz=s,eW=xo,tW=TypeError,nW=Object.getOwnPropertyDescriptor,rW=Zz&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),iW=ni,aW=Be,oW=ur,sW=ir,uW=pr,cW=rW?function(e,t){if(eW(e)&&!nW(e,"length").writable)throw tW("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},lW=vh,fW=Io,dW=Ga,pW=nD,hW=Lu("splice"),vW=Math.max,yW=Math.min;function mW(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}iW({target:"Array",proto:!0,forced:!hW},{splice:function(e,t){var n,r,i,a,o,s,u=aW(this),c=uW(u),l=oW(e,c),f=arguments.length;for(0===f?n=r=0:1===f?(n=0,r=c-l):(n=f-2,r=yW(vW(sW(t),0),c-l)),lW(c+n-r),i=fW(u,r),a=0;a<r;a++)(o=l+a)in u&&dW(i,a,u[o]);if(i.length=r,n<r){for(a=l;a<c-r;a++)s=a+n,(o=a+r)in u?u[s]=u[o]:pW(u,s);for(a=c;a>c-r+n;a--)pW(u,a-1)}else if(n>r)for(a=c-r;a>l;a--)s=a+n-1,(o=a+r-1)in u?u[s]=u[o]:pW(u,s);for(a=0;a<n;a++)u[a+l]=arguments[a+2];return cW(u,c-r+n),i}});var gW=function(e){Qu(a,e);var t,n,r,i=mW(a);function a(e,t,n){var r;return rc(this,a),ic(Yu(r=i.call(this)),"configuration",void 0),ic(Yu(r),"services",void 0),ic(Yu(r),"subscribedUsers",void 0),ic(Yu(r),"fifoStack",void 0),ic(Yu(r),"myself",void 0),r.configuration=t,r.services=n,r.fifoStack=[],r.myself=e,r.myself.on("updated",(function(e){return r.emit("userUpdated",e)})),r.myself.on("userSubscribed",(function(){return r.emit("userSubscribed",r.myself)})),r.myself.on("userUnsubscribed",(function(){r.emit("userUnsubscribed",r.myself),r.myself._ensureFetched()})),r.subscribedUsers=new Map,r}return nc(a,[{key:"handleUnsubscribeUser",value:function(e){this.subscribedUsers.has(e.identity)&&this.subscribedUsers.delete(e.identity);var t=0;this.fifoStack.find((function(n,r){return n==e.identity&&(t=r,!0)}))&&this.fifoStack.splice(t,1),this.emit("userUnsubscribed",e)}},{key:"handleSubscribeUser",value:function(e){if(!this.subscribedUsers.has(e.identity)){if(this.fifoStack.length>=this.configuration.userInfosToSubscribe){var t,n,r=this.fifoStack.shift();null===(t=this.subscribedUsers)||void 0===t||null===(n=t.get(r))||void 0===n||n.unsubscribe()}this.fifoStack.push(e.identity),this.subscribedUsers.set(e.identity,e),this.emit("userSubscribed",e)}}},{key:"getUser",value:(r=Vu(lh.mark((function e(t,n){var r,i,a,o=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.myself._ensureFetched();case 2:if(t!=this.myself.identity){e.next=4;break}return e.abrupt("return",this.myself);case 4:if(!(i=this.subscribedUsers.get(t))){e.next=7;break}return e.abrupt("return",i);case 7:if(null===(r=n)||void 0===r){e.next=11;break}e.next=14;break;case 11:return e.next=13,this.getSyncUniqueName(t);case 13:n=e.sent;case 14:return(a=new User(t,n,this.configuration,this.services)).on("updated",(function(e){return o.emit("userUpdated",e)})),a.on("userSubscribed",(function(){return o.handleSubscribeUser(a)})),a.on("userUnsubscribed",(function(){return o.handleUnsubscribeUser(a)})),e.next=20,a._ensureFetched();case 20:return e.abrupt("return",a);case 21:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"getSubscribedUsers",value:(n=Vu(lh.mark((function e(){var t;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.myself._ensureFetched();case 2:return t=[this.myself],this.subscribedUsers.forEach((function(e){return t.push(e)})),e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getSyncUniqueName",value:(t=Vu(lh.mark((function e(t){var n,r,i,a;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new jb(this.configuration.links.users).path(t).build(),e.next=3,this.services.network.get(r);case 3:return i=e.sent,a=JSON.parse(i.payload||"null"),e.abrupt("return",null!==(n=null==a?void 0:a.sync_objects.user_info_map)&&void 0!==n?n:"");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),a}(qx),bW=dy.scope("TypingIndicator"),wW=function(){function e(t,n,r){rc(this,e),ic(this,"services",void 0),ic(this,"configuration",void 0),ic(this,"sentUpdates",void 0),ic(this,"getConversation",void 0),ic(this,"serviceTypingTimeout",void 0),this.configuration=n,this.services=r,this.getConversation=t,this.serviceTypingTimeout=null,this.sentUpdates=new Map}var t;return nc(e,[{key:"typingTimeout",get:function(){return this.configuration.typingIndicatorTimeoutOverride||this.serviceTypingTimeout||this.configuration.typingIndicatorTimeoutDefault}},{key:"initialize",value:function(){var e=this;this.services.notificationClient.on("message",function(){var t=Vu(lh.mark((function t(n,r){return lh.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==LS.TYPING_INDICATOR){t.next=3;break}return t.next=3,e._handleRemoteTyping(r);case 3:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}())}},{key:"_handleRemoteTyping",value:(t=Vu(lh.mark((function e(t){var n=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:bW.trace("Got new typing indicator ",t),this.getConversation(t.channel_sid).then((function(e){e&&e._participants.forEach((function(e){if(e.identity===t.identity){var r=n.configuration.typingIndicatorTimeoutOverride?n.configuration.typingIndicatorTimeoutOverride+1e3:1e3*t.typing_timeout;e._startTyping(r)}}))})).catch((function(e){throw bW.error(e),e}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"send",value:function(e){var t=this.sentUpdates.get(e);return t&&t>Date.now()-this.typingTimeout?Promise.resolve():(this.sentUpdates.set(e,Date.now()),this._send(e))}},{key:"_send",value:function(e){var t=this;bW.trace("Sending typing indicator");var n=this.configuration.links.typing,r="ChannelSid=".concat(e);return this.services.twilsockClient.post({url:n,headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r,grant:this.configuration.productId}).then((function(e){var n=JSON.parse(e.payload);n.hasOwnProperty("typing_timeout")&&(t.serviceTypingTimeout=1e3*n.typing_timeout)})).catch((function(e){throw bW.error("Failed to send typing indicator:",e),e}))}}]),e}(),PushNotification=nc((function PushNotification(e){rc(this,PushNotification),ic(this,"title",void 0),ic(this,"body",void 0),ic(this,"sound",void 0),ic(this,"badge",void 0),ic(this,"action",void 0),ic(this,"type",void 0),ic(this,"data",void 0),this.title=e.title||null,this.body=e.body||null,this.sound=e.sound||null,this.badge=e.badge||null,this.action=e.action||null,this.type=e.type||null,this.data=e.data||{}})),kW="2.2.0";function xW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _W(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xW(Object(n),!0).forEach((function(t){ic(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xW(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var SW,OW,EW=function(e){return e.replace(/(^\/+|\/+$)/g,"")},TW=function(){function e(t,n,r){rc(this,e),ic(this,"_serviceUrl",void 0),ic(this,"_services",void 0),ic(this,"_productId",void 0),this._serviceUrl=t,this._services=n,this._productId=r}var t,n,r;return nc(e,[{key:"_preProcessUrl",value:function(e){var t=EW(e);return/^https?:\/\//.test(e)?t:"".concat(EW(this._serviceUrl),"/").concat(t)}},{key:"_makeRequest",value:(r=Vu(lh.mark((function e(t,n,r,i){var a,o,s,u;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=this._preProcessUrl(n),o=_W({"Content-Type":"application/json; charset=utf-8"},i||{}),e.t0=t,e.next="get"===e.t0?5:"post"===e.t0?11:"delete"===e.t0?15:19;break;case 5:return u=a,r&&(u+="?"+Object.entries(r).map((function(e){return e.map((function(e){return encodeURIComponent(String(e))})).join("=")})).join("&")),e.next=9,this._services.transport.get({url:u,headers:o,grant:this._productId});case 9:case 13:case 17:return s=e.sent,e.abrupt("break",19);case 11:return e.next=13,this._services.transport.post({url:a,headers:o,body:JSON.stringify(r),grant:this._productId});case 15:return e.next=17,this._services.transport.delete({url:a,headers:o,grant:this._productId});case 19:if(!(s.statusCode<200||s.statusCode>=300)){e.next=21;break}throw new Error("Request responded with a non-success code ".concat(s.statusCode));case 21:return e.abrupt("return",s);case 22:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"fetchResource",value:(n=Vu(lh.mark((function e(t,n){var r,i=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=1,e.next=4,new CS({min:50,max:1600,maxAttemptsCount:6}).run((function(){return i._makeRequest("get",t,n)}));case 4:return r=e.sent,e.abrupt("return",JSON.parse(r.payload));case 8:throw e.prev=8,e.t0=e.catch(1),new Error('Fetch resource from "'.concat(t,'" failed.'));case 11:case"end":return e.stop()}}),e,null,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"mutateResource",value:(t=Vu(lh.mark((function e(t,n,r){var i,a;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequest(t,n,r,{"X-Twilio-Mutation-Id":HS()});case 2:if(i=e.sent,a=JSON.parse(i.payload),202!==i.statusCode){e.next=8;break}return e.next=7,this.fetchResource(a.resource_url);case 7:return e.abrupt("return",e.sent);case 8:return e.abrupt("return",a);case 9:case"end":return e.stop()}}),e,this)}))),function(e,n,r){return t.apply(this,arguments)})}]),e}();function RW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function IW(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?RW(Object(n),!0).forEach((function(t){ic(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):RW(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function CW(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ec(e);if(t){var i=ec(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zu(this,n)}}var PW=nc((function e(){rc(this,e),ic(this,"commandExecutor",void 0),ic(this,"twilsockClient",void 0),ic(this,"users",void 0),ic(this,"notificationClient",void 0),ic(this,"network",void 0),ic(this,"typingIndicator",void 0),ic(this,"syncClient",void 0),ic(this,"mcsClient",void 0),ic(this,"transport",void 0)}));return e.Client=(SW=function(e){Qu(Client,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v=CW(Client);function Client(e){var t,n,r,i,a,o,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(rc(this,Client),ic(Yu(o=v.call(this)),"version",kW),ic(Yu(o),"connectionState","unknown"),ic(Yu(o),"_ensureReady",void 0),ic(Yu(o),"_options",void 0),ic(Yu(o),"_services",void 0),ic(Yu(o),"_myself",void 0),ic(Yu(o),"_resolveEnsureReady",void 0),ic(Yu(o),"_rejectEnsureReady",void 0),ic(Yu(o),"_fpaToken",void 0),ic(Yu(o),"_configuration",void 0),ic(Yu(o),"_conversationsEntity",void 0),ic(Yu(o),"_conversationsPromise",void 0),ic(Yu(o),"parsePushNotification",OW.parsePushNotification),o._fpaToken=null!=e?e:"",o._options=null!=s?s:{},!o._options.disableDeepClone){var u=IW(IW({},o._options),{},{transport:void 0,twilsockClient:void 0});(u=Ib(u)).transport=o._options.transport,u.twilsockClient=o._options.twilsockClient,o._options=u}o._options.logLevel=null!==(t=o._options.logLevel)&&void 0!==t?t:"silent",OW._logger.setLevel(o._options.logLevel);var c=o._options.productId="ip_messaging";if(o._options.clientMetadata=o._options.clientMetadata||{},o._options.clientMetadata.hasOwnProperty("type")||(o._options.clientMetadata.type="conversations"),o._options.clientMetadata.hasOwnProperty("sdk")||(o._options.clientMetadata.sdk="JS",o._options.clientMetadata.sdkv=kW),o._options.Sync=o._options.Sync||{},void 0===o._options.Sync.enableSessionStorage&&(o._options.Sync.enableSessionStorage=!0),o._options.region&&(o._options.Sync.region=o._options.region),!e)throw new Error("A valid Twilio token should be provided");o._services=new PW,o._myself=new User("","",null,o._services);var l=!o._options.twilsockClient;if(!o._options.initRegistrations){var f=new US.InitRegistration(c);OW.populateInitRegistrations(f),o._options.initRegistrations=[f]}o._services.twilsockClient=o._options.twilsockClient=null!==(n=o._options.twilsockClient)&&void 0!==n?n:new US.TwilsockClient(e,c,o._options),o._services.twilsockClient.on("tokenAboutToExpire",(function(){return o.emit("tokenAboutToExpire")})),o._services.twilsockClient.on("tokenExpired",(function(){return o.emit("tokenExpired")})),o._services.twilsockClient.on("disconnected",(function(){OW._logger.debug("Handling stateChanged for ConversationsClient: new state disconnected"),"disconnected"!==o.connectionState&&(o.connectionState="disconnected",o.emit("connectionStateChanged",o.connectionState))})),o._services.twilsockClient.on("connecting",(function(){OW._logger.debug("Handling stateChanged for ConversationsClient: new state connecting"),"connecting"!==o.connectionState&&(o.connectionState="connecting",o.emit("connectionStateChanged",o.connectionState))})),o._services.twilsockClient.on("connected",(function(){OW._logger.debug("Handling stateChanged for ConversationsClient: new state connected"),"connected"!==o.connectionState&&(o.connectionState="connected",o.emit("connectionStateChanged",o.connectionState))})),o._services.transport=o._options.transport=null!==(r=o._options.transport)&&void 0!==r?r:o._options.twilsockClient,o._services.notificationClient=o._options.notificationsClient=null!==(i=o._options.notificationsClient)&&void 0!==i?i:new YA.Notifications(e,o._options),o._services.syncClient=o._options.syncClient=null!==(a=o._options.syncClient)&&void 0!==a?a:new eU(e,o._options);var d=(null==s?void 0:s.Chat)||(null==s?void 0:s.IPMessaging)||s||{},p=d.region||(null==s?void 0:s.region),h=d.apiUri||d.typingUri||"https://aim.".concat(p||"us1",".twilio.com");o._services.commandExecutor=new TW(h,{transport:o._options.transport},c);var y=function(e){o._rejectEnsureReady(e),o.emit("initFailed",{error:e})},m=function(){y({terminal:!0,message:"Twilsock has disconnected."})};return o._services.twilsockClient.once("disconnected",m),o._services.twilsockClient.once("connected",Vu(lh.mark((function e(){var t;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW._logger.debug("ConversationsClient started INITIALIZING"),o._services.twilsockClient.off("disconnected",m),e.prev=2,e.next=6,o._initialize();case 6:e.next=13;break;case 8:e.prev=8,e.t0=e.catch(2),t={terminal:!0,message:e.t0.message},o._rejectEnsureReady(t),o.emit("initFailed",{error:t});case 13:case"end":return e.stop()}}),e,null,[[2,8]])})))),o._ensureReady=new Promise((function(e,t){o._resolveEnsureReady=e,o._rejectEnsureReady=t})).catch((function(){})),l&&o._services.twilsockClient.connect(),o}return nc(Client,[{key:"user",get:function(){return this._myself}},{key:"reachabilityEnabled",get:function(){if(!this._configuration)throw new Error("Reachability information could not yet be accessed as the client has not yet been initialized. Subscribe to 'initialized' and 'initFailed' events to properly react to the client initialization.");return this._configuration.reachabilityEnabled}},{key:"shutdown",value:(h=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._services.twilsockClient.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"updateToken",value:(p=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:if(OW._logger.info("updateToken"),this._fpaToken!==t){e.next=5;break}return e.abrupt("return",this);case 5:return e.next=7,this._services.twilsockClient.updateToken(t);case 7:return e.next=9,this._services.notificationClient.updateToken(t);case 9:return e.next=11,this._services.mcsClient.updateToken(t);case 11:return this._fpaToken=t,e.abrupt("return",this);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"getConversationBySid",value:(d=Vu(lh.mark((function e(t){var n;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return e.next=6,this._conversationsEntity.getConversation(t);case 6:if(n=e.sent){e.next=9;break}throw new Error("Conversation with SID ".concat(t," was not found."));case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"peekConversationBySid",value:(f=Vu(lh.mark((function e(t){var n;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._conversationsEntity.peekConversation(t);case 4:if(n=e.sent){e.next=7;break}throw new Error("Conversation with SID ".concat(t," was not found."));case 7:return e.abrupt("return",n);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"getConversationByUniqueName",value:(l=Vu(lh.mark((function e(t){var n;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return e.next=6,this._conversationsEntity.getConversationByUniqueName(t);case 6:if(n=e.sent){e.next=9;break}throw new Error("Conversation with unique name ".concat(t," was not found."));case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"getSubscribedConversations",value:(c=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.abrupt("return",this._conversationsPromise.then((function(e){return e.getConversations()})));case 3:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"createConversation",value:(u=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return t=t||{},e.abrupt("return",this._conversationsPromise.then((function(e){return e.addConversation(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"setPushRegistrationId",value:(s=Vu(lh.mark((function e(t,n){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return this._subscribeToPushNotifications(t),this._services.notificationClient.setPushRegistrationId(t,n),e.next=6,this._services.notificationClient.commitChanges();case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"unsetPushRegistrationId",value:(o=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return this._unsubscribeFromPushNotifications(t),e.next=5,this._services.notificationClient.commitChanges();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"removePushRegistrations",value:(a=Vu(lh.mark((function e(t,n){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.notificationClient.removeRegistrations(t,n);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handlePushNotification",value:(i=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:OW._logger.debug("handlePushNotification, notificationPayload=",t),this.emit("pushNotification",OW.parsePushNotification(t));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getUser",value:(r=Vu(lh.mark((function e(t){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.abrupt("return",this._services.users.getUser(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getSubscribedUsers",value:(n=Vu(lh.mark((function e(){return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.abrupt("return",this._services.users.getSubscribedUsers());case 3:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getTemporaryContentUrlsForMediaSids",value:function(e){var t=this;return new tU.CancellablePromise(function(){var n=Vu(lh.mark((function n(r,i,a){var o,s;return lh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(t._services.mcsClient&&e){n.next=3;break}return i(new Error("Media Content Service is unavailable")),n.abrupt("return");case 3:return o=t._services.mcsClient.mediaSetGetContentUrls(e),a((function(){o.cancel()})),n.prev=5,n.next=8,o;case 8:s=n.sent,r(s),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(5),i(n.t0);case 15:case"end":return n.stop()}}),n,null,[[5,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForMedia",value:function(e){var t=e.map((function(e){return e.sid}));return this.getTemporaryContentUrlsForMediaSids(t)}},{key:"_initialize",value:(t=Vu(lh.mark((function e(){var t,n=this;return lh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.fetchResource("Client/v2/Configuration");case 2:return t=e.sent,this._configuration=new _y(this._options,t,OW._logger),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new wW(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new MS(this._configuration,this._services),this._services.users=new gW(this._myself,this._configuration,this._services),this._services.users.on("userSubscribed",(function(e){n.emit("userSubscribed",e)})),this._services.users.on("userUpdated",(function(e){return n.emit("userUpdated",e)})),this._services.users.on("userUnsubscribed",(function(e){n.emit("userUnsubscribed",e)})),this._conversationsEntity=new Gz(this._configuration,this._services),this._conversationsEntity.on("conversationAdded",(function(e){n.emit("conversationAdded",e)})),this._conversationsEntity.on("conversationRemoved",(function(e){n.emit("conversationRemoved",e)})),this._conversationsEntity.on("conversationJoined",(function(e){n.emit("conversationJoined",e)})),this._conversationsEntity.on("conversationLeft",(function(e){n.emit("conversationLeft",e)})),this._conversationsEntity.on("conversationUpdated",(function(e){return n.emit("conversationUpdated",e)})),this._conversationsEntity.on("participantJoined",(function(e){n.emit("participantJoined",e)})),this._conversationsEntity.on("participantLeft",(function(e){n.emit("participantLeft",e)})),this._conversationsEntity.on("participantUpdated",(function(e){return n.emit("participantUpdated",e)})),this._conversationsEntity.on("messageAdded",(function(e){return n.emit("messageAdded",e)})),this._conversationsEntity.on("messageUpdated",(function(e){return n.emit("messageUpdated",e)})),this._conversationsEntity.on("messageRemoved",(function(e){return n.emit("messageRemoved",e)})),this._conversationsEntity.on("typingStarted",(function(e){return n.emit("typingStarted",e)})),this._conversationsEntity.on("typingEnded",(function(e){return n.emit("typingEnded",e)})),this._conversationsPromise=this._conversationsEntity.fetchConversations().then((function(){return n._conversationsEntity})).catch((function(e){throw e})),e.next=28,this._services.users.myself._ensureFetched();case 28:OW._supportedPushChannels.forEach((function(e){return n._subscribeToPushNotifications(e)})),this._services.typingIndicator.initialize(),this._services.mcsClient=new tU.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,IW(IW({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit("initialized");case 33:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_subscribeToPushNotifications",value:function(e){var t=this;[LS.NEW_MESSAGE,LS.ADDED_TO_CONVERSATION,LS.REMOVED_FROM_CONVERSATION,LS.TYPING_INDICATOR,LS.CONSUMPTION_UPDATE].forEach((function(n){t._services.notificationClient.subscribe(e,n)}))}},{key:"_unsubscribeFromPushNotifications",value:function(e){var t=this;[LS.NEW_MESSAGE,LS.ADDED_TO_CONVERSATION,LS.REMOVED_FROM_CONVERSATION,LS.TYPING_INDICATOR,LS.CONSUMPTION_UPDATE].forEach((function(n){t._services.notificationClient.unsubscribe(e,n)}))}}],[{key:"parsePushNotification",value:function(e){if(OW._logger.debug("parsePushNotification, notificationPayload=",e),void 0!==e.aps){if(!e.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var t,n,r,i=OW._parsePushNotificationChatData(e),a=e.aps,o=null;if("string"==typeof a.alert)t=a.alert||null;else t=(null===(n=a.alert)||void 0===n?void 0:n.body)||null,o=(null===(r=a.alert)||void 0===r?void 0:r.title)||null;return new PushNotification({title:o,body:t,sound:a.sound||null,badge:a.badge||null,action:a.category||null,type:e.twi_message_type,data:i})}if(void 0!==e.data){var s=e.data;if(!s.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var u=OW._parsePushNotificationChatData(e.data);return new PushNotification({title:s.twi_title||null,body:s.twi_body||null,sound:s.twi_sound||null,badge:null,action:s.twi_action||null,type:s.twi_message_type,data:u})}throw new Error("Provided push notification payload is not Programmable Chat notification")}},{key:"_parsePushNotificationChatData",value:function(e){var t={};for(var n in OW._supportedPushDataFields){var r=e[n];if(null!=r)if("message_index"!==n&&"media_count"!==n){if("media"!==n)t[OW._supportedPushDataFields[n]]=r;else if("string"==typeof r)try{t[OW._supportedPushDataFields[n]]=JSON.parse(r)}catch(e){OW._logger.debug("Media message notification parsing error")}}else{var i=Cb(r);null!==i&&(t[OW._supportedPushDataFields[n]]=i)}}return t}},{key:"populateInitRegistrations",value:function(e){}}]),Client}(qx),ic(SW,"conversationAdded","conversationAdded"),ic(SW,"conversationJoined","conversationJoined"),ic(SW,"conversationLeft","conversationLeft"),ic(SW,"conversationRemoved","conversationRemoved"),ic(SW,"conversationUpdated","conversationUpdated"),ic(SW,"participantJoined","participantJoined"),ic(SW,"participantLeft","participantLeft"),ic(SW,"participantUpdated","participantUpdated"),ic(SW,"messageAdded","messageAdded"),ic(SW,"messageRemoved","messageRemoved"),ic(SW,"messageUpdated","messageUpdated"),ic(SW,"tokenAboutToExpire","tokenAboutToExpire"),ic(SW,"tokenExpired","tokenExpired"),ic(SW,"typingEnded","typingEnded"),ic(SW,"typingStarted","typingStarted"),ic(SW,"pushNotification","pushNotification"),ic(SW,"userSubscribed","userSubscribed"),ic(SW,"userUnsubscribed","userUnsubscribed"),ic(SW,"userUpdated","userUpdated"),ic(SW,"initialized","initialized"),ic(SW,"initFailed","initFailed"),ic(SW,"connectionStateChanged","connectionStateChanged"),ic(SW,"connectionError","connectionError"),ic(SW,"version",kW),ic(SW,"_logger",dy.scope("Client")),ic(SW,"_supportedPushChannels",["fcm","apn"]),ic(SW,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),OW=SW),dh([tx(Yk),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],e.Client.prototype,"updateToken",null),dh([tx(Yk),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],e.Client.prototype,"getConversationBySid",null),dh([tx(Yk),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],e.Client.prototype,"peekConversationBySid",null),dh([tx(Yk),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],e.Client.prototype,"getConversationByUniqueName",null),dh([tx(["undefined",Qk("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),ph("design:type",Function),ph("design:paramtypes",[Object]),ph("design:returntype",Promise)],e.Client.prototype,"createConversation",null),dh([tx(Gk("fcm","apn"),"string"),ph("design:type",Function),ph("design:paramtypes",[String,String]),ph("design:returntype",Promise)],e.Client.prototype,"setPushRegistrationId",null),dh([tx(Gk("fcm","apn")),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],e.Client.prototype,"unsetPushRegistrationId",null),dh([tx(Gk("fcm","apn"),Yk),ph("design:type",Function),ph("design:paramtypes",[String,String]),ph("design:returntype",Promise)],e.Client.prototype,"removePushRegistrations",null),dh([tx(Xk),ph("design:type",Function),ph("design:paramtypes",[Object]),ph("design:returntype",Promise)],e.Client.prototype,"handlePushNotification",null),dh([tx(Yk),ph("design:type",Function),ph("design:paramtypes",[String]),ph("design:returntype",Promise)],e.Client.prototype,"getUser",null),dh([tx(Vk("strings","string")),ph("design:type",Function),ph("design:paramtypes",[Array]),ph("design:returntype",tU.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),dh([tx(Vk("media",Media)),ph("design:type",Function),ph("design:paramtypes",[Array]),ph("design:returntype",tU.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMedia",null),dh([ex(Xk),ph("design:type",Function),ph("design:paramtypes",[Object]),ph("design:returntype",PushNotification)],e.Client,"parsePushNotification",null),e.Client=OW=dh([Zk(Yk,[Xk,"undefined"]),ph("design:paramtypes",[String,Object])],e.Client),e.AggregatedDeliveryReceipt=AggregatedDeliveryReceipt,e.CancellablePromise=tU.CancellablePromise,e.Conversation=Conversation,e.DetailedDeliveryReceipt=DetailedDeliveryReceipt,e.Media=Media,e.Message=Message,e.MessageBuilder=Lz,e.NotificationTypes=LS,e.Participant=Participant,e.PushNotification=PushNotification,e.RestPaginator=Sz,e.UnsentMessage=Mz,e.User=User,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
129
|
+
this.Twilio=this.Twilio||{},this.Twilio.Conversations=function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}var r=function(e){return e&&e.Math==Math&&e},i=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof t&&t)||function(){return this}()||Function("return this")(),a={},o=function(e){try{return!!e()}catch(e){return!0}},s=!o((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),u=!o((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),c=u,l=Function.prototype.call,f=c?l.bind(l):function(){return l.apply(l,arguments)},d={},p={}.propertyIsEnumerable,h=Object.getOwnPropertyDescriptor,v=h&&!p.call({1:2},1);d.f=v?function(e){var t=h(this,e);return!!t&&t.enumerable}:p;var y,m,g=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},b=u,w=Function.prototype,k=w.call,x=b&&w.bind.bind(k,k),_=b?x:function(e){return function(){return k.apply(e,arguments)}},S=_,O=S({}.toString),E=S("".slice),T=function(e){return E(O(e),8,-1)},R=o,I=T,C=Object,P=_("".split),j=R((function(){return!C("z").propertyIsEnumerable(0)}))?function(e){return"String"==I(e)?P(e,""):C(e)}:C,A=function(e){return null==e},M=A,L=TypeError,U=function(e){if(M(e))throw L("Can't call method on "+e);return e},N=j,F=U,D=function(e){return N(F(e))},q="object"==typeof document&&document.all,B={all:q,IS_HTMLDDA:void 0===q&&void 0!==q},z=B.all,W=B.IS_HTMLDDA?function(e){return"function"==typeof e||e===z}:function(e){return"function"==typeof e},$=W,K=B.all,H=B.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:$(e)||e===K}:function(e){return"object"==typeof e?null!==e:$(e)},G=i,V=W,Y=function(e){return V(e)?e:void 0},J=function(e,t){return arguments.length<2?Y(G[e]):G[e]&&G[e][t]},Q=_({}.isPrototypeOf),X=J("navigator","userAgent")||"",Z=i,ee=X,te=Z.process,ne=Z.Deno,re=te&&te.versions||ne&&ne.version,ie=re&&re.v8;ie&&(m=(y=ie.split("."))[0]>0&&y[0]<4?1:+(y[0]+y[1])),!m&&ee&&(!(y=ee.match(/Edge\/(\d+)/))||y[1]>=74)&&(y=ee.match(/Chrome\/(\d+)/))&&(m=+y[1]);var ae=m,oe=ae,se=o,ue=!!Object.getOwnPropertySymbols&&!se((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&oe&&oe<41})),ce=ue&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,le=J,fe=W,de=Q,pe=Object,he=ce?function(e){return"symbol"==typeof e}:function(e){var t=le("Symbol");return fe(t)&&de(t.prototype,pe(e))},ve=String,ye=function(e){try{return ve(e)}catch(e){return"Object"}},me=W,ge=ye,be=TypeError,we=function(e){if(me(e))return e;throw be(ge(e)+" is not a function")},ke=we,xe=A,_e=function(e,t){var n=e[t];return xe(n)?void 0:ke(n)},Se=f,Oe=W,Ee=H,Te=TypeError,Re={exports:{}},Ie=i,Ce=Object.defineProperty,Pe=function(e,t){try{Ce(Ie,e,{value:t,configurable:!0,writable:!0})}catch(n){Ie[e]=t}return t},je=Pe,Ae="__core-js_shared__",Me=i[Ae]||je(Ae,{}),Le=Me;(Re.exports=function(e,t){return Le[e]||(Le[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.1",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Ue=U,Ne=Object,Fe=function(e){return Ne(Ue(e))},De=Fe,qe=_({}.hasOwnProperty),Be=Object.hasOwn||function(e,t){return qe(De(e),t)},ze=_,We=0,$e=Math.random(),Ke=ze(1..toString),He=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Ke(++We+$e,36)},Ge=i,Ve=Re.exports,Ye=Be,Je=He,Qe=ue,Xe=ce,Ze=Ve("wks"),et=Ge.Symbol,tt=et&&et.for,nt=Xe?et:et&&et.withoutSetter||Je,rt=function(e){if(!Ye(Ze,e)||!Qe&&"string"!=typeof Ze[e]){var t="Symbol."+e;Qe&&Ye(et,e)?Ze[e]=et[e]:Ze[e]=Xe&&tt?tt(t):nt(t)}return Ze[e]},it=f,at=H,ot=he,st=_e,ut=function(e,t){var n,r;if("string"===t&&Oe(n=e.toString)&&!Ee(r=Se(n,e)))return r;if(Oe(n=e.valueOf)&&!Ee(r=Se(n,e)))return r;if("string"!==t&&Oe(n=e.toString)&&!Ee(r=Se(n,e)))return r;throw Te("Can't convert object to primitive value")},ct=TypeError,lt=rt("toPrimitive"),ft=function(e,t){if(!at(e)||ot(e))return e;var n,r=st(e,lt);if(r){if(void 0===t&&(t="default"),n=it(r,e,t),!at(n)||ot(n))return n;throw ct("Can't convert object to primitive value")}return void 0===t&&(t="number"),ut(e,t)},dt=ft,pt=he,ht=function(e){var t=dt(e,"string");return pt(t)?t:t+""},vt=H,yt=i.document,mt=vt(yt)&&vt(yt.createElement),gt=function(e){return mt?yt.createElement(e):{}},bt=gt,wt=!s&&!o((function(){return 7!=Object.defineProperty(bt("div"),"a",{get:function(){return 7}}).a})),kt=s,xt=f,_t=d,St=g,Ot=D,Et=ht,Tt=Be,Rt=wt,It=Object.getOwnPropertyDescriptor;a.f=kt?It:function(e,t){if(e=Ot(e),t=Et(t),Rt)try{return It(e,t)}catch(e){}if(Tt(e,t))return St(!xt(_t.f,e,t),e[t])};var Ct={},Pt=s&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),jt=H,At=String,Mt=TypeError,Lt=function(e){if(jt(e))return e;throw Mt(At(e)+" is not an object")},Ut=s,Nt=wt,Ft=Pt,Dt=Lt,qt=ht,Bt=TypeError,zt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,$t="enumerable",Kt="configurable",Ht="writable";Ct.f=Ut?Ft?function(e,t,n){if(Dt(e),t=qt(t),Dt(n),"function"==typeof e&&"prototype"===t&&"value"in n&&Ht in n&&!n[Ht]){var r=Wt(e,t);r&&r[Ht]&&(e[t]=n.value,n={configurable:Kt in n?n[Kt]:r[Kt],enumerable:$t in n?n[$t]:r[$t],writable:!1})}return zt(e,t,n)}:zt:function(e,t,n){if(Dt(e),t=qt(t),Dt(n),Nt)try{return zt(e,t,n)}catch(e){}if("get"in n||"set"in n)throw Bt("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var Gt=Ct,Vt=g,Yt=s?function(e,t,n){return Gt.f(e,t,Vt(1,n))}:function(e,t,n){return e[t]=n,e},Jt={exports:{}},Qt=s,Xt=Be,Zt=Function.prototype,en=Qt&&Object.getOwnPropertyDescriptor,tn=Xt(Zt,"name"),nn={EXISTS:tn,PROPER:tn&&"something"===function(){}.name,CONFIGURABLE:tn&&(!Qt||Qt&&en(Zt,"name").configurable)},rn=W,an=Me,on=_(Function.toString);rn(an.inspectSource)||(an.inspectSource=function(e){return on(e)});var sn,un,cn,ln=an.inspectSource,fn=W,dn=i.WeakMap,pn=fn(dn)&&/native code/.test(String(dn)),hn=Re.exports,vn=He,yn=hn("keys"),mn=function(e){return yn[e]||(yn[e]=vn(e))},gn={},bn=pn,wn=i,kn=H,xn=Yt,_n=Be,Sn=Me,On=mn,En=gn,Tn="Object already initialized",Rn=wn.TypeError,In=wn.WeakMap;if(bn||Sn.state){var Cn=Sn.state||(Sn.state=new In);Cn.get=Cn.get,Cn.has=Cn.has,Cn.set=Cn.set,sn=function(e,t){if(Cn.has(e))throw Rn(Tn);return t.facade=e,Cn.set(e,t),t},un=function(e){return Cn.get(e)||{}},cn=function(e){return Cn.has(e)}}else{var Pn=On("state");En[Pn]=!0,sn=function(e,t){if(_n(e,Pn))throw Rn(Tn);return t.facade=e,xn(e,Pn,t),t},un=function(e){return _n(e,Pn)?e[Pn]:{}},cn=function(e){return _n(e,Pn)}}var jn={set:sn,get:un,has:cn,enforce:function(e){return cn(e)?un(e):sn(e,{})},getterFor:function(e){return function(t){var n;if(!kn(t)||(n=un(t)).type!==e)throw Rn("Incompatible receiver, "+e+" required");return n}}},An=o,Mn=W,Ln=Be,Un=s,Nn=nn.CONFIGURABLE,Fn=ln,Dn=jn.enforce,qn=jn.get,Bn=Object.defineProperty,zn=Un&&!An((function(){return 8!==Bn((function(){}),"length",{value:8}).length})),Wn=String(String).split("String"),$n=Jt.exports=function(e,t,n){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!Ln(e,"name")||Nn&&e.name!==t)&&(Un?Bn(e,"name",{value:t,configurable:!0}):e.name=t),zn&&n&&Ln(n,"arity")&&e.length!==n.arity&&Bn(e,"length",{value:n.arity});try{n&&Ln(n,"constructor")&&n.constructor?Un&&Bn(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var r=Dn(e);return Ln(r,"source")||(r.source=Wn.join("string"==typeof t?t:"")),e};Function.prototype.toString=$n((function(){return Mn(this)&&qn(this).source||Fn(this)}),"toString");var Kn=W,Hn=Ct,Gn=Jt.exports,Vn=Pe,Yn=function(e,t,n,r){r||(r={});var i=r.enumerable,a=void 0!==r.name?r.name:t;if(Kn(n)&&Gn(n,a,r),r.global)i?e[t]=n:Vn(t,n);else{try{r.unsafe?e[t]&&(i=!0):delete e[t]}catch(e){}i?e[t]=n:Hn.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},Jn={},Qn=Math.ceil,Xn=Math.floor,Zn=Math.trunc||function(e){var t=+e;return(t>0?Xn:Qn)(t)},er=Zn,tr=function(e){var t=+e;return t!=t||0===t?0:er(t)},nr=tr,rr=Math.max,ir=Math.min,ar=function(e,t){var n=nr(e);return n<0?rr(n+t,0):ir(n,t)},or=tr,sr=Math.min,ur=function(e){return e>0?sr(or(e),9007199254740991):0},cr=ur,lr=function(e){return cr(e.length)},fr=D,dr=ar,pr=lr,hr=function(e){return function(t,n,r){var i,a=fr(t),o=pr(a),s=dr(r,o);if(e&&n!=n){for(;o>s;)if((i=a[s++])!=i)return!0}else for(;o>s;s++)if((e||s in a)&&a[s]===n)return e||s||0;return!e&&-1}},vr={includes:hr(!0),indexOf:hr(!1)},yr=Be,mr=D,gr=vr.indexOf,br=gn,wr=_([].push),kr=function(e,t){var n,r=mr(e),i=0,a=[];for(n in r)!yr(br,n)&&yr(r,n)&&wr(a,n);for(;t.length>i;)yr(r,n=t[i++])&&(~gr(a,n)||wr(a,n));return a},xr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],_r=kr,Sr=xr.concat("length","prototype");Jn.f=Object.getOwnPropertyNames||function(e){return _r(e,Sr)};var Or={};Or.f=Object.getOwnPropertySymbols;var Er=J,Tr=Jn,Rr=Or,Ir=Lt,Cr=_([].concat),Pr=Er("Reflect","ownKeys")||function(e){var t=Tr.f(Ir(e)),n=Rr.f;return n?Cr(t,n(e)):t},jr=Be,Ar=Pr,Mr=a,Lr=Ct,Ur=function(e,t,n){for(var r=Ar(t),i=Lr.f,a=Mr.f,o=0;o<r.length;o++){var s=r[o];jr(e,s)||n&&jr(n,s)||i(e,s,a(t,s))}},Nr=o,Fr=W,Dr=/#|\.prototype\./,qr=function(e,t){var n=zr[Br(e)];return n==$r||n!=Wr&&(Fr(t)?Nr(t):!!t)},Br=qr.normalize=function(e){return String(e).replace(Dr,".").toLowerCase()},zr=qr.data={},Wr=qr.NATIVE="N",$r=qr.POLYFILL="P",Kr=qr,Hr=i,Gr=a.f,Vr=Yt,Yr=Yn,Jr=Pe,Qr=Ur,Xr=Kr,Zr=function(e,t){var n,r,i,a,o,s=e.target,u=e.global,c=e.stat;if(n=u?Hr:c?Hr[s]||Jr(s,{}):(Hr[s]||{}).prototype)for(r in t){if(a=t[r],i=e.dontCallGetSet?(o=Gr(n,r))&&o.value:n[r],!Xr(u?r:s+(c?".":"#")+r,e.forced)&&void 0!==i){if(typeof a==typeof i)continue;Qr(a,i)}(e.sham||i&&i.sham)&&Vr(a,"sham",!0),Yr(n,r,a,e)}},ei=Ct.f,ti=Be,ni=rt("toStringTag"),ri=function(e,t,n){e&&!n&&(e=e.prototype),e&&!ti(e,ni)&&ei(e,ni,{configurable:!0,value:t})},ii=i,ai=ri;Zr({global:!0},{Reflect:{}}),ai(ii.Reflect,"Reflect",!0);var oi=u,si=Function.prototype,ui=si.apply,ci=si.call,li="object"==typeof Reflect&&Reflect.apply||(oi?ci.bind(ui):function(){return ci.apply(ui,arguments)}),fi=_([].slice),di=_,pi=we,hi=H,vi=Be,yi=fi,mi=u,gi=Function,bi=di([].concat),wi=di([].join),ki={},xi=function(e,t,n){if(!vi(ki,t)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";ki[t]=gi("C,a","return new C("+wi(r,",")+")")}return ki[t](e,n)},_i=mi?gi.bind:function(e){var t=pi(this),n=t.prototype,r=yi(arguments,1),i=function(){var n=bi(r,yi(arguments));return this instanceof i?xi(t,n.length,n):t.apply(e,n)};return hi(n)&&(i.prototype=n),i},Si={};Si[rt("toStringTag")]="z";var Oi="[object z]"===String(Si),Ei=Oi,Ti=W,Ri=T,Ii=rt("toStringTag"),Ci=Object,Pi="Arguments"==Ri(function(){return arguments}()),ji=Ei?Ri:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Ci(e),Ii))?n:Pi?Ri(t):"Object"==(r=Ri(t))&&Ti(t.callee)?"Arguments":r},Ai=_,Mi=o,Li=W,Ui=ji,Ni=ln,Fi=function(){},Di=[],qi=J("Reflect","construct"),Bi=/^\s*(?:class|function)\b/,zi=Ai(Bi.exec),Wi=!Bi.exec(Fi),$i=function(e){if(!Li(e))return!1;try{return qi(Fi,Di,e),!0}catch(e){return!1}},Ki=function(e){if(!Li(e))return!1;switch(Ui(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Wi||!!zi(Bi,Ni(e))}catch(e){return!0}};Ki.sham=!0;var Hi=!qi||Mi((function(){var e;return $i($i.call)||!$i(Object)||!$i((function(){e=!0}))||e}))?Ki:$i,Gi=Hi,Vi=ye,Yi=TypeError,Ji=function(e){if(Gi(e))return e;throw Yi(Vi(e)+" is not a constructor")},Qi={},Xi=kr,Zi=xr,ea=Object.keys||function(e){return Xi(e,Zi)},ta=s,na=Pt,ra=Ct,ia=Lt,aa=D,oa=ea;Qi.f=ta&&!na?Object.defineProperties:function(e,t){ia(e);for(var n,r=aa(t),i=oa(t),a=i.length,o=0;a>o;)ra.f(e,n=i[o++],r[n]);return e};var sa,ua=J("document","documentElement"),ca=Lt,la=Qi,fa=xr,da=gn,pa=ua,ha=gt,va="prototype",ya="script",ma=mn("IE_PROTO"),ga=function(){},ba=function(e){return"<"+ya+">"+e+"</"+ya+">"},wa=function(e){e.write(ba("")),e.close();var t=e.parentWindow.Object;return e=null,t},ka=function(){try{sa=new ActiveXObject("htmlfile")}catch(e){}var e,t,n;ka="undefined"!=typeof document?document.domain&&sa?wa(sa):(t=ha("iframe"),n="java"+ya+":",t.style.display="none",pa.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(ba("document.F=Object")),e.close(),e.F):wa(sa);for(var r=fa.length;r--;)delete ka[va][fa[r]];return ka()};da[ma]=!0;var xa=Object.create||function(e,t){var n;return null!==e?(ga[va]=ca(e),n=new ga,ga[va]=null,n[ma]=e):n=ka(),void 0===t?n:la.f(n,t)},_a=Zr,Sa=li,Oa=_i,Ea=Ji,Ta=Lt,Ra=H,Ia=xa,Ca=o,Pa=J("Reflect","construct"),ja=Object.prototype,Aa=[].push,Ma=Ca((function(){function e(){}return!(Pa((function(){}),[],e)instanceof e)})),La=!Ca((function(){Pa((function(){}))})),Ua=Ma||La;_a({target:"Reflect",stat:!0,forced:Ua,sham:Ua},{construct:function(e,t){Ea(e),Ta(t);var n=arguments.length<3?e:Ea(arguments[2]);if(La&&!Ma)return Pa(e,t,n);if(e==n){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var r=[null];return Sa(Aa,r,t),new(Sa(Oa,e,r))}var i=n.prototype,a=Ia(Ra(i)?i:ja),o=Sa(e,a,t);return Ra(o)?o:a}});var Na=Fe,Fa=ea;Zr({target:"Object",stat:!0,forced:o((function(){Fa(1)}))},{keys:function(e){return Fa(Na(e))}});var Da=ji,qa=String,Ba=function(e){if("Symbol"===Da(e))throw TypeError("Cannot convert a Symbol value to a string");return qa(e)},za={},Wa=ht,$a=Ct,Ka=g,Ha=function(e,t,n){var r=Wa(t);r in e?$a.f(e,r,Ka(0,n)):e[r]=n},Ga=ar,Va=lr,Ya=Ha,Ja=Array,Qa=Math.max,Xa=function(e,t,n){for(var r=Va(e),i=Ga(t,r),a=Ga(void 0===n?r:n,r),o=Ja(Qa(a-i,0)),s=0;i<a;i++,s++)Ya(o,s,e[i]);return o.length=s,o},Za=T,eo=D,to=Jn.f,no=Xa,ro="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];za.f=function(e){return ro&&"Window"==Za(e)?function(e){try{return to(e)}catch(e){return no(ro)}}(e):to(eo(e))};var io={},ao=rt;io.f=ao;var oo=i,so=Be,uo=io,co=Ct.f,lo=function(e){var t=oo.Symbol||(oo.Symbol={});so(t,e)||co(t,e,{value:uo.f(e)})},fo=f,po=J,ho=rt,vo=Yn,yo=T,mo=_,go=function(e){if("Function"===yo(e))return mo(e)},bo=we,wo=u,ko=go(go.bind),xo=function(e,t){return bo(e),void 0===t?e:wo?ko(e,t):function(){return e.apply(t,arguments)}},_o=T,So=Array.isArray||function(e){return"Array"==_o(e)},Oo=So,Eo=Hi,To=H,Ro=rt("species"),Io=Array,Co=function(e){var t;return Oo(e)&&(t=e.constructor,(Eo(t)&&(t===Io||Oo(t.prototype))||To(t)&&null===(t=t[Ro]))&&(t=void 0)),void 0===t?Io:t},Po=function(e,t){return new(Co(e))(0===t?0:t)},jo=xo,Ao=j,Mo=Fe,Lo=lr,Uo=Po,No=_([].push),Fo=function(e){var t=1==e,n=2==e,r=3==e,i=4==e,a=6==e,o=7==e,s=5==e||a;return function(u,c,l,f){for(var d,p,h=Mo(u),v=Ao(h),y=jo(c,l),m=Lo(v),g=0,b=f||Uo,w=t?b(u,m):n||o?b(u,0):void 0;m>g;g++)if((s||g in v)&&(p=y(d=v[g],g,h),e))if(t)w[g]=p;else if(p)switch(e){case 3:return!0;case 5:return d;case 6:return g;case 2:No(w,d)}else switch(e){case 4:return!1;case 7:No(w,d)}return a?-1:r||i?i:w}},Do={forEach:Fo(0),map:Fo(1),filter:Fo(2),some:Fo(3),every:Fo(4),find:Fo(5),findIndex:Fo(6),filterReject:Fo(7)},qo=Zr,Bo=i,zo=f,Wo=_,$o=s,Ko=ue,Ho=o,Go=Be,Vo=Q,Yo=Lt,Jo=D,Qo=ht,Xo=Ba,Zo=g,es=xa,ts=ea,ns=Jn,rs=za,is=Or,as=a,os=Ct,ss=Qi,us=d,cs=Yn,ls=Re.exports,fs=gn,ds=He,ps=rt,hs=io,vs=lo,ys=function(){var e=po("Symbol"),t=e&&e.prototype,n=t&&t.valueOf,r=ho("toPrimitive");t&&!t[r]&&vo(t,r,(function(e){return fo(n,this)}),{arity:1})},ms=ri,gs=jn,bs=Do.forEach,ws=mn("hidden"),ks="Symbol",xs="prototype",_s=gs.set,Ss=gs.getterFor(ks),Os=Object[xs],Es=Bo.Symbol,Ts=Es&&Es[xs],Rs=Bo.TypeError,Is=Bo.QObject,Cs=as.f,Ps=os.f,js=rs.f,As=us.f,Ms=Wo([].push),Ls=ls("symbols"),Us=ls("op-symbols"),Ns=ls("wks"),Fs=!Is||!Is[xs]||!Is[xs].findChild,Ds=$o&&Ho((function(){return 7!=es(Ps({},"a",{get:function(){return Ps(this,"a",{value:7}).a}})).a}))?function(e,t,n){var r=Cs(Os,t);r&&delete Os[t],Ps(e,t,n),r&&e!==Os&&Ps(Os,t,r)}:Ps,qs=function(e,t){var n=Ls[e]=es(Ts);return _s(n,{type:ks,tag:e,description:t}),$o||(n.description=t),n},Bs=function(e,t,n){e===Os&&Bs(Us,t,n),Yo(e);var r=Qo(t);return Yo(n),Go(Ls,r)?(n.enumerable?(Go(e,ws)&&e[ws][r]&&(e[ws][r]=!1),n=es(n,{enumerable:Zo(0,!1)})):(Go(e,ws)||Ps(e,ws,Zo(1,{})),e[ws][r]=!0),Ds(e,r,n)):Ps(e,r,n)},zs=function(e,t){Yo(e);var n=Jo(t),r=ts(n).concat(Hs(n));return bs(r,(function(t){$o&&!zo(Ws,n,t)||Bs(e,t,n[t])})),e},Ws=function(e){var t=Qo(e),n=zo(As,this,t);return!(this===Os&&Go(Ls,t)&&!Go(Us,t))&&(!(n||!Go(this,t)||!Go(Ls,t)||Go(this,ws)&&this[ws][t])||n)},$s=function(e,t){var n=Jo(e),r=Qo(t);if(n!==Os||!Go(Ls,r)||Go(Us,r)){var i=Cs(n,r);return!i||!Go(Ls,r)||Go(n,ws)&&n[ws][r]||(i.enumerable=!0),i}},Ks=function(e){var t=js(Jo(e)),n=[];return bs(t,(function(e){Go(Ls,e)||Go(fs,e)||Ms(n,e)})),n},Hs=function(e){var t=e===Os,n=js(t?Us:Jo(e)),r=[];return bs(n,(function(e){!Go(Ls,e)||t&&!Go(Os,e)||Ms(r,Ls[e])})),r};Ko||(Es=function(){if(Vo(Ts,this))throw Rs("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Xo(arguments[0]):void 0,t=ds(e),n=function(e){this===Os&&zo(n,Us,e),Go(this,ws)&&Go(this[ws],t)&&(this[ws][t]=!1),Ds(this,t,Zo(1,e))};return $o&&Fs&&Ds(Os,t,{configurable:!0,set:n}),qs(t,e)},cs(Ts=Es[xs],"toString",(function(){return Ss(this).tag})),cs(Es,"withoutSetter",(function(e){return qs(ds(e),e)})),us.f=Ws,os.f=Bs,ss.f=zs,as.f=$s,ns.f=rs.f=Ks,is.f=Hs,hs.f=function(e){return qs(ps(e),e)},$o&&(Ps(Ts,"description",{configurable:!0,get:function(){return Ss(this).description}}),cs(Os,"propertyIsEnumerable",Ws,{unsafe:!0}))),qo({global:!0,constructor:!0,wrap:!0,forced:!Ko,sham:!Ko},{Symbol:Es}),bs(ts(Ns),(function(e){vs(e)})),qo({target:ks,stat:!0,forced:!Ko},{useSetter:function(){Fs=!0},useSimple:function(){Fs=!1}}),qo({target:"Object",stat:!0,forced:!Ko,sham:!$o},{create:function(e,t){return void 0===t?es(e):zs(es(e),t)},defineProperty:Bs,defineProperties:zs,getOwnPropertyDescriptor:$s}),qo({target:"Object",stat:!0,forced:!Ko},{getOwnPropertyNames:Ks}),ys(),ms(Es,ks),fs[ws]=!0;var Gs=ue&&!!Symbol.for&&!!Symbol.keyFor,Vs=Zr,Ys=J,Js=Be,Qs=Ba,Xs=Re.exports,Zs=Gs,eu=Xs("string-to-symbol-registry"),tu=Xs("symbol-to-string-registry");Vs({target:"Symbol",stat:!0,forced:!Zs},{for:function(e){var t=Qs(e);if(Js(eu,t))return eu[t];var n=Ys("Symbol")(t);return eu[t]=n,tu[n]=t,n}});var nu=Zr,ru=Be,iu=he,au=ye,ou=Gs,su=(0,Re.exports)("symbol-to-string-registry");nu({target:"Symbol",stat:!0,forced:!ou},{keyFor:function(e){if(!iu(e))throw TypeError(au(e)+" is not a symbol");if(ru(su,e))return su[e]}});var uu=Zr,cu=J,lu=li,fu=f,du=_,pu=o,hu=So,vu=W,yu=H,mu=he,gu=fi,bu=ue,wu=cu("JSON","stringify"),ku=du(/./.exec),xu=du("".charAt),_u=du("".charCodeAt),Su=du("".replace),Ou=du(1..toString),Eu=/[\uD800-\uDFFF]/g,Tu=/^[\uD800-\uDBFF]$/,Ru=/^[\uDC00-\uDFFF]$/,Iu=!bu||pu((function(){var e=cu("Symbol")();return"[null]"!=wu([e])||"{}"!=wu({a:e})||"{}"!=wu(Object(e))})),Cu=pu((function(){return'"\\udf06\\ud834"'!==wu("\udf06\ud834")||'"\\udead"'!==wu("\udead")})),Pu=function(e,t){var n=gu(arguments),r=t;if((yu(t)||void 0!==e)&&!mu(e))return hu(t)||(t=function(e,t){if(vu(r)&&(t=fu(r,this,e,t)),!mu(t))return t}),n[1]=t,lu(wu,null,n)},ju=function(e,t,n){var r=xu(n,t-1),i=xu(n,t+1);return ku(Tu,e)&&!ku(Ru,i)||ku(Ru,e)&&!ku(Tu,r)?"\\u"+Ou(_u(e,0),16):e};wu&&uu({target:"JSON",stat:!0,arity:3,forced:Iu||Cu},{stringify:function(e,t,n){var r=gu(arguments),i=lu(Iu?Pu:wu,null,r);return Cu&&"string"==typeof i?Su(i,Eu,ju):i}});var Au=Or,Mu=Fe;Zr({target:"Object",stat:!0,forced:!ue||o((function(){Au.f(1)}))},{getOwnPropertySymbols:function(e){var t=Au.f;return t?t(Mu(e)):[]}});var Lu=o,Uu=ae,Nu=rt("species"),Fu=function(e){return Uu>=51||!Lu((function(){var t=[];return(t.constructor={})[Nu]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Du=Do.filter;Zr({target:"Array",proto:!0,forced:!Fu("filter")},{filter:function(e){return Du(this,e,arguments.length>1?arguments[1]:void 0)}});var qu=Zr,Bu=o,zu=D,Wu=a.f,$u=s,Ku=Bu((function(){Wu(1)}));qu({target:"Object",stat:!0,forced:!$u||Ku,sham:!$u},{getOwnPropertyDescriptor:function(e,t){return Wu(zu(e),t)}});var Hu=Pr,Gu=D,Vu=a,Yu=Ha;function Ju(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function Qu(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Ju(a,r,i,o,s,"next",e)}function s(e){Ju(a,r,i,o,s,"throw",e)}o(void 0)}))}}function Xu(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Zu(e,t){return Zu=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Zu(e,t)}function ec(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Zu(e,t)}function tc(e){return tc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},tc(e)}function nc(e,t){if(t&&("object"===tc(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Xu(e)}function rc(e){return rc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},rc(e)}function ic(e){var t=function(e,t){if("object"!==tc(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==tc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===tc(t)?t:String(t)}function ac(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ic(r.key),r)}}function oc(e,t,n){return t&&ac(e.prototype,t),n&&ac(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function sc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function uc(e,t,n){return(t=ic(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Zr({target:"Object",stat:!0,sham:!s},{getOwnPropertyDescriptors:function(e){for(var t,n,r=Gu(e),i=Vu.f,a=Hu(r),o={},s=0;a.length>s;)void 0!==(n=i(r,t=a[s++]))&&Yu(o,t,n);return o}});var cc=ji,lc=Oi?{}.toString:function(){return"[object "+cc(this)+"]"};Oi||Yn(Object.prototype,"toString",lc,{unsafe:!0});var fc,dc,pc,hc,vc="process"==T(i.process),yc=W,mc=String,gc=TypeError,bc=_,wc=Lt,kc=function(e){if("object"==typeof e||yc(e))return e;throw gc("Can't set "+mc(e)+" as a prototype")},xc=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=bc(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),t=n instanceof Array}catch(e){}return function(n,r){return wc(n),kc(r),t?e(n,r):n.__proto__=r,n}}():void 0),_c=J,Sc=Ct,Oc=s,Ec=rt("species"),Tc=function(e){var t=_c(e),n=Sc.f;Oc&&t&&!t[Ec]&&n(t,Ec,{configurable:!0,get:function(){return this}})},Rc=Q,Ic=TypeError,Cc=function(e,t){if(Rc(t,e))return e;throw Ic("Incorrect invocation")},Pc=Lt,jc=Ji,Ac=A,Mc=rt("species"),Lc=function(e,t){var n,r=Pc(e).constructor;return void 0===r||Ac(n=Pc(r)[Mc])?t:jc(n)},Uc=TypeError,Nc=function(e,t){if(e<t)throw Uc("Not enough arguments");return e},Fc=/(?:ipad|iphone|ipod).*applewebkit/i.test(X),Dc=i,qc=li,Bc=xo,zc=W,Wc=Be,$c=o,Kc=ua,Hc=fi,Gc=gt,Vc=Nc,Yc=Fc,Jc=vc,Qc=Dc.setImmediate,Xc=Dc.clearImmediate,Zc=Dc.process,el=Dc.Dispatch,tl=Dc.Function,nl=Dc.MessageChannel,rl=Dc.String,il=0,al={},ol="onreadystatechange";try{fc=Dc.location}catch(e){}var sl=function(e){if(Wc(al,e)){var t=al[e];delete al[e],t()}},ul=function(e){return function(){sl(e)}},cl=function(e){sl(e.data)},ll=function(e){Dc.postMessage(rl(e),fc.protocol+"//"+fc.host)};Qc&&Xc||(Qc=function(e){Vc(arguments.length,1);var t=zc(e)?e:tl(e),n=Hc(arguments,1);return al[++il]=function(){qc(t,void 0,n)},dc(il),il},Xc=function(e){delete al[e]},Jc?dc=function(e){Zc.nextTick(ul(e))}:el&&el.now?dc=function(e){el.now(ul(e))}:nl&&!Yc?(hc=(pc=new nl).port2,pc.port1.onmessage=cl,dc=Bc(hc.postMessage,hc)):Dc.addEventListener&&zc(Dc.postMessage)&&!Dc.importScripts&&fc&&"file:"!==fc.protocol&&!$c(ll)?(dc=ll,Dc.addEventListener("message",cl,!1)):dc=ol in Gc("script")?function(e){Kc.appendChild(Gc("script"))[ol]=function(){Kc.removeChild(this),sl(e)}}:function(e){setTimeout(ul(e),0)});var fl,dl,pl,hl,vl,yl,ml,gl,bl={set:Qc,clear:Xc},wl=i,kl=/ipad|iphone|ipod/i.test(X)&&void 0!==wl.Pebble,xl=/web0s(?!.*chrome)/i.test(X),_l=i,Sl=xo,Ol=a.f,El=bl.set,Tl=Fc,Rl=kl,Il=xl,Cl=vc,Pl=_l.MutationObserver||_l.WebKitMutationObserver,jl=_l.document,Al=_l.process,Ml=_l.Promise,Ll=Ol(_l,"queueMicrotask"),Ul=Ll&&Ll.value;Ul||(fl=function(){var e,t;for(Cl&&(e=Al.domain)&&e.exit();dl;){t=dl.fn,dl=dl.next;try{t()}catch(e){throw dl?hl():pl=void 0,e}}pl=void 0,e&&e.enter()},Tl||Cl||Il||!Pl||!jl?!Rl&&Ml&&Ml.resolve?((ml=Ml.resolve(void 0)).constructor=Ml,gl=Sl(ml.then,ml),hl=function(){gl(fl)}):Cl?hl=function(){Al.nextTick(fl)}:(El=Sl(El,_l),hl=function(){El(fl)}):(vl=!0,yl=jl.createTextNode(""),new Pl(fl).observe(yl,{characterData:!0}),hl=function(){yl.data=vl=!vl}));var Nl=Ul||function(e){var t={fn:e,next:void 0};pl&&(pl.next=t),dl||(dl=t,hl()),pl=t},Fl=i,Dl=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},ql=function(){this.head=null,this.tail=null};ql.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var Bl=ql,zl=i.Promise,Wl="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,$l=!Wl&&!vc&&"object"==typeof window&&"object"==typeof document,Kl=i,Hl=zl,Gl=W,Vl=Kr,Yl=ln,Jl=rt,Ql=$l,Xl=Wl,Zl=ae;Hl&&Hl.prototype;var ef=Jl("species"),tf=!1,nf=Gl(Kl.PromiseRejectionEvent),rf=Vl("Promise",(function(){var e=Yl(Hl),t=e!==String(Hl);if(!t&&66===Zl)return!0;if(!Zl||Zl<51||!/native code/.test(e)){var n=new Hl((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((n.constructor={})[ef]=r,!(tf=n.then((function(){}))instanceof r))return!0}return!t&&(Ql||Xl)&&!nf})),af={CONSTRUCTOR:rf,REJECTION_EVENT:nf,SUBCLASSING:tf},of={},sf=we,uf=TypeError,cf=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw uf("Bad Promise constructor");t=e,n=r})),this.resolve=sf(t),this.reject=sf(n)};of.f=function(e){return new cf(e)};var lf,ff,df,pf=Zr,hf=vc,vf=i,yf=f,mf=Yn,gf=xc,bf=ri,wf=Tc,kf=we,xf=W,_f=H,Sf=Cc,Of=Lc,Ef=bl.set,Tf=Nl,Rf=function(e,t){var n=Fl.console;n&&n.error&&(1==arguments.length?n.error(e):n.error(e,t))},If=Dl,Cf=Bl,Pf=jn,jf=zl,Af=of,Mf="Promise",Lf=af.CONSTRUCTOR,Uf=af.REJECTION_EVENT,Nf=af.SUBCLASSING,Ff=Pf.getterFor(Mf),Df=Pf.set,qf=jf&&jf.prototype,Bf=jf,zf=qf,Wf=vf.TypeError,$f=vf.document,Kf=vf.process,Hf=Af.f,Gf=Hf,Vf=!!($f&&$f.createEvent&&vf.dispatchEvent),Yf="unhandledrejection",Jf=function(e){var t;return!(!_f(e)||!xf(t=e.then))&&t},Qf=function(e,t){var n,r,i,a=t.value,o=1==t.state,s=o?e.ok:e.fail,u=e.resolve,c=e.reject,l=e.domain;try{s?(o||(2===t.rejection&&nd(t),t.rejection=1),!0===s?n=a:(l&&l.enter(),n=s(a),l&&(l.exit(),i=!0)),n===e.promise?c(Wf("Promise-chain cycle")):(r=Jf(n))?yf(r,n,u,c):u(n)):c(a)}catch(e){l&&!i&&l.exit(),c(e)}},Xf=function(e,t){e.notified||(e.notified=!0,Tf((function(){for(var n,r=e.reactions;n=r.get();)Qf(n,e);e.notified=!1,t&&!e.rejection&&ed(e)})))},Zf=function(e,t,n){var r,i;Vf?((r=$f.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),vf.dispatchEvent(r)):r={promise:t,reason:n},!Uf&&(i=vf["on"+e])?i(r):e===Yf&&Rf("Unhandled promise rejection",n)},ed=function(e){yf(Ef,vf,(function(){var t,n=e.facade,r=e.value;if(td(e)&&(t=If((function(){hf?Kf.emit("unhandledRejection",r,n):Zf(Yf,n,r)})),e.rejection=hf||td(e)?2:1,t.error))throw t.value}))},td=function(e){return 1!==e.rejection&&!e.parent},nd=function(e){yf(Ef,vf,(function(){var t=e.facade;hf?Kf.emit("rejectionHandled",t):Zf("rejectionhandled",t,e.value)}))},rd=function(e,t,n){return function(r){e(t,r,n)}},id=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,Xf(e,!0))},ad=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw Wf("Promise can't be resolved itself");var r=Jf(t);r?Tf((function(){var n={done:!1};try{yf(r,t,rd(ad,n,e),rd(id,n,e))}catch(t){id(n,t,e)}})):(e.value=t,e.state=1,Xf(e,!1))}catch(t){id({done:!1},t,e)}}};if(Lf&&(zf=(Bf=function(e){Sf(this,zf),kf(e),yf(lf,this);var t=Ff(this);try{e(rd(ad,t),rd(id,t))}catch(e){id(t,e)}}).prototype,(lf=function(e){Df(this,{type:Mf,done:!1,notified:!1,parent:!1,reactions:new Cf,rejection:!1,state:0,value:void 0})}).prototype=mf(zf,"then",(function(e,t){var n=Ff(this),r=Hf(Of(this,Bf));return n.parent=!0,r.ok=!xf(e)||e,r.fail=xf(t)&&t,r.domain=hf?Kf.domain:void 0,0==n.state?n.reactions.add(r):Tf((function(){Qf(r,n)})),r.promise})),ff=function(){var e=new lf,t=Ff(e);this.promise=e,this.resolve=rd(ad,t),this.reject=rd(id,t)},Af.f=Hf=function(e){return e===Bf||undefined===e?new ff(e):Gf(e)},xf(jf)&&qf!==Object.prototype)){df=qf.then,Nf||mf(qf,"then",(function(e,t){var n=this;return new Bf((function(e,t){yf(df,n,e,t)})).then(e,t)}),{unsafe:!0});try{delete qf.constructor}catch(e){}gf&&gf(qf,zf)}pf({global:!0,constructor:!0,wrap:!0,forced:Lf},{Promise:Bf}),bf(Bf,Mf,!1),wf(Mf);var od={},sd=od,ud=rt("iterator"),cd=Array.prototype,ld=function(e){return void 0!==e&&(sd.Array===e||cd[ud]===e)},fd=ji,dd=_e,pd=A,hd=od,vd=rt("iterator"),yd=function(e){if(!pd(e))return dd(e,vd)||dd(e,"@@iterator")||hd[fd(e)]},md=f,gd=we,bd=Lt,wd=ye,kd=yd,xd=TypeError,_d=function(e,t){var n=arguments.length<2?kd(e):t;if(gd(n))return bd(md(n,e));throw xd(wd(e)+" is not iterable")},Sd=f,Od=Lt,Ed=_e,Td=function(e,t,n){var r,i;Od(e);try{if(!(r=Ed(e,"return"))){if("throw"===t)throw n;return n}r=Sd(r,e)}catch(e){i=!0,r=e}if("throw"===t)throw n;if(i)throw r;return Od(r),n},Rd=xo,Id=f,Cd=Lt,Pd=ye,jd=ld,Ad=lr,Md=Q,Ld=_d,Ud=yd,Nd=Td,Fd=TypeError,Dd=function(e,t){this.stopped=e,this.result=t},qd=Dd.prototype,Bd=function(e,t,n){var r,i,a,o,s,u,c,l=n&&n.that,f=!(!n||!n.AS_ENTRIES),d=!(!n||!n.IS_RECORD),p=!(!n||!n.IS_ITERATOR),h=!(!n||!n.INTERRUPTED),v=Rd(t,l),y=function(e){return r&&Nd(r,"normal",e),new Dd(!0,e)},m=function(e){return f?(Cd(e),h?v(e[0],e[1],y):v(e[0],e[1])):h?v(e,y):v(e)};if(d)r=e.iterator;else if(p)r=e;else{if(!(i=Ud(e)))throw Fd(Pd(e)+" is not iterable");if(jd(i)){for(a=0,o=Ad(e);o>a;a++)if((s=m(e[a]))&&Md(qd,s))return s;return new Dd(!1)}r=Ld(e,i)}for(u=d?e.next:r.next;!(c=Id(u,r)).done;){try{s=m(c.value)}catch(e){Nd(r,"throw",e)}if("object"==typeof s&&s&&Md(qd,s))return s}return new Dd(!1)},zd=rt("iterator"),Wd=!1;try{var $d=0,Kd={next:function(){return{done:!!$d++}},return:function(){Wd=!0}};Kd[zd]=function(){return this},Array.from(Kd,(function(){throw 2}))}catch(e){}var Hd=function(e,t){if(!t&&!Wd)return!1;var n=!1;try{var r={};r[zd]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n},Gd=zl,Vd=af.CONSTRUCTOR||!Hd((function(e){Gd.all(e).then(void 0,(function(){}))})),Yd=f,Jd=we,Qd=of,Xd=Dl,Zd=Bd;Zr({target:"Promise",stat:!0,forced:Vd},{all:function(e){var t=this,n=Qd.f(t),r=n.resolve,i=n.reject,a=Xd((function(){var n=Jd(t.resolve),a=[],o=0,s=1;Zd(e,(function(e){var u=o++,c=!1;s++,Yd(n,t,e).then((function(e){c||(c=!0,a[u]=e,--s||r(a))}),i)})),--s||r(a)}));return a.error&&i(a.value),n.promise}});var ep=Zr,tp=af.CONSTRUCTOR,np=zl,rp=J,ip=W,ap=Yn,op=np&&np.prototype;if(ep({target:"Promise",proto:!0,forced:tp,real:!0},{catch:function(e){return this.then(void 0,e)}}),ip(np)){var sp=rp("Promise").prototype.catch;op.catch!==sp&&ap(op,"catch",sp,{unsafe:!0})}var up=f,cp=we,lp=of,fp=Dl,dp=Bd;Zr({target:"Promise",stat:!0,forced:Vd},{race:function(e){var t=this,n=lp.f(t),r=n.reject,i=fp((function(){var i=cp(t.resolve);dp(e,(function(e){up(i,t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var pp=f,hp=of;Zr({target:"Promise",stat:!0,forced:af.CONSTRUCTOR},{reject:function(e){var t=hp.f(this);return pp(t.reject,void 0,e),t.promise}});var vp=Lt,yp=H,mp=of,gp=function(e,t){if(vp(e),yp(t)&&t.constructor===e)return t;var n=mp.f(e);return(0,n.resolve)(t),n.promise},bp=Zr,wp=af.CONSTRUCTOR,kp=gp;J("Promise"),bp({target:"Promise",stat:!0,forced:wp},{resolve:function(e){return kp(this,e)}});var xp=Do.map;Zr({target:"Array",proto:!0,forced:!Fu("map")},{map:function(e){return xp(this,e,arguments.length>1?arguments[1]:void 0)}});var _p={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Sp=gt("span").classList,Op=Sp&&Sp.constructor&&Sp.constructor.prototype,Ep=Op===Object.prototype?void 0:Op,Tp=o,Rp=function(e,t){var n=[][e];return!!n&&Tp((function(){n.call(null,t||function(){return 1},1)}))},Ip=Do.forEach,Cp=Rp("forEach")?[].forEach:function(e){return Ip(this,e,arguments.length>1?arguments[1]:void 0)},Pp=i,jp=_p,Ap=Ep,Mp=Cp,Lp=Yt,Up=function(e){if(e&&e.forEach!==Mp)try{Lp(e,"forEach",Mp)}catch(t){e.forEach=Mp}};for(var Np in jp)jp[Np]&&Up(Pp[Np]&&Pp[Np].prototype);Up(Ap);var Fp,Dp=Object.prototype,qp=Dp.hasOwnProperty,Bp="function"==typeof Symbol?Symbol:{},zp=Bp.iterator||"@@iterator",Wp=Bp.asyncIterator||"@@asyncIterator",$p=Bp.toStringTag||"@@toStringTag";function Kp(e,t,n,r){var i=t&&t.prototype instanceof Xp?t:Xp,a=Object.create(i.prototype),o=new fh(r||[]);return a._invoke=function(e,t,n){var r=Gp;return function(i,a){if(r===Yp)throw new Error("Generator is already running");if(r===Jp){if("throw"===i)throw a;return ph()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=uh(o,n);if(s){if(s===Qp)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===Gp)throw r=Jp,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=Yp;var u=Hp(e,t,n);if("normal"===u.type){if(r=n.done?Jp:Vp,u.arg===Qp)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=Jp,n.method="throw",n.arg=u.arg)}}}(e,n,o),a}function Hp(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}var Gp="suspendedStart",Vp="suspendedYield",Yp="executing",Jp="completed",Qp={};function Xp(){}function Zp(){}function eh(){}var th={};th[zp]=function(){return this};var nh=Object.getPrototypeOf,rh=nh&&nh(nh(dh([])));rh&&rh!==Dp&&qp.call(rh,zp)&&(th=rh);var ih=eh.prototype=Xp.prototype=Object.create(th);function ah(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function oh(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===Zp||"GeneratorFunction"===(t.displayName||t.name))}function sh(e,t){function n(r,i,a,o){var s=Hp(e[r],e,i);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"===tc(c)&&qp.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,a,o)}),(function(e){n("throw",e,a,o)})):t.resolve(c).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,o)}))}o(s.arg)}var r;this._invoke=function(e,i){function a(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(a,a):a()}}function uh(e,t){var n=e.iterator[t.method];if(n===Fp){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=Fp,uh(e,t),"throw"===t.method))return Qp;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return Qp}var r=Hp(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,Qp;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=Fp),t.delegate=null,Qp):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,Qp)}function ch(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function lh(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function fh(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(ch,this),this.reset(!0)}function dh(e){if(e){var t=e[zp];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(qp.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=Fp,t.done=!0,t};return r.next=r}}return{next:ph}}function ph(){return{value:Fp,done:!0}}Zp.prototype=ih.constructor=eh,eh.constructor=Zp,eh[$p]=Zp.displayName="GeneratorFunction",ah(sh.prototype),sh.prototype[Wp]=function(){return this},ah(ih),ih[$p]="Generator",ih[zp]=function(){return this},ih.toString=function(){return"[object Generator]"},fh.prototype={constructor:fh,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=Fp,this.done=!1,this.delegate=null,this.method="next",this.arg=Fp,this.tryEntries.forEach(lh),!e)for(var t in this)"t"===t.charAt(0)&&qp.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=Fp)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=Fp),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var o=qp.call(i,"catchLoc"),s=qp.call(i,"finallyLoc");if(o&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(o){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&qp.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,Qp):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),Qp},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),lh(n),Qp}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;lh(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:dh(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=Fp),Qp}};var hh={wrap:Kp,isGeneratorFunction:oh,AsyncIterator:sh,mark:function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,eh):(e.__proto__=eh,$p in e||(e[$p]="GeneratorFunction")),e.prototype=Object.create(ih),e},awrap:function(e){return{__await:e}},async:function(e,t,n,r,i){void 0===i&&(i=Promise);var a=new sh(Kp(e,t,n,r),i);return oh(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},keys:function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},values:dh},vh=Object.freeze({__proto__:null,default:hh});function yh(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":tc(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function mh(e,t){if("object"===("undefined"==typeof Reflect?"undefined":tc(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var gh=TypeError,bh=function(e){if(e>9007199254740991)throw gh("Maximum allowed index exceeded");return e},wh=Zr,kh=o,xh=So,_h=H,Sh=Fe,Oh=lr,Eh=bh,Th=Ha,Rh=Po,Ih=Fu,Ch=ae,Ph=rt("isConcatSpreadable"),jh=Ch>=51||!kh((function(){var e=[];return e[Ph]=!1,e.concat()[0]!==e})),Ah=Ih("concat"),Mh=function(e){if(!_h(e))return!1;var t=e[Ph];return void 0!==t?!!t:xh(e)};wh({target:"Array",proto:!0,arity:1,forced:!jh||!Ah},{concat:function(e){var t,n,r,i,a,o=Sh(this),s=Rh(o,0),u=0;for(t=-1,r=arguments.length;t<r;t++)if(Mh(a=-1===t?o:arguments[t]))for(i=Oh(a),Eh(u+i),n=0;n<i;n++,u++)n in a&&Th(s,u,a[n]);else Eh(u+1),Th(s,u++,a);return s.length=u,s}});var Lh=Lt,Uh=Td,Nh=xo,Fh=f,Dh=Fe,qh=function(e,t,n,r){try{return r?t(Lh(n)[0],n[1]):t(n)}catch(t){Uh(e,"throw",t)}},Bh=ld,zh=Hi,Wh=lr,$h=Ha,Kh=_d,Hh=yd,Gh=Array,Vh=function(e){var t=Dh(e),n=zh(this),r=arguments.length,i=r>1?arguments[1]:void 0,a=void 0!==i;a&&(i=Nh(i,r>2?arguments[2]:void 0));var o,s,u,c,l,f,d=Hh(t),p=0;if(!d||this===Gh&&Bh(d))for(o=Wh(t),s=n?new this(o):Gh(o);o>p;p++)f=a?i(t[p],p):t[p],$h(s,p,f);else for(l=(c=Kh(t,d)).next,s=n?new this:[];!(u=Fh(l,c)).done;p++)f=a?qh(c,i,[u.value,p],!0):u.value,$h(s,p,f);return s.length=p,s},Yh=Vh;Zr({target:"Array",stat:!0,forced:!Hd((function(e){Array.from(e)}))},{from:Yh});var Jh,Qh,Xh,Zh=_,ev=tr,tv=Ba,nv=U,rv=Zh("".charAt),iv=Zh("".charCodeAt),av=Zh("".slice),ov=function(e){return function(t,n){var r,i,a=tv(nv(t)),o=ev(n),s=a.length;return o<0||o>=s?e?"":void 0:(r=iv(a,o))<55296||r>56319||o+1===s||(i=iv(a,o+1))<56320||i>57343?e?rv(a,o):r:e?av(a,o,o+2):i-56320+(r-55296<<10)+65536}},sv={codeAt:ov(!1),charAt:ov(!0)},uv=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),cv=Be,lv=W,fv=Fe,dv=uv,pv=mn("IE_PROTO"),hv=Object,vv=hv.prototype,yv=dv?hv.getPrototypeOf:function(e){var t=fv(e);if(cv(t,pv))return t[pv];var n=t.constructor;return lv(n)&&t instanceof n?n.prototype:t instanceof hv?vv:null},mv=o,gv=W,bv=H,wv=yv,kv=Yn,xv=rt("iterator"),_v=!1;[].keys&&("next"in(Xh=[].keys())?(Qh=wv(wv(Xh)))!==Object.prototype&&(Jh=Qh):_v=!0);var Sv=!bv(Jh)||mv((function(){var e={};return Jh[xv].call(e)!==e}));Sv&&(Jh={}),gv(Jh[xv])||kv(Jh,xv,(function(){return this}));var Ov={IteratorPrototype:Jh,BUGGY_SAFARI_ITERATORS:_v},Ev=Ov.IteratorPrototype,Tv=xa,Rv=g,Iv=ri,Cv=od,Pv=function(){return this},jv=function(e,t,n,r){var i=t+" Iterator";return e.prototype=Tv(Ev,{next:Rv(+!r,n)}),Iv(e,i,!1),Cv[i]=Pv,e},Av=Zr,Mv=f,Lv=W,Uv=jv,Nv=yv,Fv=xc,Dv=ri,qv=Yt,Bv=Yn,zv=od,Wv=nn.PROPER,$v=nn.CONFIGURABLE,Kv=Ov.IteratorPrototype,Hv=Ov.BUGGY_SAFARI_ITERATORS,Gv=rt("iterator"),Vv="keys",Yv="values",Jv="entries",Qv=function(){return this},Xv=function(e,t,n,r,i,a,o){Uv(n,t,r);var s,u,c,l=function(e){if(e===i&&v)return v;if(!Hv&&e in p)return p[e];switch(e){case Vv:case Yv:case Jv:return function(){return new n(this,e)}}return function(){return new n(this)}},f=t+" Iterator",d=!1,p=e.prototype,h=p[Gv]||p["@@iterator"]||i&&p[i],v=!Hv&&h||l(i),y="Array"==t&&p.entries||h;if(y&&(s=Nv(y.call(new e)))!==Object.prototype&&s.next&&(Nv(s)!==Kv&&(Fv?Fv(s,Kv):Lv(s[Gv])||Bv(s,Gv,Qv)),Dv(s,f,!0)),Wv&&i==Yv&&h&&h.name!==Yv&&($v?qv(p,"name",Yv):(d=!0,v=function(){return Mv(h,this)})),i)if(u={values:l(Yv),keys:a?v:l(Vv),entries:l(Jv)},o)for(c in u)(Hv||d||!(c in p))&&Bv(p,c,u[c]);else Av({target:t,proto:!0,forced:Hv||d},u);return p[Gv]!==v&&Bv(p,Gv,v,{name:i}),zv[t]=v,u},Zv=function(e,t){return{value:e,done:t}},ey=sv.charAt,ty=Ba,ny=jn,ry=Xv,iy=Zv,ay="String Iterator",oy=ny.set,sy=ny.getterFor(ay);ry(String,"String",(function(e){oy(this,{type:ay,string:ty(e),index:0})}),(function(){var e,t=sy(this),n=t.string,r=t.index;return r>=n.length?iy(void 0,!0):(e=ey(n,r),t.index+=e.length,iy(e,!1))}));var uy,cy,ly,fy={exports:{}};function dy(e,t){return["".concat((new Date).toISOString()," Conversations ").concat(e,":")].concat(Array.from(t))}cy=t,ly=function(){var e=function(){},t="undefined",n=("undefined"==typeof window?"undefined":tc(window))!==t&&tc(window.navigator)!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"];function i(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function a(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(r){return"debug"===r&&(r="log"),("undefined"==typeof console?"undefined":tc(console))!==t&&("trace"===r&&n?a:void 0!==console[r]?i(console,r):void 0!==console.log?i(console,"log"):e)}function s(t,n){for(var i=0;i<r.length;i++){var a=r[i];this[a]=i<t?e:this.methodFactory(a,t,n)}this.log=this.debug}function u(e,n,r){return function(){("undefined"==typeof console?"undefined":tc(console))!==t&&(s.call(this,n,r),this[e].apply(this,arguments))}}function c(e,t,n){return o(e)||u.apply(this,arguments)}function l(e,n,i){var a,o=this;n=null==n?"WARN":n;var u="loglevel";function l(){var e;if(("undefined"==typeof window?"undefined":tc(window))!==t&&u){try{e=window.localStorage[u]}catch(e){}if(tc(e)===t)try{var n=window.document.cookie,r=n.indexOf(encodeURIComponent(u)+"=");-1!==r&&(e=/^([^;]+)/.exec(n.slice(r))[1])}catch(e){}return void 0===o.levels[e]&&(e=void 0),e}}"string"==typeof e?u+=":"+e:"symbol"===tc(e)&&(u=void 0),o.name=e,o.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},o.methodFactory=i||c,o.getLevel=function(){return a},o.setLevel=function(n,i){if("string"==typeof n&&void 0!==o.levels[n.toUpperCase()]&&(n=o.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=o.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(a=n,!1!==i&&function(e){var n=(r[e]||"silent").toUpperCase();if(("undefined"==typeof window?"undefined":tc(window))!==t&&u){try{return void(window.localStorage[u]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"="+n+";"}catch(e){}}}(n),s.call(o,n,e),("undefined"==typeof console?"undefined":tc(console))===t&&n<o.levels.SILENT)return"No console available for logging"},o.setDefaultLevel=function(e){n=e,l()||o.setLevel(e,!1)},o.resetLevel=function(){o.setLevel(n,!1),function(){if(("undefined"==typeof window?"undefined":tc(window))!==t&&u){try{return void window.localStorage.removeItem(u)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},o.enableAll=function(e){o.setLevel(o.levels.TRACE,e)},o.disableAll=function(e){o.setLevel(o.levels.SILENT,e)};var f=l();null==f&&(f=n),o.setLevel(f,!1)}var f=new l,d={};f.getLogger=function(e){if("symbol"!==tc(e)&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=d[e];return t||(t=d[e]=new l(e,f.getLevel(),f.methodFactory)),t};var p=("undefined"==typeof window?"undefined":tc(window))!==t?window.log:void 0;return f.noConflict=function(){return("undefined"==typeof window?"undefined":tc(window))!==t&&window.log===f&&(window.log=p),f},f.getLoggers=function(){return d},f.default=f,f},(uy=fy).exports?uy.exports=ly():cy.log=ly();var py,hy,vy=fy.exports.getLogger("twilio-conversations"),yy=function(){function e(t){sc(this,e),uc(this,"prefix",""),this.prefix=null!=t&&t.length>0?t+" ":""}return oc(e,[{key:"setLevel",value:function(e){vy.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];vy.trace.apply(null,dy(this.prefix+"T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];vy.debug.apply(null,dy(this.prefix+"D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];vy.info.apply(null,dy(this.prefix+"I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];vy.warn.apply(null,dy(this.prefix+"W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];vy.error.apply(null,dy(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){vy.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];vy.trace.apply(null,dy("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];vy.debug.apply(null,dy("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];vy.info.apply(null,dy("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];vy.warn.apply(null,dy("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];vy.error.apply(null,dy("E",t))}}]),e}(),my={};Object.defineProperty(my,"__esModule",{value:!0});var gy="\\d+(?:[\\.,]\\d+)?",by="P(?:"+("("+gy+"W)")+"|"+("("+gy+"Y)?("+gy+"M)?("+gy+"D)?")+"(?:"+("T("+gy+"H)?("+gy+"M)?("+gy+"S)?")+")?)",wy=["weeks","years","months","days","hours","minutes","seconds"],ky=my.pattern=new RegExp(by),xy=hy=my.parse=function(e){return e.match(ky).slice(1).reduce((function(e,t,n){return e[wy[n]]=parseFloat(t)||0,e}),{})},_y=my.end=function(e,t){var n=t?t.getTime():Date.now(),r=new Date(n);return r.setFullYear(r.getFullYear()+e.years),r.setMonth(r.getMonth()+e.months),r.setDate(r.getDate()+e.days),r.setHours(r.getHours()+e.hours),r.setMinutes(r.getMinutes()+e.minutes),r.setMilliseconds(r.getMilliseconds()+1e3*e.seconds),r.setDate(r.getDate()+7*e.weeks),r},Sy=py=my.toSeconds=function(e,t){var n=t?t.getTime():Date.now(),r=new Date(n);return(_y(e,r).getTime()-r.getTime())/1e3};function Oy(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ey(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Oy(Object(n),!0).forEach((function(t){uc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Oy(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}my.default={end:_y,toSeconds:Sy,pattern:ky,parse:xy};var Ty="PT5S",Ry="PT5S",Iy=oc((function e(){var t,n,r,i,a,o,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},u=arguments.length>1?arguments[1]:void 0,c=arguments.length>2?arguments[2]:void 0;sc(this,e),uc(this,"links",void 0),uc(this,"limits",void 0),uc(this,"productId",void 0),uc(this,"typingIndicatorTimeoutOverride",void 0),uc(this,"typingIndicatorTimeoutDefault",5e3),uc(this,"backoffConfiguration",void 0),uc(this,"retryWhenThrottled",void 0),uc(this,"consumptionReportInterval",void 0),uc(this,"userInfosToSubscribe",void 0),uc(this,"httpCacheInterval",void 0),uc(this,"reachabilityEnabled",void 0),uc(this,"userIdentity",void 0),uc(this,"userInfo",void 0),uc(this,"myConversations",void 0);var l=s.Chat||s.IPMessaging||s||{};this.productId=l.productId,this.links={myConversations:u.links.my_conversations,conversations:u.links.conversations,users:u.links.users,currentUser:u.links.current_user,typing:u.links.typing,mediaService:u.links.media_service,mediaSetService:u.links.media_set_service,messagesReceipts:u.links.messages_receipts},this.limits={mediaAttachmentsCountLimit:u.options.media_attachments_count_limit,mediaAttachmentSizeLimitInMb:u.options.media_attachment_size_limit_in_mb,mediaAttachmentsTotalSizeLimitInMb:u.options.media_attachments_total_size_limit_in_mb,emailHistoriesAllowedContentTypes:u.options.email_histories_allowed_mime_types,emailBodiesAllowedContentTypes:u.options.email_bodies_allowed_mime_types},this.typingIndicatorTimeoutOverride=l.typingIndicatorTimeoutOverride,this.backoffConfiguration=Ey({min:1e3,max:4e3,maxAttemptsCount:3},l.backoffConfigOverride),this.retryWhenThrottled=void 0===l.retryWhenThrottledOverride||l.retryWhenThrottledOverride,this.userInfosToSubscribe=null!==(t=null!==(n=l.userInfosToSubscribeOverride)&&void 0!==n?n:u.options.user_infos_to_subscribe)&&void 0!==t?t:100,this.reachabilityEnabled=u.options.reachability_enabled,this.userIdentity=u.identity,this.userInfo=u.sync_objects.my_user_info,this.myConversations=u.sync_objects.my_conversations;var f=null!==(r=null!==(i=l.httpCacheIntervalOverride)&&void 0!==i?i:u.options.http_cache_interval)&&void 0!==r?r:Ty;try{this.httpCacheInterval=py(hy(f))}catch(e){c.error("Failed to parse http cache interval ".concat(f,", using default value ").concat(Ty)),this.httpCacheInterval=py(hy(Ty))}var d=null!==(a=null!==(o=l.consumptionReportIntervalOverride)&&void 0!==o?o:u.options.consumption_report_interval)&&void 0!==a?a:Ry;try{this.consumptionReportInterval=py(hy(d))}catch(e){c.error("Failed to parse consumption report interval ".concat(d,", using default value ").concat(Ry)),this.consumptionReportInterval=py(hy(Ry))}})),Cy=rt,Py=xa,jy=Ct.f,Ay=Cy("unscopables"),My=Array.prototype;null==My[Ay]&&jy(My,Ay,{configurable:!0,value:Py(null)});var Ly=function(e){My[Ay][e]=!0},Uy=D,Ny=Ly,Fy=od,Dy=jn,qy=Ct.f,By=Xv,zy=Zv,Wy=s,$y="Array Iterator",Ky=Dy.set,Hy=Dy.getterFor($y),Gy=By(Array,"Array",(function(e,t){Ky(this,{type:$y,target:Uy(e),index:0,kind:t})}),(function(){var e=Hy(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,zy(void 0,!0)):zy("keys"==n?r:"values"==n?t[r]:[r,t[r]],!1)}),"values"),Vy=Fy.Arguments=Fy.Array;if(Ny("keys"),Ny("values"),Ny("entries"),Wy&&"values"!==Vy.name)try{qy(Vy,"name",{value:"values"})}catch(e){}var Yy=i,Jy=_p,Qy=Ep,Xy=Gy,Zy=Yt,em=rt,tm=em("iterator"),nm=em("toStringTag"),rm=Xy.values,im=function(e,t){if(e){if(e[tm]!==rm)try{Zy(e,tm,rm)}catch(t){e[tm]=rm}if(e[nm]||Zy(e,nm,t),Jy[t])for(var n in Xy)if(e[n]!==Xy[n])try{Zy(e,n,Xy[n])}catch(t){e[n]=Xy[n]}}};for(var am in Jy)im(Yy[am]&&Yy[am].prototype,am);im(Qy,"DOMTokenList");var om=W,sm=H,um=xc,cm=function(e,t,n){var r,i;return um&&om(r=t.constructor)&&r!==n&&sm(i=r.prototype)&&i!==n.prototype&&um(e,i),e},lm=_(1..valueOf),fm=U,dm=Ba,pm=_("".replace),hm="[\t\n\v\f\r \u2028\u2029\ufeff]",vm=RegExp("^"+hm+hm+"*"),ym=RegExp(hm+hm+"*$"),mm=function(e){return function(t){var n=dm(fm(t));return 1&e&&(n=pm(n,vm,"")),2&e&&(n=pm(n,ym,"")),n}},gm={start:mm(1),end:mm(2),trim:mm(3)},bm=s,wm=i,km=_,xm=Kr,_m=Yn,Sm=Be,Om=cm,Em=Q,Tm=he,Rm=ft,Im=o,Cm=Jn.f,Pm=a.f,jm=Ct.f,Am=lm,Mm=gm.trim,Lm="Number",Um=wm[Lm],Nm=Um.prototype,Fm=wm.TypeError,Dm=km("".slice),qm=km("".charCodeAt),Bm=function(e){var t=Rm(e,"number");return"bigint"==typeof t?t:zm(t)},zm=function(e){var t,n,r,i,a,o,s,u,c=Rm(e,"number");if(Tm(c))throw Fm("Cannot convert a Symbol value to a number");if("string"==typeof c&&c.length>2)if(c=Mm(c),43===(t=qm(c,0))||45===t){if(88===(n=qm(c,2))||120===n)return NaN}else if(48===t){switch(qm(c,1)){case 66:case 98:r=2,i=49;break;case 79:case 111:r=8,i=55;break;default:return+c}for(o=(a=Dm(c,2)).length,s=0;s<o;s++)if((u=qm(a,s))<48||u>i)return NaN;return parseInt(a,r)}return+c};if(xm(Lm,!Um(" 0o1")||!Um("0b1")||Um("+0x1"))){for(var Wm,$m=function(e){var t=arguments.length<1?0:Um(Bm(e)),n=this;return Em(Nm,n)&&Im((function(){Am(n)}))?Om(Object(t),n,$m):t},Km=bm?Cm(Um):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),Hm=0;Km.length>Hm;Hm++)Sm(Um,Wm=Km[Hm])&&!Sm($m,Wm)&&jm($m,Wm,Pm(Um,Wm));$m.prototype=Nm,Nm.constructor=$m,_m(wm,Lm,$m,{constructor:!0})}var Gm,Vm,Ym=Lt,Jm=function(){var e=Ym(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Qm=o,Xm=i.RegExp,Zm=Qm((function(){var e=Xm("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),eg=Zm||Qm((function(){return!Xm("a","y").sticky})),tg=Zm||Qm((function(){var e=Xm("^r","gy");return e.lastIndex=2,null!=e.exec("str")})),ng={BROKEN_CARET:tg,MISSED_STICKY:eg,UNSUPPORTED_Y:Zm},rg=o,ig=i.RegExp,ag=rg((function(){var e=ig(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),og=o,sg=i.RegExp,ug=og((function(){var e=sg("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),cg=f,lg=_,fg=Ba,dg=Jm,pg=ng,hg=Re.exports,vg=xa,yg=jn.get,mg=ag,gg=ug,bg=hg("native-string-replace",String.prototype.replace),wg=RegExp.prototype.exec,kg=wg,xg=lg("".charAt),_g=lg("".indexOf),Sg=lg("".replace),Og=lg("".slice),Eg=(Vm=/b*/g,cg(wg,Gm=/a/,"a"),cg(wg,Vm,"a"),0!==Gm.lastIndex||0!==Vm.lastIndex),Tg=pg.BROKEN_CARET,Rg=void 0!==/()??/.exec("")[1];(Eg||Rg||Tg||mg||gg)&&(kg=function(e){var t,n,r,i,a,o,s,u=this,c=yg(u),l=fg(e),f=c.raw;if(f)return f.lastIndex=u.lastIndex,t=cg(kg,f,l),u.lastIndex=f.lastIndex,t;var d=c.groups,p=Tg&&u.sticky,h=cg(dg,u),v=u.source,y=0,m=l;if(p&&(h=Sg(h,"y",""),-1===_g(h,"g")&&(h+="g"),m=Og(l,u.lastIndex),u.lastIndex>0&&(!u.multiline||u.multiline&&"\n"!==xg(l,u.lastIndex-1))&&(v="(?: "+v+")",m=" "+m,y++),n=new RegExp("^(?:"+v+")",h)),Rg&&(n=new RegExp("^"+v+"$(?!\\s)",h)),Eg&&(r=u.lastIndex),i=cg(wg,p?n:u,m),p?i?(i.input=Og(i.input,y),i[0]=Og(i[0],y),i.index=u.lastIndex,u.lastIndex+=i[0].length):u.lastIndex=0:Eg&&i&&(u.lastIndex=u.global?i.index+i[0].length:r),Rg&&i&&i.length>1&&cg(bg,i[0],n,(function(){for(a=1;a<arguments.length-2;a++)void 0===arguments[a]&&(i[a]=void 0)})),i&&d)for(i.groups=o=vg(null),a=0;a<d.length;a++)o[(s=d[a])[0]]=i[s[1]];return i});var Ig=kg;Zr({target:"RegExp",proto:!0,forced:/./.exec!==Ig},{exec:Ig});var Cg=go,Pg=Yn,jg=Ig,Ag=o,Mg=rt,Lg=Yt,Ug=Mg("species"),Ng=RegExp.prototype,Fg=function(e,t,n,r){var i=Mg(e),a=!Ag((function(){var t={};return t[i]=function(){return 7},7!=""[e](t)})),o=a&&!Ag((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[Ug]=function(){return n},n.flags="",n[i]=/./[i]),n.exec=function(){return t=!0,null},n[i](""),!t}));if(!a||!o||n){var s=Cg(/./[i]),u=t(i,""[e],(function(e,t,n,r,i){var o=Cg(e),u=t.exec;return u===jg||u===Ng.exec?a&&!i?{done:!0,value:s(t,n,r)}:{done:!0,value:o(n,t,r)}:{done:!1}}));Pg(String.prototype,e,u[0]),Pg(Ng,i,u[1])}r&&Lg(Ng[i],"sham",!0)},Dg=sv.charAt,qg=function(e,t,n){return t+(n?Dg(e,t).length:1)},Bg=_,zg=Fe,Wg=Math.floor,$g=Bg("".charAt),Kg=Bg("".replace),Hg=Bg("".slice),Gg=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Vg=/\$([$&'`]|\d{1,2})/g,Yg=f,Jg=Lt,Qg=W,Xg=T,Zg=Ig,eb=TypeError,tb=function(e,t){var n=e.exec;if(Qg(n)){var r=Yg(n,e,t);return null!==r&&Jg(r),r}if("RegExp"===Xg(e))return Yg(Zg,e,t);throw eb("RegExp#exec called on incompatible receiver")},nb=li,rb=f,ib=_,ab=Fg,ob=o,sb=Lt,ub=W,cb=A,lb=tr,fb=ur,db=Ba,pb=U,hb=qg,vb=_e,yb=function(e,t,n,r,i,a){var o=n+e.length,s=r.length,u=Vg;return void 0!==i&&(i=zg(i),u=Gg),Kg(a,u,(function(a,u){var c;switch($g(u,0)){case"$":return"$";case"&":return e;case"`":return Hg(t,0,n);case"'":return Hg(t,o);case"<":c=i[Hg(u,1,-1)];break;default:var l=+u;if(0===l)return a;if(l>s){var f=Wg(l/10);return 0===f?a:f<=s?void 0===r[f-1]?$g(u,1):r[f-1]+$g(u,1):a}c=r[l-1]}return void 0===c?"":c}))},mb=tb,gb=rt("replace"),bb=Math.max,wb=Math.min,kb=ib([].concat),xb=ib([].push),_b=ib("".indexOf),Sb=ib("".slice),Ob="$0"==="a".replace(/./,"$0"),Eb=!!/./[gb]&&""===/./[gb]("a","$0"),Tb=!ob((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));ab("replace",(function(e,t,n){var r=Eb?"$":"$0";return[function(e,n){var r=pb(this),i=cb(e)?void 0:vb(e,gb);return i?rb(i,e,r,n):rb(t,db(r),e,n)},function(e,i){var a=sb(this),o=db(e);if("string"==typeof i&&-1===_b(i,r)&&-1===_b(i,"$<")){var s=n(t,a,o,i);if(s.done)return s.value}var u=ub(i);u||(i=db(i));var c=a.global;if(c){var l=a.unicode;a.lastIndex=0}for(var f=[];;){var d=mb(a,o);if(null===d)break;if(xb(f,d),!c)break;""===db(d[0])&&(a.lastIndex=hb(o,fb(a.lastIndex),l))}for(var p,h="",v=0,y=0;y<f.length;y++){for(var m=db((d=f[y])[0]),g=bb(wb(lb(d.index),o.length),0),b=[],w=1;w<d.length;w++)xb(b,void 0===(p=d[w])?p:String(p));var k=d.groups;if(u){var x=kb([m],b,g,o);void 0!==k&&xb(x,k);var _=db(nb(i,void 0,x))}else _=yb(m,o,g,b,k,i);g>=v&&(h+=Sb(o,v,g)+_,v=g+m.length)}return h+Sb(o,v)}]}),!Tb||!Ob||Eb);var Rb=Zr,Ib=j,Cb=D,Pb=Rp,jb=_([].join),Ab=Ib!=Object,Mb=Pb("join",",");function Lb(e){return JSON.parse(JSON.stringify(e))}function Ub(e){return void 0===e||isNaN(Number(e))?null:Number(e)}function Nb(e){try{return new Date(e)}catch(e){return null}}function Fb(e,t,n){var r={};if(e)try{r=JSON.parse(e)}catch(e){n.warn(t,e)}return r}Rb({target:"Array",proto:!0,forced:Ab||!Mb},{join:function(e){return jb(Cb(this),void 0===e?",":e)}});var Db=function(){function e(t){sc(this,e),uc(this,"base",void 0),uc(this,"args",void 0),uc(this,"paths",void 0),this.base=t.replace(/\/$/,""),this.args=[],this.paths=[]}return oc(e,[{key:"arg",value:function(e,t){return void 0!==t&&this.args.push(encodeURIComponent(e)+"="+encodeURIComponent(t)),this}},{key:"path",value:function(e){return this.paths.push(encodeURIComponent(e)),this}},{key:"build",value:function(){var e=this.base;return this.paths.length&&(e+="/"+this.paths.join("/")),this.args.length&&(e+="?"+this.args.join("&")),e}}]),e}(),qb={},Bb=Zr,zb=So,Wb=Hi,$b=H,Kb=ar,Hb=lr,Gb=D,Vb=Ha,Yb=rt,Jb=fi,Qb=Fu("slice"),Xb=Yb("species"),Zb=Array,ew=Math.max;Bb({target:"Array",proto:!0,forced:!Qb},{slice:function(e,t){var n,r,i,a=Gb(this),o=Hb(a),s=Kb(e,o),u=Kb(void 0===t?o:t,o);if(zb(a)&&(n=a.constructor,(Wb(n)&&(n===Zb||zb(n.prototype))||$b(n)&&null===(n=n[Xb]))&&(n=void 0),n===Zb||void 0===n))return Jb(a,s,u);for(r=new(void 0===n?Zb:n)(ew(u-s,0)),i=0;s<u;s++,i++)s in a&&Vb(r,i,a[s]);return r.length=i,r}});var tw,nw,rw=Zr,iw=f,aw=W,ow=Lt,sw=Ba,uw=(tw=!1,(nw=/[ac]/).exec=function(){return tw=!0,/./.exec.apply(this,arguments)},!0===nw.test("abc")&&tw),cw=/./.test;rw({target:"RegExp",proto:!0,forced:!uw},{test:function(e){var t=ow(this),n=sw(e),r=t.exec;if(!aw(r))return iw(cw,t,n);var i=iw(r,t,n);return null!==i&&(ow(i),!0)}});var lw=Zr,fw=s,dw=i,pw=_,hw=Be,vw=W,yw=Q,mw=Ba,gw=Ct.f,bw=Ur,ww=dw.Symbol,kw=ww&&ww.prototype;if(fw&&vw(ww)&&(!("description"in kw)||void 0!==ww().description)){var xw={},_w=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:mw(arguments[0]),t=yw(kw,this)?new ww(e):void 0===e?ww():ww(e);return""===e&&(xw[t]=!0),t};bw(_w,ww),_w.prototype=kw,kw.constructor=_w;var Sw="Symbol(test)"==String(ww("test")),Ow=pw(kw.valueOf),Ew=pw(kw.toString),Tw=/^Symbol\((.*)\)[^)]+$/,Rw=pw("".replace),Iw=pw("".slice);gw(kw,"description",{configurable:!0,get:function(){var e=Ow(this);if(hw(xw,e))return"";var t=Ew(e),n=Sw?Iw(t,7,-1):Rw(t,Tw,"$1");return""===n?void 0:n}}),lw({global:!0,constructor:!0,forced:!0},{Symbol:_w})}lo("iterator");var Cw={exports:{}};!function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(Cw);var Pw=s,jw=nn.EXISTS,Aw=_,Mw=Ct.f,Lw=Function.prototype,Uw=Aw(Lw.toString),Nw=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,Fw=Aw(Nw.exec);Pw&&!jw&&Mw(Lw,"name",{configurable:!0,get:function(){try{return Fw(Nw,Uw(this))[1]}catch(e){return""}}});var Dw={exports:{}},qw={exports:{}};!function(e){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports}(qw);var Bw={exports:{}};!function(e){e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],u=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports}(Bw);var zw={exports:{}},Ww={exports:{}};!function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports}(Ww),function(e){var t=Ww.exports;e.exports=function(e,n){if(e){if("string"==typeof e)return t(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}(zw);var $w={exports:{}};!function(e){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}($w),function(e){var t=qw.exports,n=Bw.exports,r=zw.exports,i=$w.exports;e.exports=function(e,a){return t(e)||n(e,a)||r(e,a)||i()},e.exports.__esModule=!0,e.exports.default=e.exports}(Dw);var Kw={exports:{}},Hw={exports:{}};!function(e){var t=Ww.exports;e.exports=function(e){if(Array.isArray(e))return t(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(Hw);var Gw={exports:{}};!function(e){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(Gw);var Vw={exports:{}};!function(e){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}(Vw),function(e){var t=Hw.exports,n=Gw.exports,r=zw.exports,i=Vw.exports;e.exports=function(e){return t(e)||n(e)||r(e)||i()},e.exports.__esModule=!0,e.exports.default=e.exports}(Kw);var Yw={exports:{}},Jw={exports:{}},Qw={exports:{}};!function(e){var t=Cw.exports.default;e.exports=function(e,n){if("object"!==t(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,n||"default");if("object"!==t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(Qw),function(e){var t=Cw.exports.default,n=Qw.exports;e.exports=function(e){var r=n(e,"string");return"symbol"===t(r)?r:String(r)},e.exports.__esModule=!0,e.exports.default=e.exports}(Jw),function(e){var t=Jw.exports;function n(e,n){for(var r=0;r<n.length;r++){var i=n[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,t(i.key),i)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports}(Yw);var Xw={exports:{}};!function(e){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports}(Xw);var Zw={exports:{}},ek={exports:{}};!function(e){function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(ek),function(e){var t=ek.exports;e.exports=function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),n&&t(e,n)},e.exports.__esModule=!0,e.exports.default=e.exports}(Zw);var tk={exports:{}},nk={exports:{}};!function(e){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports}(nk),function(e){var t=Cw.exports.default,n=nk.exports;e.exports=function(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(tk);var rk={exports:{}};!function(e){function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(rk);var ik=vr.includes,ak=Ly;Zr({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return ik(this,e,arguments.length>1?arguments[1]:void 0)}}),ak("includes");var ok=H,sk=Math.floor,uk=Number.isInteger||function(e){return!ok(e)&&isFinite(e)&&sk(e)===e};Zr({target:"Number",stat:!0},{isInteger:uk});var ck=s,lk=_,fk=ea,dk=D,pk=lk(d.f),hk=lk([].push),vk=function(e){return function(t){for(var n,r=dk(t),i=fk(r),a=i.length,o=0,s=[];a>o;)n=i[o++],ck&&!pk(r,n)||hk(s,e?[n,r[n]]:r[n]);return s}},yk={entries:vk(!0),values:vk(!1)}.entries;Zr({target:"Object",stat:!0},{entries:function(e){return yk(e)}}),Object.defineProperty(qb,"__esModule",{value:!0});var mk=Dw.exports,gk=Kw.exports,bk=Yw.exports,wk=Xw.exports,kk=Zw.exports,xk=tk.exports,_k=rk.exports;function Sk(e){return e&&"object"===tc(e)&&"default"in e?e:{default:e}}var Ok=Sk(Cw.exports),Ek=Sk(mk),Tk=Sk(gk),Rk=Sk(bk),Ik=Sk(wk),Ck=Sk(kk),Pk=Sk(xk),jk=Sk(_k),Ak=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return{checks:t}};function Mk(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Lk(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Lk(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Lk(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Uk=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ak((function(e){var n,r=!1,i=[],a=Mk(t);try{for(a.s();!(n=a.n()).done;){var o=n.value;"string"!=typeof o?(r=r||e instanceof o,i.push("an instance of ".concat(o.name))):(r=r||Ok.default(e)===o,i.push("of type ".concat(o)))}}catch(e){a.e(e)}finally{a.f()}return[r,i]}))};function Nk(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Fk(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Fk(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Fk(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Dk(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=jk.default(e);if(t){var i=jk.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Pk.default(this,n)}}function qk(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Bk(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Bk(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Bk(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var zk=function(e,t){if(t.length>e.length)throw new Error("Expected at most ".concat(e.length," argument(s), but got ").concat(t.length));for(;t.length<e.length;)t.push(void 0);var n,r=qk(t.entries());try{for(r.s();!(n=r.n()).done;){var i=Ek.default(n.value,2),a=i[0],o=i[1],s=Hk(e[a],o),u=Ek.default(s,4),c=u[0],l=u[1],f=u[2],d=u[3];if(!c)throw new Error("Argument ".concat(a+1," is expected to be ").concat(f).concat(d," but got ").concat(l))}}catch(e){r.e(e)}finally{r.f()}},Wk=function(e){var t,n,r;(["undefined","boolean","number","bigint","string"].includes(Ok.default(e))&&(n="string"==typeof e?'"'.concat(e,'"'):"".concat(e)),"object"===Ok.default(e)&&"Object"!==(null==e||null===(t=e.constructor)||void 0===t?void 0:t.name))&&(n=null===e?"null":"instance of ".concat(null==e||null===(r=e.constructor)||void 0===r?void 0:r.name));return n||(n=Ok.default(e)),n},$k=function(e){var t,n=[],r=qk(e);try{for(r.s();!(t=r.n()).done;){var i=t.value;n.push(Kk(i))}}catch(e){r.e(e)}finally{r.f()}return n},Kk=function(e){var t,n=[],r=qk(Array.isArray(e)?e:[e]);try{for(r.s();!(t=r.n()).done;){var i=t.value;"string"!=typeof i&&"function"!=typeof i?n.push(i):n.push(Uk(i))}}catch(e){r.e(e)}finally{r.f()}return n},Hk=function(e,t){var n,r,i=[],a=!1,o=qk(e);try{for(o.s();!(r=o.n()).done;){var s,u=qk(r.value.checks);try{for(u.s();!(s=u.n()).done;){var c=(0,s.value)(t),l=Ek.default(c,3),f=l[0],d=l[1],p=l[2];a=a||f,!n&&p&&(n=p),d&&(i=[].concat(Tk.default(i),"string"==typeof d?[d]:Tk.default(d)))}}catch(e){u.e(e)}finally{u.f()}}}catch(e){o.e(e)}finally{o.f()}if(a)return[!0];var h=n||Wk(t),v=i.length-1;return[!1,h,v>0?"".concat(i.slice(0,v).join(", ")," or ").concat(i[v]):i.join(", "),v>1?";":","]};function Gk(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Vk(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Vk(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Vk(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Yk=Ak((function(e){return["string"==typeof e&&e.length>0,"a non-empty string"]})),Jk=Ak((function(e){return["number"==typeof e&&Number.isInteger(e)&&e>=0,"a non-negative integer"]})),Qk=Ak((function(e){return["object"===Ok.default(e)&&null!==e&&!Array.isArray(e),"a pure object (non-null and non-array)"]}));function Xk(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Zk(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Zk(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Zk(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}qb.array=function(e,t){return Ak((function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(e)];var r,i=Xk(n.entries());try{for(i.s();!(r=i.n()).done;){var a=Ek.default(r.value,2),o=a[0],s=a[1],u=Hk(Kk(t),s),c=Ek.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"a valid array of ".concat(e," (index ").concat(o," should be ").concat(d,")"),"malformed array of ".concat(e," (index ").concat(o," is ").concat(f,")")]}}catch(e){i.e(e)}finally{i.f()}return[!0]}))};var ex=qb.custom=Ak,tx=qb.literal=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ak((function(e){var n,r=!1,i=[],a=Nk(t);try{for(a.s();!(n=a.n()).done;){var o=n.value;r=r||e===o,i.push("string"==typeof o?'"'.concat(o,'"'):"".concat(o))}}catch(e){a.e(e)}finally{a.f()}return[r,i]}))},nx=qb.nonEmptyArray=function(e,t){return Ak((function(n){if(!Array.isArray(n)||n.length<1)return[!1,"a non-empty array of ".concat(e)];var r,i=Gk(n.entries());try{for(i.s();!(r=i.n()).done;){var a=Ek.default(r.value,2),o=a[0],s=a[1],u=Hk(Kk(t),s),c=Ek.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"a valid non-empty array of ".concat(e," (index ").concat(o," should be ").concat(d,")"),"malformed array of ".concat(e," (index ").concat(o," is ").concat(f,")")]}}catch(e){i.e(e)}finally{i.f()}return[!0]}))},rx=qb.nonEmptyString=Yk,ix=qb.nonNegativeInteger=Jk,ax=qb.objectSchema=function(e,t){return Ak((function(n){if("object"!==Ok.default(n)||null===n||Array.isArray(n))return[!1,"valid ".concat(e," (should be a pure object)")];for(var r=0,i=Object.entries(t);r<i.length;r++){var a=Ek.default(i[r],2),o=a[0],s=a[1],u=Hk(Kk(s),n[o]),c=Ek.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"valid ".concat(e,' (key "').concat(o,'" should be ').concat(d,")"),"malformed ".concat(e,' (key "').concat(o,'" is ').concat(f,")")]}return[!0]}))},ox=qb.pureObject=Qk;qb.runtimeTypeValidation=zk,qb.stringifyReceivedType=Wk,qb.type=Uk;var sx=qb.validateConstructorTypes=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=$k(t);return function(e){return function(e){Ck.default(n,e);var t=Dk(n);function n(){Ik.default(this,n);for(var e=arguments.length,i=new Array(e),a=0;a<e;a++)i[a]=arguments[a];return zk(r,i),t.call.apply(t,[this].concat(i))}return Rk.default(n)}(e)}},ux=qb.validateTypes=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=$k(t);return function(e,t,n){if("function"!=typeof n.value)throw new Error("The validateTypes decorator can only be applied to methods");var i=n.value;n.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return zk(r,t),i.apply(this,t)}}},cx=qb.validateTypesAsync=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=$k(t);return function(e,t,n){if("function"!=typeof n.value)throw new Error("The validateTypesAsync decorator can only be applied to methods");var i=n.value;n.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];try{zk(r,t)}catch(e){return Promise.reject(e)}return i.apply(this,t)}}},lx=ex((function(e){return[["string","number","boolean","object"].includes(tc(e)),"a JSON type"]})),fx=ex((function(e){return[["undefined","string","number","boolean","object"].includes(tc(e)),"an optional JSON type"]})),dx={},px={exports:{}},hx={exports:{}};!function(e){var t=rk.exports;e.exports=function(e,n){for(;!Object.prototype.hasOwnProperty.call(e,n)&&null!==(e=t(e)););return e},e.exports.__esModule=!0,e.exports.default=e.exports}(hx),function(e){var t=hx.exports;function n(){return"undefined"!=typeof Reflect&&Reflect.get?(e.exports=n=Reflect.get.bind(),e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=n=function(e,n,r){var i=t(e,n);if(i){var a=Object.getOwnPropertyDescriptor(i,n);return a.get?a.get.call(arguments.length<3?e:r):a.value}},e.exports.__esModule=!0,e.exports.default=e.exports),n.apply(this,arguments)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(px);var vx={exports:{}};!function(e){var t=Jw.exports;e.exports=function(e,n,r){return(n=t(n))in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports}(vx),Object.defineProperty(dx,"__esModule",{value:!0});var yx=Xw.exports,mx=Yw.exports,gx=nk.exports,bx=px.exports,wx=Zw.exports,kx=tk.exports,xx=rk.exports,_x=vx.exports;function Sx(e){return e&&"object"===tc(e)&&"default"in e?e:{default:e}}var Ox=Sx(Kw.exports),Ex=Sx(yx),Tx=Sx(mx),Rx=Sx(gx),Ix=Sx(bx),Cx=Sx(wx),Px=Sx(kx),jx=Sx(xx),Ax=Sx(_x);function Mx(){}function Lx(){Lx.init.call(this)}function Ux(e){return void 0===e._maxListeners?Lx.defaultMaxListeners:e._maxListeners}function Nx(e,t,n){if(t)e.call(n);else for(var r=e.length,i=Kx(e,r),a=0;a<r;++a)i[a].call(n)}function Fx(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=Kx(e,i),o=0;o<i;++o)a[o].call(n,r)}function Dx(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=Kx(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function qx(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=Kx(e,o),u=0;u<o;++u)s[u].call(n,r,i,a)}function Bx(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=Kx(e,i),o=0;o<i;++o)a[o].apply(n,r)}function zx(e,t,n,r){var i,a,o;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new Mx,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=Ux(e))&&i>0&&o.length>i){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=o.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(s)}}else o=a[t]=n,++e._eventsCount;return e}function Wx(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function $x(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function Kx(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function Hx(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=jx.default(e);if(t){var i=jx.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Px.default(this,n)}}Mx.prototype=Object.create(null),Lx.EventEmitter=Lx,Lx.usingDomains=!1,Lx.prototype.domain=void 0,Lx.prototype._events=void 0,Lx.prototype._maxListeners=void 0,Lx.defaultMaxListeners=10,Lx.init=function(){this.domain=null,Lx.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Mx,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Lx.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Lx.prototype.getMaxListeners=function(){return Ux(this)},Lx.prototype.emit=function(e){var t,n,r,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:Nx(n,l,this);break;case 2:Fx(n,l,this,arguments[1]);break;case 3:Dx(n,l,this,arguments[1],arguments[2]);break;case 4:qx(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];Bx(n,l,this,i)}return!0},Lx.prototype.addListener=function(e,t){return zx(this,e,t,!1)},Lx.prototype.on=Lx.prototype.addListener,Lx.prototype.prependListener=function(e,t){return zx(this,e,t,!0)},Lx.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Wx(this,e,t)),this},Lx.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Wx(this,e,t)),this},Lx.prototype.removeListener=function(e,t){var n,r,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new Mx:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new Mx,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},Lx.prototype.off=function(e,t){return this.removeListener(e,t)},Lx.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new Mx,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new Mx:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),a=0;a<i.length;++a)"removeListener"!==(r=i[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new Mx,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Lx.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},Lx.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):$x.call(e,t)},Lx.prototype.listenerCount=$x,Lx.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Gx=function(e){Cx.default(n,e);var t=Hx(n);function n(){var e;return Ex.default(this,n),e=t.call(this),Ax.default(Rx.default(e),"eventHistory",new Map),e}return Tx.default(n,[{key:"on",value:function(e,t){return Ix.default(jx.default(n.prototype),"on",this).call(this,e,t)}},{key:"once",value:function(e,t){return Ix.default(jx.default(n.prototype),"once",this).call(this,e,t)}},{key:"off",value:function(e,t){return Ix.default(jx.default(n.prototype),"off",this).call(this,e,t)}},{key:"emit",value:function(e){for(var t,r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return this.eventHistory.set(e,i),(t=Ix.default(jx.default(n.prototype),"emit",this)).call.apply(t,[this,e].concat(i))}},{key:"addListener",value:function(e,t){return Ix.default(jx.default(n.prototype),"addListener",this).call(this,e,t)}},{key:"removeListener",value:function(e,t){return Ix.default(jx.default(n.prototype),"removeListener",this).call(this,e,t)}},{key:"addListenerWithReplay",value:function(e,t){var n=this.eventHistory.get(e);return void 0!==n&&t.apply(void 0,Ox.default(n)),this.addListener(e,t)}},{key:"onWithReplay",value:function(e,t){return this.addListenerWithReplay(e,t)}},{key:"onceWithReplay",value:function(e,t){var r=this.eventHistory.get(e);return void 0!==r?(t.apply(void 0,Ox.default(r)),this):Ix.default(jx.default(n.prototype),"once",this).call(this,e,t)}}]),n}(Lx),Vx=dx.ReplayEventEmitter=Gx,Yx={exports:{}};!function(e,n){var r="__lodash_hash_undefined__",i=9007199254740991,a="[object Arguments]",o="[object Array]",s="[object Boolean]",u="[object Date]",c="[object Error]",l="[object Function]",f="[object Map]",d="[object Number]",p="[object Object]",h="[object Promise]",v="[object RegExp]",y="[object Set]",m="[object String]",g="[object Symbol]",b="[object WeakMap]",w="[object ArrayBuffer]",k="[object DataView]",x=/^\[object .+?Constructor\]$/,_=/^(?:0|[1-9]\d*)$/,S={};S["[object Float32Array]"]=S["[object Float64Array]"]=S["[object Int8Array]"]=S["[object Int16Array]"]=S["[object Int32Array]"]=S["[object Uint8Array]"]=S["[object Uint8ClampedArray]"]=S["[object Uint16Array]"]=S["[object Uint32Array]"]=!0,S[a]=S[o]=S[w]=S[s]=S[k]=S[u]=S[c]=S[l]=S[f]=S[d]=S[p]=S[v]=S[y]=S[m]=S[b]=!1;var O="object"==tc(t)&&t&&t.Object===Object&&t,E="object"==("undefined"==typeof self?"undefined":tc(self))&&self&&self.Object===Object&&self,T=O||E||Function("return this")(),R=n&&!n.nodeType&&n,I=R&&e&&!e.nodeType&&e,C=I&&I.exports===R,P=C&&O.process,j=function(){try{return P&&P.binding&&P.binding("util")}catch(e){}}(),A=j&&j.isTypedArray;function M(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function L(e,t){return e.has(t)}function U(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function N(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var F,D,q=Array.prototype,B=Function.prototype,z=Object.prototype,W=T["__core-js_shared__"],$=B.toString,K=z.hasOwnProperty,H=function(){var e=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),G=z.toString,V=RegExp("^"+$.call(K).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Y=C?T.Buffer:void 0,J=T.Symbol,Q=T.Uint8Array,X=z.propertyIsEnumerable,Z=q.splice,ee=J?J.toStringTag:void 0,te=Object.getOwnPropertySymbols,ne=Y?Y.isBuffer:void 0,re=(F=Object.keys,D=Object,function(e){return F(D(e))}),ie=je(T,"DataView"),ae=je(T,"Map"),oe=je(T,"Promise"),se=je(T,"Set"),ue=je(T,"WeakMap"),ce=je(Object,"create"),le=Ue(ie),fe=Ue(ae),de=Ue(oe),pe=Ue(se),he=Ue(ue),ve=J?J.prototype:void 0,ye=ve?ve.valueOf:void 0;function me(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ge(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function be(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function we(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new be;++t<n;)this.add(e[t])}function ke(e){var t=this.__data__=new ge(e);this.size=t.size}function xe(e,t){var n=De(e),r=!n&&Fe(e),i=!n&&!r&&qe(e),a=!n&&!r&&!i&&Ke(e),o=n||r||i||a,s=o?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],u=s.length;for(var c in e)!t&&!K.call(e,c)||o&&("length"==c||i&&("offset"==c||"parent"==c)||a&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Le(c,u))||s.push(c);return s}function _e(e,t){for(var n=e.length;n--;)if(Ne(e[n][0],t))return n;return-1}function Se(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":ee&&ee in Object(e)?function(e){var t=K.call(e,ee),n=e[ee];try{e[ee]=void 0;var r=!0}catch(e){}var i=G.call(e);r&&(t?e[ee]=n:delete e[ee]);return i}(e):function(e){return G.call(e)}(e)}function Oe(e){return $e(e)&&Se(e)==a}function Ee(e,t,n,r,i){return e===t||(null==e||null==t||!$e(e)&&!$e(t)?e!=e&&t!=t:function(e,t,n,r,i,l){var h=De(e),b=De(t),x=h?o:Me(e),_=b?o:Me(t),S=(x=x==a?p:x)==p,O=(_=_==a?p:_)==p,E=x==_;if(E&&qe(e)){if(!qe(t))return!1;h=!0,S=!1}if(E&&!S)return l||(l=new ke),h||Ke(e)?Ie(e,t,n,r,i,l):function(e,t,n,r,i,a,o){switch(n){case k:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case w:return!(e.byteLength!=t.byteLength||!a(new Q(e),new Q(t)));case s:case u:case d:return Ne(+e,+t);case c:return e.name==t.name&&e.message==t.message;case v:case m:return e==t+"";case f:var l=U;case y:var p=1&r;if(l||(l=N),e.size!=t.size&&!p)return!1;var h=o.get(e);if(h)return h==t;r|=2,o.set(e,t);var b=Ie(l(e),l(t),r,i,a,o);return o.delete(e),b;case g:if(ye)return ye.call(e)==ye.call(t)}return!1}(e,t,x,n,r,i,l);if(!(1&n)){var T=S&&K.call(e,"__wrapped__"),R=O&&K.call(t,"__wrapped__");if(T||R){var I=T?e.value():e,C=R?t.value():t;return l||(l=new ke),i(I,C,n,r,l)}}if(!E)return!1;return l||(l=new ke),function(e,t,n,r,i,a){var o=1&n,s=Ce(e),u=s.length,c=Ce(t),l=c.length;if(u!=l&&!o)return!1;var f=u;for(;f--;){var d=s[f];if(!(o?d in t:K.call(t,d)))return!1}var p=a.get(e);if(p&&a.get(t))return p==t;var h=!0;a.set(e,t),a.set(t,e);var v=o;for(;++f<u;){var y=e[d=s[f]],m=t[d];if(r)var g=o?r(m,y,d,t,e,a):r(y,m,d,e,t,a);if(!(void 0===g?y===m||i(y,m,n,r,a):g)){h=!1;break}v||(v="constructor"==d)}if(h&&!v){var b=e.constructor,w=t.constructor;b==w||!("constructor"in e)||!("constructor"in t)||"function"==typeof b&&b instanceof b&&"function"==typeof w&&w instanceof w||(h=!1)}return a.delete(e),a.delete(t),h}(e,t,n,r,i,l)}(e,t,n,r,Ee,i))}function Te(e){return!(!We(e)||function(e){return!!H&&H in e}(e))&&(Be(e)?V:x).test(Ue(e))}function Re(e){if(n=(t=e)&&t.constructor,r="function"==typeof n&&n.prototype||z,t!==r)return re(e);var t,n,r,i=[];for(var a in Object(e))K.call(e,a)&&"constructor"!=a&&i.push(a);return i}function Ie(e,t,n,r,i,a){var o=1&n,s=e.length,u=t.length;if(s!=u&&!(o&&u>s))return!1;var c=a.get(e);if(c&&a.get(t))return c==t;var l=-1,f=!0,d=2&n?new we:void 0;for(a.set(e,t),a.set(t,e);++l<s;){var p=e[l],h=t[l];if(r)var v=o?r(h,p,l,t,e,a):r(p,h,l,e,t,a);if(void 0!==v){if(v)continue;f=!1;break}if(d){if(!M(t,(function(e,t){if(!L(d,t)&&(p===e||i(p,e,n,r,a)))return d.push(t)}))){f=!1;break}}else if(p!==h&&!i(p,h,n,r,a)){f=!1;break}}return a.delete(e),a.delete(t),f}function Ce(e){return function(e,t,n){var r=t(e);return De(e)?r:function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}(r,n(e))}(e,He,Ae)}function Pe(e,t){var n=e.__data__;return function(e){var t=tc(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?n["string"==typeof t?"string":"hash"]:n.map}function je(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Te(n)?n:void 0}me.prototype.clear=function(){this.__data__=ce?ce(null):{},this.size=0},me.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},me.prototype.get=function(e){var t=this.__data__;if(ce){var n=t[e];return n===r?void 0:n}return K.call(t,e)?t[e]:void 0},me.prototype.has=function(e){var t=this.__data__;return ce?void 0!==t[e]:K.call(t,e)},me.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ce&&void 0===t?r:t,this},ge.prototype.clear=function(){this.__data__=[],this.size=0},ge.prototype.delete=function(e){var t=this.__data__,n=_e(t,e);return!(n<0)&&(n==t.length-1?t.pop():Z.call(t,n,1),--this.size,!0)},ge.prototype.get=function(e){var t=this.__data__,n=_e(t,e);return n<0?void 0:t[n][1]},ge.prototype.has=function(e){return _e(this.__data__,e)>-1},ge.prototype.set=function(e,t){var n=this.__data__,r=_e(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},be.prototype.clear=function(){this.size=0,this.__data__={hash:new me,map:new(ae||ge),string:new me}},be.prototype.delete=function(e){var t=Pe(this,e).delete(e);return this.size-=t?1:0,t},be.prototype.get=function(e){return Pe(this,e).get(e)},be.prototype.has=function(e){return Pe(this,e).has(e)},be.prototype.set=function(e,t){var n=Pe(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},we.prototype.add=we.prototype.push=function(e){return this.__data__.set(e,r),this},we.prototype.has=function(e){return this.__data__.has(e)},ke.prototype.clear=function(){this.__data__=new ge,this.size=0},ke.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},ke.prototype.get=function(e){return this.__data__.get(e)},ke.prototype.has=function(e){return this.__data__.has(e)},ke.prototype.set=function(e,t){var n=this.__data__;if(n instanceof ge){var r=n.__data__;if(!ae||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new be(r)}return n.set(e,t),this.size=n.size,this};var Ae=te?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}(te(e),(function(t){return X.call(e,t)})))}:function(){return[]},Me=Se;function Le(e,t){return!!(t=null==t?i:t)&&("number"==typeof e||_.test(e))&&e>-1&&e%1==0&&e<t}function Ue(e){if(null!=e){try{return $.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ne(e,t){return e===t||e!=e&&t!=t}(ie&&Me(new ie(new ArrayBuffer(1)))!=k||ae&&Me(new ae)!=f||oe&&Me(oe.resolve())!=h||se&&Me(new se)!=y||ue&&Me(new ue)!=b)&&(Me=function(e){var t=Se(e),n=t==p?e.constructor:void 0,r=n?Ue(n):"";if(r)switch(r){case le:return k;case fe:return f;case de:return h;case pe:return y;case he:return b}return t});var Fe=Oe(function(){return arguments}())?Oe:function(e){return $e(e)&&K.call(e,"callee")&&!X.call(e,"callee")},De=Array.isArray;var qe=ne||function(){return!1};function Be(e){if(!We(e))return!1;var t=Se(e);return t==l||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}function ze(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=i}function We(e){var t=tc(e);return null!=e&&("object"==t||"function"==t)}function $e(e){return null!=e&&"object"==tc(e)}var Ke=A?function(e){return function(t){return e(t)}}(A):function(e){return $e(e)&&ze(e.length)&&!!S[Se(e)]};function He(e){return null!=(t=e)&&ze(t.length)&&!Be(t)?xe(e):Re(e);var t}e.exports=function(e,t){return Ee(e,t)}}(Yx,Yx.exports);var Jx=Yx.exports;function Qx(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}var Xx=yy.scope("User"),User=function(e){ec(User,e);var t,n,r,i,a,o,s,u=Qx(User);function User(e,t,n,r){var i;return sc(this,User),uc(Xu(i=u.call(this)),"links",void 0),uc(Xu(i),"configuration",void 0),uc(Xu(i),"services",void 0),uc(Xu(i),"entity",void 0),uc(Xu(i),"state",void 0),uc(Xu(i),"promiseToFetch",null),uc(Xu(i),"subscribed",void 0),uc(Xu(i),"_initializationPromise",void 0),uc(Xu(i),"_resolveInitializationPromise",void 0),uc(Xu(i),"updated","updated"),uc(Xu(i),"userSubscribed","userSubscribed"),uc(Xu(i),"userUnsubscribed","userUnsubscribed"),i.services=r,i.subscribed="initializing",i.setMaxListeners(0),i.state={identity:e,entityName:t,friendlyName:null,attributes:{},online:null,notifiable:null},i._initializationPromise=new Promise((function(e){i._resolveInitializationPromise=e})),null!==n&&i._resolveInitialization(n,e,t,!1),i}return oc(User,[{key:"identity",get:function(){return this.state.identity},set:function(e){this.state.identity=e}},{key:"entityName",set:function(e){this.state.entityName=e}},{key:"attributes",get:function(){return this.state.attributes}},{key:"friendlyName",get:function(){return this.state.friendlyName}},{key:"isOnline",get:function(){return this.state.online}},{key:"isNotifiable",get:function(){return this.state.notifiable}},{key:"isSubscribed",get:function(){return"subscribed"==this.subscribed}},{key:"_update",value:(s=Qu(hh.mark((function e(t,n){var r,i;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:r=[],Xx.debug("User for",this.state.identity,"updated:",t,n),e.t0=t,e.next="friendlyName"===e.t0?7:"attributes"===e.t0?9:"reachability"===e.t0?12:15;break;case 7:return this.state.friendlyName!==n.value&&(r.push("friendlyName"),this.state.friendlyName=n.value),e.abrupt("break",16);case 9:return i=Fb(n.value,"Retrieved malformed attributes from the server for user: ".concat(this.state.identity),Xx),Jx(this.state.attributes,i)||(this.state.attributes=i,r.push("attributes")),e.abrupt("break",16);case 12:return this.state.online!==n.online&&(this.state.online=n.online,r.push("reachabilityOnline")),this.state.notifiable!==n.notifiable&&(this.state.notifiable=n.notifiable,r.push("reachabilityNotifiable")),e.abrupt("break",16);case 15:return e.abrupt("return");case 16:r.length>0&&this.emit("updated",{user:this,updateReasons:r});case 17:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_updateReachabilityInfo",value:(o=Qu(hh.mark((function e(t,n){var r=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if(this.configuration.reachabilityEnabled){e.next=4;break}return e.abrupt("return",Promise.resolve());case 4:return e.abrupt("return",t.get("reachability").then(n).catch((function(e){Xx.warn("Failed to get reachability info for ",r.state.identity,e)})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"_fetch",value:(a=Qu(hh.mark((function e(){var t=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if(this.state.entityName){e.next=4;break}return e.abrupt("return",this);case 4:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then((function(e){return t.entity=e,e.on("itemUpdated",(function(e){return Xx.debug(t.state.entityName+" ("+t.state.identity+") itemUpdated: "+e.item.key),t._update(e.item.key,e.item.data)})),Promise.all([e.get("friendlyName").then((function(e){return t._update(e.key,e.data)})),e.get("attributes").then((function(e){return t._update(e.key,e.data)})),t._updateReachabilityInfo(e,(function(e){return t._update(e.key,e.data)}))])})).then((function(){return Xx.debug("Fetched for",t.identity),t.subscribed="subscribed",t.emit("userSubscribed",t),t})).catch((function(e){throw t.promiseToFetch=null,e})),e.abrupt("return",this.promiseToFetch);case 6:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_ensureFetched",value:(i=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:return e.abrupt("return",this.promiseToFetch||this._fetch());case 3:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"updateAttributes",value:(r=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if("unsubscribed"!=this.subscribed){e.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return e.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(t)});case 6:return e.abrupt("return",this);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"updateFriendlyName",value:(n=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if("unsubscribed"!=this.subscribed){e.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return e.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{friendly_name:t});case 6:return e.abrupt("return",this);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribe",value:(t=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if(!this.promiseToFetch){e.next=9;break}return e.next=5,this.promiseToFetch;case 5:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 9:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_resolveInitialization",value:function(e,t,n,r){this.configuration=e,this.identity=t,this.entityName=n,this.links={self:"".concat(this.configuration.links.users,"/").concat(encodeURIComponent(this.identity))},this._resolveInitializationPromise(),r&&this.emit("updated",{user:this,updateReasons:["friendlyName","attributes","reachabilityOnline","reachabilityNotifiable"]})}}]),User}(Vx);function Zx(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function e_(e,t){if(e){if("string"==typeof e)return Zx(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Zx(e,t):void 0}}function t_(e){return function(e){if(Array.isArray(e))return Zx(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||e_(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n_(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],u=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}(e,t)||e_(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}yh([cx(lx),mh("design:type",Function),mh("design:paramtypes",[Object]),mh("design:returntype",Promise)],User.prototype,"updateAttributes",null),yh([cx(["string"]),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],User.prototype,"updateFriendlyName",null);var r_={exports:{}},i_=o((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),a_=o,o_=H,s_=T,u_=i_,c_=Object.isExtensible,l_=a_((function(){c_(1)}))||u_?function(e){return!!o_(e)&&((!u_||"ArrayBuffer"!=s_(e))&&(!c_||c_(e)))}:c_,f_=!o((function(){return Object.isExtensible(Object.preventExtensions({}))})),d_=Zr,p_=_,h_=gn,v_=H,y_=Be,m_=Ct.f,g_=Jn,b_=za,w_=l_,k_=f_,x_=!1,__=He("meta"),S_=0,O_=function(e){m_(e,__,{value:{objectID:"O"+S_++,weakData:{}}})},E_=r_.exports={enable:function(){E_.enable=function(){},x_=!0;var e=g_.f,t=p_([].splice),n={};n[__]=1,e(n).length&&(g_.f=function(n){for(var r=e(n),i=0,a=r.length;i<a;i++)if(r[i]===__){t(r,i,1);break}return r},d_({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:b_.f}))},fastKey:function(e,t){if(!v_(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!y_(e,__)){if(!w_(e))return"F";if(!t)return"E";O_(e)}return e[__].objectID},getWeakData:function(e,t){if(!y_(e,__)){if(!w_(e))return!0;if(!t)return!1;O_(e)}return e[__].weakData},onFreeze:function(e){return k_&&x_&&w_(e)&&!y_(e,__)&&O_(e),e}};h_[__]=!0;var T_=Zr,R_=i,I_=_,C_=Kr,P_=Yn,j_=r_.exports,A_=Bd,M_=Cc,L_=W,U_=A,N_=H,F_=o,D_=Hd,q_=ri,B_=cm,z_=function(e,t,n){var r=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),a=r?"set":"add",o=R_[e],s=o&&o.prototype,u=o,c={},l=function(e){var t=I_(s[e]);P_(s,e,"add"==e?function(e){return t(this,0===e?0:e),this}:"delete"==e?function(e){return!(i&&!N_(e))&&t(this,0===e?0:e)}:"get"==e?function(e){return i&&!N_(e)?void 0:t(this,0===e?0:e)}:"has"==e?function(e){return!(i&&!N_(e))&&t(this,0===e?0:e)}:function(e,n){return t(this,0===e?0:e,n),this})};if(C_(e,!L_(o)||!(i||s.forEach&&!F_((function(){(new o).entries().next()})))))u=n.getConstructor(t,e,r,a),j_.enable();else if(C_(e,!0)){var f=new u,d=f[a](i?{}:-0,1)!=f,p=F_((function(){f.has(1)})),h=D_((function(e){new o(e)})),v=!i&&F_((function(){for(var e=new o,t=5;t--;)e[a](t,t);return!e.has(-0)}));h||((u=t((function(e,t){M_(e,s);var n=B_(new o,e,u);return U_(t)||A_(t,n[a],{that:n,AS_ENTRIES:r}),n}))).prototype=s,s.constructor=u),(p||v)&&(l("delete"),l("has"),r&&l("get")),(v||d)&&l(a),i&&s.clear&&delete s.clear}return c[e]=u,T_({global:!0,constructor:!0,forced:u!=o},c),q_(u,e),i||n.setStrong(u,e,r),u},W_=Yn,$_=function(e,t,n){for(var r in t)W_(e,r,t[r],n);return e},K_=Ct.f,H_=xa,G_=$_,V_=xo,Y_=Cc,J_=A,Q_=Bd,X_=Xv,Z_=Zv,eS=Tc,tS=s,nS=r_.exports.fastKey,rS=jn.set,iS=jn.getterFor,aS={getConstructor:function(e,t,n,r){var i=e((function(e,i){Y_(e,a),rS(e,{type:t,index:H_(null),first:void 0,last:void 0,size:0}),tS||(e.size=0),J_(i)||Q_(i,e[r],{that:e,AS_ENTRIES:n})})),a=i.prototype,o=iS(t),s=function(e,t,n){var r,i,a=o(e),s=u(e,t);return s?s.value=n:(a.last=s={index:i=nS(t,!0),key:t,value:n,previous:r=a.last,next:void 0,removed:!1},a.first||(a.first=s),r&&(r.next=s),tS?a.size++:e.size++,"F"!==i&&(a.index[i]=s)),e},u=function(e,t){var n,r=o(e),i=nS(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==t)return n};return G_(a,{clear:function(){for(var e=o(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,tS?e.size=0:this.size=0},delete:function(e){var t=this,n=o(t),r=u(t,e);if(r){var i=r.next,a=r.previous;delete n.index[r.index],r.removed=!0,a&&(a.next=i),i&&(i.previous=a),n.first==r&&(n.first=i),n.last==r&&(n.last=a),tS?n.size--:t.size--}return!!r},forEach:function(e){for(var t,n=o(this),r=V_(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!u(this,e)}}),G_(a,n?{get:function(e){var t=u(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),tS&&K_(a,"size",{get:function(){return o(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=iS(t),a=iS(r);X_(e,t,(function(e,t){rS(this,{type:r,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=a(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?Z_("keys"==t?n.key:"values"==t?n.value:[n.key,n.value],!1):(e.target=void 0,Z_(void 0,!0))}),n?"entries":"values",!n,!0),eS(t)}};z_("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),aS),z_("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),aS);var oS={};Object.defineProperty(oS,"__esModule",{value:!0});var sS=Yw.exports,uS=nk.exports,cS=Zw.exports,lS=tk.exports,fS=rk.exports,dS=vx.exports;function pS(e){return e&&"object"===tc(e)&&"default"in e?e:{default:e}}var hS=pS(Xw.exports),vS=pS(sS),yS=pS(uS),mS=pS(cS),gS=pS(lS),bS=pS(fS),wS=pS(dS);function kS(){}function xS(){xS.init.call(this)}function _S(e){return void 0===e._maxListeners?xS.defaultMaxListeners:e._maxListeners}function SS(e,t,n){if(t)e.call(n);else for(var r=e.length,i=jS(e,r),a=0;a<r;++a)i[a].call(n)}function OS(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=jS(e,i),o=0;o<i;++o)a[o].call(n,r)}function ES(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=jS(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function TS(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=jS(e,o),u=0;u<o;++u)s[u].call(n,r,i,a)}function RS(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=jS(e,i),o=0;o<i;++o)a[o].apply(n,r)}function IS(e,t,n,r){var i,a,o;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new kS,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=_S(e))&&i>0&&o.length>i){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=o.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(s)}}else o=a[t]=n,++e._eventsCount;return e}function CS(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function PS(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function jS(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function AS(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=bS.default(e);if(t){var i=bS.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return gS.default(this,n)}}kS.prototype=Object.create(null),xS.EventEmitter=xS,xS.usingDomains=!1,xS.prototype.domain=void 0,xS.prototype._events=void 0,xS.prototype._maxListeners=void 0,xS.defaultMaxListeners=10,xS.init=function(){this.domain=null,xS.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new kS,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},xS.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},xS.prototype.getMaxListeners=function(){return _S(this)},xS.prototype.emit=function(e){var t,n,r,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:SS(n,l,this);break;case 2:OS(n,l,this,arguments[1]);break;case 3:ES(n,l,this,arguments[1],arguments[2]);break;case 4:TS(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];RS(n,l,this,i)}return!0},xS.prototype.addListener=function(e,t){return IS(this,e,t,!1)},xS.prototype.on=xS.prototype.addListener,xS.prototype.prependListener=function(e,t){return IS(this,e,t,!0)},xS.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,CS(this,e,t)),this},xS.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,CS(this,e,t)),this},xS.prototype.removeListener=function(e,t){var n,r,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new kS:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new kS,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},xS.prototype.off=function(e,t){return this.removeListener(e,t)},xS.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new kS,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new kS:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),a=0;a<i.length;++a)"removeListener"!==(r=i[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new kS,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},xS.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},xS.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):PS.call(e,t)},xS.prototype.listenerCount=PS,xS.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var MS=function(e){mS.default(n,e);var t=AS(n);function n(e){var r;return hS.default(this,n),r=t.call(this),wS.default(yS.default(r),"minDelay",void 0),wS.default(yS.default(r),"maxDelay",void 0),wS.default(yS.default(r),"initialDelay",void 0),wS.default(yS.default(r),"maxAttemptsCount",void 0),wS.default(yS.default(r),"maxAttemptsTime",void 0),wS.default(yS.default(r),"randomness",void 0),wS.default(yS.default(r),"prevDelay",void 0),wS.default(yS.default(r),"currDelay",void 0),wS.default(yS.default(r),"timeout",null),wS.default(yS.default(r),"inProgress",void 0),wS.default(yS.default(r),"attemptNum",void 0),wS.default(yS.default(r),"startTimestamp",-1),r.minDelay=e.min,r.maxDelay=e.max,r.initialDelay=e.initial||0,r.maxAttemptsCount=e.maxAttemptsCount||0,r.maxAttemptsTime=e.maxAttemptsTime||0,r.randomness=e.randomness||0,r.inProgress=!1,r.attemptNum=0,r.prevDelay=0,r.currDelay=0,r}return vS.default(n,[{key:"attempt",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}},{key:"nextDelay",value:function(e){if("number"==typeof e)return this.prevDelay=0,this.currDelay=e,e;if(0==this.attemptNum)return this.initialDelay;if(1==this.attemptNum)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var t=this.currDelay+this.prevDelay;return this.maxDelay&&t>this.maxDelay&&(this.currDelay=this.maxDelay,t=this.maxDelay),this.currDelay=t,t}},{key:"randomize",value:function(e){var t=e*this.randomness,n=Math.round(Math.random()*t*2-t);return Math.max(0,e+n)}},{key:"scheduleAttempt",value:function(e){var t=this;if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt count limit reached"));var n=this.nextDelay(e);if(n=this.randomize(n),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+n)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt time limit reached"));this.timeout=setTimeout((function(){return t.attempt()}),n)}},{key:"cleanup",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}},{key:"start",value:function(){if(this.inProgress)throw new Error("Retrier is already in progress");this.inProgress=!0,this.startTimestamp=Date.now(),this.scheduleAttempt(this.initialDelay)}},{key:"cancel",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.emit("cancelled"))}},{key:"succeeded",value:function(e){this.emit("succeeded",e)}},{key:"failed",value:function(e,t){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(t)}}]),n}(xS),LS=function(e){mS.default(n,e);var t=AS(n);function n(e){var r;return hS.default(this,n),r=t.call(this),wS.default(yS.default(r),"retrier",void 0),wS.default(yS.default(r),"resolve",(function(){})),wS.default(yS.default(r),"reject",(function(){})),r.retrier=new MS(e),r}return vS.default(n,[{key:"run",value:function(e){var t=this;return this.retrier.on("attempt",(function(){e().then((function(e){return t.retrier.succeeded(e)})).catch((function(e){return t.retrier.failed(e)}))})),this.retrier.on("succeeded",(function(e){return t.resolve(e)})),this.retrier.on("cancelled",(function(){return t.reject(new Error("Cancelled"))})),this.retrier.on("failed",(function(e){return t.reject(e)})),new Promise((function(e,n){t.resolve=e,t.reject=n,t.retrier.start()}))}},{key:"cancel",value:function(){this.retrier.cancel()}}]),n}(xS);function US(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=bS.default(e);if(t){var i=bS.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return gS.default(this,n)}}function NS(e){return null!=e}var FS=function(e){mS.default(n,e);var t=US(n);function n(e){var r;hS.default(this,n),r=t.call(this),wS.default(yS.default(r),"maxDelay",void 0),wS.default(yS.default(r),"initialDelay",void 0),wS.default(yS.default(r),"factor",void 0),wS.default(yS.default(r),"randomisationFactor",void 0),wS.default(yS.default(r),"backoffDelay",0),wS.default(yS.default(r),"nextBackoffDelay",0),wS.default(yS.default(r),"backoffNumber",0),wS.default(yS.default(r),"timeoutID",null),wS.default(yS.default(r),"maxNumberOfRetry",-1);var i=e=e||{},a=i.initialDelay,o=i.maxDelay,s=i.randomisationFactor,u=i.factor;if(NS(a)&&a<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(NS(o)&&o<=1)throw new Error("The maximal timeout must be greater than 1.");if(NS(s)&&(s<0||s>1))throw new Error("The randomisation factor must be between 0 and 1.");if(NS(u)&&u<=1)throw new Error("Exponential factor should be greater than 1.");if(r.initialDelay=a||100,r.maxDelay=o||1e4,r.maxDelay<=r.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return r.randomisationFactor=s||0,r.factor=u||2,r.reset(),r}return vS.default(n,[{key:"backoff",value:function(e){null==this.timeoutID&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",e),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,e)))}},{key:"reset",value:function(){this.backoffDelay=0,this.nextBackoffDelay=this.initialDelay,this.backoffNumber=0,this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=null}},{key:"failAfter",value:function(e){if(e<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(e));this.maxNumberOfRetry=e}},{key:"next",value:function(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var e=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*e))}},{key:"onBackoff",value:function(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}],[{key:"exponential",value:function(e){return new n(e)}}]),n}(xS),DS=oS.AsyncRetrier=LS;oS.Backoff=FS;var qS=oS.Retrier=MS,BS={},zS={exports:{}},WS={exports:{}};!function(e){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports}(WS),function(e){var t=ek.exports,n=WS.exports;function r(i,a,o){return n()?(e.exports=r=Reflect.construct.bind(),e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=r=function(e,n,r){var i=[null];i.push.apply(i,n);var a=new(Function.bind.apply(e,i));return r&&t(a,r.prototype),a},e.exports.__esModule=!0,e.exports.default=e.exports),r.apply(null,arguments)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(zS);var $S={exports:{}};!function(e){function t(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}e.exports=function(e){return function(){var n=this,r=arguments;return new Promise((function(i,a){var o=e.apply(n,r);function s(e){t(o,i,a,s,u,"next",e)}function u(e){t(o,i,a,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports}($S);var KS=n(vh),HS={},GS={exports:{}},VS={exports:{}};!function(e){e.exports=function(e){return-1!==Function.toString.call(e).indexOf("[native code]")},e.exports.__esModule=!0,e.exports.default=e.exports}(VS),function(e){var t=rk.exports,n=ek.exports,r=VS.exports,i=zS.exports;function a(o){var s="function"==typeof Map?new Map:void 0;return e.exports=a=function(e){if(null===e||!r(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==s){if(s.has(e))return s.get(e);s.set(e,a)}function a(){return i(e,arguments,t(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),n(a,e)},e.exports.__esModule=!0,e.exports.default=e.exports,a(o)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}(GS);var YS=function(e){return crypto.getRandomValues(new Uint8Array(e))},JS=function(e,t,n){var r=(2<<Math.log(e.length-1)/Math.LN2)-1,i=-~(1.6*r*t/e.length);return function(){for(var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t,o="";;)for(var s=n(i),u=i;u--;)if((o+=e[s[u]&r]||"").length===a)return o}},QS=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21;return crypto.getRandomValues(new Uint8Array(e)).reduce((function(e,t){return e+=(t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_"}),"")},XS=Object.freeze({__proto__:null,nanoid:QS,customAlphabet:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:21;return JS(e,t,YS)},customRandom:JS,urlAlphabet:"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",random:YS}),ZS=n(XS),eO=Zr,tO=f_,nO=o,rO=H,iO=r_.exports.onFreeze,aO=Object.freeze;eO({target:"Object",stat:!0,forced:nO((function(){aO(1)})),sham:!tO},{freeze:function(e){return aO&&rO(e)?aO(iO(e)):e}}),Object.defineProperty(HS,"__esModule",{value:!0});var oO=fy.exports,sO=nk.exports,uO=vx.exports,cO=Yw.exports,lO=Xw.exports,fO=Zw.exports,dO=tk.exports,pO=rk.exports,hO=GS.exports,vO=ZS,yO=Kw.exports;function mO(e){return e&&"object"===tc(e)&&"default"in e?e:{default:e}}var gO=mO(oO),bO=mO(sO),wO=mO(uO),kO=mO(cO),xO=mO(lO),_O=mO(fO),SO=mO(dO),OO=mO(pO),EO=mO(hO),TO=mO(yO),RO=function(e){var t=gO.default.getLevel();gO.default.setLevel("warn"),gO.default.warn(e),gO.default.setLevel(t)};function IO(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OO.default(e);if(t){var i=OO.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return SO.default(this,n)}}var CO=function(e){_O.default(n,e);var t=IO(n);function n(){return xO.default(this,n),t.call(this,"Promise was cancelled")}return kO.default(n)}(EO.default(Error)),PO=function(e){_O.default(n,e);var t=IO(n);function n(e){var r;xO.default(this,n);var i,a=vO.nanoid();return r=t.call(this,(function(t,r){return i=r,e((function(e){n.onCancelCallbackMap.delete(a),t(e)}),(function(e){n.onCancelCallbackMap.delete(a),r(e)}),(function(e){n.onCancelCallbackMap.set(a,e)}))})),wO.default(bO.default(r),"id",void 0),wO.default(bO.default(r),"rejectPromise",void 0),r.id=a,r.rejectPromise=i,r}return kO.default(n,[{key:"cancel",value:function(){var e=n.onCancelCallbackMap.get(this.id);return null==e||e(),this.rejectPromise&&(this.catch((function(){})),this.rejectPromise(new CO)),this}}]),n}(EO.default(Promise));function jO(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OO.default(e);if(t){var i=OO.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return SO.default(this,n)}}wO.default(PO,"onCancelCallbackMap",new Map);var AO={unknown:"Unknown error",cancelled:"Job was cancelled",timeout:"Timeout occurred",mediaUploadError:"Media upload error",mediaFetchError:"Media fetch error",tooManyAttachments:"Too many attachments",unsupportedEmailBodyContentType:"Unsupported email body content type",unsupportedEmailHistoryContentType:"Unsupported email history content type",transportDisconnected:"Transport has been disconnected",networkBecameUnreachable:"Network became unreachable",unauthorized:"Unauthorized",tokenExpired:"Token expired",tokenUpdatedLocally:"Transport disconnected, token updated locally and will be used at reconnect",tooManyRequests:"Request failed with 429 reply",hostnameUnverified:"Failed on ssl handshake: CERTIFICATE_VERIFY_FAILED",sslHandshakeError:"Failed on ssl handshake: UNAUTHORIZED",closeMessageReceived:"Twilsock received a close message from the server",cannotParse:"Error while parsing an incoming message"},MO=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;xO.default(this,e),wO.default(this,"reason",void 0),wO.default(this,"message",void 0),wO.default(this,"status",void 0),wO.default(this,"code",void 0),wO.default(this,"description",void 0),this.reason=t,this.message=n,this.status=r,this.code=i,this.description=AO[t]}return kO.default(e,[{key:"toString",value:function(){return"".concat(this.description," ").concat(this.status,":").concat(this.code," ").concat(this.message)}}]),e}(),LO=function(e){_O.default(n,e);var t=jO(n);function n(e){var r;return xO.default(this,n),r=t.call(this,"".concat(e)),wO.default(bO.default(r),"errorInfo",void 0),r.errorInfo=e,Object.freeze(e),r}return kO.default(n)}(EO.default(Error)),UO=function(){function e(){var t=this;xO.default(this,e),wO.default(this,"promise",void 0),wO.default(this,"_resolve",void 0),wO.default(this,"_reject",void 0),wO.default(this,"_isDone",!1),this.promise=new Promise((function(e,n){t._resolve=function(n){t._isDone=!0,e(n)},t._reject=function(e){t._isDone=!0,n(e)}}))}return kO.default(e,[{key:"resolve",get:function(){return this._resolve}},{key:"reject",get:function(){return this._reject}},{key:"isDone",get:function(){return this._isDone}}]),e}(),NO=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";xO.default(this,e),wO.default(this,"_prefix",void 0),wO.default(this,"_logger",void 0),this._prefix=n,this._logger=oO.getLogger(t)}return kO.default(e,[{key:"setLevel",value:function(e){this._logger.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.trace.apply(null,this._prepareLine("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.debug.apply(null,this._prepareLine("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.info.apply(null,this._prepareLine("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.warn.apply(null,this._prepareLine("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.error.apply(null,this._prepareLine("E",t))}},{key:"_prepareLine",value:function(e,t){return["".concat((new Date).toISOString()," ").concat(this._prefix," ").concat(e,":")].concat(TO.default(t))}}]),e}();HS.CancellablePromise=PO,HS.CancellationError=CO,HS.Deferred=UO,HS.ErrorInfo=MO,HS.Logger=NO;var FO=HS.TwilioError=LO;HS.deprecated=function(e,t,n){return function(r,i,a){if("function"!=typeof a.value&&void 0===(null==a?void 0:a.get))throw new Error("The deprecated decorator can only be applied to methods or getters");if("function"!=typeof a.value){var o=a.get;a.get=function(){return RO("The getter ".concat(e," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:".")),null==o?void 0:o.apply(this)}}else{var s=a.value;a.value=function(){RO("The method ".concat(e," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:"."));for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return s.apply(this,i)}}}},HS.deprecationWarning=RO;var DO="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,qO=tr,BO=ur,zO=RangeError,WO=function(e){if(void 0===e)return 0;var t=qO(e),n=BO(t);if(t!==n)throw zO("Wrong length or index");return n},$O=Array,KO=Math.abs,HO=Math.pow,GO=Math.floor,VO=Math.log,YO=Math.LN2,JO={pack:function(e,t,n){var r,i,a,o=$O(n),s=8*n-t-1,u=(1<<s)-1,c=u>>1,l=23===t?HO(2,-24)-HO(2,-77):0,f=e<0||0===e&&1/e<0?1:0,d=0;for((e=KO(e))!=e||e===1/0?(i=e!=e?1:0,r=u):(r=GO(VO(e)/YO),e*(a=HO(2,-r))<1&&(r--,a*=2),(e+=r+c>=1?l/a:l*HO(2,1-c))*a>=2&&(r++,a/=2),r+c>=u?(i=0,r=u):r+c>=1?(i=(e*a-1)*HO(2,t),r+=c):(i=e*HO(2,c-1)*HO(2,t),r=0));t>=8;)o[d++]=255&i,i/=256,t-=8;for(r=r<<t|i,s+=t;s>0;)o[d++]=255&r,r/=256,s-=8;return o[--d]|=128*f,o},unpack:function(e,t){var n,r=e.length,i=8*r-t-1,a=(1<<i)-1,o=a>>1,s=i-7,u=r-1,c=e[u--],l=127&c;for(c>>=7;s>0;)l=256*l+e[u--],s-=8;for(n=l&(1<<-s)-1,l>>=-s,s+=t;s>0;)n=256*n+e[u--],s-=8;if(0===l)l=1-o;else{if(l===a)return n?NaN:c?-1/0:1/0;n+=HO(2,t),l-=o}return(c?-1:1)*n*HO(2,l-t)}},QO=Fe,XO=ar,ZO=lr,eE=function(e){for(var t=QO(this),n=ZO(t),r=arguments.length,i=XO(r>1?arguments[1]:void 0,n),a=r>2?arguments[2]:void 0,o=void 0===a?n:XO(a,n);o>i;)t[i++]=e;return t},tE=i,nE=_,rE=s,iE=DO,aE=nn,oE=Yt,sE=$_,uE=o,cE=Cc,lE=tr,fE=ur,dE=WO,pE=JO,hE=yv,vE=xc,yE=Jn.f,mE=Ct.f,gE=eE,bE=Xa,wE=ri,kE=aE.PROPER,xE=aE.CONFIGURABLE,_E=jn.get,SE=jn.set,OE="ArrayBuffer",EE="DataView",TE="prototype",RE="Wrong index",IE=tE[OE],CE=IE,PE=CE&&CE[TE],jE=tE[EE],AE=jE&&jE[TE],ME=Object.prototype,LE=tE.Array,UE=tE.RangeError,NE=nE(gE),FE=nE([].reverse),DE=pE.pack,qE=pE.unpack,BE=function(e){return[255&e]},zE=function(e){return[255&e,e>>8&255]},WE=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},$E=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},KE=function(e){return DE(e,23,4)},HE=function(e){return DE(e,52,8)},GE=function(e,t){mE(e[TE],t,{get:function(){return _E(this)[t]}})},VE=function(e,t,n,r){var i=dE(n),a=_E(e);if(i+t>a.byteLength)throw UE(RE);var o=_E(a.buffer).bytes,s=i+a.byteOffset,u=bE(o,s,s+t);return r?u:FE(u)},YE=function(e,t,n,r,i,a){var o=dE(n),s=_E(e);if(o+t>s.byteLength)throw UE(RE);for(var u=_E(s.buffer).bytes,c=o+s.byteOffset,l=r(+i),f=0;f<t;f++)u[c+f]=l[a?f:t-f-1]};if(iE){var JE=kE&&IE.name!==OE;if(uE((function(){IE(1)}))&&uE((function(){new IE(-1)}))&&!uE((function(){return new IE,new IE(1.5),new IE(NaN),1!=IE.length||JE&&!xE})))JE&&xE&&oE(IE,"name",OE);else{(CE=function(e){return cE(this,PE),new IE(dE(e))})[TE]=PE;for(var QE,XE=yE(IE),ZE=0;XE.length>ZE;)(QE=XE[ZE++])in CE||oE(CE,QE,IE[QE]);PE.constructor=CE}vE&&hE(AE)!==ME&&vE(AE,ME);var eT=new jE(new CE(2)),tT=nE(AE.setInt8);eT.setInt8(0,2147483648),eT.setInt8(1,2147483649),!eT.getInt8(0)&&eT.getInt8(1)||sE(AE,{setInt8:function(e,t){tT(this,e,t<<24>>24)},setUint8:function(e,t){tT(this,e,t<<24>>24)}},{unsafe:!0})}else PE=(CE=function(e){cE(this,PE);var t=dE(e);SE(this,{bytes:NE(LE(t),0),byteLength:t}),rE||(this.byteLength=t)})[TE],AE=(jE=function(e,t,n){cE(this,AE),cE(e,PE);var r=_E(e).byteLength,i=lE(t);if(i<0||i>r)throw UE("Wrong offset");if(i+(n=void 0===n?r-i:fE(n))>r)throw UE("Wrong length");SE(this,{buffer:e,byteLength:n,byteOffset:i}),rE||(this.buffer=e,this.byteLength=n,this.byteOffset=i)})[TE],rE&&(GE(CE,"byteLength"),GE(jE,"buffer"),GE(jE,"byteLength"),GE(jE,"byteOffset")),sE(AE,{getInt8:function(e){return VE(this,1,e)[0]<<24>>24},getUint8:function(e){return VE(this,1,e)[0]},getInt16:function(e){var t=VE(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=VE(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return $E(VE(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return $E(VE(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return qE(VE(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return qE(VE(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){YE(this,1,e,BE,t)},setUint8:function(e,t){YE(this,1,e,BE,t)},setInt16:function(e,t){YE(this,2,e,zE,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){YE(this,2,e,zE,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){YE(this,4,e,WE,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){YE(this,4,e,WE,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){YE(this,4,e,KE,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){YE(this,8,e,HE,t,arguments.length>2?arguments[2]:void 0)}});wE(CE,OE),wE(jE,EE);var nT={ArrayBuffer:CE,DataView:jE},rT=Tc,iT="ArrayBuffer",aT=nT[iT];Zr({global:!0,constructor:!0,forced:i[iT]!==aT},{ArrayBuffer:aT}),rT(iT),function(e){function t(e){for(var t=0,n=Math.min(65536,e.length+1),r=new Uint16Array(n),i=[],a=0;;){var o=t<e.length;if(!o||a>=n-1){var s=r.subarray(0,a);if(i.push(String.fromCharCode.apply(null,s)),!o)return i.join("");e=e.subarray(t),t=0,a=0}var u=e[t++];if(0==(128&u))r[a++]=u;else if(192==(224&u)){var c=63&e[t++];r[a++]=(31&u)<<6|c}else if(224==(240&u)){c=63&e[t++];var l=63&e[t++];r[a++]=(31&u)<<12|c<<6|l}else if(240==(248&u)){var f=(7&u)<<18|(c=63&e[t++])<<12|(l=63&e[t++])<<6|63&e[t++];f>65535&&(f-=65536,r[a++]=f>>>10&1023|55296,f=56320|1023&f),r[a++]=f}}}var n="Failed to ",r=function(e,t,r){if(e)throw new Error("".concat(n).concat(t,": the '").concat(r,"' option is unsupported."))},i="function"==typeof Buffer&&Buffer.from,a=i?function(e){return Buffer.from(e)}:function(e){for(var t=0,n=e.length,r=0,i=Math.max(32,n+(n>>>1)+7),a=new Uint8Array(i>>>3<<3);t<n;){var o=e.charCodeAt(t++);if(o>=55296&&o<=56319){if(t<n){var s=e.charCodeAt(t);56320==(64512&s)&&(++t,o=((1023&o)<<10)+(1023&s)+65536)}if(o>=55296&&o<=56319)continue}if(r+4>a.length){i+=8,i=(i*=1+t/e.length*2)>>>3<<3;var u=new Uint8Array(i);u.set(a),a=u}if(0!=(4294967168&o)){if(0==(4294965248&o))a[r++]=o>>>6&31|192;else if(0==(4294901760&o))a[r++]=o>>>12&15|224,a[r++]=o>>>6&63|128;else{if(0!=(4292870144&o))continue;a[r++]=o>>>18&7|240,a[r++]=o>>>12&63|128,a[r++]=o>>>6&63|128}a[r++]=63&o|128}else a[r++]=o}return a.slice?a.slice(0,r):a.subarray(0,r)};function o(){this.encoding="utf-8"}o.prototype.encode=function(e,t){return r(t&&t.stream,"encode","stream"),a(e)};var s=!i&&"function"==typeof Blob&&"function"==typeof URL&&"function"==typeof URL.createObjectURL,u=["utf-8","utf8","unicode-1-1-utf-8"],c=t;i?c=function(e,t){return(e instanceof Buffer?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)).toString(t)}:s&&(c=function(e){try{return function(e){var t;try{var n=new Blob([e],{type:"text/plain;charset=UTF-8"});t=URL.createObjectURL(n);var r=new XMLHttpRequest;return r.open("GET",t,!1),r.send(),r.responseText}finally{t&&URL.revokeObjectURL(t)}}(e)}catch(n){return t(e)}});var l="construct 'TextDecoder'",f="".concat(n," ").concat(l,": the ");function d(e,t){if(r(t&&t.fatal,l,"fatal"),e=e||"utf-8",!(i?Buffer.isEncoding(e):-1!==u.indexOf(e.toLowerCase())))throw new RangeError("".concat(f," encoding label provided ('").concat(e,"') is invalid."));this.encoding=e,this.fatal=!1,this.ignoreBOM=!1}d.prototype.decode=function(e,t){var n;return r(t&&t.stream,"decode","stream"),n=e instanceof Uint8Array?e:e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer):new Uint8Array(e),c(n,this.encoding)},e.TextEncoder=e.TextEncoder||o,e.TextDecoder=e.TextDecoder||d}("undefined"!=typeof window?window:t);var oT={exports:{}};!function(e,n){(function(){var r={function:!0,object:!0}["undefined"==typeof window?"undefined":tc(window)]&&window||this,i=n,a=e&&!e.nodeType&&e,o=i&&a&&"object"==tc(t)&&t;!o||o.global!==o&&o.window!==o&&o.self!==o||(r=o);var s=Math.pow(2,53)-1,u=/\bOpera/,c=Object.prototype,l=c.hasOwnProperty,f=c.toString;function d(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function p(e){return e=g(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:d(e)}function h(e,t){for(var n in e)l.call(e,n)&&t(e[n],n,e)}function v(e){return null==e?d(e):f.call(e).slice(8,-1)}function y(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function m(e,t){var n=null;return function(e,t){var n=-1,r=e?e.length:0;if("number"==typeof r&&r>-1&&r<=s)for(;++n<r;)t(e[n],n,e);else h(e,t)}(e,(function(r,i){n=t(n,r,i,e)})),n}function g(e){return String(e).replace(/^ +| +$/g,"")}var b=function e(t){var n=r,i=t&&"object"==tc(t)&&"String"!=v(t);i&&(n=t,t=null);var a=n.navigator||{},o=a.userAgent||"";t||(t=o);var s,c,l=i?!!a.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(f.toString()),d="Object",b=i?d:"ScriptBridgingProxyObject",w=i?d:"Environment",k=i&&n.java?"JavaPackage":v(n.java),x=i?d:"RuntimeObject",_=/\bJava/.test(k)&&n.java,S=_&&v(n.environment)==w,O=_?"a":"α",E=_?"b":"β",T=n.document||{},R=n.operamini||n.opera,I=u.test(I=i&&R?R["[[Class]]"]:v(R))?I:R=null,C=t,P=[],j=null,A=t==o,M=A&&R&&"function"==typeof R.version&&R.version(),L=m([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],(function(e,n){return e||RegExp("\\b"+(n.pattern||y(n))+"\\b","i").exec(t)&&(n.label||n)})),U=function(e){return m(e,(function(e,n){return e||RegExp("\\b"+(n.pattern||y(n))+"\\b","i").exec(t)&&(n.label||n)}))}(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),N=q([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),F=function(e){return m(e,(function(e,n,r){return e||(n[N]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(N)]||RegExp("\\b"+y(r)+"(?:\\b|\\w*\\d)","i").exec(t))&&r}))}({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),D=function(e){return m(e,(function(e,n){var r=n.pattern||y(n);return!e&&(e=RegExp("\\b"+r+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,n){var r={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])&&(e="Windows "+r),e=String(e),t&&n&&(e=e.replace(RegExp(t,"i"),n)),p(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}(e,r,n.label||n)),e}))}(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function q(e){return m(e,(function(e,n){var r=n.pattern||y(n);return!e&&(e=RegExp("\\b"+r+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+r+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+r+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(n.label&&!RegExp(r,"i").test(n.label)?n.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),n=n.label||n,e=p(e[0].replace(RegExp(r,"i"),n).replace(RegExp("; *(?:"+n+"[_-])?","i")," ").replace(RegExp("("+n+")[-_.]?(\\w)","i"),"$1 $2"))),e}))}function B(e){return m(e,(function(e,n){return e||(RegExp(n+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if(L&&(L=[L]),/\bAndroid\b/.test(D)&&!N&&(s=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(N=g(s[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),F&&!N?N=q([F]):F&&N&&(N=N.replace(RegExp("^("+y(F)+")[-_.\\s]","i"),F+" ").replace(RegExp("^("+y(F)+")[-_.]?(\\w)","i"),F+" $2")),(s=/\bGoogle TV\b/.exec(N))&&(N=s[0]),/\bSimulator\b/i.test(t)&&(N=(N?N+" ":"")+"Simulator"),"Opera Mini"==U&&/\bOPiOS\b/.test(t)&&P.push("running in Turbo/Uncompressed mode"),"IE"==U&&/\blike iPhone OS\b/.test(t)?(F=(s=e(t.replace(/like iPhone OS/,""))).manufacturer,N=s.product):/^iP/.test(N)?(U||(U="Safari"),D="iOS"+((s=/ OS ([\d_]+)/i.exec(t))?" "+s[1].replace(/_/g,"."):"")):"Konqueror"==U&&/^Linux\b/i.test(D)?D="Kubuntu":F&&"Google"!=F&&(/Chrome/.test(U)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(N))||/\bAndroid\b/.test(D)&&/^Chrome/.test(U)&&/\bVersion\//i.test(t)?(U="Android Browser",D=/\bAndroid\b/.test(D)?D:"Android"):"Silk"==U?(/\bMobi/i.test(t)||(D="Android",P.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&P.unshift("accelerated")):"UC Browser"==U&&/\bUCWEB\b/.test(t)?P.push("speed mode"):"PaleMoon"==U&&(s=/\bFirefox\/([\d.]+)\b/.exec(t))?P.push("identifying as Firefox "+s[1]):"Firefox"==U&&(s=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(D||(D="Firefox OS"),N||(N=s[1])):!U||(s=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(U))?(U&&!N&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(s+"/")+8))&&(U=null),(s=N||F||D)&&(N||F||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(D))&&(U=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(D)?D:s)+" Browser")):"Electron"==U&&(s=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&P.push("Chromium "+s),M||(M=B(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",y(U),"(?:Firefox|Minefield|NetFront)"])),(s=("iCab"==L&&parseFloat(M)>3?"WebKit":/\bOpera\b/.test(U)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(L)&&"WebKit"||!L&&/\bMSIE\b/i.test(t)&&("Mac OS"==D?"Tasman":"Trident")||"WebKit"==L&&/\bPlayStation\b(?! Vita\b)/i.test(U)&&"NetFront")&&(L=[s]),"IE"==U&&(s=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(U+=" Mobile",D="Windows Phone "+(/\+$/.test(s)?s:s+".x"),P.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(U="IE Mobile",D="Windows Phone 8.x",P.unshift("desktop mode"),M||(M=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=U&&"Trident"==L&&(s=/\brv:([\d.]+)/.exec(t))&&(U&&P.push("identifying as "+U+(M?" "+M:"")),U="IE",M=s[1]),A){if(function(e,t){var n=null!=e?tc(e[t]):"number";return!(/^(?:boolean|number|string|undefined)$/.test(n)||"object"==n&&!e[t])}(n,"global"))if(_&&(C=(s=_.lang.System).getProperty("os.arch"),D=D||s.getProperty("os.name")+" "+s.getProperty("os.version")),S){try{M=n.require("ringo/engine").version.join("."),U="RingoJS"}catch(e){(s=n.system)&&s.global.system==n.system&&(U="Narwhal",D||(D=s[0].os||null))}U||(U="Rhino")}else"object"==tc(n.process)&&!n.process.browser&&(s=n.process)&&("object"==tc(s.versions)&&("string"==typeof s.versions.electron?(P.push("Node "+s.versions.node),U="Electron",M=s.versions.electron):"string"==typeof s.versions.nw&&(P.push("Chromium "+M,"Node "+s.versions.node),U="NW.js",M=s.versions.nw)),U||(U="Node.js",C=s.arch,D=s.platform,M=(M=/[\d.]+/.exec(s.version))?M[0]:null));else v(s=n.runtime)==b?(U="Adobe AIR",D=s.flash.system.Capabilities.os):v(s=n.phantom)==x?(U="PhantomJS",M=(s=s.version||null)&&s.major+"."+s.minor+"."+s.patch):"number"==typeof T.documentMode&&(s=/\bTrident\/(\d+)/i.exec(t))?(M=[M,T.documentMode],(s=+s[1]+4)!=M[1]&&(P.push("IE "+M[1]+" mode"),L&&(L[1]=""),M[1]=s),M="IE"==U?String(M[1].toFixed(1)):M[0]):"number"==typeof T.documentMode&&/^(?:Chrome|Firefox)\b/.test(U)&&(P.push("masking as "+U+" "+M),U="IE",M="11.0",L=["Trident"],D="Windows");D=D&&p(D)}if(M&&(s=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(M)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(A&&a.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(j=/b/i.test(s)?"beta":"alpha",M=M.replace(RegExp(s+"\\+?$"),"")+("beta"==j?E:O)+(/\d+\+?/.exec(s)||"")),"Fennec"==U||"Firefox"==U&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(D))U="Firefox Mobile";else if("Maxthon"==U&&M)M=M.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(N))"Xbox 360"==N&&(D=null),"Xbox 360"==N&&/\bIEMobile\b/.test(t)&&P.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(U)&&(!U||N||/Browser|Mobi/.test(U))||"Windows CE"!=D&&!/Mobi/i.test(t))if("IE"==U&&A)try{null===n.external&&P.unshift("platform preview")}catch(e){P.unshift("embedded")}else(/\bBlackBerry\b/.test(N)||/\bBB10\b/.test(t))&&(s=(RegExp(N.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||M)?(D=((s=[s,/BB10/.test(t)])[1]?(N=null,F="BlackBerry"):"Device Software")+" "+s[0],M=null):this!=h&&"Wii"!=N&&(A&&R||/Opera/.test(U)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==U&&/\bOS X (?:\d+\.){2,}/.test(D)||"IE"==U&&(D&&!/^Win/.test(D)&&M>5.5||/\bWindows XP\b/.test(D)&&M>8||8==M&&!/\bTrident\b/.test(t)))&&!u.test(s=e.call(h,t.replace(u,"")+";"))&&s.name&&(s="ing as "+s.name+((s=s.version)?" "+s:""),u.test(U)?(/\bIE\b/.test(s)&&"Mac OS"==D&&(D=null),s="identify"+s):(s="mask"+s,U=I?p(I.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(s)&&(D=null),A||(M=null)),L=["Presto"],P.push(s));else U+=" Mobile";(s=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(s=[parseFloat(s.replace(/\.(\d)$/,".0$1")),s],"Safari"==U&&"+"==s[1].slice(-1)?(U="WebKit Nightly",j="alpha",M=s[1].slice(0,-1)):M!=s[1]&&M!=(s[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(M=null),s[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==s[0]&&537.36==s[2]&&parseFloat(s[1])>=28&&"WebKit"==L&&(L=["Blink"]),A&&(l||s[1])?(L&&(L[1]="like Chrome"),s=s[1]||((s=s[0])<530?1:s<532?2:s<532.05?3:s<533?4:s<534.03?5:s<534.07?6:s<534.1?7:s<534.13?8:s<534.16?9:s<534.24?10:s<534.3?11:s<535.01?12:s<535.02?"13+":s<535.07?15:s<535.11?16:s<535.19?17:s<536.05?18:s<536.1?19:s<537.01?20:s<537.11?"21+":s<537.13?23:s<537.18?24:s<537.24?25:s<537.36?26:"Blink"!=L?"27":"28")):(L&&(L[1]="like Safari"),s=(s=s[0])<400?1:s<500?2:s<526?3:s<533?4:s<534?"4+":s<535?5:s<537?6:s<538?7:s<601?8:s<602?9:s<604?10:s<606?11:s<608?12:"12"),L&&(L[1]+=" "+(s+="number"==typeof s?".x":/[.+]/.test(s)?"":"+")),"Safari"==U&&(!M||parseInt(M)>45)?M=s:"Chrome"==U&&/\bHeadlessChrome/i.test(t)&&P.unshift("headless")),"Opera"==U&&(s=/\bzbov|zvav$/.exec(D))?(U+=" ",P.unshift("desktop mode"),"zvav"==s?(U+="Mini",M=null):U+="Mobile",D=D.replace(RegExp(" *"+s+"$"),"")):"Safari"==U&&/\bChrome\b/.exec(L&&L[1])?(P.unshift("desktop mode"),U="Chrome Mobile",M=null,/\bOS X\b/.test(D)?(F="Apple",D="iOS 4.3+"):D=null):/\bSRWare Iron\b/.test(U)&&!M&&(M=B("Chrome")),M&&0==M.indexOf(s=/[\d.]+$/.exec(D))&&t.indexOf("/"+s+"-")>-1&&(D=g(D.replace(s,""))),D&&-1!=D.indexOf(U)&&!RegExp(U+" OS").test(D)&&(D=D.replace(RegExp(" *"+y(U)+" *"),"")),L&&!/\b(?:Avant|Nook)\b/.test(U)&&(/Browser|Lunascape|Maxthon/.test(U)||"Safari"!=U&&/^iOS/.test(D)&&/\bSafari\b/.test(L[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(U)&&L[1])&&(s=L[L.length-1])&&P.push(s),P.length&&(P=["("+P.join("; ")+")"]),F&&N&&N.indexOf(F)<0&&P.push("on "+F),N&&P.push((/^on /.test(P[P.length-1])?"":"on ")+N),D&&(s=/ ([\d.+]+)$/.exec(D),c=s&&"/"==D.charAt(D.length-s[0].length-1),D={architecture:32,family:s&&!c?D.replace(s[0],""):D,version:s?s[1]:null,toString:function(){var e=this.version;return this.family+(e&&!c?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(s=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(C))&&!/\bi686\b/i.test(C)?(D&&(D.architecture=64,D.family=D.family.replace(RegExp(" *"+s),"")),U&&(/\bWOW64\b/i.test(t)||A&&/\w(?:86|32)$/.test(a.cpuClass||a.platform)&&!/\bWin64; x64\b/i.test(t))&&P.unshift("32-bit")):D&&/^OS X/.test(D.family)&&"Chrome"==U&&parseFloat(M)>=39&&(D.architecture=64),t||(t=null);var z={};return z.description=t,z.layout=L&&L[0],z.manufacturer=F,z.name=U,z.prerelease=j,z.product=N,z.ua=t,z.version=U&&M,z.os=D||{architecture:null,family:null,version:null,toString:function(){return"null"}},z.parse=e,z.toString=function(){return this.description||""},z.version&&P.unshift(M),z.name&&P.unshift(U),D&&U&&(D!=String(D).split(" ")[0]||D!=U.split(" ")[0]&&!N)&&P.push(N?"("+D+")":"on "+D),P.length&&(z.description=P.join(" ")),z}();i&&a?h(b,(function(e,t){i[t]=e})):r.platform=b}).call(t)}(oT,oT.exports);var sT={},uT=Symbol("@ts-pattern/matcher"),cT="@ts-pattern/anonymous-select-key",lT=function(e){return Boolean(e&&"object"==tc(e))},fT=function(e){return e&&!!e[uT]},dT=function e(t,n,r){if(lT(t)){if(fT(t)){var i=t[uT]().match(n),a=i.matched,o=i.selections;return a&&o&&Object.keys(o).forEach((function(e){return r(e,o[e])})),a}if(!lT(n))return!1;if(Array.isArray(t))return!!Array.isArray(n)&&t.length===n.length&&t.every((function(t,i){return e(t,n[i],r)}));if(t instanceof Map)return n instanceof Map&&Array.from(t.keys()).every((function(i){return e(t.get(i),n.get(i),r)}));if(t instanceof Set){if(!(n instanceof Set))return!1;if(0===t.size)return 0===n.size;if(1===t.size){var s=Array.from(t.values())[0];return fT(s)?Array.from(n.values()).every((function(t){return e(s,t,r)})):n.has(s)}return Array.from(t.values()).every((function(e){return n.has(e)}))}return Object.keys(t).every((function(i){var a,o=t[i];return(i in n||fT(a=o)&&"optional"===a[uT]().matcherType)&&e(o,n[i],r)}))}return Object.is(n,t)},pT=function e(t){var n,r,i;return lT(t)?fT(t)?null!=(n=null==(r=(i=t[uT]()).getSelectionKeys)?void 0:r.call(i))?n:[]:Array.isArray(t)?hT(t,e):hT(Object.values(t),e):[]},hT=function(e,t){return e.reduce((function(e,n){return e.concat(t(n))}),[])};function vT(e){var t;return(t={})[uT]=function(){return{match:function(t){var n={},r=function(e,t){n[e]=t};return void 0===t?(pT(e).forEach((function(e){return r(e,void 0)})),{matched:!0,selections:n}):{matched:dT(e,t,r),selections:n}},getSelectionKeys:function(){return pT(e)},matcherType:"optional"}},t}function yT(e){var t;return(t={})[uT]=function(){return{match:function(t){if(!Array.isArray(t))return{matched:!1};var n={};if(0===t.length)return pT(e).forEach((function(e){n[e]=[]})),{matched:!0,selections:n};var r=function(e,t){n[e]=(n[e]||[]).concat([t])};return{matched:t.every((function(t){return dT(e,t,r)})),selections:n}},getSelectionKeys:function(){return pT(e)}}},t}function mT(){var e,t=[].slice.call(arguments);return(e={})[uT]=function(){return{match:function(e){var n={},r=function(e,t){n[e]=t};return{matched:t.every((function(t){return dT(t,e,r)})),selections:n}},getSelectionKeys:function(){return hT(t,pT)},matcherType:"and"}},e}function gT(){var e,t=[].slice.call(arguments);return(e={})[uT]=function(){return{match:function(e){var n={},r=function(e,t){n[e]=t};return hT(t,pT).forEach((function(e){return r(e,void 0)})),{matched:t.some((function(t){return dT(t,e,r)})),selections:n}},getSelectionKeys:function(){return hT(t,pT)},matcherType:"or"}},e}function bT(e){var t;return(t={})[uT]=function(){return{match:function(t){return{matched:!dT(e,t,(function(){}))}},getSelectionKeys:function(){return[]},matcherType:"not"}},t}function wT(e){var t;return(t={})[uT]=function(){return{match:function(t){return{matched:Boolean(e(t))}}}},t}function kT(){var e,t=[].slice.call(arguments),n="string"==typeof t[0]?t[0]:void 0,r=2===t.length?t[1]:"string"==typeof t[0]?void 0:t[0];return(e={})[uT]=function(){return{match:function(e){var t,i=((t={})[null!=n?n:cT]=e,t);return{matched:void 0===r||dT(r,e,(function(e,t){i[e]=t})),selections:i}},getSelectionKeys:function(){return[null!=n?n:cT].concat(void 0===r?[]:pT(r))}}},e}var xT=wT((function(e){return!0})),_T=xT,ST=wT((function(e){return"string"==typeof e})),OT=wT((function(e){return"number"==typeof e})),ET=wT((function(e){return"boolean"==typeof e})),TT=wT((function(e){return"bigint"==typeof e})),RT=wT((function(e){return"symbol"==tc(e)})),IT=wT((function(e){return null==e})),CT={__proto__:null,optional:vT,array:yT,intersection:mT,union:gT,not:bT,when:wT,select:kT,any:xT,_:_T,string:ST,number:OT,boolean:ET,bigint:TT,symbol:RT,nullish:IT,instanceOf:function(e){return wT(function(e){return function(t){return t instanceof e}}(e))},typed:function(){return{array:yT,optional:vT,intersection:mT,union:gT,not:bT,select:kT,when:wT}}},PT=function(){function e(e,t){this.value=void 0,this.cases=void 0,this.value=e,this.cases=t}var t=e.prototype;return t.with=function(){var t=[].slice.call(arguments),n=t[t.length-1],r=[t[0]],i=[];return 3===t.length&&"function"==typeof t[1]?(r.push(t[0]),i.push(t[1])):t.length>2&&r.push.apply(r,t.slice(1,t.length-1)),new e(this.value,this.cases.concat([{match:function(e){var t={},n=Boolean(r.some((function(n){return dT(n,e,(function(e,n){t[e]=n}))}))&&i.every((function(t){return t(e)})));return{matched:n,value:n&&Object.keys(t).length?cT in t?t[cT]:t:e}},handler:n}]))},t.when=function(t,n){return new e(this.value,this.cases.concat([{match:function(e){return{matched:Boolean(t(e)),value:e}},handler:n}]))},t.otherwise=function(t){return new e(this.value,this.cases.concat([{match:function(e){return{matched:!0,value:e}},handler:t}])).run()},t.exhaustive=function(){return this.run()},t.run=function(){for(var e=this.value,t=void 0,n=0;n<this.cases.length;n++){var r=this.cases[n],i=r.match(this.value);if(i.matched){e=i.value,t=r.handler;break}}if(!t){var a;try{a=JSON.stringify(this.value)}catch(e){a=this.value}throw new Error("Pattern matching error: no pattern matches value "+a)}return t(e,this.value)},e}();sT.P=CT,sT.Pattern=CT,sT.isMatching=function(){var e=[].slice.call(arguments);if(1===e.length){var t=e[0];return function(e){return dT(t,e,(function(){}))}}if(2===e.length){var n=e,r=n[0],i=n[1];return dT(r,i,(function(){}))}throw new Error("isMatching wasn't given the right number of arguments: expected 1 or 2, received "+e.length+".")},sT.match=function(e){return new PT(e,[])};var jT=Zr,AT=zl,MT=o,LT=J,UT=W,NT=Lc,FT=gp,DT=Yn,qT=AT&&AT.prototype;if(jT({target:"Promise",proto:!0,real:!0,forced:!!AT&&MT((function(){qT.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=NT(this,LT("Promise")),n=UT(e);return this.then(n?function(n){return FT(t,e()).then((function(){return n}))}:e,n?function(n){return FT(t,e()).then((function(){throw n}))}:e)}}),UT(AT)){var BT=LT("Promise").prototype.finally;qT.finally!==BT&&DT(qT,"finally",BT,{unsafe:!0})}function zT(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function WT(e,t,n){return WT=zT()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&Zu(i,n.prototype),i},WT.apply(null,arguments)}function $T(e){var t="function"==typeof Map?new Map:void 0;return $T=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return WT(e,arguments,rc(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Zu(r,e)},$T(e)}var KT={},HT="[a-fA-F\\d:]",GT=function(e){return e&&e.includeBoundaries?"(?:(?<=\\s|^)(?=".concat(HT,")|(?<=").concat(HT,")(?=\\s|$))"):""},VT="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",YT="[a-fA-F\\d]{1,4}",JT="\n(?:\n(?:".concat(YT,":){7}(?:").concat(YT,"|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:").concat(YT,":){6}(?:").concat(VT,"|:").concat(YT,"|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:").concat(YT,":){5}(?::").concat(VT,"|(?::").concat(YT,"){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:").concat(YT,":){4}(?:(?::").concat(YT,"){0,1}:").concat(VT,"|(?::").concat(YT,"){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:").concat(YT,":){3}(?:(?::").concat(YT,"){0,2}:").concat(VT,"|(?::").concat(YT,"){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:").concat(YT,":){2}(?:(?::").concat(YT,"){0,3}:").concat(VT,"|(?::").concat(YT,"){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:").concat(YT,":){1}(?:(?::").concat(YT,"){0,4}:").concat(VT,"|(?::").concat(YT,"){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::").concat(YT,"){0,5}:").concat(VT,"|(?::").concat(YT,"){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n").replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),QT=new RegExp("(?:^".concat(VT,"$)|(?:^").concat(JT,"$)")),XT=new RegExp("^".concat(VT,"$")),ZT=new RegExp("^".concat(JT,"$")),eR=function(e){return e&&e.exact?QT:new RegExp("(?:".concat(GT(e)).concat(VT).concat(GT(e),")|(?:").concat(GT(e)).concat(JT).concat(GT(e),")"),"g")};eR.v4=function(e){return e&&e.exact?XT:new RegExp("".concat(GT(e)).concat(VT).concat(GT(e)),"g")},eR.v6=function(e){return e&&e.exact?ZT:new RegExp("".concat(GT(e)).concat(JT).concat(GT(e)),"g")};var tR=eR,nR=function(e){return tR({exact:!0}).test(e)};function rR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function iR(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rR(Object(n),!0).forEach((function(t){uc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rR(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function aR(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return oR(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return oR(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function oR(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function sR(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}nR.v4=function(e){return tR.v4({exact:!0}).test(e)},nR.v6=function(e){return tR.v6({exact:!0}).test(e)},nR.version=function(e){return nR(e)?nR.v4(e)?4:6:void 0};var uR=nR,cR=function(e){ec(n,e);var t=sR(n);function n(){var e;return sc(this,n),(e=t.call(this,"Request was cancelled")).name="CancelError",e}return oc(n,[{key:"isCanceled",get:function(){return!0}}]),n}($T(Error)),lR={timeout:5e3},fR={v4:["https://ipv4.icanhazip.com/","https://api.ipify.org/"],v6:["https://ipv6.icanhazip.com/","https://api6.ipify.org/"]},dR=function(e,t,n){var r,i=new XMLHttpRequest,a=new Promise((function(a,o){r=o,i.addEventListener("error",o,{once:!0}),i.addEventListener("timeout",o,{once:!0}),i.addEventListener("load",(function(){var e=i.responseText.trim();e&&uR[n](e)?a(e):o()}),{once:!0}),i.open("GET",e),i.timeout=t.timeout,i.send()}));return a.cancel=function(){i.abort(),r(new cR)},a},pR=function(e,t){var n,r=Qu(hh.mark((function r(){var i,a,o,s,u;return hh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:i=[].concat.apply(fR[e],t.fallbackUrls||[]),a=aR(i),r.prev=2,a.s();case 4:if((o=a.n()).done){r.next=20;break}return s=o.value,r.prev=6,n=dR(s,t,e),r.next=10,n;case 10:return u=r.sent,r.abrupt("return",u);case 14:if(r.prev=14,r.t0=r.catch(6),!(r.t0 instanceof cR)){r.next=18;break}throw r.t0;case 18:r.next=4;break;case 20:r.next=25;break;case 22:r.prev=22,r.t1=r.catch(2),a.e(r.t1);case 25:return r.prev=25,a.f(),r.finish(25);case 28:throw new Error("Couldn't find your IP");case 29:case"end":return r.stop()}}),r,null,[[2,22,25,28],[6,14]])})))();return r.cancel=function(){n.cancel()},r};function hR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function vR(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?hR(Object(n),!0).forEach((function(t){uc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hR(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}KT.v4=function(e){return pR("v4",iR(iR({},lR),e))},KT.v6=function(e){return pR("v6",iR(iR({},lR),e))};var yR,mR=KT,gR=function(){var e=Qu(hh.mark((function e(t){var n;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=vR({timeout:5e3,ipVersion:4},t),!navigator||navigator.onLine){e.next=3;break}return e.abrupt("return",!1);case 3:return n=4===t.ipVersion?"v4":"v6",e.prev=4,e.next=7,mR[n](t);case 7:return e.abrupt("return",!0);case 10:return e.prev=10,e.t0=e.catch(4),e.abrupt("return",!1);case 13:case"end":return e.stop()}}),e,null,[[4,10]])})));return function(t){return e.apply(this,arguments)}}(),bR=gR,wR=H,kR=T,xR=rt("match"),_R=function(e){var t;return wR(e)&&(void 0!==(t=e[xR])?!!t:"RegExp"==kR(e))},SR=_R,OR=TypeError,ER=function(e){if(SR(e))throw OR("The method doesn't accept regular expressions");return e},TR=rt("match"),RR=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[TR]=!1,"/./"[e](t)}catch(e){}}return!1},IR=Zr,CR=go,PR=a.f,jR=ur,AR=Ba,MR=ER,LR=U,UR=RR,NR=CR("".startsWith),FR=CR("".slice),DR=Math.min,qR=UR("startsWith");IR({target:"String",proto:!0,forced:!!(qR||(yR=PR(String.prototype,"startsWith"),!yR||yR.writable))&&!qR},{startsWith:function(e){var t=AR(LR(this));MR(e);var n=jR(DR(arguments.length>1?arguments[1]:void 0,t.length)),r=AR(e);return NR?NR(t,r,n):FR(t,n,n+r.length)===r}});var BR="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",zR={nanoid:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,t="",n=e;n--;)t+=BR[64*Math.random()|0];return t},customAlphabet:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:21;return function(){for(var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t,r="",i=n;i--;)r+=e[Math.random()*e.length|0];return r}}},WR={};function $R(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return KR(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return KR(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function KR(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function HR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function GR(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?HR(Object(n),!0).forEach((function(t){uc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):HR(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Type=e.TypeBuilder=e.Modifier=e.Hint=e.Kind=void 0,e.Kind=Symbol.for("TypeBox.Kind"),e.Hint=Symbol.for("TypeBox.Hint"),e.Modifier=Symbol.for("TypeBox.Modifier");var t=0,n=function(){function n(){sc(this,n)}return oc(n,[{key:"ReadonlyOptional",value:function(t){return GR(uc({},e.Modifier,"ReadonlyOptional"),t)}},{key:"Readonly",value:function(t){return GR(uc({},e.Modifier,"Readonly"),t)}},{key:"Optional",value:function(t){return GR(uc({},e.Modifier,"Optional"),t)}},{key:"Any",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(GR(GR({},t),{},uc({},e.Kind,"Any")))}},{key:"Array",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.Create(GR(GR({},r),{},(uc(n={},e.Kind,"Array"),uc(n,"type","array"),uc(n,"items",t),n)))}},{key:"Boolean",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(GR(GR({},n),{},(uc(t={},e.Kind,"Boolean"),uc(t,"type","boolean"),t)))}},{key:"ConstructorParameters",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.Tuple(t_(e.parameters),GR({},t))}},{key:"Constructor",value:function(t,n){var r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("Tuple"===t[e.Kind]){var a,o=void 0===t.items?[]:t.items;return this.Create(GR(GR({},i),{},(uc(a={},e.Kind,"Constructor"),uc(a,"type","constructor"),uc(a,"parameters",o),uc(a,"returns",n),a)))}if(globalThis.Array.isArray(t))return this.Create(GR(GR({},i),{},(uc(r={},e.Kind,"Constructor"),uc(r,"type","constructor"),uc(r,"parameters",t),uc(r,"returns",n),r)));throw new Error("TypeBuilder.Constructor: Invalid parameters")}},{key:"Enum",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=Object.keys(t).filter((function(e){return isNaN(e)})).map((function(e){return t[e]})),a=i.map((function(t){var n,r;return"string"==typeof t?(uc(n={},e.Kind,"Literal"),uc(n,"type","string"),uc(n,"const",t),n):(uc(r={},e.Kind,"Literal"),uc(r,"type","number"),uc(r,"const",t),r)}));return this.Create(GR(GR({},r),{},(uc(n={},e.Kind,"Union"),uc(n,e.Hint,"Enum"),uc(n,"anyOf",a),n)))}},{key:"Function",value:function(t,n){var r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("Tuple"===t[e.Kind]){var a,o=void 0===t.items?[]:t.items;return this.Create(GR(GR({},i),{},(uc(a={},e.Kind,"Function"),uc(a,"type","function"),uc(a,"parameters",o),uc(a,"returns",n),a)))}if(globalThis.Array.isArray(t))return this.Create(GR(GR({},i),{},(uc(r={},e.Kind,"Function"),uc(r,"type","function"),uc(r,"parameters",t),uc(r,"returns",n),r)));throw new Error("TypeBuilder.Function: Invalid parameters")}},{key:"InstanceType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return GR(GR({},t),this.Clone(e.returns))}},{key:"Integer",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(GR(GR({},n),{},(uc(t={},e.Kind,"Integer"),uc(t,"type","integer"),t)))}},{key:"Intersect",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=function(t){return t[e.Modifier]&&"Optional"===t[e.Modifier]||"ReadonlyOptional"===t[e.Modifier]},a=new Set,o=new Set,s=$R(t);try{for(s.s();!(n=s.n()).done;)for(var u=n.value,c=0,l=Object.entries(u.properties);c<l.length;c++){var f=n_(l[c],2),d=f[0],p=f[1];i(p)&&o.add(d)}}catch(e){s.e(e)}finally{s.f()}var h,v=$R(t);try{for(v.s();!(h=v.n()).done;)for(var y=h.value,m=0,g=Object.keys(y.properties);m<g.length;m++){var b=g[m];o.has(b)||a.add(b)}}catch(e){v.e(e)}finally{v.f()}var w,k,x,_={},S=$R(t);try{for(S.s();!(w=S.n()).done;)for(var O=w.value,E=0,T=Object.entries(O.properties);E<T.length;E++){var R,I=n_(T[E],2),C=I[0],P=I[1];_[C]=void 0===_[C]?P:(uc(R={},e.Kind,"Union"),uc(R,"anyOf",[_[C],GR({},P)]),R)}}catch(e){S.e(e)}finally{S.f()}return a.size>0?this.Create(GR(GR({},r),{},(uc(k={},e.Kind,"Object"),uc(k,"type","object"),uc(k,"properties",_),uc(k,"required",t_(a)),k))):this.Create(GR(GR({},r),{},(uc(x={},e.Kind,"Object"),uc(x,"type","object"),uc(x,"properties",_),x)))}},{key:"KeyOf",value:function(t){var n,r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=Object.keys(t.properties).map((function(t){var n;return r.Create(GR(GR({},i),{},(uc(n={},e.Kind,"Literal"),uc(n,"type","string"),uc(n,"const",t),n)))}));return this.Create(GR(GR({},i),{},(uc(n={},e.Kind,"Union"),uc(n,e.Hint,"KeyOf"),uc(n,"anyOf",a),n)))}},{key:"Literal",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.Create(GR(GR({},r),{},(uc(n={},e.Kind,"Literal"),uc(n,"const",t),uc(n,"type",tc(t)),n)))}},{key:"Never",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(GR(GR({},n),{},(uc(t={},e.Kind,"Never"),uc(t,"allOf",[{type:"boolean",const:!1},{type:"boolean",const:!0}]),t)))}},{key:"Null",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(GR(GR({},n),{},(uc(t={},e.Kind,"Null"),uc(t,"type","null"),t)))}},{key:"Number",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(GR(GR({},n),{},(uc(t={},e.Kind,"Number"),uc(t,"type","number"),t)))}},{key:"Object",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(t){var n,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=Object.keys(t),o=a.filter((function(n){var r=t[n][e.Modifier];return r&&("Optional"===r||"ReadonlyOptional"===r)})),s=a.filter((function(e){return!o.includes(e)}));return s.length>0?this.Create(GR(GR({},i),{},(uc(n={},e.Kind,"Object"),uc(n,"type","object"),uc(n,"properties",t),uc(n,"required",s),n))):this.Create(GR(GR({},i),{},(uc(r={},e.Kind,"Object"),uc(r,"type","object"),uc(r,"properties",t),r)))}))},{key:"Omit",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i="Union"===n[e.Kind]?n.anyOf.map((function(e){return e.const})):n,a=GR(GR(GR({},this.Clone(t)),r),{},uc({},e.Hint,"Omit"));a.required&&(a.required=a.required.filter((function(e){return!i.includes(e)})),0===a.required.length&&delete a.required);for(var o=0,s=Object.keys(a.properties);o<s.length;o++){var u=s[o];i.includes(u)&&delete a.properties[u]}return this.Create(a)}},{key:"Parameters",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.Type.Tuple(t.parameters,GR({},n))}},{key:"Partial",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=GR(GR(GR({},this.Clone(t)),n),{},uc({},e.Hint,"Partial"));delete r.required;for(var i=0,a=Object.keys(r.properties);i<a.length;i++){var o=a[i],s=r.properties[o],u=s[e.Modifier];switch(u){case"ReadonlyOptional":case"Readonly":s[e.Modifier]="ReadonlyOptional";break;default:s[e.Modifier]="Optional"}}return this.Create(r)}},{key:"Pick",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i="Union"===n[e.Kind]?n.anyOf.map((function(e){return e.const})):n,a=GR(GR(GR({},this.Clone(t)),r),{},uc({},e.Hint,"Pick"));a.required&&(a.required=a.required.filter((function(e){return i.includes(e)})),0===a.required.length&&delete a.required);for(var o=0,s=Object.keys(a.properties);o<s.length;o++){var u=s[o];i.includes(u)||delete a.properties[u]}return this.Create(a)}},{key:"Promise",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.Create(GR(GR({},r),{},(uc(n={},e.Kind,"Promise"),uc(n,"type","promise"),uc(n,"item",t),n)))}},{key:"Record",value:function(t,n){var r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("Union"===t[e.Kind])return this.Object(t.anyOf.reduce((function(e,t){return GR(GR({},e),{},uc({},t.const,n))}),{}),GR(GR({},i),{},uc({},e.Hint,"Record")));var a=["Integer","Number"].includes(t[e.Kind])?"^(0|[1-9][0-9]*)$":"String"===t[e.Kind]&&t.pattern?t.pattern:"^.*$";return this.Create(GR(GR({},i),{},(uc(r={},e.Kind,"Record"),uc(r,"type","object"),uc(r,"patternProperties",uc({},a,n)),uc(r,"additionalProperties",!1),r)))}},{key:"Recursive",value:function(n){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};void 0===i.$id&&(i.$id="T".concat(t++));var a=n((uc(r={},e.Kind,"Self"),uc(r,"$ref","".concat(i.$id)),r));return a.$id=i.$id,this.Create(GR(GR({},i),a))}},{key:"Ref",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0===t.$id)throw Error("TypeBuilder.Ref: Referenced schema must specify an $id");return this.Create(GR(GR({},r),{},(uc(n={},e.Kind,"Ref"),uc(n,"$ref",t.$id),n)))}},{key:"RegEx",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.Create(GR(GR({},r),{},(uc(n={},e.Kind,"String"),uc(n,"type","string"),uc(n,"pattern",t.source),n)))}},{key:"Required",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=GR(GR(GR({},this.Clone(t)),n),{},uc({},e.Hint,"Required"));r.required=Object.keys(r.properties);for(var i=0,a=Object.keys(r.properties);i<a.length;i++){var o=a[i],s=r.properties[o],u=s[e.Modifier];switch(u){case"ReadonlyOptional":case"Readonly":s[e.Modifier]="Readonly";break;default:delete s[e.Modifier]}}return this.Create(r)}},{key:"ReturnType",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return GR(GR({},t),this.Clone(e.returns))}},{key:"Strict",value:function(e){return JSON.parse(JSON.stringify(e))}},{key:"String",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(GR(GR({},n),{},(uc(t={},e.Kind,"String"),uc(t,"type","string"),t)))}},{key:"Tuple",value:function(t){var n,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=!1,o=t.length,s=t.length,u=t.length>0?GR(GR({},i),{},(uc(n={},e.Kind,"Tuple"),uc(n,"type","array"),uc(n,"items",t),uc(n,"additionalItems",a),uc(n,"minItems",o),uc(n,"maxItems",s),n)):GR(GR({},i),{},(uc(r={},e.Kind,"Tuple"),uc(r,"type","array"),uc(r,"minItems",o),uc(r,"maxItems",s),r));return this.Create(u)}},{key:"Undefined",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(GR(GR({},n),{},(uc(t={},e.Kind,"Undefined"),uc(t,"type","object"),uc(t,"specialized","Undefined"),t)))}},{key:"Union",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return 0===t.length?e.Type.Never(GR({},r)):this.Create(GR(GR({},r),{},(uc(n={},e.Kind,"Union"),uc(n,"anyOf",t),n)))}},{key:"Uint8Array",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(GR(GR({},n),{},(uc(t={},e.Kind,"Uint8Array"),uc(t,"type","object"),uc(t,"specialized","Uint8Array"),t)))}},{key:"Unknown",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(GR(GR({},t),{},uc({},e.Kind,"Unknown")))}},{key:"Unsafe",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(GR(GR({},t),{},uc({},e.Kind,t[e.Kind]||"Unsafe")))}},{key:"Void",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.Create(GR(GR({},n),{},(uc(t={},e.Kind,"Void"),uc(t,"type","null"),t)))}},{key:"Create",value:function(e){return e}},{key:"Clone",value:function(e){var t,n=this;return"object"!==tc(t=e)||null===t||Array.isArray(t)?function(e){return"object"===tc(e)&&null!==e&&Array.isArray(e)}(e)?e.map((function(e){return n.Clone(e)})):e:Object.keys(e).reduce((function(t,r){return GR(GR({},t),{},uc({},r,n.Clone(e[r])))}),Object.getOwnPropertySymbols(e).reduce((function(t,r){return GR(GR({},t),{},uc({},r,n.Clone(e[r])))}),{}))}}]),n}();e.TypeBuilder=n,e.Type=new n}(WR);var VR={},YR={},JR={},QR={},XR={};function ZR(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return eI(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eI(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function eI(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function tI(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}!function(e){var t,n;Object.defineProperty(e,"__esModule",{value:!0}),e.Format=void 0,t=e.Format||(e.Format={}),n=new Map,t.Clear=function(){return n.clear()},t.Has=function(e){return n.has(e)},t.Set=function(e,t){n.set(e,t)},t.Get=function(e){return n.get(e)}}(XR),function(e){var n=t&&t.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=t&&t.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),r(XR,e)}(QR),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueErrors=e.ValueErrorsUnknownTypeError=e.ValueErrorType=void 0;var t,n=WR,r=QR;!function(e){e[e.Array=0]="Array",e[e.ArrayMinItems=1]="ArrayMinItems",e[e.ArrayMaxItems=2]="ArrayMaxItems",e[e.ArrayUniqueItems=3]="ArrayUniqueItems",e[e.Boolean=4]="Boolean",e[e.Function=5]="Function",e[e.Integer=6]="Integer",e[e.IntegerMultipleOf=7]="IntegerMultipleOf",e[e.IntegerExclusiveMinimum=8]="IntegerExclusiveMinimum",e[e.IntegerExclusiveMaximum=9]="IntegerExclusiveMaximum",e[e.IntegerMinimum=10]="IntegerMinimum",e[e.IntegerMaximum=11]="IntegerMaximum",e[e.Literal=12]="Literal",e[e.Never=13]="Never",e[e.Null=14]="Null",e[e.Number=15]="Number",e[e.NumberMultipleOf=16]="NumberMultipleOf",e[e.NumberExclusiveMinimum=17]="NumberExclusiveMinimum",e[e.NumberExclusiveMaximum=18]="NumberExclusiveMaximum",e[e.NumberMinumum=19]="NumberMinumum",e[e.NumberMaximum=20]="NumberMaximum",e[e.Object=21]="Object",e[e.ObjectMinProperties=22]="ObjectMinProperties",e[e.ObjectMaxProperties=23]="ObjectMaxProperties",e[e.ObjectAdditionalProperties=24]="ObjectAdditionalProperties",e[e.ObjectRequiredProperties=25]="ObjectRequiredProperties",e[e.Promise=26]="Promise",e[e.RecordKeyNumeric=27]="RecordKeyNumeric",e[e.RecordKeyString=28]="RecordKeyString",e[e.String=29]="String",e[e.StringMinLength=30]="StringMinLength",e[e.StringMaxLength=31]="StringMaxLength",e[e.StringPattern=32]="StringPattern",e[e.StringFormatUnknown=33]="StringFormatUnknown",e[e.StringFormat=34]="StringFormat",e[e.TupleZeroLength=35]="TupleZeroLength",e[e.TupleLength=36]="TupleLength",e[e.Undefined=37]="Undefined",e[e.Union=38]="Union",e[e.Uint8Array=39]="Uint8Array",e[e.Uint8ArrayMinByteLength=40]="Uint8ArrayMinByteLength",e[e.Uint8ArrayMaxByteLength=41]="Uint8ArrayMaxByteLength",e[e.Void=42]="Void"}(t=e.ValueErrorType||(e.ValueErrorType={}));var i=function(e){ec(n,e);var t=tI(n);function n(e){var r;return sc(this,n),(r=t.call(this,"ValueErrors: Unknown type")).schema=e,r}return oc(n)}($T(Error));e.ValueErrorsUnknownTypeError=i,function(e){var a=hh.mark(I),o=hh.mark(C),s=hh.mark(P),u=hh.mark(j),c=hh.mark(A),l=hh.mark(M),f=hh.mark(L),d=hh.mark(U),p=hh.mark(N),h=hh.mark(F),v=hh.mark(D),y=hh.mark(q),m=hh.mark(B),g=hh.mark(z),b=hh.mark(W),w=hh.mark($),k=hh.mark(K),x=hh.mark(H),_=hh.mark(G),S=hh.mark(V),O=hh.mark(Y),E=hh.mark(J),T=hh.mark(Q),R=hh.mark(X);function I(e,t,n,r){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),a)}function C(e,n,r,i){var a;return hh.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(globalThis.Array.isArray(i)){o.next=4;break}return o.next=3,{type:t.Array,schema:e,path:r,value:i,message:"Expected array"};case 3:return o.abrupt("return",o.sent);case 4:if(void 0===e.minItems||i.length>=e.minItems){o.next=7;break}return o.next=7,{type:t.ArrayMinItems,schema:e,path:r,value:i,message:"Expected array length to be greater or equal to ".concat(e.minItems)};case 7:if(void 0===e.maxItems||i.length<=e.maxItems){o.next=10;break}return o.next=10,{type:t.ArrayMinItems,schema:e,path:r,value:i,message:"Expected array length to be less or equal to ".concat(e.maxItems)};case 10:if(!0!==e.uniqueItems||new Set(i).size===i.length){o.next=13;break}return o.next=13,{type:t.ArrayUniqueItems,schema:e,path:r,value:i,message:"Expected array elements to be unique"};case 13:a=0;case 14:if(!(a<i.length)){o.next=19;break}return o.delegateYield(Q(e.items,n,"".concat(r,"/").concat(a),i[a]),"t0",16);case 16:a++,o.next=14;break;case 19:case"end":return o.stop()}}),o)}function P(e,n,r,i){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("boolean"==typeof i){n.next=4;break}return n.next=3,{type:t.Boolean,schema:e,path:r,value:i,message:"Expected boolean"};case 3:return n.abrupt("return",n.sent);case 4:case"end":return n.stop()}}),s)}function j(e,t,n,r){return hh.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(Q(e.returns,t,n,r.prototype),"t0",1);case 1:case"end":return i.stop()}}),u)}function A(e,n,r,i){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("function"==typeof i){n.next=4;break}return n.next=3,{type:t.Function,schema:e,path:r,value:i,message:"Expected function"};case 3:return n.abrupt("return",n.sent);case 4:case"end":return n.stop()}}),c)}function M(e,n,r,i){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("number"==typeof i){n.next=4;break}return n.next=3,{type:t.Number,schema:e,path:r,value:i,message:"Expected number"};case 3:return n.abrupt("return",n.sent);case 4:if(globalThis.Number.isInteger(i)){n.next=7;break}return n.next=7,{type:t.Integer,schema:e,path:r,value:i,message:"Expected integer"};case 7:if(!e.multipleOf||i%e.multipleOf==0){n.next=10;break}return n.next=10,{type:t.IntegerMultipleOf,schema:e,path:r,value:i,message:"Expected integer to be a multiple of ".concat(e.multipleOf)};case 10:if(!e.exclusiveMinimum||i>e.exclusiveMinimum){n.next=13;break}return n.next=13,{type:t.IntegerExclusiveMinimum,schema:e,path:r,value:i,message:"Expected integer to be greater than ".concat(e.exclusiveMinimum)};case 13:if(!e.exclusiveMaximum||i<e.exclusiveMaximum){n.next=16;break}return n.next=16,{type:t.IntegerExclusiveMaximum,schema:e,path:r,value:i,message:"Expected integer to be less than ".concat(e.exclusiveMaximum)};case 16:if(!e.minimum||i>=e.minimum){n.next=19;break}return n.next=19,{type:t.IntegerMinimum,schema:e,path:r,value:i,message:"Expected integer to be greater or equal to ".concat(e.minimum)};case 19:if(!e.maximum||i<=e.maximum){n.next=22;break}return n.next=22,{type:t.IntegerMaximum,schema:e,path:r,value:i,message:"Expected integer to be less or equal to ".concat(e.maximum)};case 22:case"end":return n.stop()}}),l)}function L(e,n,r,i){var a;return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(i===e.const){n.next=5;break}return a="string"==typeof e.const?"'".concat(e.const,"'"):e.const,n.next=4,{type:t.Literal,schema:e,path:r,value:i,message:"Expected ".concat(a)};case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),f)}function U(e,n,r,i){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,{type:t.Never,schema:e,path:r,value:i,message:"Value cannot be validated"};case 2:case"end":return n.stop()}}),d)}function N(e,n,r,i){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===i){n.next=4;break}return n.next=3,{type:t.Null,schema:e,path:r,value:i,message:"Expected null"};case 3:return n.abrupt("return",n.sent);case 4:case"end":return n.stop()}}),p)}function F(e,n,r,i){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("number"==typeof i){n.next=4;break}return n.next=3,{type:t.Number,schema:e,path:r,value:i,message:"Expected number"};case 3:return n.abrupt("return",n.sent);case 4:if(!e.multipleOf||i%e.multipleOf==0){n.next=7;break}return n.next=7,{type:t.NumberMultipleOf,schema:e,path:r,value:i,message:"Expected number to be a multiple of ".concat(e.multipleOf)};case 7:if(!e.exclusiveMinimum||i>e.exclusiveMinimum){n.next=10;break}return n.next=10,{type:t.NumberExclusiveMinimum,schema:e,path:r,value:i,message:"Expected number to be greater than ".concat(e.exclusiveMinimum)};case 10:if(!e.exclusiveMaximum||i<e.exclusiveMaximum){n.next=13;break}return n.next=13,{type:t.NumberExclusiveMaximum,schema:e,path:r,value:i,message:"Expected number to be less than ".concat(e.exclusiveMaximum)};case 13:if(!e.minimum||i>=e.minimum){n.next=16;break}return n.next=16,{type:t.NumberMaximum,schema:e,path:r,value:i,message:"Expected number to be greater or equal to ".concat(e.minimum)};case 16:if(!e.maximum||i<=e.maximum){n.next=19;break}return n.next=19,{type:t.NumberMinumum,schema:e,path:r,value:i,message:"Expected number to be less or equal to ".concat(e.maximum)};case 19:case"end":return n.stop()}}),h)}function D(e,n,r,i){var a,o,s,u,c,l,f,d,p,h,y,m,g,b,w;return hh.wrap((function(v){for(;;)switch(v.prev=v.next){case 0:if("object"===tc(i)&&null!==i&&!globalThis.Array.isArray(i)){v.next=4;break}return v.next=3,{type:t.Object,schema:e,path:r,value:i,message:"Expected object"};case 3:return v.abrupt("return",v.sent);case 4:if(void 0===e.minProperties||globalThis.Object.keys(i).length>=e.minProperties){v.next=7;break}return v.next=7,{type:t.ObjectMinProperties,schema:e,path:r,value:i,message:"Expected object to have at least ".concat(e.minProperties," properties")};case 7:if(void 0===e.maxProperties||globalThis.Object.keys(i).length<=e.maxProperties){v.next=10;break}return v.next=10,{type:t.ObjectMaxProperties,schema:e,path:r,value:i,message:"Expected object to have less than ".concat(e.minProperties," properties")};case 10:if(a=globalThis.Object.keys(e.properties),!1!==e.additionalProperties){v.next=30;break}o=ZR(globalThis.Object.keys(i)),v.prev=13,o.s();case 15:if((s=o.n()).done){v.next=22;break}if(u=s.value,a.includes(u)){v.next=20;break}return v.next=20,{type:t.ObjectAdditionalProperties,schema:e,path:"".concat(r,"/").concat(u),value:i[u],message:"Unexpected property"};case 20:v.next=15;break;case 22:v.next=27;break;case 24:v.prev=24,v.t0=v.catch(13),o.e(v.t0);case 27:return v.prev=27,o.f(),v.finish(27);case 30:if(!(e.required&&e.required.length>0)){v.next=51;break}c=globalThis.Object.keys(i),l=ZR(e.required),v.prev=33,l.s();case 35:if((f=l.n()).done){v.next=43;break}if(d=f.value,!c.includes(d)){v.next=39;break}return v.abrupt("continue",41);case 39:return v.next=41,{type:t.ObjectRequiredProperties,schema:e.properties[d],path:"".concat(r,"/").concat(d),value:void 0,message:"Expected required property"};case 41:v.next=35;break;case 43:v.next=48;break;case 45:v.prev=45,v.t1=v.catch(33),l.e(v.t1);case 48:return v.prev=48,l.f(),v.finish(48);case 51:if("object"!==tc(e.additionalProperties)){v.next=70;break}p=ZR(globalThis.Object.keys(i)),v.prev=53,p.s();case 55:if((h=p.n()).done){v.next=62;break}if(y=h.value,!a.includes(y)){v.next=59;break}return v.abrupt("continue",60);case 59:return v.delegateYield(Q(e.additionalProperties,n,"".concat(r,"/").concat(y),i[y]),"t2",60);case 60:v.next=55;break;case 62:v.next=67;break;case 64:v.prev=64,v.t3=v.catch(53),p.e(v.t3);case 67:return v.prev=67,p.f(),v.finish(67);case 70:m=ZR(a),v.prev=71,m.s();case 73:if((g=m.n()).done){v.next=84;break}if(b=g.value,w=e.properties[b],!e.required||!e.required.includes(b)){v.next=80;break}return v.delegateYield(Q(w,n,"".concat(r,"/").concat(b),i[b]),"t4",78);case 78:v.next=82;break;case 80:if(void 0===i[b]){v.next=82;break}return v.delegateYield(Q(w,n,"".concat(r,"/").concat(b),i[b]),"t5",82);case 82:v.next=73;break;case 84:v.next=89;break;case 86:v.prev=86,v.t6=v.catch(71),m.e(v.t6);case 89:return v.prev=89,m.f(),v.finish(89);case 92:case"end":return v.stop()}}),v,null,[[13,24,27,30],[33,45,48,51],[53,64,67,70],[71,86,89,92]])}function q(e,n,r,i){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("object"===tc(i)&&"function"==typeof i.then){n.next=3;break}return n.next=3,{type:t.Promise,schema:e,path:r,value:i,message:"Expected Promise"};case 3:case"end":return n.stop()}}),y)}function B(e,n,r,i){var a,o,s,u,c,l,f,d,p,h,v,y;return hh.wrap((function(m){for(;;)switch(m.prev=m.next){case 0:if("object"===tc(i)&&null!==i&&!globalThis.Array.isArray(i)){m.next=4;break}return m.next=3,{type:t.Object,schema:e,path:r,value:i,message:"Expected object"};case 3:return m.abrupt("return",m.sent);case 4:if(a=n_(globalThis.Object.entries(e.patternProperties)[0],2),o=a[0],s=a[1],u=new RegExp(o),globalThis.Object.keys(i).every((function(e){return u.test(e)}))){m.next=13;break}return l=(c="^(0|[1-9][0-9]*)$"===o)?t.RecordKeyNumeric:t.RecordKeyString,f=c?"Expected all object property keys to be numeric":"Expected all object property keys to be strings",m.next=12,{type:l,schema:e,path:r,value:i,message:f};case 12:return m.abrupt("return",m.sent);case 13:d=ZR(globalThis.Object.entries(i)),m.prev=14,d.s();case 16:if((p=d.n()).done){m.next=21;break}return h=n_(p.value,2),v=h[0],y=h[1],m.delegateYield(Q(s,n,"".concat(r,"/").concat(v),y),"t0",19);case 19:m.next=16;break;case 21:m.next=26;break;case 23:m.prev=23,m.t1=m.catch(14),d.e(m.t1);case 26:return m.prev=26,d.f(),m.finish(26);case 29:case"end":return m.stop()}}),m,null,[[14,23,26,29]])}function z(e,t,n,r){var i;return hh.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(void 0!==(i=t.find((function(t){return t.$id===e.$ref})))){a.next=3;break}throw new Error("ValueErrors.Ref: Cannot find schema with $id '".concat(e.$ref,"'."));case 3:return a.delegateYield(Q(i,t,n,r),"t0",4);case 4:case"end":return a.stop()}}),g)}function W(e,t,n,r){var i;return hh.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(void 0!==(i=t.find((function(t){return t.$id===e.$ref})))){a.next=3;break}throw new Error("ValueErrors.Self: Cannot find schema with $id '".concat(e.$ref,"'."));case 3:return a.delegateYield(Q(i,t,n,r),"t0",4);case 4:case"end":return a.stop()}}),b)}function $(e,n,i,a){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("string"==typeof a){n.next=4;break}return n.next=3,{type:t.String,schema:e,path:i,value:a,message:"Expected string"};case 3:return n.abrupt("return",n.sent);case 4:if(void 0===e.minLength||a.length>=e.minLength){n.next=7;break}return n.next=7,{type:t.StringMinLength,schema:e,path:i,value:a,message:"Expected string length greater or equal to ".concat(e.minLength)};case 7:if(void 0===e.maxLength||a.length<=e.maxLength){n.next=10;break}return n.next=10,{type:t.StringMaxLength,schema:e,path:i,value:a,message:"Expected string length less or equal to ".concat(e.maxLength)};case 10:if(void 0===e.pattern){n.next=15;break}if(new RegExp(e.pattern).test(a)){n.next=15;break}return n.next=15,{type:t.StringPattern,schema:e,path:i,value:a,message:"Expected string to match pattern ".concat(e.pattern)};case 15:if(void 0===e.format){n.next=25;break}if(r.Format.Has(e.format)){n.next=21;break}return n.next=19,{type:t.StringFormatUnknown,schema:e,path:i,value:a,message:"Unknown string format '".concat(e.format,"'")};case 19:n.next=25;break;case 21:if(r.Format.Get(e.format)(a)){n.next=25;break}return n.next=25,{type:t.StringFormat,schema:e,path:i,value:a,message:"Expected string to match format '".concat(e.format,"'")};case 25:case"end":return n.stop()}}),w)}function K(e,n,r,i){var a;return hh.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(globalThis.Array.isArray(i)){o.next=4;break}return o.next=3,{type:t.Array,schema:e,path:r,value:i,message:"Expected Array"};case 3:return o.abrupt("return",o.sent);case 4:if(void 0!==e.items||0===i.length){o.next=8;break}return o.next=7,{type:t.TupleZeroLength,schema:e,path:r,value:i,message:"Expected tuple to have 0 elements"};case 7:return o.abrupt("return",o.sent);case 8:if(i.length===e.maxItems){o.next=11;break}return o.next=11,{type:t.TupleLength,schema:e,path:r,value:i,message:"Expected tuple to have ".concat(e.maxItems," elements")};case 11:if(e.items){o.next=13;break}return o.abrupt("return");case 13:a=0;case 14:if(!(a<e.items.length)){o.next=19;break}return o.delegateYield(Q(e.items[a],n,"".concat(r,"/").concat(a),i[a]),"t0",16);case 16:a++,o.next=14;break;case 19:case"end":return o.stop()}}),k)}function H(e,n,r,i){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(void 0===i){n.next=3;break}return n.next=3,{type:t.Undefined,schema:e,path:r,value:i,message:"Expected undefined"};case 3:case"end":return n.stop()}}),x)}function G(e,n,r,i){var a,o,s,u,c,l,f,d;return hh.wrap((function(p){for(;;)switch(p.prev=p.next){case 0:a=[],o=ZR(e.anyOf),p.prev=2,o.s();case 4:if((s=o.n()).done){p.next=12;break}if(u=s.value,0!==(c=t_(Q(u,n,r,i))).length){p.next=9;break}return p.abrupt("return");case 9:a.push.apply(a,t_(c));case 10:p.next=4;break;case 12:p.next=17;break;case 14:p.prev=14,p.t0=p.catch(2),o.e(p.t0);case 17:return p.prev=17,o.f(),p.finish(17);case 20:l=0,f=a;case 21:if(!(l<f.length)){p.next=28;break}return d=f[l],p.next=25,d;case 25:l++,p.next=21;break;case 28:if(!(a.length>0)){p.next=31;break}return p.next=31,{type:t.Union,schema:e,path:r,value:i,message:"Expected value of union"};case 31:case"end":return p.stop()}}),_,null,[[2,14,17,20]])}function V(e,n,r,i){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(i instanceof globalThis.Uint8Array){n.next=4;break}return n.next=3,{type:t.Uint8Array,schema:e,path:r,value:i,message:"Expected Uint8Array"};case 3:return n.abrupt("return",n.sent);case 4:if(!e.maxByteLength||i.length<=e.maxByteLength){n.next=7;break}return n.next=7,{type:t.Uint8ArrayMaxByteLength,schema:e,path:r,value:i,message:"Expected Uint8Array to have a byte length less or equal to ".concat(e.maxByteLength)};case 7:if(!e.minByteLength||i.length>=e.minByteLength){n.next=10;break}return n.next=10,{type:t.Uint8ArrayMinByteLength,schema:e,path:r,value:i,message:"Expected Uint8Array to have a byte length greater or equal to ".concat(e.maxByteLength)};case 10:case"end":return n.stop()}}),S)}function Y(e,t,n,r){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),O)}function J(e,n,r,i){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===i){n.next=4;break}return n.next=3,{type:t.Void,schema:e,path:r,value:i,message:"Expected null"};case 3:return n.abrupt("return",n.sent);case 4:case"end":return n.stop()}}),E)}function Q(e,t,r,a){var o,s;return hh.wrap((function(u){for(;;)switch(u.prev=u.next){case 0:o=void 0===e.$id?t:[e].concat(t_(t)),s=e,u.t0=s[n.Kind],u.next="Any"===u.t0?5:"Array"===u.t0?7:"Boolean"===u.t0?9:"Constructor"===u.t0?11:"Function"===u.t0?13:"Integer"===u.t0?15:"Literal"===u.t0?17:"Never"===u.t0?19:"Null"===u.t0?21:"Number"===u.t0?23:"Object"===u.t0?25:"Promise"===u.t0?27:"Record"===u.t0?29:"Ref"===u.t0?31:"Self"===u.t0?33:"String"===u.t0?35:"Tuple"===u.t0?37:"Undefined"===u.t0?39:"Union"===u.t0?41:"Uint8Array"===u.t0?43:"Unknown"===u.t0?45:"Void"===u.t0?47:49;break;case 5:return u.delegateYield(I(),"t1",6);case 6:return u.abrupt("return",u.t1);case 7:return u.delegateYield(C(s,o,r,a),"t2",8);case 8:return u.abrupt("return",u.t2);case 9:return u.delegateYield(P(s,0,r,a),"t3",10);case 10:return u.abrupt("return",u.t3);case 11:return u.delegateYield(j(s,o,r,a),"t4",12);case 12:return u.abrupt("return",u.t4);case 13:return u.delegateYield(A(s,0,r,a),"t5",14);case 14:return u.abrupt("return",u.t5);case 15:return u.delegateYield(M(s,0,r,a),"t6",16);case 16:return u.abrupt("return",u.t6);case 17:return u.delegateYield(L(s,0,r,a),"t7",18);case 18:return u.abrupt("return",u.t7);case 19:return u.delegateYield(U(s,0,r,a),"t8",20);case 20:return u.abrupt("return",u.t8);case 21:return u.delegateYield(N(s,0,r,a),"t9",22);case 22:return u.abrupt("return",u.t9);case 23:return u.delegateYield(F(s,0,r,a),"t10",24);case 24:return u.abrupt("return",u.t10);case 25:return u.delegateYield(D(s,o,r,a),"t11",26);case 26:return u.abrupt("return",u.t11);case 27:return u.delegateYield(q(s,0,r,a),"t12",28);case 28:return u.abrupt("return",u.t12);case 29:return u.delegateYield(B(s,o,r,a),"t13",30);case 30:return u.abrupt("return",u.t13);case 31:return u.delegateYield(z(s,o,r,a),"t14",32);case 32:return u.abrupt("return",u.t14);case 33:return u.delegateYield(W(s,o,r,a),"t15",34);case 34:return u.abrupt("return",u.t15);case 35:return u.delegateYield($(s,0,r,a),"t16",36);case 36:return u.abrupt("return",u.t16);case 37:return u.delegateYield(K(s,o,r,a),"t17",38);case 38:return u.abrupt("return",u.t17);case 39:return u.delegateYield(H(s,0,r,a),"t18",40);case 40:return u.abrupt("return",u.t18);case 41:return u.delegateYield(G(s,o,r,a),"t19",42);case 42:return u.abrupt("return",u.t19);case 43:return u.delegateYield(V(s,0,r,a),"t20",44);case 44:return u.abrupt("return",u.t20);case 45:return u.delegateYield(Y(),"t21",46);case 46:return u.abrupt("return",u.t21);case 47:return u.delegateYield(J(s,0,r,a),"t22",48);case 48:return u.abrupt("return",u.t22);case 49:throw new i(e);case 50:case"end":return u.stop()}}),T)}function X(e,t,n){return hh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(Q(e,t,"",n),"t0",1);case 1:case"end":return r.stop()}}),R)}e.Errors=X}(e.ValueErrors||(e.ValueErrors={}))}(JR),function(e){var n=t&&t.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=t&&t.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),r(JR,e)}(YR);var nI={},rI={},iI={};function aI(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return oI(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return oI(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function oI(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function sI(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}function uI(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return cI(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return cI(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function cI(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function lI(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TypeGuard=e.TypeGuardInvalidTypeError=void 0;var t=WR,n=function(e){ec(n,e);var t=sI(n);function n(e){var r;return sc(this,n),(r=t.call(this,"TypeGuard: Invalid type")).schema=e,r}return oc(n)}($T(Error));e.TypeGuardInvalidTypeError=n,function(e){function r(e){return"object"===tc(e)&&null!==e&&!Array.isArray(e)}function i(e){return"object"===tc(e)&&null!==e&&Array.isArray(e)}function a(e){try{return new RegExp(e),!0}catch(e){return!1}}function o(e){if("string"!=typeof e)return!1;for(var t=0;t<e.length;t++){var n=e.charCodeAt(t);if(n>=7&&n<=13||27===n||127===n)return!1}return!0}function s(e){return"string"==typeof e}function u(e){return"number"==typeof e}function c(e){return"boolean"==typeof e}function l(e){return void 0===e||void 0!==e&&u(e)}function f(e){return void 0===e||void 0!==e&&c(e)}function d(e){return void 0===e||void 0!==e&&s(e)}function p(e){return r(e)&&"Any"===e[t.Kind]&&d(e.$id)}function h(e){return r(e)&&"Array"===e[t.Kind]&&"array"===e.type&&d(e.$id)&&L(e.items)&&l(e.minItems)&&l(e.maxItems)&&f(e.uniqueItems)}function v(e){return r(e)&&"Boolean"===e[t.Kind]&&"boolean"===e.type&&d(e.$id)}function y(e){if(!(r(e)&&"Constructor"===e[t.Kind]&&"constructor"===e.type&&d(e.$id)&&i(e.parameters)&&L(e.returns)))return!1;var n,a=aI(e.parameters);try{for(a.s();!(n=a.n()).done;){if(!L(n.value))return!1}}catch(e){a.e(e)}finally{a.f()}return!0}function m(e){if(!(r(e)&&"Function"===e[t.Kind]&&"function"===e.type&&d(e.$id)&&i(e.parameters)&&L(e.returns)))return!1;var n,a=aI(e.parameters);try{for(a.s();!(n=a.n()).done;){if(!L(n.value))return!1}}catch(e){a.e(e)}finally{a.f()}return!0}function g(e){return r(e)&&"Integer"===e[t.Kind]&&"integer"===e.type&&d(e.$id)&&l(e.multipleOf)&&l(e.minimum)&&l(e.maximum)&&l(e.exclusiveMinimum)&&l(e.exclusiveMaximum)}function b(e){return r(e)&&"Literal"===e[t.Kind]&&d(e.$id)&&(s(e.const)||u(e.const)||c(e.const))}function w(e){return r(e)&&"Never"===e[t.Kind]&&i(e.allOf)&&2===e.allOf.length&&r(e.allOf[0])&&s(e.allOf[0].type)&&"boolean"===e.allOf[0].type&&!1===e.allOf[0].const&&r(e.allOf[1])&&s(e.allOf[1].type)&&"boolean"===e.allOf[1].type&&!0===e.allOf[1].const}function k(e){return r(e)&&"Null"===e[t.Kind]&&"null"===e.type&&d(e.$id)}function x(e){return r(e)&&"Number"===e[t.Kind]&&"number"===e.type&&d(e.$id)&&l(e.multipleOf)&&l(e.minimum)&&l(e.maximum)&&l(e.exclusiveMinimum)&&l(e.exclusiveMaximum)}function _(e){if(!(r(e)&&"Object"===e[t.Kind]&&"object"===e.type&&d(e.$id)&&r(e.properties)&&(f(e.additionalProperties)||function(e){return void 0===e||L(e)}(e.additionalProperties))&&l(e.minProperties)&&l(e.maxProperties)))return!1;for(var n=0,i=Object.entries(e.properties);n<i.length;n++){var a=n_(i[n],2),s=a[0],u=a[1];if(!o(s))return!1;if(!L(u))return!1}return!0}function S(e){return r(e)&&"Promise"===e[t.Kind]&&"promise"===e.type&&d(e.$id)&&L(e.item)}function O(e){if(!(r(e)&&"Record"===e[t.Kind]&&"object"===e.type&&d(e.$id)&&!1===e.additionalProperties&&r(e.patternProperties)))return!1;var n=Object.keys(e.patternProperties);return 1===n.length&&(!!a(n[0])&&!!L(e.patternProperties[n[0]]))}function E(e){return r(e)&&"Self"===e[t.Kind]&&d(e.$id)&&s(e.$ref)}function T(e){return r(e)&&"Ref"===e[t.Kind]&&d(e.$id)&&s(e.$ref)}function R(e){return r(e)&&"String"===e[t.Kind]&&"string"===e.type&&d(e.$id)&&l(e.minLength)&&l(e.maxLength)&&(void 0===(n=e.pattern)||void 0!==n&&s(n)&&o(n)&&a(n))&&function(e){return void 0===e||void 0!==e&&s(e)&&o(e)}(e.format);var n}function I(e){if(!(r(e)&&"Tuple"===e[t.Kind]&&"array"===e.type&&d(e.$id)&&u(e.minItems)&&u(e.maxItems)&&e.minItems===e.maxItems))return!1;if(void 0===e.items&&void 0===e.additionalItems&&0===e.minItems)return!0;if(!i(e.items))return!1;var n,a=aI(e.items);try{for(a.s();!(n=a.n()).done;){if(!L(n.value))return!1}}catch(e){a.e(e)}finally{a.f()}return!0}function C(e){return r(e)&&"Undefined"===e[t.Kind]&&"object"===e.type&&d(e.$id)&&"Undefined"===e.specialized}function P(e){if(!(r(e)&&"Union"===e[t.Kind]&&i(e.anyOf)&&d(e.$id)))return!1;var n,a=aI(e.anyOf);try{for(a.s();!(n=a.n()).done;){if(!L(n.value))return!1}}catch(e){a.e(e)}finally{a.f()}return!0}function j(e){return r(e)&&"Uint8Array"===e[t.Kind]&&"object"===e.type&&d(e.$id)&&"Uint8Array"===e.specialized&&l(e.minByteLength)&&l(e.maxByteLength)}function A(e){return r(e)&&"Unknown"===e[t.Kind]&&d(e.$id)}function M(e){return r(e)&&"Void"===e[t.Kind]&&"null"===e.type&&d(e.$id)}function L(e){return p(e)||h(e)||v(e)||y(e)||m(e)||g(e)||b(e)||w(e)||k(e)||x(e)||_(e)||S(e)||O(e)||E(e)||T(e)||R(e)||I(e)||C(e)||P(e)||j(e)||A(e)||M(e)}e.TAny=p,e.TArray=h,e.TBoolean=v,e.TConstructor=y,e.TFunction=m,e.TInteger=g,e.TLiteral=b,e.TNever=w,e.TNull=k,e.TNumber=x,e.TObject=_,e.TPromise=S,e.TRecord=O,e.TSelf=E,e.TRef=T,e.TString=R,e.TTuple=I,e.TUndefined=C,e.TUnion=P,e.TUint8Array=j,e.TUnknown=A,e.TVoid=M,e.TSchema=L,e.Assert=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!L(e))throw new n(e);var r,i=aI(t);try{for(i.s();!(r=i.n()).done;){var a=r.value;if(!L(a))throw new n(a)}}catch(e){i.e(e)}finally{i.f()}}}(e.TypeGuard||(e.TypeGuard={}))}(iI),function(e){var n=t&&t.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=t&&t.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),r(iI,e)}(rI),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TypeCompiler=e.TypeCompilerUnknownTypeError=e.Property=e.TypeCheck=void 0;var t,n=YR,r=rI,i=QR,a=WR,o=function(){function e(t,n,r,i){sc(this,e),this.schema=t,this.references=n,this.checkFunc=r,this.code=i}return oc(e,[{key:"Code",value:function(){return this.code}},{key:"Errors",value:function(e){return n.ValueErrors.Errors(this.schema,this.references,e)}},{key:"Check",value:function(e){return this.checkFunc(e)}}]),e}();e.TypeCheck=o,function(e){function t(e){return 36===e}function n(e){return 95===e}function r(e){return e>=48&&e<=57}function i(e){return e>=65&&e<=90||e>=97&&e<=122}e.Check=function(e){if(0===e.length)return!1;var a=e.charCodeAt(0);if(!(t(a)||n(a)||i(a)))return!1;for(var o=1;o<e.length;o++){var s=e.charCodeAt(o);if(!(t(s)||n(s)||i(s)||r(s)))return!1}return!0}}(t=e.Property||(e.Property={}));var s=function(e){ec(n,e);var t=lI(n);function n(e){var r;return sc(this,n),(r=t.call(this,"TypeCompiler: Unknown type")).schema=e,r}return oc(n)}($T(Error));e.TypeCompilerUnknownTypeError=s,function(e){var n=hh.mark(C),u=hh.mark(P),c=hh.mark(j),l=hh.mark(A),f=hh.mark(M),d=hh.mark(L),p=hh.mark(U),h=hh.mark(N),v=hh.mark(F),y=hh.mark(D),m=hh.mark(q),g=hh.mark(B),b=hh.mark(z),w=hh.mark(W),k=hh.mark($),x=hh.mark(K),_=hh.mark(H),S=hh.mark(G),O=hh.mark(V),E=hh.mark(Y),T=hh.mark(J),R=hh.mark(Q),I=hh.mark(X);function C(e,t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(true)";case 2:case"end":return e.stop()}}),n)}function P(e,t){var n;return hh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=ie(e.items,"value"),void 0===e.minItems){r.next=4;break}return r.next=4,"(".concat(t,".length >= ").concat(e.minItems,")");case 4:if(void 0===e.maxItems){r.next=7;break}return r.next=7,"(".concat(t,".length <= ").concat(e.maxItems,")");case 7:if(void 0===e.uniqueItems){r.next=10;break}return r.next=10,"(new Set(".concat(t,").size === ").concat(t,".length)");case 10:return r.next=12,"(Array.isArray(".concat(t,") && ").concat(t,".every(value => ").concat(n,"))");case 12:case"end":return r.stop()}}),u)}function j(e,t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(typeof ".concat(t," === 'boolean')");case 2:case"end":return e.stop()}}),c)}function A(e,t){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(X(e.returns,"".concat(t,".prototype")),"t0",1);case 1:case"end":return n.stop()}}),l)}function M(e,t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(typeof ".concat(t," === 'function')");case 2:case"end":return e.stop()}}),f)}function L(e,t){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,"(typeof ".concat(t," === 'number' && Number.isInteger(").concat(t,"))");case 2:if(void 0===e.multipleOf){n.next=5;break}return n.next=5,"(".concat(t," % ").concat(e.multipleOf," === 0)");case 5:if(void 0===e.exclusiveMinimum){n.next=8;break}return n.next=8,"(".concat(t," > ").concat(e.exclusiveMinimum,")");case 8:if(void 0===e.exclusiveMaximum){n.next=11;break}return n.next=11,"(".concat(t," < ").concat(e.exclusiveMaximum,")");case 11:if(void 0===e.minimum){n.next=14;break}return n.next=14,"(".concat(t," >= ").concat(e.minimum,")");case 14:if(void 0===e.maximum){n.next=17;break}return n.next=17,"(".concat(t," <= ").concat(e.maximum,")");case 17:case"end":return n.stop()}}),d)}function U(e,t){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("number"!=typeof e.const&&"boolean"!=typeof e.const){n.next=5;break}return n.next=3,"(".concat(t," === ").concat(e.const,")");case 3:n.next=7;break;case 5:return n.next=7,"(".concat(t," === '").concat(e.const,"')");case 7:case"end":return n.stop()}}),p)}function N(e,t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(false)";case 2:case"end":return e.stop()}}),h)}function F(e,t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(".concat(t," === null)");case 2:case"end":return e.stop()}}),v)}function D(e,t){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,"(typeof ".concat(t," === 'number')");case 2:if(void 0===e.multipleOf){n.next=5;break}return n.next=5,"(".concat(t," % ").concat(e.multipleOf," === 0)");case 5:if(void 0===e.exclusiveMinimum){n.next=8;break}return n.next=8,"(".concat(t," > ").concat(e.exclusiveMinimum,")");case 8:if(void 0===e.exclusiveMaximum){n.next=11;break}return n.next=11,"(".concat(t," < ").concat(e.exclusiveMaximum,")");case 11:if(void 0===e.minimum){n.next=14;break}return n.next=14,"(".concat(t," >= ").concat(e.minimum,")");case 14:if(void 0===e.maximum){n.next=17;break}return n.next=17,"(".concat(t," <= ").concat(e.maximum,")");case 17:case"end":return n.stop()}}),y)}function q(e,n){var i,a,o,s,u,c,l,f,d,p;return hh.wrap((function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,"(typeof ".concat(n," === 'object' && ").concat(n," !== null && !Array.isArray(").concat(n,"))");case 2:if(void 0===e.minProperties){h.next=5;break}return h.next=5,"(Object.keys(".concat(n,").length >= ").concat(e.minProperties,")");case 5:if(void 0===e.maxProperties){h.next=8;break}return h.next=8,"(Object.keys(".concat(n,").length <= ").concat(e.maxProperties,")");case 8:if(i=globalThis.Object.keys(e.properties),!1!==e.additionalProperties){h.next=18;break}if(!e.required||e.required.length!==i.length){h.next=15;break}return h.next=13,"(Object.keys(".concat(n,").length === ").concat(i.length,")");case 13:h.next=18;break;case 15:return a="[".concat(i.map((function(e){return"'".concat(e,"'")})).join(", "),"]"),h.next=18,"(Object.keys(".concat(n,").every(key => ").concat(a,".includes(key)))");case 18:if(!r.TypeGuard.TSchema(e.additionalProperties)){h.next=23;break}return o=ie(e.additionalProperties,"value[key]"),s="[".concat(i.map((function(e){return"'".concat(e,"'")})).join(", "),"]"),h.next=23,"(Object.keys(".concat(n,").every(key => ").concat(s,".includes(key) || ").concat(o,"))");case 23:u=uI(i),h.prev=24,u.s();case 26:if((c=u.n()).done){h.next=39;break}if(l=c.value,f=t.Check(l)?"".concat(n,".").concat(l):"".concat(n,"['").concat(l,"']"),d=e.properties[l],!e.required||!e.required.includes(l)){h.next=34;break}return h.delegateYield(X(d,f),"t0",32);case 32:h.next=37;break;case 34:return p=ie(d,f),h.next=37,"(".concat(f," === undefined ? true : (").concat(p,"))");case 37:h.next=26;break;case 39:h.next=44;break;case 41:h.prev=41,h.t1=h.catch(24),u.e(h.t1);case 44:return h.prev=44,u.f(),h.finish(44);case 47:case"end":return h.stop()}}),m,null,[[24,41,44,47]])}function B(e,t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(typeof value === 'object' && typeof ".concat(t,".then === 'function')");case 2:case"end":return e.stop()}}),g)}function z(e,t){var n,r,i,a,o;return hh.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,"(typeof ".concat(t," === 'object' && ").concat(t," !== null && !Array.isArray(").concat(t,"))");case 2:return n=n_(globalThis.Object.entries(e.patternProperties)[0],2),r=n[0],i=n[1],a=se("new RegExp(/".concat(r,"/)")),s.next=6,"(Object.keys(".concat(t,").every(key => ").concat(a,".test(key)))");case 6:return o=ie(i,"value"),s.next=9,"(Object.values(".concat(t,").every(value => ").concat(o,"))");case 9:case"end":return s.stop()}}),b)}function W(e,t){var n;return hh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!te.has(e.$ref)){r.next=4;break}return r.next=3,"(".concat(ae(e.$ref),"(").concat(t,"))");case 3:return r.abrupt("return",r.sent);case 4:if(Z.has(e.$ref)){r.next=6;break}throw Error("TypeCompiler.Ref: Cannot de-reference schema with $id '".concat(e.$ref,"'"));case 6:return n=Z.get(e.$ref),r.delegateYield(X(n,t),"t0",8);case 8:case"end":return r.stop()}}),w)}function $(e,t){var n;return hh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=ae(e.$ref),r.next=3,"(".concat(n,"(").concat(t,"))");case 3:case"end":return r.stop()}}),k)}function K(e,t){var n;return hh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,"(typeof ".concat(t," === 'string')");case 2:if(void 0===e.minLength){r.next=5;break}return r.next=5,"(".concat(t,".length >= ").concat(e.minLength,")");case 5:if(void 0===e.maxLength){r.next=8;break}return r.next=8,"(".concat(t,".length <= ").concat(e.maxLength,")");case 8:if(void 0===e.pattern){r.next=12;break}return n=se("new RegExp(/".concat(e.pattern,"/);")),r.next=12,"(".concat(n,".test(").concat(t,"))");case 12:if(void 0===e.format){r.next=15;break}return r.next=15,"(format('".concat(e.format,"', ").concat(t,"))");case 15:case"end":return r.stop()}}),x)}function H(e,t){var n,r;return hh.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,"(Array.isArray(".concat(t,"))");case 2:if(void 0!==e.items){i.next=6;break}return i.next=5,"(".concat(t,".length === 0)");case 5:return i.abrupt("return",i.sent);case 6:return i.next=8,"(".concat(t,".length === ").concat(e.maxItems,")");case 8:n=0;case 9:if(!(n<e.items.length)){i.next=16;break}return r=ie(e.items[n],"".concat(t,"[").concat(n,"]")),i.next=13,"(".concat(r,")");case 13:n++,i.next=9;break;case 16:case"end":return i.stop()}}),_)}function G(e,t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(".concat(t," === undefined)");case 2:case"end":return e.stop()}}),S)}function V(e,t){var n;return hh.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=e.anyOf.map((function(e){return ie(e,t)})),r.next=3,"(".concat(n.join(" || "),")");case 3:case"end":return r.stop()}}),O)}function Y(e,t){return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,"(".concat(t," instanceof Uint8Array)");case 2:if(!e.maxByteLength){n.next=5;break}return n.next=5,"(".concat(t,".length <= ").concat(e.maxByteLength,")");case 5:if(!e.minByteLength){n.next=8;break}return n.next=8,"(".concat(t,".length >= ").concat(e.minByteLength,")");case 8:case"end":return n.stop()}}),E)}function J(e,t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(true)";case 2:case"end":return e.stop()}}),T)}function Q(e,t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,"(".concat(t," === null)");case 2:case"end":return e.stop()}}),R)}function X(e,t){var n,r,i;return hh.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(!e.$id||te.has(e.$id)){o.next=8;break}return te.add(e.$id),n=ae(e.$id),r=oe(n,e,"value"),u=r,ee.add(u),o.next=7,"(".concat(n,"(").concat(t,"))");case 7:return o.abrupt("return");case 8:i=e,o.t0=i[a.Kind],o.next="Any"===o.t0?12:"Array"===o.t0?14:"Boolean"===o.t0?16:"Constructor"===o.t0?18:"Function"===o.t0?20:"Integer"===o.t0?22:"Literal"===o.t0?24:"Never"===o.t0?26:"Null"===o.t0?28:"Number"===o.t0?30:"Object"===o.t0?32:"Promise"===o.t0?34:"Record"===o.t0?36:"Ref"===o.t0?38:"Self"===o.t0?40:"String"===o.t0?42:"Tuple"===o.t0?44:"Undefined"===o.t0?46:"Union"===o.t0?48:"Uint8Array"===o.t0?50:"Unknown"===o.t0?52:"Void"===o.t0?54:56;break;case 12:return o.delegateYield(C(),"t1",13);case 13:return o.abrupt("return",o.t1);case 14:return o.delegateYield(P(i,t),"t2",15);case 15:return o.abrupt("return",o.t2);case 16:return o.delegateYield(j(0,t),"t3",17);case 17:return o.abrupt("return",o.t3);case 18:return o.delegateYield(A(i,t),"t4",19);case 19:return o.abrupt("return",o.t4);case 20:return o.delegateYield(M(0,t),"t5",21);case 21:return o.abrupt("return",o.t5);case 22:return o.delegateYield(L(i,t),"t6",23);case 23:return o.abrupt("return",o.t6);case 24:return o.delegateYield(U(i,t),"t7",25);case 25:return o.abrupt("return",o.t7);case 26:return o.delegateYield(N(),"t8",27);case 27:return o.abrupt("return",o.t8);case 28:return o.delegateYield(F(0,t),"t9",29);case 29:return o.abrupt("return",o.t9);case 30:return o.delegateYield(D(i,t),"t10",31);case 31:return o.abrupt("return",o.t10);case 32:return o.delegateYield(q(i,t),"t11",33);case 33:return o.abrupt("return",o.t11);case 34:return o.delegateYield(B(0,t),"t12",35);case 35:return o.abrupt("return",o.t12);case 36:return o.delegateYield(z(i,t),"t13",37);case 37:return o.abrupt("return",o.t13);case 38:return o.delegateYield(W(i,t),"t14",39);case 39:return o.abrupt("return",o.t14);case 40:return o.delegateYield($(i,t),"t15",41);case 41:return o.abrupt("return",o.t15);case 42:return o.delegateYield(K(i,t),"t16",43);case 43:return o.abrupt("return",o.t16);case 44:return o.delegateYield(H(i,t),"t17",45);case 45:return o.abrupt("return",o.t17);case 46:return o.delegateYield(G(0,t),"t18",47);case 47:return o.abrupt("return",o.t18);case 48:return o.delegateYield(V(i,t),"t19",49);case 49:return o.abrupt("return",o.t19);case 50:return o.delegateYield(Y(i,t),"t20",51);case 51:return o.abrupt("return",o.t20);case 52:return o.delegateYield(J(),"t21",53);case 53:return o.abrupt("return",o.t21);case 54:return o.delegateYield(Q(0,t),"t22",55);case 55:return o.abrupt("return",o.t22);case 56:throw new s(e);case 57:case"end":return o.stop()}var u}),I)}var Z=new Map,ee=new Set,te=new Set;function ne(){Z.clear(),ee.clear(),te.clear()}function re(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=uI(t);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(!r.$id)throw new Error("TypeCompiler: Referenced schemas must specify an $id.");if(Z.has(r.$id))throw new Error("TypeCompiler: Duplicate schema $id found for '".concat(r.$id,"'"));Z.set(r.$id,r)}}catch(e){n.e(e)}finally{n.f()}}function ie(e,t){return t_(X(e,t)).join(" && ")}function ae(e){return"check_".concat(e.replace(/-/g,"_"))}function oe(e,t,n){var r=t_(X(t,n)).map((function(e){return" ".concat(e)})).join(" &&\n");return"function ".concat(e,"(value) {\n return (\n").concat(r,"\n )\n}")}function se(e){var t="local_".concat(ee.size);return ee.add("const ".concat(t," = ").concat(e)),t}function ue(){return t_(ee.values())}function ce(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];ne(),re(t);var n=oe("check",e,"value"),r=ue();return"".concat(r.join("\n"),"\nreturn ").concat(n)}e.Compile=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];r.TypeGuard.Assert(e,t);var n=ce(e,t),a=globalThis.Function("format",n),s=a((function(e,t){return!!i.Format.Has(e)&&i.Format.Get(e)(t)}));return new o(e,t,s,n)}}(e.TypeCompiler||(e.TypeCompiler={}))}(nI),function(e){var n=t&&t.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),r=t&&t.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.ValueErrorType=void 0;var i=YR;Object.defineProperty(e,"ValueErrorType",{enumerable:!0,get:function(){return i.ValueErrorType}}),r(nI,e)}(VR);var fI=o,dI=rt("iterator"),pI=!fI((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[dI]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host})),hI=Jt.exports,vI=Ct,yI=s,mI=_,gI=f,bI=o,wI=ea,kI=Or,xI=d,_I=Fe,SI=j,OI=Object.assign,EI=Object.defineProperty,TI=mI([].concat),RI=!OI||bI((function(){if(yI&&1!==OI({b:1},OI(EI({},"a",{enumerable:!0,get:function(){EI(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach((function(e){t[e]=e})),7!=OI({},e)[n]||wI(OI({},t)).join("")!=r}))?function(e,t){for(var n=_I(e),r=arguments.length,i=1,a=kI.f,o=xI.f;r>i;)for(var s,u=SI(arguments[i++]),c=a?TI(wI(u),a(u)):wI(u),l=c.length,f=0;l>f;)s=c[f++],yI&&!gI(o,u,s)||(n[s]=u[s]);return n}:OI,II=_,CI=2147483647,PI=/[^\0-\u007E]/,jI=/[.\u3002\uFF0E\uFF61]/g,AI="Overflow: input needs wider integers to process",MI=RangeError,LI=II(jI.exec),UI=Math.floor,NI=String.fromCharCode,FI=II("".charCodeAt),DI=II([].join),qI=II([].push),BI=II("".replace),zI=II("".split),WI=II("".toLowerCase),$I=function(e){return e+22+75*(e<26)},KI=function(e,t,n){var r=0;for(e=n?UI(e/700):e>>1,e+=UI(e/t);e>455;)e=UI(e/35),r+=36;return UI(r+36*e/(e+38))},HI=function(e){var t=[];e=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=FI(e,n++);if(i>=55296&&i<=56319&&n<r){var a=FI(e,n++);56320==(64512&a)?qI(t,((1023&i)<<10)+(1023&a)+65536):(qI(t,i),n--)}else qI(t,i)}return t}(e);var n,r,i=e.length,a=128,o=0,s=72;for(n=0;n<e.length;n++)(r=e[n])<128&&qI(t,NI(r));var u=t.length,c=u;for(u&&qI(t,"-");c<i;){var l=CI;for(n=0;n<e.length;n++)(r=e[n])>=a&&r<l&&(l=r);var f=c+1;if(l-a>UI((CI-o)/f))throw MI(AI);for(o+=(l-a)*f,a=l,n=0;n<e.length;n++){if((r=e[n])<a&&++o>CI)throw MI(AI);if(r==a){for(var d=o,p=36;;){var h=p<=s?1:p>=s+26?26:p-s;if(d<h)break;var v=d-h,y=36-h;qI(t,NI($I(h+v%y))),d=UI(v/y),p+=36}qI(t,NI($I(d))),s=KI(o,f,c==u),o=0,c++}}o++,a++}return DI(t,"")},GI=Xa,VI=Math.floor,YI=function(e,t){var n=e.length,r=VI(n/2);return n<8?JI(e,t):QI(e,YI(GI(e,0,r),t),YI(GI(e,r),t),t)},JI=function(e,t){for(var n,r,i=e.length,a=1;a<i;){for(r=a,n=e[a];r&&t(e[r-1],n)>0;)e[r]=e[--r];r!==a++&&(e[r]=n)}return e},QI=function(e,t,n,r){for(var i=t.length,a=n.length,o=0,s=0;o<i||s<a;)e[o+s]=o<i&&s<a?r(t[o],n[s])<=0?t[o++]:n[s++]:o<i?t[o++]:n[s++];return e},XI=YI,ZI=Zr,eC=i,tC=f,nC=_,rC=s,iC=pI,aC=Yn,oC=$_,sC=ri,uC=jv,cC=jn,lC=Cc,fC=W,dC=Be,pC=xo,hC=ji,vC=Lt,yC=H,mC=Ba,gC=xa,bC=g,wC=_d,kC=yd,xC=Nc,_C=XI,SC=rt("iterator"),OC="URLSearchParams",EC=OC+"Iterator",TC=cC.set,RC=cC.getterFor(OC),IC=cC.getterFor(EC),CC=Object.getOwnPropertyDescriptor,PC=function(e){if(!rC)return eC[e];var t=CC(eC,e);return t&&t.value},jC=PC("fetch"),AC=PC("Request"),MC=PC("Headers"),LC=AC&&AC.prototype,UC=MC&&MC.prototype,NC=eC.RegExp,FC=eC.TypeError,DC=eC.decodeURIComponent,qC=eC.encodeURIComponent,BC=nC("".charAt),zC=nC([].join),WC=nC([].push),$C=nC("".replace),KC=nC([].shift),HC=nC([].splice),GC=nC("".split),VC=nC("".slice),YC=/\+/g,JC=Array(4),QC=function(e){return JC[e-1]||(JC[e-1]=NC("((?:%[\\da-f]{2}){"+e+"})","gi"))},XC=function(e){try{return DC(e)}catch(t){return e}},ZC=function(e){var t=$C(e,YC," "),n=4;try{return DC(t)}catch(e){for(;n;)t=$C(t,QC(n--),XC);return t}},eP=/[!'()~]|%20/g,tP={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},nP=function(e){return tP[e]},rP=function(e){return $C(qC(e),eP,nP)},iP=uC((function(e,t){TC(this,{type:EC,iterator:wC(RC(e).entries),kind:t})}),"Iterator",(function(){var e=IC(this),t=e.kind,n=e.iterator.next(),r=n.value;return n.done||(n.value="keys"===t?r.key:"values"===t?r.value:[r.key,r.value]),n}),!0),aP=function(e){this.entries=[],this.url=null,void 0!==e&&(yC(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===BC(e,0)?VC(e,1):e:mC(e)))};aP.prototype={type:OC,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,i,a,o,s,u=kC(e);if(u)for(n=(t=wC(e,u)).next;!(r=tC(n,t)).done;){if(a=(i=wC(vC(r.value))).next,(o=tC(a,i)).done||(s=tC(a,i)).done||!tC(a,i).done)throw FC("Expected sequence with length 2");WC(this.entries,{key:mC(o.value),value:mC(s.value)})}else for(var c in e)dC(e,c)&&WC(this.entries,{key:c,value:mC(e[c])})},parseQuery:function(e){if(e)for(var t,n,r=GC(e,"&"),i=0;i<r.length;)(t=r[i++]).length&&(n=GC(t,"="),WC(this.entries,{key:ZC(KC(n)),value:ZC(zC(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],r=0;r<t.length;)e=t[r++],WC(n,rP(e.key)+"="+rP(e.value));return zC(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var oP=function(){lC(this,sP);var e=arguments.length>0?arguments[0]:void 0;TC(this,new aP(e))},sP=oP.prototype;if(oC(sP,{append:function(e,t){xC(arguments.length,2);var n=RC(this);WC(n.entries,{key:mC(e),value:mC(t)}),n.updateURL()},delete:function(e){xC(arguments.length,1);for(var t=RC(this),n=t.entries,r=mC(e),i=0;i<n.length;)n[i].key===r?HC(n,i,1):i++;t.updateURL()},get:function(e){xC(arguments.length,1);for(var t=RC(this).entries,n=mC(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){xC(arguments.length,1);for(var t=RC(this).entries,n=mC(e),r=[],i=0;i<t.length;i++)t[i].key===n&&WC(r,t[i].value);return r},has:function(e){xC(arguments.length,1);for(var t=RC(this).entries,n=mC(e),r=0;r<t.length;)if(t[r++].key===n)return!0;return!1},set:function(e,t){xC(arguments.length,1);for(var n,r=RC(this),i=r.entries,a=!1,o=mC(e),s=mC(t),u=0;u<i.length;u++)(n=i[u]).key===o&&(a?HC(i,u--,1):(a=!0,n.value=s));a||WC(i,{key:o,value:s}),r.updateURL()},sort:function(){var e=RC(this);_C(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,n=RC(this).entries,r=pC(e,arguments.length>1?arguments[1]:void 0),i=0;i<n.length;)r((t=n[i++]).value,t.key,this)},keys:function(){return new iP(this,"keys")},values:function(){return new iP(this,"values")},entries:function(){return new iP(this,"entries")}},{enumerable:!0}),aC(sP,SC,sP.entries,{name:"entries"}),aC(sP,"toString",(function(){return RC(this).serialize()}),{enumerable:!0}),sC(oP,OC),ZI({global:!0,constructor:!0,forced:!iC},{URLSearchParams:oP}),!iC&&fC(MC)){var uP=nC(UC.has),cP=nC(UC.set),lP=function(e){if(yC(e)){var t,n=e.body;if(hC(n)===OC)return t=e.headers?new MC(e.headers):new MC,uP(t,"content-type")||cP(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),gC(e,{body:bC(0,mC(n)),headers:bC(0,t)})}return e};if(fC(jC)&&ZI({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return jC(e,arguments.length>1?lP(arguments[1]):{})}}),fC(AC)){var fP=function(e){return lC(this,LC),new AC(e,arguments.length>1?lP(arguments[1]):{})};LC.constructor=fP,fP.prototype=LC,ZI({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:fP})}}var dP,pP=Zr,hP=s,vP=pI,yP=i,mP=xo,gP=_,bP=Yn,wP=function(e,t,n){return n.get&&hI(n.get,t,{getter:!0}),n.set&&hI(n.set,t,{setter:!0}),vI.f(e,t,n)},kP=Cc,xP=Be,_P=RI,SP=Vh,OP=Xa,EP=sv.codeAt,TP=function(e){var t,n,r=[],i=zI(BI(WI(e),jI,"."),".");for(t=0;t<i.length;t++)n=i[t],qI(r,LI(PI,n)?"xn--"+HI(n):n);return DI(r,".")},RP=Ba,IP=ri,CP=Nc,PP={URLSearchParams:oP,getState:RC},jP=jn,AP=jP.set,MP=jP.getterFor("URL"),LP=PP.URLSearchParams,UP=PP.getState,NP=yP.URL,FP=yP.TypeError,DP=yP.parseInt,qP=Math.floor,BP=Math.pow,zP=gP("".charAt),WP=gP(/./.exec),$P=gP([].join),KP=gP(1..toString),HP=gP([].pop),GP=gP([].push),VP=gP("".replace),YP=gP([].shift),JP=gP("".split),QP=gP("".slice),XP=gP("".toLowerCase),ZP=gP([].unshift),ej="Invalid scheme",tj="Invalid host",nj="Invalid port",rj=/[a-z]/i,ij=/[\d+-.a-z]/i,aj=/\d/,oj=/^0x/i,sj=/^[0-7]+$/,uj=/^\d+$/,cj=/^[\da-f]+$/i,lj=/[\0\t\n\r #%/:<>?@[\\\]^|]/,fj=/[\0\t\n\r #/:<>?@[\\\]^|]/,dj=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,pj=/[\t\n\r]/g,hj=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)ZP(t,e%256),e=qP(e/256);return $P(t,".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,a=0;a<8;a++)0!==e[a]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=a),++i);return i>n&&(t=r,n=i),t}(e),n=0;n<8;n++)i&&0===e[n]||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=KP(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},vj={},yj=_P({},vj,{" ":1,'"':1,"<":1,">":1,"`":1}),mj=_P({},yj,{"#":1,"?":1,"{":1,"}":1}),gj=_P({},mj,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),bj=function(e,t){var n=EP(e,0);return n>32&&n<127&&!xP(t,e)?e:encodeURIComponent(e)},wj={ftp:21,file:null,http:80,https:443,ws:80,wss:443},kj=function(e,t){var n;return 2==e.length&&WP(rj,zP(e,0))&&(":"==(n=zP(e,1))||!t&&"|"==n)},xj=function(e){var t;return e.length>1&&kj(QP(e,0,2))&&(2==e.length||"/"===(t=zP(e,2))||"\\"===t||"?"===t||"#"===t)},_j=function(e){return"."===e||"%2e"===XP(e)},Sj={},Oj={},Ej={},Tj={},Rj={},Ij={},Cj={},Pj={},jj={},Aj={},Mj={},Lj={},Uj={},Nj={},Fj={},Dj={},qj={},Bj={},zj={},Wj={},$j={},Kj=function(e,t,n){var r,i,a,o=RP(e);if(t){if(i=this.parse(o))throw FP(i);this.searchParams=null}else{if(void 0!==n&&(r=new Kj(n,!0)),i=this.parse(o,null,r))throw FP(i);(a=UP(new LP)).bindURL(this),this.searchParams=a}};Kj.prototype={type:"URL",parse:function(e,t,n){var r,i,a,o,s,u=this,c=t||Sj,l=0,f="",d=!1,p=!1,h=!1;for(e=RP(e),t||(u.scheme="",u.username="",u.password="",u.host=null,u.port=null,u.path=[],u.query=null,u.fragment=null,u.cannotBeABaseURL=!1,e=VP(e,dj,"")),e=VP(e,pj,""),r=SP(e);l<=r.length;){switch(i=r[l],c){case Sj:if(!i||!WP(rj,i)){if(t)return ej;c=Ej;continue}f+=XP(i),c=Oj;break;case Oj:if(i&&(WP(ij,i)||"+"==i||"-"==i||"."==i))f+=XP(i);else{if(":"!=i){if(t)return ej;f="",c=Ej,l=0;continue}if(t&&(u.isSpecial()!=xP(wj,f)||"file"==f&&(u.includesCredentials()||null!==u.port)||"file"==u.scheme&&!u.host))return;if(u.scheme=f,t)return void(u.isSpecial()&&wj[u.scheme]==u.port&&(u.port=null));f="","file"==u.scheme?c=Nj:u.isSpecial()&&n&&n.scheme==u.scheme?c=Tj:u.isSpecial()?c=Pj:"/"==r[l+1]?(c=Rj,l++):(u.cannotBeABaseURL=!0,GP(u.path,""),c=zj)}break;case Ej:if(!n||n.cannotBeABaseURL&&"#"!=i)return ej;if(n.cannotBeABaseURL&&"#"==i){u.scheme=n.scheme,u.path=OP(n.path),u.query=n.query,u.fragment="",u.cannotBeABaseURL=!0,c=$j;break}c="file"==n.scheme?Nj:Ij;continue;case Tj:if("/"!=i||"/"!=r[l+1]){c=Ij;continue}c=jj,l++;break;case Rj:if("/"==i){c=Aj;break}c=Bj;continue;case Ij:if(u.scheme=n.scheme,i==dP)u.username=n.username,u.password=n.password,u.host=n.host,u.port=n.port,u.path=OP(n.path),u.query=n.query;else if("/"==i||"\\"==i&&u.isSpecial())c=Cj;else if("?"==i)u.username=n.username,u.password=n.password,u.host=n.host,u.port=n.port,u.path=OP(n.path),u.query="",c=Wj;else{if("#"!=i){u.username=n.username,u.password=n.password,u.host=n.host,u.port=n.port,u.path=OP(n.path),u.path.length--,c=Bj;continue}u.username=n.username,u.password=n.password,u.host=n.host,u.port=n.port,u.path=OP(n.path),u.query=n.query,u.fragment="",c=$j}break;case Cj:if(!u.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){u.username=n.username,u.password=n.password,u.host=n.host,u.port=n.port,c=Bj;continue}c=Aj}else c=jj;break;case Pj:if(c=jj,"/"!=i||"/"!=zP(f,l+1))continue;l++;break;case jj:if("/"!=i&&"\\"!=i){c=Aj;continue}break;case Aj:if("@"==i){d&&(f="%40"+f),d=!0,a=SP(f);for(var v=0;v<a.length;v++){var y=a[v];if(":"!=y||h){var m=bj(y,gj);h?u.password+=m:u.username+=m}else h=!0}f=""}else if(i==dP||"/"==i||"?"==i||"#"==i||"\\"==i&&u.isSpecial()){if(d&&""==f)return"Invalid authority";l-=SP(f).length+1,f="",c=Mj}else f+=i;break;case Mj:case Lj:if(t&&"file"==u.scheme){c=Dj;continue}if(":"!=i||p){if(i==dP||"/"==i||"?"==i||"#"==i||"\\"==i&&u.isSpecial()){if(u.isSpecial()&&""==f)return tj;if(t&&""==f&&(u.includesCredentials()||null!==u.port))return;if(o=u.parseHost(f))return o;if(f="",c=qj,t)return;continue}"["==i?p=!0:"]"==i&&(p=!1),f+=i}else{if(""==f)return tj;if(o=u.parseHost(f))return o;if(f="",c=Uj,t==Lj)return}break;case Uj:if(!WP(aj,i)){if(i==dP||"/"==i||"?"==i||"#"==i||"\\"==i&&u.isSpecial()||t){if(""!=f){var g=DP(f,10);if(g>65535)return nj;u.port=u.isSpecial()&&g===wj[u.scheme]?null:g,f=""}if(t)return;c=qj;continue}return nj}f+=i;break;case Nj:if(u.scheme="file","/"==i||"\\"==i)c=Fj;else{if(!n||"file"!=n.scheme){c=Bj;continue}if(i==dP)u.host=n.host,u.path=OP(n.path),u.query=n.query;else if("?"==i)u.host=n.host,u.path=OP(n.path),u.query="",c=Wj;else{if("#"!=i){xj($P(OP(r,l),""))||(u.host=n.host,u.path=OP(n.path),u.shortenPath()),c=Bj;continue}u.host=n.host,u.path=OP(n.path),u.query=n.query,u.fragment="",c=$j}}break;case Fj:if("/"==i||"\\"==i){c=Dj;break}n&&"file"==n.scheme&&!xj($P(OP(r,l),""))&&(kj(n.path[0],!0)?GP(u.path,n.path[0]):u.host=n.host),c=Bj;continue;case Dj:if(i==dP||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&kj(f))c=Bj;else if(""==f){if(u.host="",t)return;c=qj}else{if(o=u.parseHost(f))return o;if("localhost"==u.host&&(u.host=""),t)return;f="",c=qj}continue}f+=i;break;case qj:if(u.isSpecial()){if(c=Bj,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=dP&&(c=Bj,"/"!=i))continue}else u.fragment="",c=$j;else u.query="",c=Wj;break;case Bj:if(i==dP||"/"==i||"\\"==i&&u.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=XP(s=f))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(u.shortenPath(),"/"==i||"\\"==i&&u.isSpecial()||GP(u.path,"")):_j(f)?"/"==i||"\\"==i&&u.isSpecial()||GP(u.path,""):("file"==u.scheme&&!u.path.length&&kj(f)&&(u.host&&(u.host=""),f=zP(f,0)+":"),GP(u.path,f)),f="","file"==u.scheme&&(i==dP||"?"==i||"#"==i))for(;u.path.length>1&&""===u.path[0];)YP(u.path);"?"==i?(u.query="",c=Wj):"#"==i&&(u.fragment="",c=$j)}else f+=bj(i,mj);break;case zj:"?"==i?(u.query="",c=Wj):"#"==i?(u.fragment="",c=$j):i!=dP&&(u.path[0]+=bj(i,vj));break;case Wj:t||"#"!=i?i!=dP&&("'"==i&&u.isSpecial()?u.query+="%27":u.query+="#"==i?"%23":bj(i,vj)):(u.fragment="",c=$j);break;case $j:i!=dP&&(u.fragment+=bj(i,yj))}l++}},parseHost:function(e){var t,n,r;if("["==zP(e,0)){if("]"!=zP(e,e.length-1))return tj;if(t=function(e){var t,n,r,i,a,o,s,u=[0,0,0,0,0,0,0,0],c=0,l=null,f=0,d=function(){return zP(e,f)};if(":"==d()){if(":"!=zP(e,1))return;f+=2,l=++c}for(;d();){if(8==c)return;if(":"!=d()){for(t=n=0;n<4&&WP(cj,d());)t=16*t+DP(d(),16),f++,n++;if("."==d()){if(0==n)return;if(f-=n,c>6)return;for(r=0;d();){if(i=null,r>0){if(!("."==d()&&r<4))return;f++}if(!WP(aj,d()))return;for(;WP(aj,d());){if(a=DP(d(),10),null===i)i=a;else{if(0==i)return;i=10*i+a}if(i>255)return;f++}u[c]=256*u[c]+i,2!=++r&&4!=r||c++}if(4!=r)return;break}if(":"==d()){if(f++,!d())return}else if(d())return;u[c++]=t}else{if(null!==l)return;f++,l=++c}}if(null!==l)for(o=c-l,c=7;0!=c&&o>0;)s=u[c],u[c--]=u[l+o-1],u[l+--o]=s;else if(8!=c)return;return u}(QP(e,1,-1)),!t)return tj;this.host=t}else if(this.isSpecial()){if(e=TP(e),WP(lj,e))return tj;if(t=function(e){var t,n,r,i,a,o,s,u=JP(e,".");if(u.length&&""==u[u.length-1]&&u.length--,(t=u.length)>4)return e;for(n=[],r=0;r<t;r++){if(""==(i=u[r]))return e;if(a=10,i.length>1&&"0"==zP(i,0)&&(a=WP(oj,i)?16:8,i=QP(i,8==a?1:2)),""===i)o=0;else{if(!WP(10==a?uj:8==a?sj:cj,i))return e;o=DP(i,a)}GP(n,o)}for(r=0;r<t;r++)if(o=n[r],r==t-1){if(o>=BP(256,5-t))return null}else if(o>255)return null;for(s=HP(n),r=0;r<n.length;r++)s+=n[r]*BP(256,3-r);return s}(e),null===t)return tj;this.host=t}else{if(WP(fj,e))return tj;for(t="",n=SP(e),r=0;r<n.length;r++)t+=bj(n[r],vj);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return xP(wj,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&kj(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,r=e.password,i=e.host,a=e.port,o=e.path,s=e.query,u=e.fragment,c=t+":";return null!==i?(c+="//",e.includesCredentials()&&(c+=n+(r?":"+r:"")+"@"),c+=hj(i),null!==a&&(c+=":"+a)):"file"==t&&(c+="//"),c+=e.cannotBeABaseURL?o[0]:o.length?"/"+$P(o,"/"):"",null!==s&&(c+="?"+s),null!==u&&(c+="#"+u),c},setHref:function(e){var t=this.parse(e);if(t)throw FP(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new Hj(e.path[0]).origin}catch(e){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+hj(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(RP(e)+":",Sj)},getUsername:function(){return this.username},setUsername:function(e){var t=SP(RP(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=bj(t[n],gj)}},getPassword:function(){return this.password},setPassword:function(e){var t=SP(RP(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=bj(t[n],gj)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?hj(e):hj(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Mj)},getHostname:function(){var e=this.host;return null===e?"":hj(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Lj)},getPort:function(){var e=this.port;return null===e?"":RP(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=RP(e))?this.port=null:this.parse(e,Uj))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+$P(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,qj))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=RP(e))?this.query=null:("?"==zP(e,0)&&(e=QP(e,1)),this.query="",this.parse(e,Wj)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=RP(e))?("#"==zP(e,0)&&(e=QP(e,1)),this.fragment="",this.parse(e,$j)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Hj=function(e){var t=kP(this,Gj),n=CP(arguments.length,1)>1?arguments[1]:void 0,r=AP(t,new Kj(e,!1,n));hP||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},Gj=Hj.prototype,Vj=function(e,t){return{get:function(){return MP(this)[e]()},set:t&&function(e){return MP(this)[t](e)},configurable:!0,enumerable:!0}};if(hP&&(wP(Gj,"href",Vj("serialize","setHref")),wP(Gj,"origin",Vj("getOrigin")),wP(Gj,"protocol",Vj("getProtocol","setProtocol")),wP(Gj,"username",Vj("getUsername","setUsername")),wP(Gj,"password",Vj("getPassword","setPassword")),wP(Gj,"host",Vj("getHost","setHost")),wP(Gj,"hostname",Vj("getHostname","setHostname")),wP(Gj,"port",Vj("getPort","setPort")),wP(Gj,"pathname",Vj("getPathname","setPathname")),wP(Gj,"search",Vj("getSearch","setSearch")),wP(Gj,"searchParams",Vj("getSearchParams")),wP(Gj,"hash",Vj("getHash","setHash"))),bP(Gj,"toJSON",(function(){return MP(this).serialize()}),{enumerable:!0}),bP(Gj,"toString",(function(){return MP(this).serialize()}),{enumerable:!0}),NP){var Yj=NP.createObjectURL,Jj=NP.revokeObjectURL;Yj&&bP(Hj,"createObjectURL",mP(Yj,NP)),Jj&&bP(Hj,"revokeObjectURL",mP(Jj,NP))}IP(Hj,"URL"),pP({global:!0,constructor:!0,forced:!vP,sham:!hP},{URL:Hj});var Qj={},Xj={},Zj=t&&t.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Xj,"__esModule",{value:!0}),Xj.StateMachine=void 0;var eA=function(){function e(e){var t,n,r=this;if(this._configuration={},this._listeners=new Set,this._scopeStack=[],"function"!=typeof e)throw new Error("The StateMachine constructor expects a callback as the first argument");if(this._scopeStack.unshift("config"),e({initialState:function(e){r._checkConfigScope(),r._currentState=e},state:function(e,t){r._checkConfigScope();var n={on:{}};r._scopeStack.unshift("state"),t({onEnter:function(e){r._checkStateScope("onEnter"),n.onEnter=e},onExit:function(e){r._checkStateScope("onExit"),n.onExit=e},on:function(e,t){r._checkStateScope("on"),n.on[e]=t}}),r._scopeStack.shift(),r._configuration[e]=n}}),this._scopeStack.shift(),void 0===this._currentState)throw new Error("No initial state provided");if(0===Object.keys(this._configuration).length)throw new Error("No state definition was provided");null===(n=null===(t=this._configuration[this._currentState.type])||void 0===t?void 0:t.onEnter)||void 0===n||n.call(t,{state:this._currentState})}return e.prototype.transition=function(e){var t,n,r,i,a,o=this._configuration[this._currentState.type];if(o){var s=o.on[e.type];if(s){var u=s({state:this._currentState,event:e,transitionTo:function(e,t){return{state:e,sideEffect:null!=t?t:null}},dontTransition:function(e){return{state:null,sideEffect:null!=e?e:null}}}),c=u.state,l=u.sideEffect,f=this._currentState;null!==c&&(null===(r=o.onExit)||void 0===r||r.call(o,{state:this._currentState}),this._currentState=c,null===(a=null===(i=this._configuration[c.type])||void 0===i?void 0:i.onEnter)||void 0===a||a.call(i,{state:c}));try{for(var d=Zj(this._listeners),p=d.next();!p.done;p=d.next()){(0,p.value)(f,null!=c?c:f,e)}}catch(e){t={error:e}}finally{try{p&&!p.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}l&&setTimeout((function(){null==l||l()}),0)}}},e.prototype.subscribe=function(e){var t=this;return this._listeners.add(e),e(null,this._currentState,null),function(){t._listeners.delete(e)}},Object.defineProperty(e.prototype,"state",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),e.prototype._checkConfigScope=function(){if("config"!==this._scopeStack[0])throw new Error("Call to `initialState` is allowed only from within the config callback, but not inside a state callback")},e.prototype._checkStateScope=function(e){if("state"!==this._scopeStack[0])throw new Error("Call to `".concat(e,"` is allowed only from within a state callback"))},e}();function tA(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}Xj.StateMachine=eA,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.StateMachine=void 0;var t=Xj;Object.defineProperty(e,"StateMachine",{enumerable:!0,get:function(){return t.StateMachine}})}(Qj),function(e){var t=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Object.defineProperty(e,"__esModule",{value:!0});var n=Kw.exports,r=$S.exports,i=Xw.exports,a=Yw.exports,o=nk.exports,s=Zw.exports,u=tk.exports,c=rk.exports,l=vx.exports,f=KS,d=HS,p=dx,h=Dw.exports,v=oT.exports,y=sT,m=bR,g=zR,b=WR,w=VR,k=Qj;function x(e){return e&&"object"===tc(e)&&"default"in e?e:{default:e}}function _(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var S,O=x(zS.exports),E=x(n),T=x(r),R=x(i),I=x(a),C=x(o),P=x(s),j=x(u),A=x(c),M=x(l),L=x(f),U=x(h),N=_(v),F=x(m),D=function(){function e(t,n){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;R.default(this,e),M.default(this,"message",void 0),M.default(this,"_onFinished",void 0),M.default(this,"_timer",void 0),M.default(this,"_deferredResponse",new d.Deferred),this.message=t,this._onFinished=i,this._timer=setTimeout((function(){var e;if(!r._deferredResponse.isDone){var t=new d.ErrorInfo("timeout","Request timeout: ".concat(r.message.id));r._deferredResponse.reject(new d.TwilioError(t)),null===(e=r._onFinished)||void 0===e||e.call(r,r)}}),n)}return I.default(e,[{key:"complete",value:function(e){var t;this._deferredResponse.isDone||(clearTimeout(this._timer),this._deferredResponse.resolve(e),null===(t=this._onFinished)||void 0===t||t.call(this,this))}},{key:"cancel",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new d.ErrorInfo("cancelled","Request has been cancelled");this._deferredResponse.isDone||(clearTimeout(this._timer),this._deferredResponse.reject(new d.TwilioError(t)),null===(e=this._onFinished)||void 0===e||e.call(this,this))}},{key:"promise",get:function(){return this._deferredResponse.promise}}]),e}(),q=new d.Logger("twilsock","Twilsock"),B=new TextEncoder,z=new TextDecoder;function W(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return $(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function K(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=A.default(e);if(t){var i=A.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return j.default(this,n)}}var H=null!==(S=t.WebSocket)&&void 0!==S?S:{},G=function(e){P.default(n,e);var t=K(n);function n(){var e;R.default(this,n);for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return e=t.call.apply(t,[this].concat(i)),M.default(C.default(e),"_webSocket",null),M.default(C.default(e),"_state","disconnected"),M.default(C.default(e),"_listeners",[]),e}return I.default(n,[{key:"connect",value:function(e){var t=this;if(q.info("Call to Transport.connect(".concat(e,")")),"disconnected"===this._state){this._state="connecting";try{this._webSocket=new H(e)}catch(e){return q.error("Error in Transport.connect:",e),void this._doDisconnect(new d.ErrorInfo("unknown","Error in Transport.connect"))}this._webSocket.binaryType="arraybuffer",this._subscribeToEvent("open",(function(){q.info('WebSocket "open" event'),t._state="connected",t.emit("connected")})),this._subscribeToEvent("error",(function(e){q.info('WebSocket "error" event:',e),t._doDisconnect(new d.ErrorInfo("unknown","Failed to connect WebSocket"))})),this._subscribeToEvent("close",(function(e){q.info('WebSocket "close" event:',e),t._doDisconnect(new d.ErrorInfo("transportDisconnected",'WebSocket "close" event received'))})),this._subscribeToEvent("message",(function(e){q.info('WebSocket "message" event:',z.decode(e.data));var n=e.data;n instanceof ArrayBuffer&&t.emit("messageReceived",n)}))}else q.warn('Cannot connect in state "'.concat(this._state,'". Ignored.'))}},{key:"sendMessage",value:function(e){q.info("Call to Transport.sendMessage(".concat(z.decode(e),")"));var t=new Error("Transport is not ready. Call `connect()` first");if(null===this._webSocket)throw t;try{this._webSocket.send(e)}catch(e){throw t}}},{key:"disconnect",value:function(e){this._doDisconnect(new d.ErrorInfo("transportDisconnected","Transport.Disconnect called: ".concat(e)))}},{key:"_doDisconnect",value:function(e){var t;(q.info("Call to Transport.doDisconnect(".concat(e,"): ").concat(this._state)),"disconnected"!==this._state)&&(this._state="disconnected",null===(t=this._webSocket)||void 0===t||t.close(),this._unsubscribeFromListeners(),this.emit("disconnected",e))}},{key:"_subscribeToEvent",value:function(e,t){var n;null===(n=this._webSocket)||void 0===n||n.addEventListener(e,t),this._listeners.push([e,t])}},{key:"_unsubscribeFromListeners",value:function(){var e,t=W(this._listeners);try{for(t.s();!(e=t.n()).done;){var n,r=U.default(e.value,2),i=r[0],a=r[1];null===(n=this._webSocket)||void 0===n||n.removeEventListener(i,a)}}catch(e){t.e(e)}finally{t.f()}this._listeners=[]}}]),n}(p.ReplayEventEmitter);function V(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var Y=function(e){var t,n,r,i,a,o,s,u;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?V(Object(n),!0).forEach((function(t){M.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):V(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({env:null!==(t=N.name)&&void 0!==t?t:"unknown",envv:null!==(n=N.version)&&void 0!==n?n:"unknown",os:null!==(r=null===(i=N.os)||void 0===i?void 0:i.family)&&void 0!==r?r:"unknown",osv:null!==(a=null===(o=N.os)||void 0===o?void 0:o.version)&&void 0!==a?a:"unknown",osa:String(null!==(s=null===(u=N.os)||void 0===u?void 0:u.architecture)&&void 0!==s?s:"unknown"),sdk:"js-default"},e)},J=I.default((function e(t,n,r){var i,a,o,s,u,c,l,f,d,p;R.default(this,e),M.default(this,"retryPolicy",void 0),M.default(this,"url",void 0),M.default(this,"activeGrant",void 0),M.default(this,"logLevel",void 0),M.default(this,"clientMetadata",void 0),M.default(this,"tweaks",void 0),M.default(this,"token",void 0),M.default(this,"continuationToken",void 0),M.default(this,"initRegistrations",void 0);var h=null!==(i=r.region)&&void 0!==i?i:"us1",v="wss://tsock.".concat(h,".twilio.com/v3/wsconnect"),y=null!==(a=null!==(o=r.twilsock)&&void 0!==o?o:r.Twilsock)&&void 0!==a?a:{};this.token=t,this.continuationToken=null!==(s=r.continuationToken)&&void 0!==s?s:null,this.activeGrant=n,this.url=null!==(u=y.uri)&&void 0!==u?u:v,this.logLevel=null!==(c=r.logLevel)&&void 0!==c?c:"error",this.retryPolicy=null!==(l=r.retryPolicy)&&void 0!==l?l:{min:1e3,max:12e4,randomness:.2},this.clientMetadata=Y(null!==(f=r.clientMetadata)&&void 0!==f?f:{}),this.clientMetadata.ver="1.0.0-rc.1",this.initRegistrations=null!==(d=r.initRegistrations)&&void 0!==d?d:null,this.tweaks=null!==(p=r.tweaks)&&void 0!==p?p:null}));function Q(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=A.default(e);if(t){var i=A.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return j.default(this,n)}}var X=function(e){P.default(r,e);var n=Q(r);function r(){var e;R.default(this,r);for(var t=arguments.length,i=new Array(t),a=0;a<t;a++)i[a]=arguments[a];return e=n.call.apply(n,[this].concat(i)),M.default(C.default(e),"_timer",null),M.default(C.default(e),"_isNetworkAvailable",!0),e}return I.default(r,[{key:"isNetworkAvailable",get:function(){return this._isNetworkAvailable}},{key:"start",value:function(){null===this._timer&&(this.emit("changed",this._isNetworkAvailable),this._checkConnectivity())}},{key:"stop",value:function(){var e;null!==this._timer&&("number"==typeof(e=this._timer)&&"function"==typeof t.clearTimeout?t.clearTimeout(e):function(e){e&&"function"==typeof e.close&&e.close()}(e),this._timer=null)}},{key:"_checkConnectivity",value:function(){var e=this,t=this._isNetworkAvailable;F.default().then((function(t){e._isNetworkAvailable=t})).catch((function(t){q.warn("Error on checking connectivity",t),e._isNetworkAvailable=!1})).finally((function(){t!==e._isNetworkAvailable&&e.emit("changed",e._isNetworkAvailable),e._timer=setTimeout((function(){e._checkConnectivity()}),5e3)}))}}]),r}(p.ReplayEventEmitter),Z=b.Type.Union([b.Type.Literal("init"),b.Type.Literal("update"),b.Type.Literal("ping"),b.Type.Literal("close"),b.Type.Literal("notification"),b.Type.Literal("message"),b.Type.Literal("reply"),b.Type.Literal("client_update")]),ee=b.Type.Object({method:Z,id:b.Type.String(),payload_size:b.Type.Optional(b.Type.Number()),payload_type:b.Type.Optional(b.Type.String())}),te=w.TypeCompiler.Compile(ee);function ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function re(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ne(Object(n),!0).forEach((function(t){M.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ne(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ie="TWILSOCK V3.0",ae=g.customAlphabet("1234567890abcdef",32),Message=function(){function Message(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"RQ".concat(ae());R.default(this,Message),M.default(this,"method",void 0),M.default(this,"headers",void 0),M.default(this,"payloadType",void 0),M.default(this,"payload",void 0),M.default(this,"id",void 0),this.method=e,this.headers=t,this.payloadType=n,this.payload=r,this.id=i}return I.default(Message,[{key:"encode",value:function(){var e,t={method:this.method,id:this.id};""!==this.payload&&(t.payload_size=B.encode(this.payload).length,t.payload_type=this.payloadType);var n=JSON.stringify(re(re({},null!==(e=this.headers)&&void 0!==e?e:{}),t)),r=B.encode(n).length,i=""===this.payload?"":"\r\n";return B.encode("".concat(ie," ").concat(r,"\r\n").concat(n,"\r\n").concat(this.payload).concat(i))}}],[{key:"parse",value:function(e){var t,n=z.decode(e);if(!n.startsWith(ie))throw new Error("Invalid Twilsock prefix");var r=n.split("\r\n"),i=U.default(r,3),a=i[0],o=i[1],s=i[2],u=Number(a.split(" ")[2]);if(o.length!==u)throw new Error("Invalid header size: expected ".concat(u,", got ").concat(o.length));var c=JSON.parse(o);if(!te.Check(c))throw new Error("Invalid headers received");var l=null!==(t=c.payload_type)&&void 0!==t?t:"";return new Message(c.method,c,l,s,c.id)}}]),Message}(),oe=I.default((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"ers",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];R.default(this,e),M.default(this,"product",void 0),M.default(this,"type",void 0),M.default(this,"notification_protocol_version",void 0),M.default(this,"message_types",void 0),this.product=t,this.type=n,this.notification_protocol_version=r,this.message_types=i,Object.freeze(i)})),se=b.Type.Object({code:b.Type.Number(),status:b.Type.String(),errorCode:b.Type.Optional(b.Type.Number())}),ue=b.Type.Object({status:se,http_status:b.Type.Optional(se),continuation_token:b.Type.Optional(b.Type.String()),http_headers:b.Type.Optional(b.Type.Record(b.Type.String(),b.Type.String()))}),ce=w.TypeCompiler.Compile(ue),le=b.Type.Object({backoff_policy:b.Type.Optional(b.Type.Object({reconnect_min_ms:b.Type.Optional(b.Type.Number()),reconnect_max_ms:b.Type.Optional(b.Type.Number())}))}),fe=w.TypeCompiler.Compile(le);function de(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=A.default(e);if(t){var i=A.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return j.default(this,n)}}var pe=function(e){P.default(n,e);var t=de(n);function n(e,r,i,a){var o,s,u,c,l,f;if(R.default(this,n),c=t.call(this,"reply",r,i,a,e),M.default(C.default(c),"replyHeaders",void 0),M.default(C.default(c),"replyPayload",void 0),!ce.Check(r))throw new Error("Invalid reply headers passed");c.replyHeaders={status:r.status,httpStatus:null!==(o=r.http_status)&&void 0!==o?o:{code:200,status:"ok"},continuationToken:null!==(s=r.continuation_token)&&void 0!==s?s:"",httpHeaders:null!==(u=r.http_headers)&&void 0!==u?u:{}};try{var d,p,h=JSON.parse(a);if(fe.Check(h))l=null===(d=h.backoff_policy)||void 0===d?void 0:d.reconnect_min_ms,f=null===(p=h.backoff_policy)||void 0===p?void 0:p.reconnect_max_ms}catch(e){}finally{var v,y;c.replyPayload={backoffPolicy:{reconnectMinMs:null!==(v=l)&&void 0!==v?v:1e3,reconnectMaxMs:null!==(y=f)&&void 0!==y?y:2e3}}}return c}return I.default(n)}(Message),he=I.default((function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;R.default(this,e),M.default(this,"capabilities",void 0),M.default(this,"token",void 0),M.default(this,"continuation_token",void 0),M.default(this,"registrations",void 0),M.default(this,"tweaks",void 0),M.default(this,"metadata",void 0),this.capabilities=t,this.token=n,this.continuation_token=r,this.registrations=i,this.tweaks=a,this.metadata=o,Object.freeze(i),Object.freeze(a),Object.freeze(o)}));function ve(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ye(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ve(Object(n),!0).forEach((function(t){M.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ve(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var me=function(){function e(t,n,r,i,a){R.default(this,e),M.default(this,"host",void 0),M.default(this,"path",void 0),M.default(this,"method",void 0),M.default(this,"params",void 0),M.default(this,"headers",void 0),this.host=t,this.path=n,this.method=r,this.params=i,this.headers=a,Object.freeze(i),Object.freeze(a)}return I.default(e,null,[{key:"from",value:function(t){var n=new URL(t.url),r=E.default(new URLSearchParams(n.searchParams).entries()).reduce((function(e,t){var n=U.default(t,2),r=n[0],i=n[1];return ye(ye({},e),{},M.default({},r,i))}),{});return new e(n.host,n.pathname,t.method,r,t.headers)}}]),e}(),ge=I.default((function e(t,n){R.default(this,e),M.default(this,"active_grant",void 0),M.default(this,"http_request",void 0),this.active_grant=t,this.http_request=n,Object.freeze(n)})),be=b.Type.Object({status:se}),we=w.TypeCompiler.Compile(be);function ke(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=A.default(e);if(t){var i=A.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return j.default(this,n)}}var xe=function(e){P.default(n,e);var t=ke(n);function n(e,r,i,a){var o;if(R.default(this,n),o=t.call(this,"close",r,i,a,e),M.default(C.default(o),"status",void 0),!we.Check(r))throw new Error("Invalid close headers passed");return o.status=r.status,o}return I.default(n)}(Message),_e=b.Type.Object({client_update_type:b.Type.Optional(b.Type.String())}),Se=w.TypeCompiler.Compile(_e);function Oe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=A.default(e);if(t){var i=A.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return j.default(this,n)}}var Ee=function(e){P.default(n,e);var t=Oe(n);function n(e,r,i,a){var o,s;if(R.default(this,n),s=t.call(this,"client_update",r,i,a,e),M.default(C.default(s),"clientUpdateType",void 0),!Se.Check(r))throw new Error("Invalid client update headers passed");return s.clientUpdateType=null!==(o=r.client_update_type)&&void 0!==o?o:"",s}return I.default(n)}(Message),Te=b.Type.Object({message_type:b.Type.Optional(b.Type.String())}),Re=w.TypeCompiler.Compile(Te);function Ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=A.default(e);if(t){var i=A.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return j.default(this,n)}}var Ce=function(e){P.default(n,e);var t=Ie(n);function n(e,r,i,a){var o,s;if(R.default(this,n),s=t.call(this,"notification",r,i,a,e),M.default(C.default(s),"messageType",void 0),!Re.Check(r))throw new Error("Invalid notification headers passed");return s.messageType=null!==(o=r.message_type)&&void 0!==o?o:"",s}return I.default(n)}(Message),Pe=I.default((function e(t,n,r,i){R.default(this,e),M.default(this,"statusCode",void 0),M.default(this,"status",void 0),M.default(this,"headers",void 0),M.default(this,"payload",void 0),this.statusCode=t,this.status=n,this.headers=r,this.payload=i,Object.freeze(r)}));function je(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ae(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ae(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Ae(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Me(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=A.default(e);if(t){var i=A.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return j.default(this,n)}}var Le={code:200,status:"Ok"},Ue={code:400,status:"Bad Request"},Ne=20104,Fe=function(e,t){return new d.ErrorInfo(t,e.status,e.code,e.errorCode)},De=function(e){P.default(n,e);var t=Me(n);function n(e,r){var i,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};R.default(this,n),i=t.call(this),M.default(C.default(i),"_config",void 0),M.default(C.default(i),"_fsm",void 0),M.default(C.default(i),"_pendingRequests",new Map),M.default(C.default(i),"_sentRequests",new Map),M.default(C.default(i),"_connectivityMonitor",new X),M.default(C.default(i),"_failedReconnectionAttempts",0),M.default(C.default(i),"_webSocket",null),M.default(C.default(i),"_watchdogTimer",null),i._config=new J(e,r,a),a.logLevel&&q.setLevel(a.logLevel);var o=function(e){var t=e.event;return(0,e.dontTransition)((function(){i._handleMessageReceived(t.message)}))},s=function(e){return(0,e.transitionTo)({type:"disconnected",errorInfo:new d.ErrorInfo("unknown","Disconnect called")})},u=function(e){var t=e.event;return(0,e.transitionTo)({type:"waitAndReconnect"},(function(){i.emit("nonFatalError",t.errorInfo)}))},c=function(e){return(0,e.transitionTo)({type:"waitAndReconnect"},(function(){i.emit("nonFatalError",new d.ErrorInfo("networkBecameUnreachable","Network became unreachable"))}))},l=function(e){var t=e.event;return(0,e.transitionTo)({type:"disconnected",errorInfo:t.errorInfo},(function(){i.emit("fatalError",t.errorInfo)}))};return i._fsm=new k.StateMachine((function(e){var t=e.initialState,n=e.state;t({type:"disconnected",errorInfo:new d.ErrorInfo("unknown","Twilsock created")}),n("disconnected",(function(e){var t=e.onEnter,n=e.onExit,r=e.on;t((function(e){var t=e.state;i._failedReconnectionAttempts=0,i._connectivityMonitor.stop(),i._failAllSentRequests(t.errorInfo),i._failAllPendingRequests(t.errorInfo),i._disconnectWebSocket(),i.emit("disconnected",t.errorInfo.message)})),n((function(){i._connectivityMonitor.start()})),r("connect",(function(e){return(0,e.transitionTo)({type:"connecting"})})),r("updateToken",(function(e){var t=e.event,n=e.transitionTo;return i._config.token=t.token,t.request.cancel(),n({type:"connecting"})})),r("sendRequest",(function(e){var t=e.event,n=e.dontTransition,r=new d.ErrorInfo("transportDisconnected","Cannot send request in the disconnected state");return t.request.cancel(r),n()}))})),n("connecting",(function(e){var t=e.onEnter,n=e.on;t((function(){i._connectWebSocket(),i.emit("connecting")})),n("updateToken",(function(e){var t=e.event,n=e.dontTransition,r=new d.ErrorInfo("tokenUpdatedLocally");return i._config.token=t.token,t.request.cancel(r),n()})),n("sendRequest",(function(e){var t=e.event,n=e.dontTransition;return i._addPendingRequest(t.request),n()})),n("transportConnected",(function(e){return(0,e.transitionTo)({type:"initializing"})})),n("disconnect",(function(e){return s(e)})),n("networkBecameUnreachable",(function(e){return c(e)})),n("nonFatalError",(function(e){return u(e)})),n("fatalError",(function(e){return l(e)}))})),n("initializing",(function(e){var t,n=e.onEnter,r=e.onExit,a=e.on;n((function(){(t=i._createInitRequest(5e3)).promise.then((function(){q.debug("Init message received"),i._fsm.transition({type:"initMessageReceived"})})).catch((function(e){e instanceof d.ErrorInfo&&"timeout"===e.reason&&i._onTimeout()})),i._sendRequest(t)})),r((function(){t.cancel()})),a("timeout",(function(e){return(0,e.transitionTo)({type:"waitAndReconnect"},(function(){var e=new d.ErrorInfo("timeout");i.emit("nonFatalError",e)}))})),a("updateToken",(function(e){var t=e.event,n=e.dontTransition;return i._config.token=t.token,i._addPendingRequest(t.request),n()})),a("sendRequest",(function(e){var t=e.event,n=e.dontTransition;return i._addPendingRequest(t.request),n()})),a("initMessageReceived",(function(e){return(0,e.transitionTo)({type:"connected"})})),a("tooManyRequests",(function(e){var t=e.event;return(0,e.transitionTo)({type:"waitAndReconnect",waitTime:t.waitTime},(function(){var e=new d.ErrorInfo("tooManyRequests");i.emit("nonFatalError",e)}))})),a("messageReceived",(function(e){return o(e)})),a("disconnect",(function(e){return s(e)})),a("networkBecameUnreachable",(function(e){return c(e)})),a("nonFatalError",(function(e){return u(e)})),a("fatalError",(function(e){return l(e)}))})),n("connected",(function(e){var t=e.onEnter,n=e.onExit,r=e.on;t((function(){i._failedReconnectionAttempts=0,i._startWatchdogTimer(),i._sendAllPendingRequests(),i.emit("connected")})),n((function(){i._cancelWatchdogTimer()})),r("updateToken",(function(e){var t=e.event,n=e.dontTransition;return i._config.token=t.token,i._sendRequest(t.request),n()})),r("sendRequest",(function(e){var t=e.event,n=e.dontTransition;return i._sendRequest(t.request),n()})),r("tooManyRequests",(function(e){var t=e.event;return(0,e.transitionTo)({type:"throttling",waitTime:t.waitTime},(function(){var e=new d.ErrorInfo("tooManyRequests");i.emit("nonFatalError",e)}))})),r("messageReceived",(function(e){return o(e)})),r("disconnect",(function(e){return s(e)})),r("networkBecameUnreachable",(function(e){return c(e)})),r("nonFatalError",(function(e){return u(e)})),r("fatalError",(function(e){return l(e)}))})),n("waitAndReconnect",(function(e){var t=e.onEnter,n=e.onExit,r=e.on,a=null;t((function(e){var t,n=null!==(t=e.state.waitTime)&&void 0!==t?t:i._calculateDefaultWaitTime();q.debug("Started the reconnection timer for ".concat(n," ms"));var r=new d.ErrorInfo("transportDisconnected","Transport disconnected, started the reconnection timer...");i._failAllSentRequests(r),i._disconnectWebSocket(),i._connectivityMonitor.isNetworkAvailable&&(a=setTimeout((function(){i._onTimeout()}),n)),i._failedReconnectionAttempts++,i.emit("disconnected","Wait and reconnect")})),n((function(){null!==a&&(clearTimeout(a),a=null)})),r("timeout",(function(e){return(0,e.transitionTo)({type:"connecting"})})),r("connect",(function(e){return(0,e.transitionTo)({type:"connecting"})})),r("updateToken",(function(e){var t=e.event,n=e.dontTransition;i._config.token=t.token;var r=new d.ErrorInfo("tokenUpdatedLocally");return t.request.cancel(r),n()})),r("sendRequest",(function(e){var t=e.event,n=e.dontTransition;return i._addPendingRequest(t.request),n()})),r("networkBecameReachable",(function(e){var t=e.transitionTo;return i._failedReconnectionAttempts=0,t({type:"connecting"})})),r("networkBecameUnreachable",(function(e){var t=e.dontTransition;return null!==a&&(clearTimeout(a),a=null),t()})),r("disconnect",(function(e){return s(e)}))})),n("throttling",(function(e){var t,n=e.onEnter,r=e.onExit,a=e.on;n((function(e){var n=e.state;t=setTimeout((function(){i._onTimeout()}),n.waitTime)})),r((function(){clearTimeout(t)})),a("timeout",(function(e){return(0,e.transitionTo)({type:"connected"})})),a("updateToken",(function(e){var t=e.event,n=e.dontTransition;return i._config.token=t.token,i._addPendingRequest(t.request),n()})),a("sendRequest",(function(e){var t=e.event,n=e.dontTransition;return i._addPendingRequest(t.request),n()})),a("messageReceived",(function(e){return o(e)})),a("disconnect",(function(e){return s(e)})),a("networkBecameUnreachable",(function(e){return c(e)})),a("nonFatalError",(function(e){return u(e)})),a("fatalError",(function(e){return l(e)}))}))})),i._fsm.subscribe((function(e,t,n){null!==e&&null!==n?q.debug("FSM transition ".concat(n.type,": ").concat(e.type," -> ").concat(t.type)):q.debug("FSM initiated: ".concat(t.type))})),i._connectivityMonitor.on("changed",(function(e){q.debug('ConnectivityMonitor "changed" event: '.concat(e)),i._fsm.transition({type:e?"networkBecameReachable":"networkBecameUnreachable"})})),i}return I.default(n,[{key:"connect",value:function(){q.debug("Call to TwilsockClient.connect"),this._fsm.transition({type:"connect"})}},{key:"disconnect",value:function(){q.debug("Call to TwilsockClient.disconnect"),this._fsm.transition({type:"disconnect"})}},{key:"sendRequest",value:function(e){var t=this;return new d.CancellablePromise(function(){var n=T.default(L.default.mark((function n(r,i,a){var o,s,u;return L.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return q.debug("Call to TwilsockClient.sendRequest:",JSON.stringify(e)),o=t._createUpstreamRequest(e),t._fsm.transition({type:"sendRequest",request:o}),a((function(){q.debug("Request ".concat(o.message.id," has been cancelled by the user")),o.cancel()})),n.prev=4,n.next=7,o.promise;case 7:s=n.sent,n.next=14;break;case 10:return n.prev=10,n.t0=n.catch(4),i(n.t0),n.abrupt("return");case 14:if(s instanceof pe){n.next=17;break}return i(new Error("Expected instance of ReplyMessage")),n.abrupt("return");case 17:if(!e.typeCheck){n.next=31;break}if(n.prev=18,u=JSON.parse(s.payload),e.typeCheck.Check(u)){n.next=23;break}return i(new Error("Payload doesn't match the provided schema")),n.abrupt("return");case 23:return r(new Pe(s.replyHeaders.httpStatus.code,s.replyHeaders.httpStatus.status,s.replyHeaders.httpHeaders,u)),n.abrupt("return");case 27:return n.prev=27,n.t1=n.catch(18),i(n.t1),n.abrupt("return");case 31:r(new Pe(s.replyHeaders.httpStatus.code,s.replyHeaders.httpStatus.status,s.replyHeaders.httpHeaders,s.payload));case 32:case"end":return n.stop()}}),n,null,[[4,10],[18,27]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"updateToken",value:function(e){var t=this;return new d.CancellablePromise(function(){var n=T.default(L.default.mark((function n(r,i,a){var o;return L.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return q.debug("Call to TwilsockClient.updateToken:",e),o=t._createUpdateTokenRequest(e),t._fsm.transition({type:"updateToken",token:e,request:o}),a((function(){q.debug("Update token request has been cancelled by the user"),o.cancel()})),n.prev=4,n.next=7,o.promise;case 7:n.next=16;break;case 9:if(n.prev=9,n.t0=n.catch(4),!(n.t0 instanceof d.TwilioError&&"tokenUpdatedLocally"===n.t0.errorInfo.reason)){n.next=15;break}return q.debug("Token was updated locally"),r(),n.abrupt("return");case 15:i(n.t0);case 16:q.debug("Token was updated remotely"),r();case 18:case"end":return n.stop()}}),n,null,[[4,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"populateInitRegistrations",value:function(e){var t=E.default(e.values());q.debug("Call to TwilsockClient.populateInitRegistrations:",t.join(", ")),this._config.initRegistrations=[new oe(this._config.activeGrant,"ers",4,t)]}},{key:"_failAllPendingRequests",value:function(e){var t,n=je(this._pendingRequests.values());try{for(n.s();!(t=n.n()).done;){t.value.cancel(e)}}catch(e){n.e(e)}finally{n.f()}this._pendingRequests.clear()}},{key:"_failAllSentRequests",value:function(e){var t,n=je(this._sentRequests.values());try{for(n.s();!(t=n.n()).done;){t.value.cancel(e)}}catch(e){n.e(e)}finally{n.f()}this._sentRequests.clear()}},{key:"_sendAllPendingRequests",value:function(){var e,t=je(this._pendingRequests.values());try{for(t.s();!(e=t.n()).done;){var n=e.value;this._sendRequest(n)}}catch(e){t.e(e)}finally{t.f()}this._pendingRequests.clear()}},{key:"_addPendingRequest",value:function(e){this._pendingRequests.set(e.message.id,e)}},{key:"_calculateDefaultWaitTime",value:function(){var e=1e3*Math.pow(2,this._failedReconnectionAttempts)+Math.floor(1e3*Math.random())-1e3;return Math.min(e,45e3)}},{key:"_connectWebSocket",value:function(){var e=this;if(q.debug("Call to TwilsockClient._connectWebSocket"),null!==this._webSocket)throw new Error("Websocket already exists");this._webSocket=new G,this._webSocket.on("connected",(function(){q.debug('TwilsockTransport "connected" event'),e._fsm.transition({type:"transportConnected"})})),this._webSocket.on("disconnected",(function(t){e._fsm.transition({type:"nonFatalError",errorInfo:t})})),this._webSocket.on("messageReceived",(function(t){var n;e._restartWatchdogTimer();try{n=Message.parse(t)}catch(t){q.warn("Error while parsing an incoming message",t);var r=new d.ErrorInfo("cannotParse");return void e._fsm.transition({type:"fatalError",errorInfo:r})}e._fsm.transition({type:"messageReceived",message:n})})),this._webSocket.connect(this._config.url)}},{key:"_disconnectWebSocket",value:function(){var e;q.debug("Call to TwilsockClient._disconnectWebSocket"),null===(e=this._webSocket)||void 0===e||e.disconnect("TwilsockClient._disconnectWebSocket called"),this._webSocket=null}},{key:"_startWatchdogTimer",value:function(){var e=this;if(null!==this._watchdogTimer)throw new Error("The watchdog time is already running");this._watchdogTimer=setTimeout((function(){q.warn("Watchdog timeout"),e._fsm.transition({type:"nonFatalError",errorInfo:new d.ErrorInfo("timeout","Watchdog timeout")})}),43e3)}},{key:"_createInitRequest",value:function(e){var t=this,n=new he(["client_update"],this._config.token,this._config.continuationToken,this._config.initRegistrations,this._config.tweaks,this._config.clientMetadata),r=new Message("init",n);return new D(r,e,(function(e){t._onRequestFinished(e)}))}},{key:"_createUpdateTokenRequest",value:function(e){var t=this,n=new Message("update",{token:e});return new D(n,6e4,(function(e){t._onRequestFinished(e)}))}},{key:"_createUpstreamRequest",value:function(e){var t,n,r=this,i=new ge(null!==(t=e.grant)&&void 0!==t?t:this._config.activeGrant,me.from(e)),a=new Message("message",i,null!==(n=e.headers["Content-Type"])&&void 0!==n?n:"application/json",e.payload);return new D(a,e.timeout,(function(e){r._onRequestFinished(e)}))}},{key:"_onRequestFinished",value:function(e){this._pendingRequests.delete(e.message.id),this._sentRequests.delete(e.message.id)}},{key:"_onTimeout",value:function(){q.debug("Call to TwilsockClient._onTimeout"),this._fsm.transition({type:"timeout"})}},{key:"_cancelWatchdogTimer",value:function(){if(null===this._watchdogTimer)throw new Error("The watchdog time is not running");clearTimeout(this._watchdogTimer),this._watchdogTimer=null}},{key:"_restartWatchdogTimer",value:function(){null!==this._watchdogTimer&&(this._cancelWatchdogTimer(),this._startWatchdogTimer())}},{key:"_handleMessageReceived",value:function(e){var t=this,n=[e.id,e.headers,e.payloadType,e.payload];y.match(e.method).with("reply",(function(){t._handleReplyMessage(O.default(pe,n))})).with("close",(function(){t._handleCloseMessage(O.default(xe,n))})).with("client_update",(function(){t._handleClientUpdateMessage(O.default(Ee,n))})).with("notification",(function(){t._handleNotificationMessage(O.default(Ce,n))})).with("ping",(function(){t._sendMessageReply(e,Le)})).otherwise((function(e){q.warn('Skipped a message with an unexpected method "'.concat(e,'"'))}))}},{key:"_handleReplyMessage",value:function(e){var t=this,n=this._sentRequests.get(e.id);if(n){var r=e.replyHeaders.status;if(r.code<200||r.code>=300){var i=y.match(r).with({errorCode:Ne},(function(){return Fe(r,"tokenExpired")})).with({code:401},(function(){return Fe(r,"unauthorized")})).with({code:429},(function(){return Fe(r,"tooManyRequests")})).otherwise((function(){return Fe(r,"unknown")}));return n.cancel(i),r.errorCode===Ne&&(q.warn("Received a token expired reply"),this.emit("tokenExpired")),void y.match(r.code).with(401,(function(){t._fsm.transition({type:"fatalError",errorInfo:i})})).with(429,(function(){var n=e.replyPayload.backoffPolicy,r=n.reconnectMinMs,i=n.reconnectMaxMs,a=Math.floor(Math.random()*(i-r)+r);t._fsm.transition({type:"tooManyRequests",waitTime:a})})).otherwise((function(){t._fsm.transition({type:"nonFatalError",errorInfo:i})}))}var a=e.replyHeaders.continuationToken;void 0!==a&&(this._config.continuationToken=a),n.complete(e)}else q.warn("Skipped a reply to an unknown request: ".concat(e.id))}},{key:"_handleCloseMessage",value:function(e){var t=this;q.debug("Server has initiated the process of closing the connection: ".concat(e.payload)),this._sendMessageReply(e,Le);var n=Fe(e.status,"closeMessageReceived");if(308===e.status.code&&51232===e.status.errorCode)return q.debug("Token with a different instanceSid"),void this._fsm.transition({type:"fatalError",errorInfo:n});var r=e.status.code;y.match(r).with(308,(function(){q.debug("Offloading to another instance"),t._fsm.transition({type:"nonFatalError",errorInfo:n})})).with(401,406,410,417,(function(){q.debug("Server closed connection due to a fatal error: ".concat(n));var r=y.match(e.status).with({code:410},{errorCode:Ne},(function(){return Fe(e.status,"tokenExpired")})).with({code:401},(function(){return Fe(e.status,"unauthorized")})).otherwise((function(){return n}));t._fsm.transition({type:"fatalError",errorInfo:r})})).otherwise((function(){q.warn("Unexpected close message ".concat(n)),t._fsm.transition({type:"nonFatalError",errorInfo:n})}))}},{key:"_handleClientUpdateMessage",value:function(e){this._sendMessageReply(e,Le),"token_about_to_expire"!==e.clientUpdateType?q.warn("Ignoring an unknown client update ".concat(e.clientUpdateType)):this.emit("tokenAboutToExpire")}},{key:"_handleNotificationMessage",value:function(e){if(""===e.payload)return q.warn("Skipped a notification message with no payload: ".concat(e.id)),void this._sendMessageReply(e,Ue,"Notification message must carry data");this._sendMessageReply(e,Le),""!==e.messageType?this.emit("targetedMessageReceived",e.messageType,e.payload):this.emit("messageReceived",e.payload)}},{key:"_sendMessageReply",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(null!==this._webSocket){var r=new Message("reply",{status:t},""!==n?"text/plain":"",n,e.id);this._webSocket.sendMessage(r.encode())}}},{key:"_sendRequest",value:function(e){if(null===this._webSocket)throw new Error("WebSocket not initialized");this._webSocket.sendMessage(e.message.encode()),this._sentRequests.set(e.message.id,e)}}]),n}(p.ReplayEventEmitter);M.default(De,"connecting","connecting"),M.default(De,"connected","connected"),M.default(De,"disconnected","disconnected"),M.default(De,"fatalError","fatalError"),M.default(De,"nonFatalError","nonFatalError"),M.default(De,"tokenExpired","tokenExpired"),M.default(De,"tokenAboutToExpire","tokenAboutToExpire"),M.default(De,"messageReceived","messageReceived"),M.default(De,"targetedMessageReceived","targetedMessageReceived");var qe=I.default((function e(t){var n=t.url,r=t.method,i=void 0===r?"GET":r,a=t.headers,o=void 0===a?{}:a,s=t.payload,u=void 0===s?"":s,c=t.grant,l=void 0===c?null:c,f=t.timeout,d=void 0===f?6e4:f,p=t.typeCheck,h=void 0===p?null:p;R.default(this,e),M.default(this,"url",void 0),M.default(this,"method",void 0),M.default(this,"headers",void 0),M.default(this,"payload",void 0),M.default(this,"grant",void 0),M.default(this,"timeout",void 0),M.default(this,"typeCheck",void 0),this.url=n,this.method=i,this.headers=o,this.payload="string"==typeof u?u:JSON.stringify(u),this.grant=l,this.timeout=d,this.typeCheck=h,Object.freeze(o)}));Object.defineProperty(e,"CancellablePromise",{enumerable:!0,get:function(){return d.CancellablePromise}}),Object.defineProperty(e,"CancellationError",{enumerable:!0,get:function(){return d.CancellationError}}),Object.defineProperty(e,"ErrorInfo",{enumerable:!0,get:function(){return d.ErrorInfo}}),e.HttpRequest=qe,e.InitRegistration=oe,e.TwilsockClient=De}(BS);var nA=function(e){ec(SyncError,e);var t=tA(SyncError);function SyncError(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return sc(this,SyncError),uc(Xu(n=t.call(this)),"name",void 0),uc(Xu(n),"message",void 0),uc(Xu(n),"status",void 0),uc(Xu(n),"code",void 0),n.name=n.constructor.name,n.message="".concat(e," (status: ").concat(r,", code: ").concat(i,")"),n.status=r,n.code=i,n}return oc(SyncError)}($T(Error)),rA=function(e){ec(n,e);var t=tA(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3?arguments[3]:void 0;return sc(this,n),uc(Xu(r=t.call(this,e,i,a)),"body",void 0),r.body=o,r}return oc(n)}(nA);function iA(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return aA(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return aA(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function aA(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function oA(e,t){if(null!=t&&t.message)return t.message;switch(e.statusCode){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function sA(e){var t;return null!==(t=null==e?void 0:e.code)&&void 0!==t?t:0}function uA(e,t){return 409===e.statusCode?new rA(oA(e,t),e.statusCode,sA(t),t):e.statusCode?new nA(oA(e,t),e.statusCode,sA(t)):e instanceof FO&&"transportDisconnected"===e.errorInfo.reason?e:new nA(null!==(n=null!==(r=null==t?void 0:t.message)&&void 0!==r?r:e.message)&&void 0!==n?n:"Unexpected error",0,0);var n,r}var cA=function(){function e(t,n){sc(this,e),uc(this,"configuration",void 0),uc(this,"services",void 0),uc(this,"cacheLifetime",void 0),uc(this,"cache",void 0),uc(this,"timer",void 0),uc(this,"pendingRequests",void 0),uc(this,"isShutdownInitiated",!1),this.configuration=t,this.services=n,this.cache=new Map,this.cacheLifetime=100*this.configuration.httpCacheInterval,this.pendingRequests=new Set,this.cleanupCache()}var t;return oc(e,[{key:"isExpired",value:function(e){return!this.cacheLifetime||Date.now()-e>this.cacheLifetime}},{key:"cleanupCache",value:function(){var e,t=iA(this.cache);try{for(t.s();!(e=t.n()).done;){var n=n_(e.value,2),r=n[0],i=n[1];this.isExpired(i.timestamp)&&this.cache.delete(r)}}catch(e){t.e(e)}finally{t.f()}0===this.cache.size&&clearInterval(this.timer)}},{key:"pokeTimer",value:function(){var e=this;this.timer=this.timer||setInterval((function(){return e.cleanupCache()}),2*this.cacheLifetime)}},{key:"responsePostProcess",value:function(e){var t;try{t=JSON.parse(e.payload)}catch(n){t=e.payload}return{status:{code:e.statusCode,status:e.status},headers:e.headers,body:t}}},{key:"executeWithRetry",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise((function(r,i){var a=[502,503,504];n&&a.push(429);var o=new qS(t.configuration.backoffConfiguration);o.on("attempt",(function(){e().then((function(e){if(e.statusCode>=400){var t={};try{t=JSON.parse(e.payload)}catch(e){}if(a.includes(e.statusCode)){var n=parseInt(e.headers?e.headers["Retry-After"]:null);o.failed(uA(e,t),isNaN(n)?void 0:1e3*n)}else"Twilsock disconnected"===t.message?o.failed(uA(e,t)):(o.removeAllListeners(),o.cancel(),i(uA(e,t)))}else o.succeeded(e)})).catch((function(e){o.removeAllListeners(),o.cancel(),i(e)}))})),o.on("succeeded",(function(e){r(e)})),o.on("cancelled",(function(e){return i(e)})),o.on("failed",(function(e){return i(e)})),o.start()}))}},{key:"get",value:function(){var e=Qu(hh.mark((function e(t){var n,r,i,a,o=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isShutdownInitiated){e.next=2;break}throw new Error("Client has been shut down.");case 2:if(!(n=this.cache.get(t))||this.isExpired(n.timestamp)){e.next=5;break}return e.abrupt("return",n.response);case 5:return r=this.executeWithRetry((function(){return o.services.transport.sendRequest(new BS.HttpRequest({url:t,grant:o.configuration.productId}))}),this.configuration.retryWhenThrottled),this.pendingRequests.add(r),e.next=9,r;case 9:return i=e.sent,this.pendingRequests.delete(r),a=this.responsePostProcess(i),this.cache.set(t,{response:a,timestamp:Date.now()}),this.pokeTimer(),e.abrupt("return",a);case 15:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"disconnect",value:(t=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.isShutdownInitiated=!0,e.prev=1,e.next=4,Promise.all(t_(this.pendingRequests));case 4:e.next=8;break;case 6:e.prev=6,e.t0=e.catch(1);case 8:return e.next=10,this.services.syncClient.shutdown();case 10:case"end":return e.stop()}}),e,this,[[1,6]])}))),function(){return t.apply(this,arguments)})}]),e}(),lA=oc((function e(){sc(this,e)}));uc(lA,"TYPING_INDICATOR","twilio.ipmsg.typing_indicator"),uc(lA,"NEW_MESSAGE","twilio.conversations.new_message"),uc(lA,"ADDED_TO_CONVERSATION","twilio.conversations.added_to_conversation"),uc(lA,"REMOVED_FROM_CONVERSATION","twilio.conversations.removed_from_conversation"),uc(lA,"CONSUMPTION_UPDATE","twilio.channel.consumption_update");var fA={},dA=f,pA=Be,hA=Q,vA=Jm,yA=RegExp.prototype,mA=nn.PROPER,gA=Yn,bA=Lt,wA=Ba,kA=o,xA=function(e){var t=e.flags;return void 0!==t||"flags"in yA||pA(e,"flags")||!hA(yA,e)?t:dA(vA,e)},_A="toString",SA=RegExp.prototype[_A],OA=kA((function(){return"/a/b"!=SA.call({source:"a",flags:"b"})})),EA=mA&&SA.name!=_A;(OA||EA)&&gA(RegExp.prototype,_A,(function(){var e=bA(this);return"/"+wA(e.source)+"/"+wA(xA(e))}),{unsafe:!0});var TA=RI;Zr({target:"Object",stat:!0,arity:2,forced:Object.assign!==TA},{assign:TA}),function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=$S.exports,n=Xw.exports,r=Yw.exports,i=nk.exports,a=Zw.exports,o=tk.exports,s=rk.exports,u=vx.exports,c=KS,l=Cw.exports,f=BS,d=oS,p=Dw.exports,h=Kw.exports,v=fy.exports,y=ZS,m=qb;function g(e){return e&&"object"===tc(e)&&"default"in e?e:{default:e}}function b(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var w=g(t),k=g(n),x=g(r),_=g(i),S=g(a),O=g(o),E=g(s),T=g(u),R=g(c),I=g(l),C=g(p),P=g(h),j=b(v);function A(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":I.default(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function M(e,t){if("object"===("undefined"==typeof Reflect?"undefined":I.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function L(){}function U(){U.init.call(this)}function N(e){return void 0===e._maxListeners?U.defaultMaxListeners:e._maxListeners}function F(e,t,n){if(t)e.call(n);else for(var r=e.length,i=H(e,r),a=0;a<r;++a)i[a].call(n)}function D(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=H(e,i),o=0;o<i;++o)a[o].call(n,r)}function q(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=H(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function B(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=H(e,o),u=0;u<o;++u)s[u].call(n,r,i,a)}function z(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=H(e,i),o=0;o<i;++o)a[o].apply(n,r)}function W(e,t,n,r){var i,a,o;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new L,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=N(e))&&i>0&&o.length>i){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=o.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(s)}}else o=a[t]=n,++e._eventsCount;return e}function $(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function K(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function H(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}L.prototype=Object.create(null),U.EventEmitter=U,U.usingDomains=!1,U.prototype.domain=void 0,U.prototype._events=void 0,U.prototype._maxListeners=void 0,U.defaultMaxListeners=10,U.init=function(){this.domain=null,U.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new L,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},U.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},U.prototype.getMaxListeners=function(){return N(this)},U.prototype.emit=function(e){var t,n,r,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:F(n,l,this);break;case 2:D(n,l,this,arguments[1]);break;case 3:q(n,l,this,arguments[1],arguments[2]);break;case 4:B(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];z(n,l,this,i)}return!0},U.prototype.addListener=function(e,t){return W(this,e,t,!1)},U.prototype.on=U.prototype.addListener,U.prototype.prependListener=function(e,t){return W(this,e,t,!0)},U.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,$(this,e,t)),this},U.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,$(this,e,t)),this},U.prototype.removeListener=function(e,t){var n,r,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new L:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new L,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},U.prototype.off=function(e,t){return this.removeListener(e,t)},U.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new L,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new L:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),a=0;a<i.length;++a)"removeListener"!==(r=i[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new L,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},U.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},U.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):K.call(e,t)},U.prototype.listenerCount=K,U.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var G=j.getLogger("twilio-notificatiions");function V(e,t){return["".concat((new Date).toISOString()," Twilio.Notifications ").concat(e,":")].concat(Array.from(t))}var Y=function(){function e(){k.default(this,e)}return x.default(e,[{key:"setLevel",value:function(e){G.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];G.trace.apply(null,V("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];G.debug.apply(null,V("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];G.info.apply(null,V("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];G.warn.apply(null,V("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];G.error.apply(null,V("E",t))}}]),e}(),J=new Y;function Q(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return O.default(this,n)}}var X=x.default((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;k.default(this,e),T.default(this,"token",void 0),T.default(this,"notificationId",void 0),T.default(this,"messageTypes",void 0),this.token=t,this.notificationId=n,this.messageTypes=r}));function Z(e,t){var n=new Set;return e.notificationId!==t.notificationId&&n.add("notificationId"),e.token!==t.token&&n.add("token"),function(e,t){return[].concat(P.default(P.default(e).filter((function(e){return!t.has(e)}))),P.default(P.default(t).filter((function(t){return!e.has(t)}))))}(e.messageTypes,t.messageTypes).length>0&&n.add("messageType"),[n.size>0,n]}var ee=function(e){S.default(r,e);var t,n=Q(r);function r(e){var t;return k.default(this,r),t=n.call(this),T.default(_.default(t),"channelType",void 0),T.default(_.default(t),"desiredState",new X),T.default(_.default(t),"currentState",new X),T.default(_.default(t),"_hasActiveAttempt",!1),t.channelType=e,t}return x.default(r,[{key:"setNotificationId",value:function(e){this.desiredState.notificationId=e}},{key:"isActive",value:function(){return""!==this.desiredState.notificationId}},{key:"subscribe",value:function(e){this.desiredState.messageTypes.has(e)?J.debug("message type '".concat(e,"' for channel ").concat(this.channelType," is already registered")):this.desiredState.messageTypes.add(e)}},{key:"unsubscribe",value:function(e){this.desiredState.messageTypes.has(e)&&this.desiredState.messageTypes.delete(e)}},{key:"updateToken",value:function(e){this.desiredState.token=e}},{key:"commitChanges",value:(t=w.default(R.default.mark((function e(){var t,n,r,i,a,o;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._hasActiveAttempt){e.next=3;break}throw J.error("One registration attempt is already in progress"),new Error("One registration attempt is already in progress");case 3:if(t=Z(this.desiredState,this.currentState),n=C.default(t,2),r=n[0],i=n[1],r){e.next=6;break}return e.abrupt("return");case 6:if(this.currentState.notificationId||i.delete("notificationId"),J.trace("Persisting ".concat(this.channelType," registration"),i,this.desiredState),e.prev=8,this._hasActiveAttempt=!0,(a=new X).token=this.desiredState.token,a.notificationId=this.desiredState.notificationId,a.messageTypes=new Set(this.desiredState.messageTypes),!(a.messageTypes.size>0)){e.next=24;break}return e.next=17,this.updateRegistration(a,i);case 17:o=e.sent,this.currentState.token=o.token,this.currentState.notificationId=o.notificationId,this.currentState.messageTypes=new Set(o.messageTypes),this.emit("stateChanged",this.channelType,"registered",this.currentState),e.next=30;break;case 24:return e.next=26,this.removeRegistration();case 26:this.currentState.token=a.token,this.currentState.notificationId=a.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged",this.channelType,"unregistered",this.currentState);case 30:e.next=35;break;case 32:throw e.prev=32,e.t0=e.catch(8),e.t0;case 35:return e.prev=35,this._hasActiveAttempt=!1,e.finish(35);case 38:case"end":return e.stop()}}),e,this,[[8,32,35,38]])}))),function(){return t.apply(this,arguments)})}]),r}(U);function te(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return O.default(this,n)}}var ne={min:2e3,max:12e4,randomness:.2},re=function(e){S.default(a,e);var t,n,r,i=te(a);function a(e,t,n,r){var o;return k.default(this,a),o=i.call(this,e),T.default(_.default(o),"context",void 0),T.default(_.default(o),"twilsock",void 0),T.default(_.default(o),"registrarUrl",void 0),T.default(_.default(o),"registrationId",null),o.context=t,o.twilsock=n,o.registrarUrl=r,o}return x.default(a,[{key:"updateRegistration",value:(r=w.default(R.default.mark((function e(t,n){var r,i,a,o,s,u=this;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.has("notificationId")){e.next=3;break}return e.next=3,this.removeRegistration();case 3:if(t.notificationId&&t.notificationId.length){e.next=6;break}throw J.error("No push notification ID for registration"),new Error("No push notification ID for registration");case 6:return J.trace("Registering",this.channelType,t),r={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:Array.from(t.messageTypes),data:{registration_id:t.notificationId}},i=this.context.productId,a="".concat(this.registrarUrl,"?productId=").concat(i),o={"Content-Type":"application/json"},J.trace("Creating registration for channel ".concat(this.channelType)),e.prev=12,e.t0=JSON,e.next=16,new d.AsyncRetrier(ne).run((function(){return u.twilsock.sendRequest(new f.HttpRequest({method:"POST",url:a,headers:o,payload:r,grant:i}))}));case 16:e.t1=e.sent.payload,s=e.t0.parse.call(e.t0,e.t1),this.registrationId=s.id,J.debug("Registration created: ",s),e.next=26;break;case 22:throw e.prev=22,e.t2=e.catch(12),J.error("Registration failed: ",e.t2),e.t2;case 26:return e.abrupt("return",t);case 27:case"end":return e.stop()}}),e,this,[[12,22]])}))),function(e,t){return r.apply(this,arguments)})},{key:"removeRegistration",value:(n=w.default(R.default.mark((function e(){var t,n,r,i=this;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.registrationId){e.next=2;break}return e.abrupt("return");case 2:return t=this.context.productId,n="".concat(this.registrarUrl,"/").concat(this.registrationId,"?productId=").concat(t),r={"Content-Type":"application/json"},J.trace("Removing registration for ".concat(this.channelType)),e.prev=6,e.next=9,new d.AsyncRetrier(Object.assign(ne,{maxAttemptsCount:3})).run((function(){return i.twilsock.sendRequest(new f.HttpRequest({method:"DELETE",url:n,headers:r,grant:t}))}));case 9:this.registrationId=null,this.currentState.notificationId="",J.debug("Registration removed for ".concat(this.channelType)),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(6),J.error("Failed to remove registration ",this.channelType,e.t0),e.t0;case 18:case"end":return e.stop()}}),e,this,[[6,14]])}))),function(){return n.apply(this,arguments)})},{key:"sendDeviceRemoveRequest",value:(t=w.default(R.default.mark((function e(t){var n,r,i,a,o=this;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(""!==t){e.next=2;break}throw new Error("Empty registration ID");case 2:return n=this.context.productId,r="".concat(this.registrarUrl,"?productId=").concat(n),i={"Content-Type":"application/json"},a={binding_type:this.channelType,address:t},e.prev=6,J.trace("Removing old registrations for ".concat(this.channelType)),e.next=10,new d.AsyncRetrier(Object.assign(ne,{maxAttemptsCount:3})).run((function(){return o.twilsock.sendRequest(new f.HttpRequest({method:"DELETE",url:r,headers:i,payload:a,grant:n}))}));case 10:this.registrationId=null,this.currentState.notificationId="",J.debug("Registration removed for ".concat(this.channelType)),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(6),J.error("Failed to remove registration ",this.channelType,e.t0),e.t0;case 19:case"end":return e.stop()}}),e,this,[[6,15]])}))),function(e){return t.apply(this,arguments)})}]),a}(ee);function ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return O.default(this,n)}}var ae,oe=function(e){S.default(a,e);var t,n,r,i=ie(a);function a(e,t,n){var r;return k.default(this,a),r=i.call(this,"twilsock"),T.default(_.default(r),"productId",void 0),T.default(_.default(r),"platform",void 0),T.default(_.default(r),"twilsock",void 0),T.default(_.default(r),"contextId",y.nanoid()),r.productId=e,r.platform=t,r.twilsock=n,r}return x.default(a,[{key:"updateRegistration",value:(r=w.default(R.default.mark((function e(t,n){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.has("messageType")){e.next=2;break}return e.abrupt("return",t);case 2:Array.from(t.messageTypes),this.productId,this.platform,e.prev=4,e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(4),J.error("Failed to update twilsock notification context: ".concat(e.t0)),e.t0;case 11:return e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this,[[4,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"removeRegistration",value:(n=w.default(R.default.mark((function e(){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,e.next=7;break;case 3:throw e.prev=3,e.t0=e.catch(0),J.error("Failed to remove twilsock notification context: ".concat(e.t0)),e.t0;case 7:case"end":return e.stop()}}),e,null,[[0,3]])}))),function(){return n.apply(this,arguments)})},{key:"sendDeviceRemoveRequest",value:(t=w.default(R.default.mark((function e(t){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),a}(ee);function se(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return O.default(this,n)}}var ue=m.literal("apn","fcm","twilsock");e.Notifications=ae=function(e){S.default(Client,e);var t,n,r,i=se(Client);function Client(e){var t,n,r,a,o,s,u,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};k.default(this,Client),u=i.call(this),T.default(_.default(u),"twilsock",void 0),T.default(_.default(u),"connectors",void 0),c.logLevel=null!==(t=c.logLevel)&&void 0!==t?t:"error",J.setLevel(c.logLevel);var l=null!==(n=c.productId)&&void 0!==n?n:"notifications",d=!c.twilsockClient,p=c.twilsockClient=null!==(r=c.twilsockClient)&&void 0!==r?r:new f.TwilsockClient(e,l,c),h=null!==(a=c.notifications)&&void 0!==a?a:{},v=null!==(o=null!==(s=h.region)&&void 0!==s?s:c.region)&&void 0!==o?o:"us1",y="https://ers.".concat(v,".twilio.com/v1/registrations"),m=h.ersUrl||y;u.connectors=new Map;var g=ae._detectPlatform();return u.connectors.set("apn",new re("apn",{protocolVersion:4,productId:l,platform:g},p,m)),u.connectors.set("fcm",new re("fcm",{protocolVersion:3,productId:l,platform:g},p,m)),u.connectors.set("twilsock",new oe(l,g,p)),p.on("connecting",(function(){return u.emit("transportState","connecting")})),p.on("connected",(function(){return u.emit("transportState","connected")})),p.on("disconnected",(function(){return u.emit("transportState","disconnected")})),u._connector("twilsock").on("stateChanged",(function(e,t,n){return u.emit("stateChanged",e,t,n)})),u._connector("apn").on("stateChanged",(function(e,t,n){return u.emit("stateChanged",e,t,n)})),u._connector("fcm").on("stateChanged",(function(e,t,n){return u.emit("stateChanged",e,t,n)})),p.on("targetedMessageReceived",(function(e,t){return u._routeMessage(e,t)})),u.updateToken(e),d&&(p.connect(),u.twilsock=p),u}return x.default(Client,[{key:"shutdown",value:(r=w.default(R.default.mark((function e(){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectors.clear(),!this.twilsock){e.next=4;break}return e.next=4,this.twilsock.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"setPushRegistrationId",value:function(e,t){J.debug("Set ".concat(e," push registration id '").concat(t,"'")),this._connector(e).setNotificationId(t)}},{key:"subscribe",value:function(e,t){J.debug("Add ".concat(e," subscriptions for message type ").concat(t)),this._connector(e).subscribe(t)}},{key:"unsubscribe",value:function(e,t){J.debug("Remove ".concat(e," subscriptions for message type ").concat(t)),this._connector(e).unsubscribe(t)}},{key:"updateToken",value:function(e){this.connectors.forEach((function(t){return t.updateToken(e)}))}},{key:"commitChanges",value:(n=w.default(R.default.mark((function e(){var t;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],this.connectors.forEach((function(e){e.isActive()&&t.push(e.commitChanges())})),e.next=4,Promise.all(t);case 4:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"removeRegistrations",value:(t=w.default(R.default.mark((function e(t,n){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._connector(t).sendDeviceRemoveRequest(n);case 2:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"handlePushNotification",value:function(e){return{messageType:e.twi_message_type,payload:e.payload}}},{key:"_routeMessage",value:function(e,t){J.debug("Notification message arrived: ",e,t),this.emit("message",e,t)}},{key:"_connector",value:function(e){var t=this.connectors.get(e);if(!t)throw new Error("Unknown channel type: ".concat(e));return t}}],[{key:"_detectPlatform",value:function(){var e="";return"undefined"!=typeof navigator?(e="unknown",void 0!==navigator.product&&(e=navigator.product),void 0!==navigator.userAgent&&(e=navigator.userAgent)):e="web",e.substring(0,128)}}]),Client}(U),A([m.validateTypes(ue,m.nonEmptyString),M("design:type",Function),M("design:paramtypes",[String,String]),M("design:returntype",void 0)],e.Notifications.prototype,"setPushRegistrationId",null),A([m.validateTypes(ue,m.nonEmptyString),M("design:type",Function),M("design:paramtypes",[String,String]),M("design:returntype",void 0)],e.Notifications.prototype,"subscribe",null),A([m.validateTypes(ue,m.nonEmptyString),M("design:type",Function),M("design:paramtypes",[String,String]),M("design:returntype",void 0)],e.Notifications.prototype,"unsubscribe",null),A([m.validateTypes(m.nonEmptyString),M("design:type",Function),M("design:paramtypes",[String]),M("design:returntype",void 0)],e.Notifications.prototype,"updateToken",null),A([m.validateTypesAsync(ue,m.nonEmptyString),M("design:type",Function),M("design:paramtypes",[String,String]),M("design:returntype",Promise)],e.Notifications.prototype,"removeRegistrations",null),e.Notifications=ae=A([m.validateConstructorTypes(m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),M("design:paramtypes",[String,Object])],e.Notifications)}(fA);var RA={},IA=f,CA=Lt,PA=A,jA=ur,AA=Ba,MA=U,LA=_e,UA=qg,NA=tb;Fg("match",(function(e,t,n){return[function(t){var n=MA(this),r=PA(t)?void 0:LA(t,e);return r?IA(r,t,n):new RegExp(t)[e](AA(n))},function(e){var r=CA(this),i=AA(e),a=n(t,r,i);if(a.done)return a.value;if(!r.global)return NA(r,i);var o=r.unicode;r.lastIndex=0;for(var s,u=[],c=0;null!==(s=NA(r,i));){var l=AA(s[0]);u[c]=l,""===l&&(r.lastIndex=UA(i,jA(r.lastIndex),o)),c++}return 0===c?null:u}]})),Object.defineProperty(RA,"__esModule",{value:!0});var FA=$S.exports,DA=Xw.exports,qA=Yw.exports,BA=nk.exports,zA=Zw.exports,WA=tk.exports,$A=rk.exports,KA=vx.exports,HA=KS,GA=Cw.exports,VA=qb,YA=BS,JA=GS.exports,QA=fy.exports,XA=Dw.exports,ZA=oS,eM=nk.exports,tM=vx.exports,nM=Yw.exports,rM=Xw.exports,iM=Zw.exports,aM=tk.exports,oM=rk.exports,sM=GS.exports,uM=ZS,cM=Kw.exports,lM=Kw.exports,fM=px.exports,dM=dx,pM=oT.exports;function hM(e){return e&&"object"===tc(e)&&"default"in e?e:{default:e}}function vM(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var yM=hM(FA),mM=hM(DA),gM=hM(qA),bM=hM(BA),wM=hM(zA),kM=hM(WA),xM=hM($A),_M=hM(KA),SM=hM(HA),OM=hM(GA),EM=hM(JA),TM=vM(QA),RM=hM(QA),IM=hM(XA),CM=hM(eM),PM=hM(tM),jM=hM(nM),AM=hM(rM),MM=hM(iM),LM=hM(aM),UM=hM(oM),NM=hM(sM),FM=hM(uM),DM=hM(cM),qM=hM(lM),BM=hM(fM),zM=vM(pM);function WM(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":OM.default(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function $M(e,t){if("object"===("undefined"==typeof Reflect?"undefined":OM.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var KM=function(){function e(t){mM.default(this,e),_M.default(this,"base",void 0),_M.default(this,"args",void 0),_M.default(this,"paths",void 0),this.base=t,this.args=new Array,this.paths=new Array}return gM.default(e,[{key:"pathSegment",value:function(e){return this.paths.push(encodeURIComponent(e)),this}},{key:"queryParam",value:function(e,t){return void 0!==t&&this.args.push(encodeURIComponent(e)+"="+encodeURIComponent(t)),this}},{key:"build",value:function(){var e=this.base;return this.paths.length&&(e+="/"+this.paths.join("/")),this.args.length&&(e+="?"+this.args.join("&")),e}}]),e}();function HM(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=xM.default(e);if(t){var i=xM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return kM.default(this,n)}}var SyncError=function(e){wM.default(SyncError,e);var t=HM(SyncError);function SyncError(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return mM.default(this,SyncError),n=t.call(this),_M.default(bM.default(n),"name",void 0),_M.default(bM.default(n),"message",void 0),_M.default(bM.default(n),"status",void 0),_M.default(bM.default(n),"code",void 0),n.name=n.constructor.name,n.message="".concat(e," (status: ").concat(r,", code: ").concat(i,")"),n.status=r,n.code=i,n}return gM.default(SyncError)}(EM.default(Error)),GM=function(e){wM.default(n,e);var t=HM(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3?arguments[3]:void 0;return mM.default(this,n),r=t.call(this,e,i,a),_M.default(bM.default(r),"body",void 0),r.body=o,r}return gM.default(n)}(SyncError);function VM(e){return JSON.parse(JSON.stringify(e))}function YM(e){if(!(void 0===e||JM(e)))throw new SyncError("Invalid pageSize parameter. Expected a positive integer, was '".concat(e,"'."),400,20007)}function JM(e){return function(e){return!isNaN(parseInt(e))&&isFinite(e)}(e)&&e>0}var QM=TM.getLogger("twilio-sync");function XM(e,t){return["".concat((new Date).toISOString()," Sync ").concat(e,":")].concat(Array.from(t))}var ZM=function(e){QM.setLevel(e)},eL=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];QM.trace.apply(null,XM("T",t))},tL=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];QM.debug.apply(null,XM("D",t))},nL=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];QM.error.apply(null,XM("E",t))},rL="/v4/Subscriptions",iL="/v3/Maps",aL="/v3/Lists",oL="/v3/Documents",sL="/v3/Streams",uL="/v3/Insights";function cL(e,t,n){return e&&void 0!==e[t]?e[t]:n}var lL=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};mM.default(this,e),_M.default(this,"settings",void 0);var n=t.region||"us1",r="https://cds.".concat(n,".twilio.com"),i=t.cdsUri||r;this.settings={subscriptionsUri:i+rL,documentsUri:i+oL,listsUri:i+aL,mapsUri:i+iL,streamsUri:i+sL,insightsUri:i+uL,sessionStorageEnabled:cL(t.Sync,"enableSessionStorage",!0),productId:t.productId}}return gM.default(e,[{key:"subscriptionsUri",get:function(){return this.settings.subscriptionsUri}},{key:"documentsUri",get:function(){return this.settings.documentsUri}},{key:"listsUri",get:function(){return this.settings.listsUri}},{key:"mapsUri",get:function(){return this.settings.mapsUri}},{key:"streamsUri",get:function(){return this.settings.streamsUri}},{key:"insightsUri",get:function(){return this.settings.insightsUri}},{key:"backoffConfig",get:function(){return this.settings.backoffConfig||{}}},{key:"sessionStorageEnabled",get:function(){return this.settings.sessionStorageEnabled}},{key:"productId",get:function(){return this.settings.productId}}]),e}(),fL={};Object.defineProperty(fL,"__esModule",{value:!0});var dL=RM.default,pL=CM.default,hL=PM.default,vL=jM.default,yL=AM.default,mL=MM.default,gL=LM.default,bL=UM.default,wL=NM.default,kL=FM.default,xL=DM.default;function _L(e){return e&&"object"===OM.default(e)&&"default"in e?e:{default:e}}var SL=_L(dL),OL=_L(pL),EL=_L(hL),TL=_L(vL),RL=_L(yL),IL=_L(mL),CL=_L(gL),PL=_L(bL),jL=_L(wL),AL=_L(xL),ML=function(e){var t=SL.default.getLevel();SL.default.setLevel("warn"),SL.default.warn(e),SL.default.setLevel(t)};function LL(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=PL.default(e);if(t){var i=PL.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CL.default(this,n)}}var UL=function(e){IL.default(n,e);var t=LL(n);function n(){return RL.default(this,n),t.call(this,"Promise was cancelled")}return TL.default(n)}(jL.default(Error)),NL=function(e){IL.default(n,e);var t=LL(n);function n(e){var r;RL.default(this,n);var i,a=kL.nanoid();return r=t.call(this,(function(t,r){return i=r,e((function(e){n.onCancelCallbackMap.delete(a),t(e)}),(function(e){n.onCancelCallbackMap.delete(a),r(e)}),(function(e){n.onCancelCallbackMap.set(a,e)}))})),EL.default(OL.default(r),"id",void 0),EL.default(OL.default(r),"rejectPromise",void 0),r.id=a,r.rejectPromise=i,r}return TL.default(n,[{key:"cancel",value:function(){var e=n.onCancelCallbackMap.get(this.id);return null==e||e(),this.rejectPromise&&(this.catch((function(){})),this.rejectPromise(new UL)),this}}]),n}(jL.default(Promise));function FL(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=PL.default(e);if(t){var i=PL.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CL.default(this,n)}}EL.default(NL,"onCancelCallbackMap",new Map);var DL={unknown:"Unknown error",cancelled:"Job was cancelled",timeout:"Timeout occurred",mediaUploadError:"Media upload error",mediaFetchError:"Media fetch error",tooManyAttachments:"Too many attachments",unsupportedEmailBodyContentType:"Unsupported email body content type",unsupportedEmailHistoryContentType:"Unsupported email history content type",transportDisconnected:"Transport has been disconnected",networkBecameUnreachable:"Network became unreachable",unauthorized:"Unauthorized",tokenExpired:"Token expired",tokenUpdatedLocally:"Transport disconnected, token updated locally and will be used at reconnect",tooManyRequests:"Request failed with 429 reply",hostnameUnverified:"Failed on ssl handshake: CERTIFICATE_VERIFY_FAILED",sslHandshakeError:"Failed on ssl handshake: UNAUTHORIZED",closeMessageReceived:"Twilsock received a close message from the server",cannotParse:"Error while parsing an incoming message"},qL=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;RL.default(this,e),EL.default(this,"reason",void 0),EL.default(this,"message",void 0),EL.default(this,"status",void 0),EL.default(this,"code",void 0),EL.default(this,"description",void 0),this.reason=t,this.message=n,this.status=r,this.code=i,this.description=DL[t]}return TL.default(e,[{key:"toString",value:function(){return"".concat(this.description," ").concat(this.status,":").concat(this.code," ").concat(this.message)}}]),e}(),BL=function(e){IL.default(n,e);var t=FL(n);function n(e){var r;return RL.default(this,n),r=t.call(this,"".concat(e)),EL.default(OL.default(r),"errorInfo",void 0),r.errorInfo=e,Object.freeze(e),r}return TL.default(n)}(jL.default(Error)),zL=function(){function e(){var t=this;RL.default(this,e),EL.default(this,"promise",void 0),EL.default(this,"_resolve",void 0),EL.default(this,"_reject",void 0),EL.default(this,"_isDone",!1),this.promise=new Promise((function(e,n){t._resolve=function(n){t._isDone=!0,e(n)},t._reject=function(e){t._isDone=!0,n(e)}}))}return TL.default(e,[{key:"resolve",get:function(){return this._resolve}},{key:"reject",get:function(){return this._reject}},{key:"isDone",get:function(){return this._isDone}}]),e}(),WL=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";RL.default(this,e),EL.default(this,"_prefix",void 0),EL.default(this,"_logger",void 0),this._prefix=n,this._logger=dL.getLogger(t)}return TL.default(e,[{key:"setLevel",value:function(e){this._logger.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.trace.apply(null,this._prepareLine("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.debug.apply(null,this._prepareLine("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.info.apply(null,this._prepareLine("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.warn.apply(null,this._prepareLine("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._logger.error.apply(null,this._prepareLine("E",t))}},{key:"_prepareLine",value:function(e,t){return["".concat((new Date).toISOString()," ").concat(this._prefix," ").concat(e,":")].concat(AL.default(t))}}]),e}();fL.CancellablePromise=NL,fL.CancellationError=UL,fL.Deferred=zL,fL.ErrorInfo=qL,fL.Logger=WL;var $L=fL.TwilioError=BL;function KL(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return HL(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return HL(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function HL(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}fL.deprecated=function(e,t,n){return function(r,i,a){if("function"!=typeof a.value&&void 0===(null==a?void 0:a.get))throw new Error("The deprecated decorator can only be applied to methods or getters");if("function"!=typeof a.value){var o=a.get;a.get=function(){return ML("The getter ".concat(e," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:".")),null==o?void 0:o.apply(this)}}else{var s=a.value;a.value=function(){ML("The method ".concat(e," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:"."));for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return s.apply(this,i)}}}},fL.deprecationWarning=ML;var GL=function(){function e(t){mM.default(this,e),_M.default(this,"localObject",void 0),_M.default(this,"pendingCorrelationId",void 0),_M.default(this,"pendingAction",void 0),_M.default(this,"rejectedWithError",void 0),_M.default(this,"retryCount",void 0),_M.default(this,"established",void 0),this.localObject=t,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return gM.default(e,[{key:"sid",get:function(){return this.localObject.sid}},{key:"type",get:function(){return this.localObject.type}},{key:"lastEventId",get:function(){return this.localObject.lastEventId}},{key:"indexName",get:function(){return this.localObject.indexName}},{key:"queryString",get:function(){return this.localObject.queryString}},{key:"isEstablished",get:function(){return this.established}},{key:"update",value:function(e,t){this.localObject._update(e,t)}},{key:"updatePending",value:function(e,t){this.pendingAction=e,this.pendingCorrelationId=t}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(e){this.rejectedWithError=e.error,this.updatePending(null,null),this.localObject.reportFailure(new SyncError("Failed to subscribe on service events: ".concat(e.error.message),e.error.status,e.error.code))}},{key:"complete",value:function(e){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(e)}},{key:"setSubscriptionState",value:function(e){this.localObject._setSubscriptionState(e)}}]),e}(),VL=function(){function e(t){var n=this;mM.default(this,e),_M.default(this,"services",void 0),_M.default(this,"subscriptions",void 0),_M.default(this,"persisted",void 0),_M.default(this,"latestPokeResponseArrivalTimestampByCorrelationId",void 0),_M.default(this,"backoff",void 0),_M.default(this,"isConnected",!1),_M.default(this,"maxBatchSize",100),_M.default(this,"subscriptionTtlTimer",null),_M.default(this,"pendingPokeReason",null),this.services=t,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;this.backoff=ZA.Backoff.exponential(Object.assign({randomisationFactor:.2,initialDelay:100,maxDelay:12e4},this.services.config.backoffConfig)),this.backoff.on("ready",(function(){var e=n.getSubscriptionUpdateBatch(),t=e.action,r=e.subscriptions;t?n.applyNewSubscriptionUpdateBatch(t,r):(n.backoff.reset(),tL("All subscriptions resolved."))}))}var t;return gM.default(e,[{key:"getSubscriptionUpdateBatch",value:function(){function e(e,t,n,r){var i,a=[],o=KL(e);try{for(o.s();!(i=o.n()).done;){var s=IM.default(i.value,2),u=s[0],c=s[1];if(!t.get(u)&&n!==c.pendingAction&&!c.rejectedWithError&&(a.push(c),r&&a.length>=r))break}}catch(e){o.e(e)}finally{o.f()}return a}var t=e(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(t.length>0)return{action:"establish",subscriptions:t};var n=e(this.persisted,this.subscriptions,"cancel",this.maxBatchSize);return n.length>0?{action:"cancel",subscriptions:n}:{action:null,subscriptions:null}}},{key:"persist",value:function(){this.backoff.backoff()}},{key:"applyNewSubscriptionUpdateBatch",value:(t=yM.default(SM.default.mark((function e(t,n){var r,i,a,o,s,u,c,l,f,d,p,h,v=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isConnected){e.next=4;break}return tL("Twilsock connection (required for subscription) not ready; waiting…"),this.backoff.reset(),e.abrupt("return");case 4:n=this.processLocalActions(t,n),r=(new Date).getTime(),i=KL(n);try{for(i.s();!(a=i.n()).done;)o=a.value,this.recordActionAttemptOn(o,t,r)}catch(e){i.e(e)}finally{i.f()}return s=this.pendingPokeReason,this.pendingPokeReason=null,e.prev=10,e.next=13,this.request(t,r,s,n);case 13:u=e.sent,c=u.body.max_batch_size,!isNaN(parseInt(c))&&isFinite(c)&&c>0&&(this.maxBatchSize=c),this.subscriptionTtlTimer||(l=u.body.ttl_in_s,!isNaN(parseFloat(l))&&isFinite(l)&&l>0&&(this.subscriptionTtlTimer=setTimeout((function(){return v.onSubscriptionTtlElapsed()}),1e3*l))),"establish"===t&&(f=u.body.estimated_delivery_in_ms,!isNaN(parseFloat(f))&&isFinite(f)&&f>0?setTimeout((function(){return v.verifyPokeDelivery(r,f,n)}),f):nL("Invalid timeout: ".concat(f)),n.filter((function(e){return e.pendingCorrelationId===r})).forEach((function(e){return e.setSubscriptionState("response_in_flight")}))),this.backoff.reset(),e.next=26;break;case 21:e.prev=21,e.t0=e.catch(10),d=KL(n);try{for(d.s();!(p=d.n()).done;)h=p.value,this.recordActionFailureOn(h,t)}catch(e){d.e(e)}finally{d.f()}e.t0 instanceof $L&&"transportDisconnected"===e.t0.errorInfo.reason?(tL("Twilsock connection (required for subscription) not ready (c:".concat(r,"); waiting…")),this.backoff.reset()):(tL("Failed an attempt to ".concat(t," subscriptions (c:").concat(r,"); retrying"),e.t0),this.persist());case 26:case"end":return e.stop()}}),e,this,[[10,21]])}))),function(e,n){return t.apply(this,arguments)})},{key:"verifyPokeDelivery",value:function(e,t,n){var r=this,i=this.latestPokeResponseArrivalTimestampByCorrelationId.get(e),a=i?(new Date).getTime()-i:t;a>=t?(n.filter((function(t){return t.pendingCorrelationId===e})).forEach((function(e){e.updatePending(null,null),e.retryCount++,r.persisted.delete(e.sid)})),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(e)):setTimeout((function(){return r.verifyPokeDelivery(e,t,n)}),t-a)}},{key:"processLocalActions",value:function(e,t){return"cancel"===e?t.filter((function(e){return!e.rejectedWithError})):t}},{key:"recordActionAttemptOn",value:function(e,t,n){if(e.setSubscriptionState("request_in_flight"),"establish"===t)this.persisted.set(e.sid,e),e.updatePending(t,n);else{var r=this.persisted.get(e.sid);r&&r.updatePending(t,n)}}},{key:"recordActionFailureOn",value:function(e,t){e.setSubscriptionState("none"),e.updatePending(null,null),"establish"===t&&this.persisted.delete(e.sid)}},{key:"request",value:function(e,t,n,r){var i=r.map((function(t){return{object_sid:t.sid,object_type:t.type,last_event_id:"establish"===e?t.lastEventId:void 0,index_name:"establish"===e?t.indexName:void 0,query_string:"establish"===e?t.queryString:void 0}})),a=r.filter((function(e){return e.retryCount>0})).length;tL("Attempting '".concat(e,"' request (c:").concat(t,"):"),i);var o={event_protocol_version:4,action:e,correlation_id:t,retried_requests:a,ttl_in_s:-1,requests:i};return"ttl"===n&&(o.reason=n),this.services.network.post(this.services.config.subscriptionsUri,o)}},{key:"add",value:function(e,t){tL("Establishing intent to subscribe to ".concat(e));var n=this.subscriptions.get(e);n&&t&&n.lastEventId===t.lastEventId||(this.persisted.delete(e),this.subscriptions.set(e,new GL(t)),this.persist())}},{key:"remove",value:function(e){tL("Establishing intent to unsubscribe from ".concat(e)),this.subscriptions.delete(e)&&this.persist()}},{key:"acceptMessage",value:function(e,t){eL("Subscriptions received",e);var n=e.event_type,r=void 0!==e.events?e.events:[e.event],i=e.correlation_id;i&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(i,(new Date).getTime());var a,o=KL(r);try{for(o.s();!(a=o.n()).done;){var s=a.value,u=void 0;switch(e.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(s,i);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(s,i);break;case"subscription_failed":this.applySubscriptionFailedMessage(s,i);break;case(u=n.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:var c=void 0;switch(u[0]){case"map_":c=s.map_sid;break;case"list_":c=s.list_sid;break;case"document_":c=s.document_sid;break;case"stream_":c=s.stream_sid;break;case"live_query_":c=s.query_id,t=!1,!0===e.strictly_ordered&&(t=!0);break;default:c=void 0}this.applyEventToSubscribedEntity(c,s,n,t);break;default:tL("Dropping unknown message type ".concat(n))}}}catch(e){o.e(e)}finally{o.f()}}},{key:"applySubscriptionEstablishedMessage",value:function(e,t){var n=e.object_sid,r=this.persisted.get(e.object_sid);r&&r.pendingCorrelationId===t?"interrupted"===e.replay_status?(tL("Event Replay for subscription to ".concat(n," (c:").concat(t,") interrupted; continuing eagerly.")),r.updatePending(null,null),this.persisted.delete(r.sid),this.backoff.reset()):"completed"===e.replay_status&&(tL("Event Replay for subscription to ".concat(n," (c:").concat(t,") completed. Subscription is ready.")),r.complete(e.last_event_id),this.persisted.set(e.object_sid,r),r.setSubscriptionState("established"),this.backoff.reset()):tL("Late message for ".concat(e.object_sid," (c:").concat(t,") dropped.")),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(e,t){var n=this.persisted.get(e.object_sid);n&&n.pendingCorrelationId===t?(n.updatePending(null,null),n.setSubscriptionState("none"),this.persisted.delete(e.object_sid)):tL("Late message for ".concat(e.object_sid," (c:").concat(t,") dropped.")),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(e,t){var n=e.object_sid,r=this.subscriptions.get(n),i=this.persisted.get(n);r&&i?i.pendingCorrelationId===t&&(nL("Failed to subscribe on ".concat(i.sid),e.error),i.markAsFailed(e),i.setSubscriptionState("none")):!r&&i&&(this.persisted.delete(n),i.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(e,t,n,r){if(e){var i;r=r||(i=this.persisted.get(e))&&i.isEstablished;var a=this.subscriptions.get(e);a?(t.type=n,a.update(t,r)):tL("Message dropped for SID '".concat(e,"', for which there is no subscription."))}}},{key:"onConnectionStateChanged",value:function(e){this.isConnected=e,e&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(e){tL("Triggering event replay for all subscriptions, reason=".concat(e)),this.pendingPokeReason=e,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var t,n=[],r=KL(this.persisted.values());try{for(r.s();!(t=r.n()).done;){var i=t.value;i.reset(),i.rejectedWithError&&n.push(i)}}catch(e){r.e(e)}finally{r.f()}this.persisted.clear();for(var a=0,o=n;a<o.length;a++){var s=o[a];this.persisted.set(s.sid,s)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),e}(),YL=uM.customAlphabet("1234567890abcdef",32);function JL(e,t){if(null!=t&&t.message)return t.message;switch(e.statusCode){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function QL(e){var t;return null!==(t=null==e?void 0:e.code)&&void 0!==t?t:0}function XL(e,t){return 409===e.statusCode?new GM(JL(e,t),e.statusCode,QL(t),t):e.statusCode?new SyncError(JL(e,t),e.statusCode,QL(t)):e instanceof $L&&"transportDisconnected"===e.errorInfo.reason?e:new SyncError(null!==(n=null!==(r=null==t?void 0:t.message)&&void 0!==r?r:e.message)&&void 0!==n?n:"Unexpected error",0,0);var n,r}var ZL=function(){function e(t,n,r){mM.default(this,e),_M.default(this,"clientInfo",void 0),_M.default(this,"config",void 0),_M.default(this,"transport",void 0),_M.default(this,"pendingRequests",void 0),_M.default(this,"isShutdownInitiated",!1),this.clientInfo=t,this.config=n,this.transport=r,this.pendingRequests=new Set}var t;return gM.default(e,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ".concat(YL())}}},{key:"backoffConfig",value:function(){return Object.assign({min:4e3,max:6e4,maxAttemptsTime:9e4,randomness:.2},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new Promise((function(r,i){var a=[502,503,504];n&&a.push(429);var o=new ZA.Retrier(t.backoffConfig());o.on("attempt",(function(){e().then((function(e){if(e.statusCode>=400){var t={};try{t=JSON.parse(e.payload)}catch(e){}if(a.includes(e.statusCode)){var n=parseInt(e.headers?e.headers["Retry-After"]:null);o.failed(XL(e,t),isNaN(n)?null:1e3*n)}else"Twilsock disconnected"===t.message?o.failed(XL(e,t)):(o.removeAllListeners(),o.cancel(),i(XL(e,t)))}else o.succeeded(e)})).catch((function(e){o.removeAllListeners(),o.cancel(),i(XL(e,null))}))})),o.on("succeeded",(function(e){r(e)})),o.on("cancelled",(function(e){return i(XL(e,null))})),o.on("failed",(function(e){return i(XL(e,null))})),o.start()}))}},{key:"responsePostProcess",value:function(e){var t={};try{t=JSON.parse(e.payload)}catch(e){}return{status:{code:e.statusCode,status:e.status},headers:e.headers,body:t}}},{key:"get",value:function(e){var t=this;if(this.isShutdownInitiated)throw new Error("Client has been shut down.");var n=this.createHeaders();tL("GET",e,"ID:",n["Twilio-Request-Id"]);var r=this.executeWithRetry((function(){return t.transport.sendRequest(new YA.HttpRequest({url:e,headers:n,grant:t.config.productId}))}),!0);return this.pendingRequests.add(r),r.then((function(e){return t.pendingRequests.delete(r),t.responsePostProcess(e)}))}},{key:"post",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(this.isShutdownInitiated)throw new Error("Client has been shut down.");var a=this.createHeaders();null!=n&&(a["If-Match"]=n),tL("POST",e,"ID:",a["Twilio-Request-Id"]);var o=this.executeWithRetry((function(){return r.transport.sendRequest(new YA.HttpRequest({method:"POST",url:e,headers:a,payload:t,grant:r.config.productId}))}),i);return this.pendingRequests.add(o),o.then((function(e){return r.pendingRequests.delete(o),r.responsePostProcess(e)}))}},{key:"put",value:function(e,t,n){var r=this;if(this.isShutdownInitiated)throw new Error("Client has been shut down.");var i=this.createHeaders();null!=n&&(i["If-Match"]=n),tL("PUT",e,"ID:",i["Twilio-Request-Id"]);var a=this.executeWithRetry((function(){return r.transport.sendRequest(new YA.HttpRequest({method:"PUT",url:e,headers:i,payload:t,grant:r.config.productId}))}),!1);return this.pendingRequests.add(a),a.then((function(e){return r.pendingRequests.delete(a),r.responsePostProcess(e)}))}},{key:"delete",value:function(e){var t=this;if(this.isShutdownInitiated)throw new Error("Client has been shut down.");var n=this.createHeaders();tL("DELETE",e,"ID:",n["Twilio-Request-Id"]);var r=this.executeWithRetry((function(){return t.transport.sendRequest(new YA.HttpRequest({method:"DELETE",url:e,headers:n,grant:t.config.productId}))}),!1);return this.pendingRequests.add(r),r.then((function(e){return t.pendingRequests.delete(r),t.responsePostProcess(e)}))}},{key:"disconnect",value:(t=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.isShutdownInitiated=!0,e.prev=1,e.next=4,Promise.all(qM.default(this.pendingRequests));case 4:e.next=8;break;case 6:e.prev=6,e.t0=e.catch(1);case 8:return e.next=10,this.transport.disconnect();case 10:case"end":return e.stop()}}),e,this,[[1,6]])}))),function(){return t.apply(this,arguments)})}]),e}(),eU=function(){function e(t,n){mM.default(this,e),_M.default(this,"config",void 0),_M.default(this,"storage",void 0),_M.default(this,"storageId",void 0),this.config=t,this.storageId=null;try{this.storage=n||sessionStorage}catch(e){}}return gM.default(e,[{key:"storageKey",value:function(e,t){return"".concat(this.storageId,"::").concat(e,"::").concat(t)}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}},{key:"updateStorageId",value:function(e){this.storageId=e}},{key:"store",value:function(e,t,n){return this.isReady?this._store(this.storageKey(e,t),n):null}},{key:"read",value:function(e,t){return this.isReady?this._read(this.storageKey(e,t)):null}},{key:"remove",value:function(e,t,n){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(e,t)),n&&this.storage.removeItem(this.storageKey(e,n))}catch(e){}}},{key:"update",value:function(e,t,n,r){if(!this.isReady)return null;this._apply(this.storageKey(e,t),r),n&&this._apply(this.storageKey(e,n),r)}},{key:"_store",value:function(e,t){try{this.storage.setItem(e,JSON.stringify(t))}catch(e){}}},{key:"_read",value:function(e){try{var t=this.storage.getItem(e);if(t)return JSON.parse(t)}catch(e){}return null}},{key:"_apply",value:function(e,t){var n=this._read(e);if(!n)return!1;this._store(e,Object.assign(n,t))}}]),e}();function tU(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return nU(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nU(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function nU(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var rU=function(){function e(t,n){mM.default(this,e),_M.default(this,"services",void 0),_M.default(this,"removalHandler",void 0),_M.default(this,"subscriptionState",void 0),_M.default(this,"_attachedListeners",void 0),this.services=t,this.removalHandler=n,this.subscriptionState="none",this._attachedListeners=new Map}return gM.default(e,[{key:"_advanceLastEventId",value:function(e,t){}},{key:"reportFailure",value:function(e){404===e.status?this.onRemoved(!1):this.broadcastEventToListeners("failure",e)}},{key:"_subscribe",value:function(){this.services.router._subscribe(this.sid,this)}},{key:"_unsubscribe",value:function(){this.services.router._unsubscribe(this.sid)}},{key:"_setSubscriptionState",value:function(e){this.subscriptionState=e,this.broadcastEventToListeners("_subscriptionStateChanged",e)}},{key:"close",value:function(){this._unsubscribe(),null!=this.removalHandler&&this.removalHandler(this.type,this.sid,this.uniqueName)}},{key:"attach",value:function(e){var t=e.listenerUuid;this._attachedListeners.get(t)||(this._attachedListeners.size||this._subscribe(),this._attachedListeners.set(t,e))}},{key:"detach",value:function(e){this._attachedListeners.delete(e),this._attachedListeners.size||this.close()}},{key:"broadcastEventToListeners",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i,a=tU(this._attachedListeners.values());try{for(a.s();!(i=a.n()).done;){var o=i.value;o.emit.apply(o,[e].concat(n))}}catch(e){a.e(e)}finally{a.f()}}}]),e}(),iU=function(){function e(t){mM.default(this,e),_M.default(this,"queuedRequests",[]),_M.default(this,"inputMergingFunction",void 0),_M.default(this,"isRequestInFlight",!1),this.inputMergingFunction=t}return gM.default(e,[{key:"add",value:function(e,t){var n=this,r=new Promise((function(r,i){return n.queuedRequests.push({input:e,requestFunction:t,resolve:r,reject:i})}));return this.wakeupQueue(),r}},{key:"squashAndAdd",value:function(e,t){var n,r=this.queuedRequests;this.queuedRequests=[],r.length>0?(n=r.map((function(e){return e.input})).reduce(this.inputMergingFunction),n=this.inputMergingFunction(n,e)):n=e;var i=this.add(n,t);return r.forEach((function(e){return i.then(e.resolve,e.reject)})),i}},{key:"isEmpty",value:function(){return 0===this.queuedRequests.length&&!this.isRequestInFlight}},{key:"wakeupQueue",value:function(){var e=this;if(0!==this.queuedRequests.length&&!this.isRequestInFlight){var t=this.queuedRequests.shift();this.isRequestInFlight=!0,t.requestFunction(t.input).then(t.resolve,t.reject).then((function(t){e.isRequestInFlight=!1,e.wakeupQueue()}))}}}]),e}(),aU=function(){function e(t){mM.default(this,e),_M.default(this,"inputReducer",void 0),_M.default(this,"queueByNamespaceKey",new Map),this.inputReducer=t}var t,n,r;return gM.default(e,[{key:"add",value:(r=yM.default(SM.default.mark((function e(t,n,r){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.invokeQueueMethod(t,(function(e){return e.add(n,r)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"squashAndAdd",value:(n=yM.default(SM.default.mark((function e(t,n,r){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.invokeQueueMethod(t,(function(e){return e.squashAndAdd(n,r)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"invokeQueueMethod",value:(t=yM.default(SM.default.mark((function e(t,n){var r,i;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queueByNamespaceKey.has(t)||this.queueByNamespaceKey.set(t,new iU(this.inputReducer)),r=this.queueByNamespaceKey.get(t),i=n(r),this.queueByNamespaceKey.get(t).isEmpty()&&this.queueByNamespaceKey.delete(t),e.abrupt("return",i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})}]),e}();function oU(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=xM.default(e);if(t){var i=xM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return kM.default(this,n)}}var sU=function(e){wM.default(n,e);var t=oU(n);function n(){var e;return mM.default(this,n),e=t.call(this),_M.default(bM.default(e),"uuid",void 0),_M.default(bM.default(e),"closed",void 0),e.closed=!1,e.uuid=uM.nanoid(),e}return gM.default(n,[{key:"listenerUuid",get:function(){return this.uuid}},{key:"close",value:function(){this.removeAllListeners(),this.closed=!0}},{key:"ensureNotClosed",value:function(){if(this.closed)throw new Error("Invalid operation on closed object")}}]),n}(dM.ReplayEventEmitter);function uU(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=xM.default(e);if(t){var i=xM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return kM.default(this,n)}}var cU=function(e){wM.default(f,e);var t,n,r,i,a,o,s,u,c,l=uU(f);function f(e,t,n){var r;mM.default(this,f),r=l.call(this,e,n),_M.default(bM.default(r),"updateMergingQueue",void 0),_M.default(bM.default(r),"descriptor",void 0),_M.default(bM.default(r),"isDeleted",!1);return r.updateMergingQueue=new iU((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.descriptor=t,r.descriptor.data=r.descriptor.data||{},r.descriptor.date_updated=new Date(r.descriptor.date_updated),r}return gM.default(f,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"document"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"_update",value:function(e){switch(e.date_created=new Date(e.date_created),e.type){case"document_updated":if(e.id<=this.lastEventId){eL("Document update skipped, current:",this.lastEventId,", remote:",e.id);break}var t=void 0!==this.descriptor.data?VM(this.descriptor.data):null;this.descriptor.last_event_id=e.id,this.descriptor.revision=e.document_revision,this.descriptor.date_updated=e.date_created,this.descriptor.data=e.document_data,this.broadcastEventToListeners("updated",{data:e.document_data,isLocal:!1,previousData:t}),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:e.id,revision:e.document_revision,date_updated:e.date_created,data:e.document_data});break;case"document_removed":this.onRemoved(!1)}}},{key:"set",value:(c=yM.default(SM.default.mark((function e(t,n){var r,i=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n||{},e.abrupt("return",this.updateMergingQueue.squashAndAdd(r,(function(e){return i._setUnconditionally(t,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"mutate",value:(u=yM.default(SM.default.mark((function e(t,n){var r,i=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n||{},e.abrupt("return",this.updateMergingQueue.add(r,(function(e){return i._setWithIfMatch(t,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"update",value:(s=yM.default(SM.default.mark((function e(t,n){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate((function(e){return Object.assign(e,t)}),n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"setTtl",value:(o=yM.default(SM.default.mark((function e(t){var n;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._postUpdateToServer({ttl:t});case 2:n=e.sent,this.descriptor.date_expires=n.date_expires;case 4:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_setUnconditionally",value:(a=yM.default(SM.default.mark((function e(t,n){var r;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._postUpdateToServer({data:t,revision:void 0,ttl:n});case 2:return r=e.sent,this._handleSuccessfulUpdateResult(r),e.abrupt("return",this.descriptor.data);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"_setWithIfMatch",value:(i=yM.default(SM.default.mark((function e(t,n){var r,i,a;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t(VM(this.descriptor.data)))){e.next=22;break}return i=this.revision,e.prev=3,e.next=6,this._postUpdateToServer({data:r,revision:i,ttl:n});case 6:return a=e.sent,this._handleSuccessfulUpdateResult(a),e.abrupt("return",this.descriptor.data);case 11:if(e.prev=11,e.t0=e.catch(3),412!==e.t0.status){e.next=19;break}return e.next=16,this._softSync();case 16:return e.abrupt("return",this._setWithIfMatch(t));case 19:throw e.t0;case 20:e.next=23;break;case 22:return e.abrupt("return",this.descriptor.data);case 23:case"end":return e.stop()}}),e,this,[[3,11]])}))),function(e,t){return i.apply(this,arguments)})},{key:"_handleSuccessfulUpdateResult",value:function(e){if(!(e.last_event_id<=this.descriptor.last_event_id)){var t=void 0!==this.descriptor.data?VM(this.descriptor.data):null;this.descriptor.revision=e.revision,this.descriptor.data=e.data,this.descriptor.last_event_id=e.last_event_id,this.descriptor.date_expires=e.date_expires,this.descriptor.date_updated=new Date(e.date_updated),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:e.last_event_id,revision:e.revision,date_updated:e.date_updated,data:e.data}),this.broadcastEventToListeners("updated",{data:this.descriptor.data,isLocal:!0,previousData:t})}}},{key:"_postUpdateToServer",value:(r=yM.default(SM.default.mark((function e(t){var n,r,i;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isDeleted){e.next=17;break}return n={data:t.data},void 0!==t.ttl&&(n.ttl=t.ttl),r=t.revision,e.prev=4,e.next=7,this.services.network.post(this.uri,n,r);case 7:return i=e.sent,e.abrupt("return",{revision:i.body.revision,data:t.data,last_event_id:i.body.last_event_id,date_updated:i.body.date_updated,date_expires:i.body.date_expires});case 11:throw e.prev=11,e.t0=e.catch(4),404===e.t0.status&&this.onRemoved(!1),e.t0;case 15:e.next=18;break;case 17:return e.abrupt("return",Promise.reject(new SyncError("The Document has been removed",404,54100)));case 18:case"end":return e.stop()}}),e,this,[[4,11]])}))),function(e){return r.apply(this,arguments)})},{key:"_softSync",value:(n=yM.default(SM.default.mark((function e(){var t=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.services.network.get(this.uri).then((function(e){var n={type:"document_updated",id:e.body.last_event_id,document_revision:e.body.revision,document_data:e.body.data,date_created:e.body.date_updated};return t._update(n),t})).catch((function(e){404===e.status?t.onRemoved(!1):nL("Can't get updates for ".concat(t.sid,":"),e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"onRemoved",value:function(e){if(!this.isDeleted){var t=void 0!==this.descriptor.data?VM(this.descriptor.data):null;this.isDeleted=!0,this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e,previousData:t})}}},{key:"removeDocument",value:(t=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isDeleted){e.next=6;break}return e.next=3,this.services.network.delete(this.uri);case 3:this.onRemoved(!0),e.next=7;break;case 6:return e.abrupt("return",Promise.reject(new SyncError("The Document has been removed",404,54100)));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}],[{key:"type",get:function(){return"document"}}]),f}(rU),lU=function(e){wM.default(s,e);var t,n,r,i,a,o=uU(s);function s(e){var t;return mM.default(this,s),t=o.call(this),_M.default(bM.default(t),"syncDocumentImpl",void 0),t.syncDocumentImpl=e,t.syncDocumentImpl.attach(bM.default(t)),t}return gM.default(s,[{key:"uri",get:function(){return this.syncDocumentImpl.uri}},{key:"revision",get:function(){return this.syncDocumentImpl.revision}},{key:"lastEventId",get:function(){return this.syncDocumentImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncDocumentImpl.dateExpires}},{key:"type",get:function(){return cU.type}},{key:"sid",get:function(){return this.syncDocumentImpl.sid}},{key:"data",get:function(){return this.syncDocumentImpl.data}},{key:"dateUpdated",get:function(){return this.syncDocumentImpl.dateUpdated}},{key:"uniqueName",get:function(){return this.syncDocumentImpl.uniqueName}},{key:"set",value:(a=yM.default(SM.default.mark((function e(t,n){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.set(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"mutate",value:(i=yM.default(SM.default.mark((function e(t,n){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.mutate(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"update",value:(r=yM.default(SM.default.mark((function e(t,n){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.update(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setTtl",value:(n=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"removeDocument",value:(t=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.removeDocument());case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){BM.default(xM.default(s.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return cU.type}}]),s}(sU);_M.default(lU,"removed","removed"),_M.default(lU,"updated","updated"),WM([VA.validateTypesAsync(VA.pureObject,["undefined",VA.objectSchema("document metadata",{ttl:[VA.nonNegativeInteger,"undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[Object,Object]),$M("design:returntype",Promise)],lU.prototype,"set",null),WM([VA.validateTypesAsync("function",["undefined",VA.objectSchema("document metadata",{ttl:[VA.nonNegativeInteger,"undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[Function,Object]),$M("design:returntype",Promise)],lU.prototype,"mutate",null),WM([VA.validateTypesAsync(VA.pureObject,["undefined",VA.objectSchema("document metadata",{ttl:[VA.nonNegativeInteger,"undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[Object,Object]),$M("design:returntype",Promise)],lU.prototype,"update",null),WM([VA.validateTypesAsync(VA.nonNegativeInteger),$M("design:type",Function),$M("design:paramtypes",[Number]),$M("design:returntype",Promise)],lU.prototype,"setTtl",null);var fU,dU=function(){function e(t){mM.default(this,e),_M.default(this,"descriptor",void 0),this.descriptor=t}return gM.default(e,[{key:"uri",get:function(){return this.descriptor.uri}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.lastEventId}},{key:"dateUpdated",get:function(){return this.descriptor.dateUpdated}},{key:"dateExpires",get:function(){return this.descriptor.dateExpires}},{key:"index",get:function(){return this.descriptor.index}},{key:"data",get:function(){return this.descriptor.data}},{key:"update",value:function(e,t,n,r){return this.descriptor.lastEventId=e,this.descriptor.revision=t,this.descriptor.data=n,this.descriptor.dateUpdated=r,this}},{key:"updateDateExpires",value:function(e){this.descriptor.dateExpires=e}}]),e}(),Paginator=function(){function Paginator(e,t,n,r){mM.default(this,Paginator),_M.default(this,"prevToken",void 0),_M.default(this,"nextToken",void 0),_M.default(this,"source",void 0),_M.default(this,"items",void 0),this.prevToken=n,this.nextToken=r,this.items=e,this.source=t}var e,t;return gM.default(Paginator,[{key:"hasNextPage",get:function(){return!!this.nextToken}},{key:"hasPrevPage",get:function(){return!!this.prevToken}},{key:"nextPage",value:(t=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasNextPage){e.next=2;break}throw new Error("No next page");case 2:return e.abrupt("return",this.source(this.nextToken));case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"prevPage",value:(e=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasPrevPage){e.next=2;break}throw new Error("No previous page");case 2:return e.abrupt("return",this.source(this.prevToken));case 3:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]),Paginator}();function pU(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return hU(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return hU(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function hU(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var vU=function(){function e(t,n){mM.default(this,e),_M.default(this,"parent",void 0),_M.default(this,"left",void 0),_M.default(this,"right",void 0),_M.default(this,"balanceFactor",void 0),_M.default(this,"key",void 0),_M.default(this,"value",void 0),this.balanceFactor=0,this.key=t,this.value=n,this.parent=null,this.left=null,this.right=null}return gM.default(e,[{key:"isRoot",get:function(){return null===this.parent}},{key:"isLeaf",get:function(){return null===this.left&&null===this.right}},{key:"isLeftChild",get:function(){return this.parent.left===this}},{key:"update",value:function(e){this.value=e}},{key:"replace",value:function(e,t){e&&(this.left===t?this.left=t:this.right===t&&(this.right=t))}}]),e}();fU=Symbol.iterator;var yU=function(){function e(t,n){mM.default(this,e),_M.default(this,"isLessThan",void 0),_M.default(this,"isEqual",void 0),_M.default(this,"root",void 0),_M.default(this,"count",void 0),this.isLessThan=t||function(e,t){return e<t},this.isEqual=n||function(e,t){return e===t},this.root=null,this.count=null}return gM.default(e,[{key:"size",get:function(){return this.count}},{key:"clear",value:function(){this.root=null,this.count=0}},{key:"set",value:function(e,t){var n=this.getNode(e);n?n.update(t):this.insert(e,t)}},{key:"insert",value:function(e,t){var n=new vU(e,t);if(this.count++,this.root){for(var r=this.root;;)if(this.isLessThan(e,r.key)){if(!r.left){r.left=n;break}r=r.left}else{if(!r.right){r.right=n;break}r=r.right}for(n.parent=r,r=n;r.parent;){var i=r.parent,a=i.balanceFactor;if(r.isLeftChild?i.balanceFactor++:i.balanceFactor--,Math.abs(i.balanceFactor)<Math.abs(a))break;if(i.balanceFactor<-1||i.balanceFactor>1){this.rebalance(i);break}r=i}}else this.root=n}},{key:"get",value:function(e){for(var t=this.root;t;){if(this.isEqual(e,t.key))return t.value;t=this.isLessThan(e,t.key)?t.left:t.right}return null}},{key:"delete",value:function(e){var t=this.getNode(e);if(!t||t.key!==e)return null;var n=t.parent,r=t.left,i=t.right;if(!!r!=!!i){var a=r||i;n||a?n&&!a?this.root=a:(n.replace(t,null),this.rebalance(n)):this.root=null}else{for(var o=t.left;o.right;)o=o.right;if(t.left===o)t.isRoot?(this.root=o,o.parent=null):(t.isLeftChild?t.parent.left=o:t.parent.right=o,o.parent=t.parent),o.right=t.right,o.right.parent=o,o.balanceFactor=t.balanceFactor,t={parent:o,isLeftChild:!0};else{var s=o.parent,u=o.left;s.right=u,u&&(u.parent=s),t.isRoot?(this.root=o,o.parent=null):(t.isLeftChild?t.parent.left=o:t.parent.right=o,o.parent=t.parent),o.right=t.right,o.right.parent=o,o.left=t.left,o.left.parent=o,o.balanceFactor=t.balanceFactor,t={parent:s,isLeftChild:!1}}}for(this.count--;t.parent;){var c=t.parent,l=c.balanceFactor;if(t.isLeftChild?c.balanceFactor-=1:c.balanceFactor+=1,Math.abs(c.balanceFactor)>Math.abs(l)){if(!(c.balanceFactor<-1||c.balanceFactor>1))break;if(this.rebalance(c),0!==c.parent.balanceFactor)break;t=c.parent}else t=c}return null}},{key:"getNode",value:function(e){for(var t=this.root;t;){if(this.isEqual(e,t.key))return t;t=this.isLessThan(e,t.key)?t.left:t.right}return null}},{key:"rebalance",value:function(e){e.balanceFactor<0?e.right.balanceFactor>0?(this.rotateRight(e.right),this.rotateLeft(e)):this.rotateLeft(e):e.balanceFactor>0&&(e.left.balanceFactor<0?(this.rotateLeft(e.left),this.rotateRight(e)):this.rotateRight(e))}},{key:"rotateLeft",value:function(e){var t=e.right;e.right=t.left,null!==t.left&&(t.left.parent=e),t.parent=e.parent,null===t.parent?this.root=t:e.isLeftChild?t.parent.left=t:t.parent.right=t,t.left=e,e.parent=t,e.balanceFactor=e.balanceFactor+1-Math.min(t.balanceFactor,0),t.balanceFactor=t.balanceFactor+1-Math.max(e.balanceFactor,0)}},{key:"rotateRight",value:function(e){var t=e.left;e.left=t.right,null!==t.right&&(t.right.parent=e),t.parent=e.parent,null===t.parent?this.root=t:e.isLeftChild?t.parent.left=t:t.parent.right=t,t.right=e,e.parent=t,e.balanceFactor=e.balanceFactor-1-Math.min(t.balanceFactor,0),t.balanceFactor=t.balanceFactor-1-Math.max(e.balanceFactor,0)}},{key:fU,value:SM.default.mark((function e(){var t,n,r;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=pU(this.getIterator()),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=n.value,e.next=7,r;case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[1,11,14,17]])}))},{key:"getIterator",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return SM.default.mark((function n(){var r,i;return SM.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=e.root;case 1:if(!r){n.next=7;break}if(!e.isEqual(t,r.key)&&(null!==t||r.left)){n.next=4;break}return n.abrupt("break",7);case 4:r=e.isLessThan(t,r.key)||null===t?r.left:r.right,n.next=1;break;case 7:if(r){n.next=9;break}return n.abrupt("return",null);case 9:i=!0;case 10:if(!i){n.next=28;break}return n.next=13,[r.key,r.value];case 13:if(i=!1,!r.right){n.next=20;break}for(r=r.right;r.left;)r=r.left;i=!0,n.next=26;break;case 20:if(!r.parent){n.next=25;break}i=r.parent.left===r,r=r.parent,n.next=26;break;case 25:return n.abrupt("break",36);case 26:n.next=34;break;case 28:if(!r.parent){n.next=33;break}i=r.parent.left===r,r=r.parent,n.next=34;break;case 33:return n.abrupt("break",36);case 34:n.next=10;break;case 36:return n.abrupt("return",null);case 37:case"end":return n.stop()}}),n)}))()}},{key:"getReverseIterator",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return SM.default.mark((function n(){var r,i;return SM.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=e.root;case 1:if(!r){n.next=7;break}if(!e.isEqual(t,r.key)&&(null!==t||r.right)){n.next=4;break}return n.abrupt("break",7);case 4:r=e.isLessThan(t,r.key)&&null!==t?r.left:r.right,n.next=1;break;case 7:if(r){n.next=9;break}return n.abrupt("return",null);case 9:i=!0;case 10:if(!i){n.next=28;break}return n.next=13,[r.key,r.value];case 13:if(i=!1,!r.left){n.next=20;break}for(r=r.left;r.right;)r=r.right;i=!0,n.next=26;break;case 20:if(!r.parent){n.next=25;break}i=r.parent.right===r,r=r.parent,n.next=26;break;case 25:return n.abrupt("break",36);case 26:n.next=34;break;case 28:if(!r.parent){n.next=33;break}i=r.parent.right===r,r=r.parent,n.next=34;break;case 33:return n.abrupt("break",36);case 34:n.next=10;break;case 36:return n.abrupt("return",null);case 37:case"end":return n.stop()}}),n)}))()}}]),e}();function mU(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return gU(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return gU(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function gU(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var bU=function(){function e(t,n){mM.default(this,e),_M.default(this,"value",void 0),_M.default(this,"revision",void 0),this.value=t,this.revision=n||0}return gM.default(e,[{key:"isValid",get:function(){return!0}}]),e}(),wU=function(){function e(t){mM.default(this,e),_M.default(this,"value",void 0),_M.default(this,"revision",void 0),this.revision=t}return gM.default(e,[{key:"isValid",get:function(){return!1}}]),e}(),kU=function(){function e(){mM.default(this,e),_M.default(this,"items",void 0),this.items=new yU}return gM.default(e,[{key:"store",value:function(e,t,n){var r=this.items.get(e);return r&&r.revision>n?r.isValid?r.value:null:(this.items.set(e,new bU(t,n)),t)}},{key:"delete",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.items.get(e);(!r||r.revision<t||r&&!0===n)&&this.items.set(e,new wU(t))}},{key:"isKnown",value:function(e,t){var n=this.items.get(e);return n&&n.revision>=t}},{key:"get",value:function(e){var t=this.items.get(e);return t&&t.isValid?t.value:null}},{key:"has",value:function(e){var t=this.items.get(e);return t&&t.isValid}},{key:"forEach",value:function(e){if(this.items){var t,n=mU(this.items);try{for(n.s();!(t=n.n()).done;){var r=IM.default(t.value,2),i=r[0],a=r[1];a.isValid&&e(i,a.value)}}catch(e){n.e(e)}finally{n.f()}}}}]),e}();function xU(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=xM.default(e);if(t){var i=xM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return kM.default(this,n)}}var _U=function(e){wM.default(y,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v=xU(y);function y(e,t,n){var r;mM.default(this,y),r=v.call(this,e,n),_M.default(bM.default(r),"descriptor",void 0),_M.default(bM.default(r),"updateMergingQueue",void 0),_M.default(bM.default(r),"cache",void 0),_M.default(bM.default(r),"context",void 0),_M.default(bM.default(r),"contextEventId",void 0);return r.updateMergingQueue=new aU((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.cache=new kU,r.descriptor=t,r.descriptor.date_updated=new Date(r.descriptor.date_updated),r}return gM.default(y,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"list"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"_addOrUpdateItemOnServer",value:(h=yM.default(SM.default.mark((function e(t,n,r,i){var a,o;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a={data:n},void 0!==i&&(a.ttl=i),e.next=4,this.services.network.post(t,a,r);case 4:return(o=e.sent).body.data=n,o.body.date_updated=new Date(o.body.date_updated),e.abrupt("return",o.body);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n,r){return h.apply(this,arguments)})},{key:"push",value:(p=yM.default(SM.default.mark((function e(t,n){var r,i,a;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=(n||{}).ttl,e.next=3,this._addOrUpdateItemOnServer(this.links.items,t,void 0,r);case 3:return i=e.sent,a=Number(i.index),this._handleItemMutated(a,i.url,i.last_event_id,i.revision,t,i.date_updated,i.date_expires,!0,!1),e.abrupt("return",this.cache.get(a));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"set",value:(d=yM.default(SM.default.mark((function e(t,n,r){var i,a=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.squashAndAdd(t,i,(function(e){return a._updateItemUnconditionally(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return d.apply(this,arguments)})},{key:"_updateItemUnconditionally",value:(f=yM.default(SM.default.mark((function e(t,n,r){var i,a;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return i=e.sent,e.next=5,this._addOrUpdateItemOnServer(i.uri,n,void 0,r);case 5:return a=e.sent,this._handleItemMutated(t,a.url,a.last_event_id,a.revision,a.data,a.date_updated,a.date_expires,!1,!1),e.abrupt("return",this.cache.get(t));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return f.apply(this,arguments)})},{key:"_updateItemWithIfMatch",value:(l=yM.default(SM.default.mark((function e(t,n,r){var i,a,o,s;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:if(i=e.sent,!(a=n(VM(i.data)))){e.next=25;break}return o=i.revision,e.prev=6,e.next=9,this._addOrUpdateItemOnServer(i.uri,a,o,r);case 9:return s=e.sent,this._handleItemMutated(t,s.url,s.last_event_id,s.revision,s.data,s.date_updated,s.date_expires,!1,!1),e.abrupt("return",this.cache.get(t));case 14:if(e.prev=14,e.t0=e.catch(6),412!==e.t0.status){e.next=22;break}return e.next=19,this._getItemFromServer(t);case 19:return e.abrupt("return",this._updateItemWithIfMatch(t,n,r));case 22:throw e.t0;case 23:e.next=26;break;case 25:return e.abrupt("return",i);case 26:case"end":return e.stop()}}),e,this,[[6,14]])}))),function(e,t,n){return l.apply(this,arguments)})},{key:"mutate",value:(c=yM.default(SM.default.mark((function e(t,n,r){var i,a=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.add(t,i,(function(e){return a._updateItemWithIfMatch(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return c.apply(this,arguments)})},{key:"update",value:(u=yM.default(SM.default.mark((function e(t,n,r){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate(t,(function(e){return Object.assign(e,n)}),r));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return u.apply(this,arguments)})},{key:"remove",value:(s=yM.default(SM.default.mark((function e(t){var n,r,i;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return n=e.sent,r=VM(n.data),e.next=6,this.services.network.delete(n.uri);case 6:i=e.sent,this._handleItemRemoved(t,i.body.last_event_id,r,new Date(i.body.date_updated),!1);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"get",value:function(){var e=yM.default(SM.default.mark((function e(t){var n;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.cache.get(t))){e.next=5;break}return e.abrupt("return",n);case 5:return e.abrupt("return",this._getItemFromServer(t));case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"_getItemFromServer",value:(o=yM.default(SM.default.mark((function e(t){var n;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.queryItems({index:t});case 2:if(!((n=e.sent).items.length<1)){e.next=7;break}throw new SyncError("No item with index ".concat(t," found"),404,54151);case 7:return e.abrupt("return",n.items[0]);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"queryItems",value:function(){var e=yM.default(SM.default.mark((function e(t){var n,r,i,a,o=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},n=new KM(this.links.items).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Index",t.index).queryParam("PageToken",t.pageToken).queryParam("Order",t.order).build(),e.next=4,this.services.network.get(n);case 4:return r=e.sent,i=r.body.items.map((function(e){return e.date_updated=new Date(e.date_updated),o.cache.get(e.index)?o._handleItemMutated(e.index,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0):o.cache.store(Number(e.index),new dU({index:Number(e.index),uri:e.url,revision:e.revision,lastEventId:e.last_event_id,dateUpdated:e.date_updated,dateExpires:e.date_expires,data:e.data}),e.last_event_id),o.cache.get(e.index)})),a=r.body.meta,e.abrupt("return",new Paginator(i,(function(e){return o.queryItems({pageToken:e})}),a.previous_token,a.next_token));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:(a=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return YM((t=t||{}).pageSize),t.limit=t.pageSize||t.limit||50,t.order=t.order||"asc",e.abrupt("return",this.queryItems(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getContext",value:(i=yM.default(SM.default.mark((function e(){var t;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.context){e.next=5;break}return e.next=3,this.services.network.get(this.links.context);case 3:t=e.sent,this._updateContextIfRequired(t.body.data,t.body.last_event_id);case 5:return e.abrupt("return",this.context);case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"setTtl",value:(r=yM.default(SM.default.mark((function e(t){var n,r;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={ttl:t},e.next=4,this.services.network.post(this.uri,n);case 4:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),404===e.t0.status&&this.onRemoved(!1),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=yM.default(SM.default.mark((function e(t,n){var r,i,a;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return r=e.sent,i={ttl:n},e.next=6,this.services.network.post(r.uri,i);case 6:a=e.sent,r.updateDateExpires(a.body.date_expires);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeList",value:(t=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}},{key:"shouldIgnoreEvent",value:function(e,t){return this.cache.isKnown(e,t)}},{key:"_update",value:function(e,t){var n=Number(e.item_index);switch(e.date_created=new Date(e.date_created),e.type){case"list_item_added":case"list_item_updated":this._handleItemMutated(n,e.item_url,e.id,e.item_revision,e.item_data,e.date_created,void 0,"list_item_added"===e.type,!0);break;case"list_item_removed":this._handleItemRemoved(n,e.id,e.item_data,e.date_created,!0);break;case"list_context_updated":this._handleContextUpdate(e.context_data,e.id,e.date_created);break;case"list_removed":this.onRemoved(!1)}t&&this._advanceLastEventId(e.id,e.list_revision)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e,t&&(this.descriptor.revision=t))}},{key:"_updateRootDateUpdated",value:function(e){(!this.descriptor.date_updated||e.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=e,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:e}))}},{key:"_handleItemMutated",value:function(e,t,n,r,i,a,o,s,u){if(this.shouldIgnoreEvent(e,n))eL("Item ".concat(e," update skipped, current: ").concat(this.lastEventId,", remote: ").concat(n));else{this._updateRootDateUpdated(a);var c=this.cache.get(e);if(!c){var l=new dU({index:e,uri:t,lastEventId:n,revision:r,data:i,dateUpdated:a,dateExpires:o});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,s)}var f=VM(c.data);c.update(n,r,i,a),this.cache.store(e,c,n),void 0!==o&&c.updateDateExpires(o),this.emitItemMutationEvent(c,u,!1,f)}}},{key:"emitItemMutationEvent",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=n?"itemAdded":"itemUpdated",a={item:e,isLocal:!t};n||(a.previousItemData=r),this.broadcastEventToListeners(i,a)}},{key:"_handleItemRemoved",value:function(e,t,n,r,i){this._updateRootDateUpdated(r),this.cache.delete(e,t),this.broadcastEventToListeners("itemRemoved",{index:e,isLocal:!i,previousItemData:n})}},{key:"_handleContextUpdate",value:function(e,t,n){this._updateRootDateUpdated(n),this._updateContextIfRequired(e,t)&&this.broadcastEventToListeners("contextUpdated",{context:e,isLocal:!1})}},{key:"_updateContextIfRequired",value:function(e,t){return!this.contextEventId||t>this.contextEventId?(this.context=e,this.contextEventId=t,!0):(eL("Context update skipped, current:",this.lastEventId,", remote:",t),!1)}}],[{key:"type",get:function(){return"list"}}]),y}(rU),SU=function(e){wM.default(p,e);var t,n,r,i,a,o,s,u,c,l,f,d=xU(p);function p(e){var t;return mM.default(this,p),t=d.call(this),_M.default(bM.default(t),"syncListImpl",void 0),t.syncListImpl=e,t.syncListImpl.attach(bM.default(t)),t}return gM.default(p,[{key:"uri",get:function(){return this.syncListImpl.uri}},{key:"revision",get:function(){return this.syncListImpl.revision}},{key:"lastEventId",get:function(){return this.syncListImpl.lastEventId}},{key:"links",get:function(){return this.syncListImpl.links}},{key:"dateExpires",get:function(){return this.syncListImpl.dateExpires}},{key:"type",get:function(){return _U.type}},{key:"sid",get:function(){return this.syncListImpl.sid}},{key:"uniqueName",get:function(){return this.syncListImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncListImpl.dateUpdated}},{key:"push",value:(f=yM.default(SM.default.mark((function e(t,n){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.push(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"set",value:(l=yM.default(SM.default.mark((function e(t,n,r){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.set(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return l.apply(this,arguments)})},{key:"mutate",value:(c=yM.default(SM.default.mark((function e(t,n,r){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.mutate(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return c.apply(this,arguments)})},{key:"update",value:(u=yM.default(SM.default.mark((function e(t,n,r){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.update(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return u.apply(this,arguments)})},{key:"remove",value:(s=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.remove(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"get",value:(o=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.get(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getContext",value:(a=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.getContext());case 2:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getItems",value:(i=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.getItems(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setTtl",value:(r=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=yM.default(SM.default.mark((function e(t,n){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.setItemTtl(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeList",value:(t=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.removeList());case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){BM.default(xM.default(p.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return _U.type}}]),p}(sU);_M.default(SU,"itemAdded","itemAdded"),_M.default(SU,"itemUpdated","itemUpdated"),_M.default(SU,"itemRemoved","itemRemoved"),_M.default(SU,"removed","removed"),WM([VA.validateTypesAsync(VA.pureObject,["undefined",VA.objectSchema("item metadata",{ttl:[VA.nonNegativeInteger,"undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[Object,Object]),$M("design:returntype",Promise)],SU.prototype,"push",null),WM([VA.validateTypesAsync(VA.nonNegativeInteger,VA.pureObject,["undefined",VA.objectSchema("item metadata",{ttl:[VA.nonNegativeInteger,"undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[Number,Object,Object]),$M("design:returntype",Promise)],SU.prototype,"set",null),WM([VA.validateTypesAsync(VA.nonNegativeInteger,"function",["undefined",VA.objectSchema("item metadata",{ttl:[VA.nonNegativeInteger,"undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[Number,Function,Object]),$M("design:returntype",Promise)],SU.prototype,"mutate",null),WM([VA.validateTypesAsync(VA.nonNegativeInteger,VA.pureObject,["undefined",VA.objectSchema("item metadata",{ttl:[VA.nonNegativeInteger,"undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[Number,Object,Object]),$M("design:returntype",Promise)],SU.prototype,"update",null),WM([VA.validateTypesAsync(VA.nonNegativeInteger),$M("design:type",Function),$M("design:paramtypes",[Number]),$M("design:returntype",Promise)],SU.prototype,"remove",null),WM([VA.validateTypesAsync(VA.nonNegativeInteger),$M("design:type",Function),$M("design:paramtypes",[Number]),$M("design:returntype",Promise)],SU.prototype,"get",null),WM([VA.validateTypesAsync(["undefined",VA.objectSchema("query options",{from:[VA.nonNegativeInteger,"undefined"],pageSize:[VA.custom((function(e){return[JM(e),"a positive integer"]})),"undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[Object]),$M("design:returntype",Promise)],SU.prototype,"getItems",null),WM([VA.validateTypesAsync(VA.nonNegativeInteger),$M("design:type",Function),$M("design:paramtypes",[Number]),$M("design:returntype",Promise)],SU.prototype,"setTtl",null),WM([VA.validateTypesAsync(VA.nonNegativeInteger,VA.nonNegativeInteger),$M("design:type",Function),$M("design:paramtypes",[Number,Number]),$M("design:returntype",Promise)],SU.prototype,"setItemTtl",null);var OU=function(){function e(t){mM.default(this,e),_M.default(this,"descriptor",void 0),this.descriptor=t}return gM.default(e,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"key",get:function(){return this.descriptor.key}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"update",value:function(e,t,n,r){return this.descriptor.last_event_id=e,this.descriptor.revision=t,this.descriptor.data=n,this.descriptor.date_updated=r,this}},{key:"updateDateExpires",value:function(e){this.descriptor.date_expires=e}}]),e}();function EU(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=xM.default(e);if(t){var i=xM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return kM.default(this,n)}}var TU=function(e){wM.default(h,e);var t,n,r,i,a,o,s,u,c,l,f,d,p=EU(h);function h(e,t,n){var r;mM.default(this,h),r=p.call(this,e,n),_M.default(bM.default(r),"descriptor",void 0),_M.default(bM.default(r),"updateMergingQueue",void 0),_M.default(bM.default(r),"cache",void 0);return r.updateMergingQueue=new aU((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.cache=new kU,r.descriptor=t,r.descriptor.date_updated=new Date(r.descriptor.date_updated),t.items&&t.items.forEach((function(e){e.date_updated=new Date(e.date_updated),r.cache.store(e.key,new OU(e),e.last_event_id)})),r}return gM.default(h,[{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"map"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"set",value:(d=yM.default(SM.default.mark((function e(t,n,r){var i,a=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.squashAndAdd(t,i,(function(e){return a._putItemUnconditionally(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return d.apply(this,arguments)})},{key:"get",value:function(){var e=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}throw new SyncError("SyncMapItem key may not be empty",400,54209);case 2:if(!this.cache.has(t)){e.next=6;break}return e.abrupt("return",this.cache.get(t));case 6:return e.abrupt("return",this._getItemFromServer(t));case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"_getItemFromServer",value:(f=yM.default(SM.default.mark((function e(t){var n;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.queryItems({key:t});case 2:if(!((n=e.sent).items.length<1)){e.next=7;break}throw new SyncError("The specified Map Item does not exist",404,54201);case 7:return e.abrupt("return",n.items[0]);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"mutate",value:(l=yM.default(SM.default.mark((function e(t,n,r){var i,a=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.add(t,i,(function(e){return a._putItemWithIfMatch(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return l.apply(this,arguments)})},{key:"update",value:(c=yM.default(SM.default.mark((function e(t,n,r){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate(t,(function(e){return Object.assign(e,n)}),r));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return c.apply(this,arguments)})},{key:"_putItemUnconditionally",value:(u=yM.default(SM.default.mark((function e(t,n,r){var i,a;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._putItemToServer(t,n,void 0,r);case 2:return i=e.sent,a=i.item,this._handleItemMutated(a.key,a.url,a.last_event_id,a.revision,a.data,a.date_updated,a.date_expires,i.added,!1),e.abrupt("return",this.cache.get(a.key));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return u.apply(this,arguments)})},{key:"_putItemWithIfMatch",value:(s=yM.default(SM.default.mark((function e(t,n,r){var i,a,o,s,u;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t).catch((function(e){if(404===e.status)return new OU({key:t,data:{},last_event_id:-1,revision:"-1",url:null,date_updated:null,date_expires:null});throw e}));case 2:if(i=e.sent,!(a=n(VM(i.data)))){e.next=26;break}return o=i.revision,e.prev=6,e.next=9,this._putItemToServer(t,a,o,r);case 9:return s=e.sent,u=s.item,this._handleItemMutated(u.key,u.url,u.last_event_id,u.revision,u.data,u.date_updated,u.date_expires,s.added,!1),e.abrupt("return",this.cache.get(u.key));case 15:if(e.prev=15,e.t0=e.catch(6),412!==e.t0.status){e.next=23;break}return e.next=20,this._getItemFromServer(t);case 20:return e.abrupt("return",this._putItemWithIfMatch(t,n,r));case 23:throw e.t0;case 24:e.next=27;break;case 26:return e.abrupt("return",i);case 27:case"end":return e.stop()}}),e,this,[[6,15]])}))),function(e,t,n){return s.apply(this,arguments)})},{key:"_putItemToServer",value:(o=yM.default(SM.default.mark((function e(t,n,r,i){var a,o,s,u,c;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new KM(this.links.items).pathSegment(t).build(),o={data:n},void 0!==i&&(o.ttl=i),e.prev=3,e.next=6,this.services.network.put(a,o,r);case 6:return s=e.sent,(u=s.body).data=n,u.date_updated=new Date(u.date_updated),c=201===s.status.code,e.abrupt("return",{added:c,item:u});case 14:throw e.prev=14,e.t0=e.catch(3),404===e.t0.status&&this.onRemoved(!1),e.t0;case 18:case"end":return e.stop()}}),e,this,[[3,14]])}))),function(e,t,n,r){return o.apply(this,arguments)})},{key:"remove",value:(a=yM.default(SM.default.mark((function e(t){var n,r,i;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return n=e.sent,r=VM(n.data),e.next=6,this.services.network.delete(n.uri);case 6:i=e.sent,this._handleItemRemoved(t,i.body.last_event_id,r,new Date(i.body.date_updated),!1);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"queryItems",value:function(){var e=yM.default(SM.default.mark((function e(t){var n,r,i,a,o=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},n=new KM(this.links.items).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Key",t.key).queryParam("PageToken",t.pageToken).queryParam("Order",t.order).build(),e.next=4,this.services.network.get(n);case 4:return r=e.sent,i=r.body.items.map((function(e){return e.date_updated=new Date(e.date_updated),o.cache.get(e.key)?o._handleItemMutated(e.key,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0):o.cache.store(e.key,new OU(e),e.last_event_id),o.cache.get(e.key)})),a=r.body.meta,e.abrupt("return",new Paginator(i,(function(e){return o.queryItems({pageToken:e})}),a.previous_token,a.next_token));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:(i=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return YM((t=t||{}).pageSize),t.limit=t.pageSize||t.limit||50,t.order=t.order||"asc",e.abrupt("return",this.queryItems(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"shouldIgnoreEvent",value:function(e,t){return this.cache.isKnown(e,t)}},{key:"_update",value:function(e,t){switch(e.date_created=new Date(e.date_created),e.type){case"map_item_added":case"map_item_updated":this._handleItemMutated(e.item_key,e.item_url,e.id,e.item_revision,e.item_data,e.date_created,void 0,"map_item_added"===e.type,!0);break;case"map_item_removed":this._handleItemRemoved(e.item_key,e.id,e.item_data,e.date_created,!0);break;case"map_removed":this.onRemoved(!1)}t&&this._advanceLastEventId(e.id,e.map_revision)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e,t&&(this.descriptor.revision=t))}},{key:"_updateRootDateUpdated",value:function(e){(!this.descriptor.date_updated||e.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=e,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:e}))}},{key:"_handleItemMutated",value:function(e,t,n,r,i,a,o,s,u){if(this.shouldIgnoreEvent(e,n))eL("SyncMapItem ",e," update skipped, current:",this.lastEventId,", remote:",n);else{this._updateRootDateUpdated(a);var c=this.cache.get(e);if(!c){var l=new OU({key:e,url:t,last_event_id:n,revision:r,data:i,date_updated:a,date_expires:o});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,s)}var f=VM(c.data);c.update(n,r,i,a),this.cache.store(e,c,n),void 0!==o&&c.updateDateExpires(o),this.emitItemMutationEvent(c,u,!1,f)}}},{key:"emitItemMutationEvent",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=n?"itemAdded":"itemUpdated",a={item:e,isLocal:!t};n||(a.previousItemData=r),this.broadcastEventToListeners(i,a)}},{key:"_handleItemRemoved",value:function(e,t,n,r,i){this._updateRootDateUpdated(r),this.cache.delete(e,t),this.broadcastEventToListeners("itemRemoved",{key:e,isLocal:!i,previousItemData:n})}},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}},{key:"setTtl",value:(r=yM.default(SM.default.mark((function e(t){var n,r;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={ttl:t},e.next=4,this.services.network.post(this.uri,n);case 4:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),404===e.t0.status&&this.onRemoved(!1),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=yM.default(SM.default.mark((function e(t,n){var r,i,a;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return r=e.sent,i={ttl:n},e.next=6,this.services.network.post(r.uri,i);case 6:a=e.sent,r.updateDateExpires(a.body.date_expires);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeMap",value:(t=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}],[{key:"type",get:function(){return"map"}}]),h}(rU),RU=function(e){wM.default(f,e);var t,n,r,i,a,o,s,u,c,l=EU(f);function f(e){var t;return mM.default(this,f),t=l.call(this),_M.default(bM.default(t),"syncMapImpl",void 0),t.syncMapImpl=e,t.syncMapImpl.attach(bM.default(t)),t}return gM.default(f,[{key:"uri",get:function(){return this.syncMapImpl.uri}},{key:"links",get:function(){return this.syncMapImpl.links}},{key:"revision",get:function(){return this.syncMapImpl.revision}},{key:"lastEventId",get:function(){return this.syncMapImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncMapImpl.dateExpires}},{key:"type",get:function(){return TU.type}},{key:"sid",get:function(){return this.syncMapImpl.sid}},{key:"uniqueName",get:function(){return this.syncMapImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncMapImpl.dateUpdated}},{key:"set",value:(c=yM.default(SM.default.mark((function e(t,n,r){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.set(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return c.apply(this,arguments)})},{key:"get",value:(u=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.get(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"mutate",value:(s=yM.default(SM.default.mark((function e(t,n,r){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.mutate(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return s.apply(this,arguments)})},{key:"update",value:(o=yM.default(SM.default.mark((function e(t,n,r){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.update(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return o.apply(this,arguments)})},{key:"remove",value:(a=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.remove(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getItems",value:(i=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.getItems(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setTtl",value:(r=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=yM.default(SM.default.mark((function e(t,n){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.setItemTtl(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeMap",value:(t=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.next=3,this.syncMapImpl.removeMap();case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){BM.default(xM.default(f.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return TU.type}}]),f}(sU);function IU(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=xM.default(e);if(t){var i=xM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return kM.default(this,n)}}_M.default(RU,"itemAdded","itemAdded"),_M.default(RU,"itemUpdated","itemUpdated"),_M.default(RU,"itemRemoved","itemRemoved"),_M.default(RU,"removed","removed"),WM([VA.validateTypesAsync("string",VA.pureObject,["undefined",VA.objectSchema("item metadata",{ttl:[VA.nonNegativeInteger,"undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[String,Object,Object]),$M("design:returntype",Promise)],RU.prototype,"set",null),WM([VA.validateTypesAsync("string"),$M("design:type",Function),$M("design:paramtypes",[String]),$M("design:returntype",Promise)],RU.prototype,"get",null),WM([VA.validateTypesAsync("string","function",["undefined",VA.objectSchema("item metadata",{ttl:[VA.nonNegativeInteger,"undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[String,Function,Object]),$M("design:returntype",Promise)],RU.prototype,"mutate",null),WM([VA.validateTypesAsync("string",VA.pureObject,["undefined",VA.objectSchema("item metadata",{ttl:[VA.nonNegativeInteger,"undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[String,Object,Object]),$M("design:returntype",Promise)],RU.prototype,"update",null),WM([VA.validateTypesAsync("string"),$M("design:type",Function),$M("design:paramtypes",[String]),$M("design:returntype",Promise)],RU.prototype,"remove",null),WM([VA.validateTypesAsync(["undefined",VA.objectSchema("query options",{from:["string","undefined"],pageSize:[VA.custom((function(e){return[JM(e),"a positive integer"]})),"undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[Object]),$M("design:returntype",Promise)],RU.prototype,"getItems",null),WM([VA.validateTypesAsync(VA.nonNegativeInteger),$M("design:type",Function),$M("design:paramtypes",[Number]),$M("design:returntype",Promise)],RU.prototype,"setTtl",null),WM([VA.validateTypesAsync("string",VA.nonNegativeInteger),$M("design:type",Function),$M("design:paramtypes",[String,Number]),$M("design:returntype",Promise)],RU.prototype,"setItemTtl",null);var CU=function(e){wM.default(a,e);var t,n,r,i=IU(a);function a(e,t,n){var r;return mM.default(this,a),r=i.call(this,e,n),_M.default(bM.default(r),"descriptor",void 0),r.descriptor=t,r}return gM.default(a,[{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"stream"}},{key:"lastEventId",get:function(){return null}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"publishMessage",value:(r=yM.default(SM.default.mark((function e(t){var n,r,i,a;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={data:t},e.next=3,this.services.network.post(this.links.messages,n);case 3:return r=e.sent,i=r.body,a=this._handleMessagePublished(i.sid,t,!1),e.abrupt("return",a);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setTtl",value:(n=yM.default(SM.default.mark((function e(t){var n,r;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={ttl:t},e.next=4,this.services.network.post(this.uri,n);case 4:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),404===e.t0.status&&this.onRemoved(!1),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return n.apply(this,arguments)})},{key:"removeStream",value:(t=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_update",value:function(e){switch(e.type){case"stream_message_published":this._handleMessagePublished(e.message_sid,e.message_data,!0);break;case"stream_removed":this.onRemoved(!1)}}},{key:"_handleMessagePublished",value:function(e,t,n){var r={sid:e,data:t};return this.broadcastEventToListeners("messagePublished",{message:r,isLocal:!n}),r}},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}}],[{key:"type",get:function(){return"stream"}}]),a}(rU);WM([VA.validateTypesAsync(VA.pureObject),$M("design:type",Function),$M("design:paramtypes",[Object]),$M("design:returntype",Promise)],CU.prototype,"publishMessage",null),WM([VA.validateTypesAsync(VA.nonNegativeInteger),$M("design:type",Function),$M("design:paramtypes",[Number]),$M("design:returntype",Promise)],CU.prototype,"setTtl",null);var PU=function(e){wM.default(a,e);var t,n,r,i=IU(a);function a(e){var t;return mM.default(this,a),t=i.call(this),_M.default(bM.default(t),"syncStreamImpl",void 0),t.syncStreamImpl=e,t.syncStreamImpl.attach(bM.default(t)),t}return gM.default(a,[{key:"uri",get:function(){return this.syncStreamImpl.uri}},{key:"links",get:function(){return this.syncStreamImpl.links}},{key:"dateExpires",get:function(){return this.syncStreamImpl.dateExpires}},{key:"type",get:function(){return CU.type}},{key:"lastEventId",get:function(){return null}},{key:"sid",get:function(){return this.syncStreamImpl.sid}},{key:"uniqueName",get:function(){return this.syncStreamImpl.uniqueName}},{key:"publishMessage",value:(r=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.publishMessage(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setTtl",value:(n=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"removeStream",value:(t=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.removeStream());case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){BM.default(xM.default(a.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return CU.type}}]),a}(sU);_M.default(PU,"messagePublished","messagePublished"),_M.default(PU,"removed","removed"),WM([VA.validateTypesAsync(VA.pureObject),$M("design:type",Function),$M("design:paramtypes",[Object]),$M("design:returntype",Promise)],PU.prototype,"publishMessage",null),WM([VA.validateTypesAsync(VA.nonNegativeInteger),$M("design:type",Function),$M("design:paramtypes",[Number]),$M("design:returntype",Promise)],PU.prototype,"setTtl",null);var jU=gM.default((function e(t){mM.default(this,e),_M.default(this,"sdk",void 0),_M.default(this,"sdkVer",void 0),_M.default(this,"os",void 0),_M.default(this,"osVer",void 0),_M.default(this,"pl",void 0),_M.default(this,"plVer",void 0),this.sdk="js",this.sdkVer=t,this.os=zM.os.family,this.osVer=zM.os.version,this.pl=zM.name,this.plVer=zM.version})),AU=function(){function e(){mM.default(this,e),_M.default(this,"names",void 0),_M.default(this,"entities",void 0),this.names=new Map,this.entities=new Map}return gM.default(e,[{key:"store",value:function(e){var t=this.entities.get(e.sid);return t||(this.entities.set(e.sid,e),e.uniqueName&&this.names.set(e.type+"::"+e.uniqueName,e.sid),e)}},{key:"getResolved",value:function(e,t){var n=this.names.get(t+"::"+e);return n?this.entities.get(n):null}},{key:"get",value:function(e,t){return this.entities.get(e)||this.getResolved(e,t)||null}},{key:"remove",value:function(e){var t=this.entities.get(e);t&&(this.entities.delete(e),t.uniqueName&&this.names.delete(t.type+"::"+t.uniqueName))}}]),e}();function MU(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=xM.default(e);if(t){var i=xM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return kM.default(this,n)}}var LU=gM.default((function e(){mM.default(this,e),_M.default(this,"key",void 0),_M.default(this,"value",void 0)})),UU=function(e){wM.default(n,e);var t=MU(n);function n(e,r,i,a){var o;return mM.default(this,n),o=t.call(this,r,i),_M.default(bM.default(o),"descriptor",void 0),_M.default(bM.default(o),"cache",void 0),o.descriptor=e,o.cache=new kU,a&&a.forEach((function(e){o.cache.store(e.key,{key:e.key,value:e.data},e.revision)})),o}return gM.default(n,[{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return null}},{key:"type",get:function(){return n.type}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"indexName",get:function(){return this.descriptor.indexName}},{key:"queryString",get:function(){return this.descriptor.queryExpression}},{key:"queryUri",get:function(){return this.descriptor.queryUri}},{key:"liveQueryDescriptor",get:function(){return this.descriptor}},{key:"onRemoved",value:function(){}},{key:"getItems",value:function(){var e={};return this.cache.forEach((function(t,n){e[t]=n.value})),e}},{key:"_update",value:function(e,t){switch(e.type){case"live_query_item_updated":this.handleItemMutated(e.item_key,e.item_data,e.item_revision);break;case"live_query_item_removed":this.handleItemRemoved(e.item_key,e.item_revision);break;case"live_query_updated":this.handleBatchUpdate(e.items)}t&&this._advanceLastEventId(e.last_event_id)}},{key:"handleItemMutated",value:function(e,t,n){if(this.shouldIgnoreEvent(e,n))eL("Item ".concat(e," update skipped, revision: ").concat(n));else{var r={key:e,value:t};this.cache.store(e,r,n),this.broadcastEventToListeners("itemUpdated",r)}}},{key:"handleItemRemoved",value:function(e,t){var n=null===t;this.shouldIgnoreEvent(e,t)?eL("Item ".concat(e," delete skipped, revision: ").concat(t)):(this.cache.delete(e,t,n),this.broadcastEventToListeners("itemRemoved",{key:e}))}},{key:"handleBatchUpdate",value:function(e){var t=this,n={};for(var r in null!=e&&e.forEach((function(e){n[e.key]={data:e.data,revision:e.revision}})),this.cache.forEach((function(e,r){var i=n[e];null!=i?t.handleItemMutated(e,i.data,i.revision):t.handleItemRemoved(e,null),delete n[e]})),n)this.handleItemMutated(r,n[r].data,n[r].revision)}},{key:"shouldIgnoreEvent",value:function(e,t){return null!=e&&null!=t&&this.cache.isKnown(e,t)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e)}}],[{key:"type",get:function(){return"live_query"}}]),n}(rU);function NU(e){return FU.apply(this,arguments)}function FU(){return FU=yM.default(SM.default.mark((function e(t){var n,r,i,a,o,s;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.network,r=t.queryString,i=t.uri,a=t.type,null!=r){e.next=3;break}throw new SyncError("Invalid query",400,54507);case 3:return o={query_string:r},a===DU.type&&(o.type=a),e.next=7,n.post(i,o,void 0,!0);case 7:return s=e.sent,e.abrupt("return",s.body);case 9:case"end":return e.stop()}}),e)}))),FU.apply(this,arguments)}var DU=function(e){wM.default(n,e);var t=MU(n);function n(e){var r;return mM.default(this,n),r=t.call(this),_M.default(bM.default(r),"liveQueryImpl",void 0),r.liveQueryImpl=e,r.liveQueryImpl.attach(bM.default(r)),r}return gM.default(n,[{key:"type",get:function(){return UU.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){BM.default(xM.default(n.prototype),"close",this).call(this),this.liveQueryImpl.detach(this.listenerUuid)}},{key:"getItems",value:function(){return this.ensureNotClosed(),this.liveQueryImpl.getItems()}}],[{key:"type",get:function(){return UU.type}}]),n}(sU);_M.default(DU,"itemUpdated","itemUpdated"),_M.default(DU,"itemRemoved","itemRemoved");var qU=function(e){wM.default(i,e);var t,n,r=MU(i);function i(e){var t;return mM.default(this,i),t=r.call(this),_M.default(bM.default(t),"indexName",void 0),_M.default(bM.default(t),"queryUri",void 0),_M.default(bM.default(t),"insightsUri",void 0),_M.default(bM.default(t),"liveQueryCreator",void 0),_M.default(bM.default(t),"network",void 0),_M.default(bM.default(t),"queryExpression",null),_M.default(bM.default(t),"items",{}),Object.assign(bM.default(t),e),t.updateIndexName(e.indexName),t}return gM.default(i,[{key:"type",get:function(){return i.type}},{key:"search",value:(n=yM.default(SM.default.mark((function e(t){var n=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.items={},e.abrupt("return",NU({network:this.network,uri:this.queryUri,queryString:t}).then((function(e){n.queryExpression=t,e.items&&e.items.forEach((function(e){n.items[e.key]=e.data})),n.emit("searchResult",n.getItems())})).catch((function(e){throw nL("Error '".concat(e.message,"' while executing query '").concat(t,"'")),n.queryExpression=null,e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"subscribe",value:(t=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=this.queryExpression){e.next=2;break}return e.abrupt("return",Promise.reject(new SyncError("Invalid query",400,54507)));case 2:return e.abrupt("return",this.liveQueryCreator(this.indexName,this.queryExpression));case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getItems",value:function(){return this.items}},{key:"updateIndexName",value:function(e){this.indexName=e,this.queryUri=this.generateQueryUri(this.indexName)}},{key:"generateQueryUri",value:function(e){return new KM(this.insightsUri).pathSegment(e).pathSegment("Items").build()}}],[{key:"type",get:function(){return"instant_query"}}]),i}(dM.ReplayEventEmitter);_M.default(qU,"searchResult","searchResult"),WM([VA.validateTypesAsync("string"),$M("design:type",Function),$M("design:paramtypes",[String]),$M("design:returntype",Promise)],qU.prototype,"search",null),WM([VA.validateTypes(VA.nonEmptyString),$M("design:type",Function),$M("design:paramtypes",[String]),$M("design:returntype",void 0)],qU.prototype,"updateIndexName",null);function BU(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=xM.default(e);if(t){var i=xM.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return kM.default(this,n)}}function zU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function WU(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?zU(Object(n),!0).forEach((function(t){_M.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zU(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var $U="data_sync",KU="4.0.0-rc.1";function HU(e){if(e){if("string"==typeof e)return{id:e,mode:"open_or_create"};var t=e.mode||(e.id?"open_or_create":"create_new");return WU(WU({},e),{},{mode:t})}return{mode:"create_new"}}var Client=function(e){wM.default(Client,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v,y=BU(Client);function Client(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(mM.default(this,Client),n=y.call(this),_M.default(bM.default(n),"services",void 0),_M.default(bM.default(n),"entities",void 0),_M.default(bM.default(n),"_currentState","disconnected"),!e)throw new Error("Sync library needs a valid Twilio token to be passed");r.hasOwnProperty("logLevel")?ZM(r.logLevel):ZM("silent");var i=r.productId=r.productId||$U;r.clientMetadata=r.clientMetadata||{},r.clientMetadata.hasOwnProperty("type")||(r.clientMetadata.type="sync"),r.clientMetadata.hasOwnProperty("sdk")||(r.clientMetadata.sdk="JS",r.clientMetadata.sdkv=KU);var a=!r.twilsockClient;if(!r.initRegistrations){var o=new YA.InitRegistration(i);Client.populateInitRegistrations(o),r.initRegistrations=[o]}var s=r.twilsockClient=null!==(t=r.twilsockClient)&&void 0!==t?t:new YA.TwilsockClient(e,i,r);s.on("tokenAboutToExpire",(function(){return n.emit("tokenAboutToExpire")})),s.on("tokenExpired",(function(){return n.emit("tokenExpired")})),s.on("connecting",(function(){n._currentState="connecting",n.emit("connectionStateChanged","connecting"),n.services.subscriptions.onConnectionStateChanged(!1)})),s.on("connected",(function(){n._currentState="connected",n.emit("connectionStateChanged","connected"),n.services.subscriptions.onConnectionStateChanged(!0)})),s.on("disconnected",(function(){n._currentState="disconnected",n.emit("connectionStateChanged","disconnected"),n.services.subscriptions.onConnectionStateChanged(!1)})),s.on("targetedMessageReceived",(function(e,t){return n._routeMessage(e,JSON.parse(t))}));var u=new lL(r),c=new ZL(new jU(KU),u,s),l=new eU(u);return n.services={config:u,twilsock:s,network:c,storage:l,router:bM.default(n),subscriptions:null},n.services.subscriptions=new VL(n.services),n.entities=new AU,a&&s.connect(),n}return gM.default(Client,[{key:"_routeMessage",value:function(e,t){switch(eL("Notification type:",e,"content:",t),e){case"com.twilio.rtd.cds.document":case"com.twilio.rtd.cds.list":case"com.twilio.rtd.cds.map":this.services.subscriptions.acceptMessage(t,!1);break;case"twilio.sync.event":this.services.subscriptions.acceptMessage(t,!0)}}},{key:"_subscribe",value:function(e,t){this.services.subscriptions.add(e,t)}},{key:"_unsubscribe",value:function(e){this.services.subscriptions.remove(e)}},{key:"connectionState",get:function(){return this._currentState}},{key:"ensureReady",value:(v=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.services.config.sessionStorageEnabled){e.next=2;break}return e.abrupt("return");case 2:case 3:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"storeRootInSessionCache",value:function(e,t,n){if(this.services.config.sessionStorageEnabled&&t){var r=VM(n);e!==SU.type&&e!==RU.type||(r.last_event_id=null,delete r.items),this.services.storage.store(e,t,r)}}},{key:"readRootFromSessionCache",value:function(e,t){return this.services.config.sessionStorageEnabled&&t?this.services.storage.read(e,t):null}},{key:"_get",value:(h=yM.default(SM.default.mark((function e(t,n){var r,i,a,o=arguments;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=o.length>2&&void 0!==o[2]&&o[2],n){e.next=3;break}throw new SyncError("Cannot get entity without id",404);case 3:return i=new KM(t).pathSegment(n).queryParam("Include",r?"items":void 0).build(),e.next=6,this.services.network.get(i);case 6:return a=e.sent,e.abrupt("return",a.body);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"_createDocument",value:function(e,t,n){var r={unique_name:e,data:t||{}};return void 0!==n&&(r.ttl=n),this.services.network.post(this.services.config.documentsUri,r).then((function(e){return e.body.data=r.data,e.body}))}},{key:"_getDocument",value:(p=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(lU.type,t)||this._get(this.services.config.documentsUri,t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"_createList",value:function(e,t,n,r){var i={unique_name:e,purpose:t,context:n};return void 0!==r&&(i.ttl=r),this.services.network.post(this.services.config.listsUri,i).then((function(e){return e.body}))}},{key:"_getList",value:(d=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(SU.type,t)||this._get(this.services.config.listsUri,t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"_createMap",value:function(e,t){var n={unique_name:e};return void 0!==t&&(n.ttl=t),this.services.network.post(this.services.config.mapsUri,n).then((function(e){return e.body}))}},{key:"_getMap",value:(f=yM.default(SM.default.mark((function e(t){var n,r=arguments;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.length>1&&void 0!==r[1]&&r[1],e.abrupt("return",this.readRootFromSessionCache(RU.type,t)||this._get(this.services.config.mapsUri,t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"_getStream",value:(l=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(PU.type,t)||this._get(this.services.config.streamsUri,t,!1));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"_createStream",value:(c=yM.default(SM.default.mark((function e(t,n){var r,i;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={unique_name:t},void 0!==n&&(r.ttl=n),e.next=4,this.services.network.post(this.services.config.streamsUri,r);case 4:return i=e.sent,e.abrupt("return",i.body);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"_getLiveQuery",value:function(e){return this.readRootFromSessionCache(DU.type,e)}},{key:"getCached",value:function(e,t){return e&&this.entities.get(e,t)||null}},{key:"removeFromCacheAndSession",value:function(e,t,n){this.entities.remove(t),this.services.config.sessionStorageEnabled&&this.services.storage.remove(e,t,n)}},{key:"document",value:(u=yM.default(SM.default.mark((function e(t){var n,r,i,a,o=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=HU(t)).mode){e.next=9;break}return e.next=6,this._createDocument(n.id,n.data,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,lU.type))){e.next=14;break}return e.abrupt("return",new lU(i));case 14:return e.prev=14,e.next=17,this._getDocument(n.id);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createDocument(n.id,n.data,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.document(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(lU.type,n.id,r),a=new cU(this.services,r,(function(e,t,n){return o.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new lU(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return u.apply(this,arguments)})},{key:"map",value:(s=yM.default(SM.default.mark((function e(t){var n,r,i,a,o=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=HU(t)).mode){e.next=9;break}return e.next=6,this._createMap(n.id,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,RU.type))){e.next=14;break}return e.abrupt("return",new RU(i));case 14:return e.prev=14,e.next=17,this._getMap(n.id,n.includeItems);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createMap(n.id,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.map(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(RU.type,n.id,r),a=new TU(this.services,r,(function(e,t,n){return o.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new RU(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return s.apply(this,arguments)})},{key:"list",value:(o=yM.default(SM.default.mark((function e(t){var n,r,i,a,o=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=HU(t)).mode){e.next=9;break}return e.next=6,this._createList(n.id,n.purpose,n.context,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,SU.type))){e.next=14;break}return e.abrupt("return",new SU(i));case 14:return e.prev=14,e.next=17,this._getList(n.id);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createList(n.id,n.purpose,n.context,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.list(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(SU.type,n.id,r),a=new _U(this.services,r,(function(e,t,n){return o.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new SU(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return o.apply(this,arguments)})},{key:"stream",value:(a=yM.default(SM.default.mark((function e(t){var n,r,i,a,o,s=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=HU(t)).mode){e.next=9;break}return e.next=6,this._createStream(n.id,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,PU.type))){e.next=14;break}return e.abrupt("return",new PU(i));case 14:return e.prev=14,e.next=17,this._getStream(n.id);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createStream(n.id,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.stream(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(PU.type,n.id,r),a=function(e,t,n){return s.removeFromCacheAndSession(e,t,n)},o=new CU(this.services,r,a),o=this.entities.store(o),e.abrupt("return",new PU(o));case 44:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return a.apply(this,arguments)})},{key:"shutdown",value:(i=yM.default(SM.default.mark((function e(){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.subscriptions.shutdown();case 2:return e.next=4,this.services.network.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"updateToken",value:(r=yM.default(SM.default.mark((function e(t){return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.services.twilsock.updateToken(t).catch((function(e){if(e instanceof $L&&401===e.errorInfo.status)throw new SyncError("Updated token was rejected by server",400,51130);throw e})));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"liveQuery",value:(n=yM.default(SM.default.mark((function e(t,n){var r,i,a,o,s,u=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:return r=new KM(this.services.config.insightsUri).pathSegment(t).pathSegment("Items").build(),e.next=5,NU({network:this.services.network,uri:r,queryString:n,type:DU.type});case 5:return i=e.sent,(a=this.getCached(i.query_id,DU.type))||((o=this._getLiveQuery(i.query_id))||(o={indexName:t,queryExpression:n,sid:i.query_id,queryUri:r,last_event_id:i.last_event_id}),s=function(e,t,n){return u.removeFromCacheAndSession(e,t,n)},a=new UU(o,this.services,s,i.items)),this.storeRootInSessionCache(DU.type,i.query_id,a.liveQueryDescriptor),a=this.entities.store(a),e.abrupt("return",new DU(a));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"instantQuery",value:(t=yM.default(SM.default.mark((function e(t){var n,r=this;return SM.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:return n=function(e,t){return r.liveQuery(e,t)},e.abrupt("return",new qU({indexName:t,network:this.services.network,insightsUri:this.services.config.insightsUri,liveQueryCreator:n}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}],[{key:"populateInitRegistrations",value:function(e){}},{key:"version",get:function(){return KU}}]),Client}(dM.ReplayEventEmitter);_M.default(Client,"connectionStateChanged","connectionStateChanged"),_M.default(Client,"connectionError","connectionError"),_M.default(Client,"tokenAboutToExpire","tokenAboutToExpire"),_M.default(Client,"tokenExpired","tokenExpired"),WM([VA.validateTypesAsync(["undefined","string",VA.objectSchema("open document options",{id:["string","undefined"],mode:[VA.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[VA.nonNegativeInteger,"undefined"],data:[VA.pureObject,"undefined",VA.literal(null)]})]),$M("design:type",Function),$M("design:paramtypes",[Object]),$M("design:returntype",Promise)],Client.prototype,"document",null),WM([VA.validateTypesAsync(["undefined","string",VA.objectSchema("open map options",{id:["string","undefined"],mode:[VA.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[VA.nonNegativeInteger,"undefined"],data:[VA.pureObject,"undefined",VA.literal(null)],includeItems:["boolean","undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[Object]),$M("design:returntype",Promise)],Client.prototype,"map",null),WM([VA.validateTypesAsync(["undefined","string",VA.objectSchema("open list options",{id:["string","undefined"],mode:[VA.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[VA.nonNegativeInteger,"undefined"],data:[VA.pureObject,"undefined",VA.literal(null)],purpose:["string","undefined"],context:[VA.pureObject,"undefined"],includeItems:["boolean","undefined"]})]),$M("design:type",Function),$M("design:paramtypes",[Object]),$M("design:returntype",Promise)],Client.prototype,"list",null),WM([VA.validateTypesAsync(["undefined","string",VA.objectSchema("open stream options",{id:["string","undefined"],mode:[VA.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[VA.nonNegativeInteger,"undefined"],data:[VA.pureObject,"undefined",VA.literal(null)]})]),$M("design:type",Function),$M("design:paramtypes",[Object]),$M("design:returntype",Promise)],Client.prototype,"stream",null),WM([VA.validateTypesAsync(VA.nonEmptyString),$M("design:type",Function),$M("design:paramtypes",[String]),$M("design:returntype",Promise)],Client.prototype,"updateToken",null),WM([VA.validateTypesAsync(VA.nonEmptyString,"string"),$M("design:type",Function),$M("design:paramtypes",[String,String]),$M("design:returntype",Promise)],Client.prototype,"liveQuery",null),WM([VA.validateTypesAsync(VA.nonEmptyString),$M("design:type",Function),$M("design:paramtypes",[String]),$M("design:returntype",Promise)],Client.prototype,"instantQuery",null),RA.Client=Client,RA.InsightsItem=LU,RA.InstantQuery=qU,RA.LiveQuery=DU,RA.Paginator=Paginator;var GU=RA.SyncClient=Client;RA.SyncDocument=lU,RA.SyncList=SU,RA.SyncListItem=dU,RA.SyncMap=RU,RA.SyncMapItem=OU,RA.SyncStream=PU;var VU={},YU=we,JU=Fe,QU=j,XU=lr,ZU=TypeError,eN=function(e){return function(t,n,r,i){YU(n);var a=JU(t),o=QU(a),s=XU(a),u=e?s-1:0,c=e?-1:1;if(r<2)for(;;){if(u in o){i=o[u],u+=c;break}if(u+=c,e?u<0:s<=u)throw ZU("Reduce of empty array with no initial value")}for(;e?u>=0:s>u;u+=c)u in o&&(i=n(i,o[u],u,a));return i}},tN={left:eN(!1),right:eN(!0)},nN=tN.left,rN=ae,iN=vc;Zr({target:"Array",proto:!0,forced:!Rp("reduce")||!iN&&rN>79&&rN<83},{reduce:function(e){var t=arguments.length;return nN(this,e,t,t>1?arguments[1]:void 0)}});var aN=li,oN=f,sN=_,uN=Fg,cN=Lt,lN=A,fN=_R,dN=U,pN=Lc,hN=qg,vN=ur,yN=Ba,mN=_e,gN=Xa,bN=tb,wN=Ig,kN=o,xN=ng.UNSUPPORTED_Y,_N=4294967295,SN=Math.min,ON=[].push,EN=sN(/./.exec),TN=sN(ON),RN=sN("".slice),IN=!kN((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]}));function CN(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}uN("split",(function(e,t,n){var r;return r="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(e,n){var r=yN(dN(this)),i=void 0===n?_N:n>>>0;if(0===i)return[];if(void 0===e)return[r];if(!fN(e))return oN(t,r,e,i);for(var a,o,s,u=[],c=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),l=0,f=new RegExp(e.source,c+"g");(a=oN(wN,f,r))&&!((o=f.lastIndex)>l&&(TN(u,RN(r,l,a.index)),a.length>1&&a.index<r.length&&aN(ON,u,gN(a,1)),s=a[0].length,l=o,u.length>=i));)f.lastIndex===a.index&&f.lastIndex++;return l===r.length?!s&&EN(f,"")||TN(u,""):TN(u,RN(r,l)),u.length>i?gN(u,0,i):u}:"0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:oN(t,this,e,n)}:t,[function(t,n){var i=dN(this),a=lN(t)?void 0:mN(t,e);return a?oN(a,t,i,n):oN(r,yN(i),t,n)},function(e,i){var a=cN(this),o=yN(e),s=n(r,a,o,i,r!==t);if(s.done)return s.value;var u=pN(a,RegExp),c=a.unicode,l=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.unicode?"u":"")+(xN?"g":"y"),f=new u(xN?"^(?:"+a.source+")":a,l),d=void 0===i?_N:i>>>0;if(0===d)return[];if(0===o.length)return null===bN(f,o)?[o]:[];for(var p=0,h=0,v=[];h<o.length;){f.lastIndex=xN?0:h;var y,m=bN(f,xN?RN(o,h):o);if(null===m||(y=SN(vN(f.lastIndex+(xN?h:0)),o.length))===p)h=hN(o,h,c);else{if(TN(v,RN(o,p,h)),v.length===d)return v;for(var g=1;g<=m.length-1;g++)if(TN(v,m[g]),v.length===d)return v;h=p=y}}return TN(v,RN(o,p)),v}]}),!IN,xN),function(e){var t=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Object.defineProperty(e,"__esModule",{value:!0});var n=HS,r=$S.exports,i=vx.exports,a=KS,o=fy.exports,s=oS,u=qb;function c(e){return e&&"object"===tc(e)&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var f=c(r),d=c(i),p=c(a),h=l(o);function v(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":tc(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function y(e,t){if("object"===("undefined"==typeof Reflect?"undefined":tc(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function m(e,t){return["".concat((new Date).toISOString()," MCS Client ").concat(e,":")].concat(Array.from(t))}var g=function(){function e(t){sc(this,e),d.default(this,"prefix",""),this.prefix=null!=t&&t.length>0?t+" ":""}return oc(e,[{key:"setLevel",value:function(e){h.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.trace.apply(null,m(this.prefix+"T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.debug.apply(null,m(this.prefix+"D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.info.apply(null,m(this.prefix+"I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.warn.apply(null,m(this.prefix+"W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.error.apply(null,m(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){h.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.trace.apply(null,m("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.debug.apply(null,m("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.info.apply(null,m("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.warn.apply(null,m("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];h.error.apply(null,m("E",t))}}]),e}(),b=function(e,t){return"".concat((n=e,n.startsWith("http")?"":function(e){return"https://mcs.".concat(null!=e?e:"us1",".twilio.com")}(t))).concat(e);var n},w=function(){function e(t,n,r,i){var a,o,s,u,c,l;sc(this,e),d.default(this,"token",void 0),d.default(this,"retryWhenThrottledOverride",void 0),d.default(this,"backoffConfigOverride",void 0),d.default(this,"mediaUrl",void 0),d.default(this,"mediaSetUrl",void 0),d.default(this,"region",void 0);var f=null!==(a=null!==(o=i.MCS)&&void 0!==o?o:i)&&void 0!==a?a:{};this.region=null!==(s=null!==(u=f.region)&&void 0!==u?u:i.region)&&void 0!==s?s:"us1",this.mediaUrl=b(n,this.region),this.mediaSetUrl=r?b(r):"".concat(this.mediaUrl,"Set"),this.token=t,this.retryWhenThrottledOverride=null===(c=f.retryWhenThrottledOverride)||void 0===c||c,this.backoffConfigOverride=null!==(l=f.backoffConfigOverride)&&void 0!==l?l:e.backoffConfigDefault}return oc(e,[{key:"updateToken",value:function(e){this.token=e}}],[{key:"backoffConfigDefault",get:function(){return{min:1e3,max:4e3,maxAttemptsCount:3}}},{key:"retryWhenThrottledDefault",get:function(){return true}}]),e}(),Media=function(){function Media(e,t,n){sc(this,Media),d.default(this,"state",void 0),d.default(this,"network",void 0),d.default(this,"config",void 0),this.config=e,this.network=t,this._update(n)}return oc(Media,[{key:"sid",get:function(){return this.state.sid}},{key:"serviceSid",get:function(){return this.state.serviceSid}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"fileName",get:function(){return this.state.filename}},{key:"filename",get:function(){return this.state.filename}},{key:"category",get:function(){return this.state.category}},{key:"getContentUrl",value:function(){var e=this;return new n.CancellablePromise(function(){var t=f.default(p.default.mark((function t(n,r,i){var a,o;return p.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.network.get("".concat(e.config.mediaUrl,"/").concat(e.sid)),i((function(){return a.cancel()})),t.prev=2,t.next=5,a;case 5:o=t.sent,e._update(o.body),n(e.state.contentDirectUrl),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),r(t.t0);case 13:case"end":return t.stop()}}),t,null,[[2,10]])})));return function(e,n,r){return t.apply(this,arguments)}}())}},{key:"_update",value:function(e){var t,n,r,i;this.state={sid:e.sid,serviceSid:e.service_sid,channelSid:e.channel_sid,messageSid:e.message_sid,dateCreated:e.date_created?new Date(e.date_created):null,dateUploadUpdated:e.date_upload_updated?new Date(e.date_upload_updated):null,dateUpdated:e.date_updated?new Date(e.date_updated):null,size:e.size,contentType:e.content_type,author:e.author,url:e.url,contentUrl:e.links.content,contentDirectUrl:null!==(t=e.links.content_direct_temporary)&&void 0!==t?t:null,filename:null!==(n=e.filename)&&void 0!==n?n:null,category:null!==(r=e.category)&&void 0!==r?r:"media",isMultipartUpstream:null!==(i=e.is_multipart_upstream)&&void 0!==i&&i}}}]),Media}(),k=function(e){ec(n,e);var t=CN(n);function n(e,r,i,a,o){var s;return sc(this,n),s=t.call(this,e),d.default(Xu(s),"code",void 0),d.default(Xu(s),"body",void 0),d.default(Xu(s),"status",void 0),d.default(Xu(s),"headers",void 0),s.code=r,s.body=i,s.status=a,s.headers=o,s}return oc(n)}($T(Error)),x=t.XMLHttpRequest||{};var _,S=function(){function e(){sc(this,e)}return oc(e,[{key:"get",value:function(t,n){return e.request("GET",t,n)}},{key:"post",value:function(t,n,r){return e.request("POST",t,n,r)}}],[{key:"request",value:function(e,t,r,i){return new n.CancellablePromise((function(n,a,o){var s=new x,u=!1;for(var c in o((function(){s.abort(),u=!0})),s.open(e,t,!0),s.onreadystatechange=function(){if(4===s.readyState&&!u){var e,t=(e=s.getAllResponseHeaders())?e.split("\r\n").map((function(e){return e.split(": ")})).filter((function(e){return 2===e.length&&e[1].length>0})).reduce((function(e,t){return e[t[0]]=t[1],e}),{}):{},r=function(e){var t=e.getResponseHeader("Content-Type");if(!t||0!==t.indexOf("application/json")||0===e.responseText.length)return e.responseText;try{return JSON.parse(e.responseText)}catch(t){return e.responseText}}(s);if(200<=s.status&&s.status<300)n({status:s.status,headers:t,body:r});else{var i,o,c=null!==(i=s.statusText)&&void 0!==i?i:"NONE";if("string"==typeof r)if(r&&1===r.split("\n",2).length)o=r;else{var l,f=null===(l=r.replace(/<.*?>/g,"").split(/\r\n/g).filter((function(e){return e.length}))[0])||void 0===l?void 0:l.split(" ");o=(null==f?void 0:f.length)>2?null==f?void 0:f.slice(1).join(" "):""}else o=JSON.stringify(r);var d="".concat(s.status,": [").concat(c,"] ").concat(o);a(new k(d,s.status,r,c,t))}}},r)s.setRequestHeader(c,r[c]),"Content-Type"===c&&"application/json"===r[c]&&(i=JSON.stringify(i));s.send(i)}))}}]),e}(),O=g.scope("Network"),E=function(){function e(t,n){sc(this,e),d.default(this,"config",void 0),d.default(this,"transport",void 0),this.config=t,this.transport=n}return oc(e,[{key:"backoffConfig",value:function(){return Object.assign(w.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var e,t;return null!==(e=null!==(t=this.config.retryWhenThrottledOverride)&&void 0!==t?t:w.retryWhenThrottledDefault)&&void 0!==e&&e}},{key:"executeWithRetry",value:function(e,t){var r=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(i,a,o){var u,c;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:u=new s.Retrier(r.backoffConfig()),c=[502,503,504],t&&c.push(429),o((function(){u.cancel(),u.removeAllListeners()})),u.on("attempt",f.default(p.default.mark((function t(){var n,r;return p.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n=e(),o((function(){n.cancel(),u.cancel(),u.removeAllListeners()})),t.next=5,n;case 5:r=t.sent,u.succeeded(r),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(0),c.indexOf(t.t0.status)>-1||"Twilsock disconnected"===t.t0.message?u.failed(t.t0):(u.removeAllListeners(),u.cancel(),a(t.t0));case 12:case"end":return t.stop()}}),t,null,[[0,9]])})))),u.on("succeeded",(function(e){i(e)})),u.on("cancelled",(function(e){return a(e)})),u.on("failed",(function(e){return a(e)})),u.start();case 9:case"end":return n.stop()}}),n)})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"get",value:function(e){var t=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(r,i,a){var o,s,u;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o={"X-Twilio-Token":t.config.token},s=t.executeWithRetry((function(){return t.transport.get(e,o)}),t.retryWhenThrottled()),O.trace("sending GET request to ",e," headers ",o),a((function(){return s.cancel()})),n.prev=4,n.next=7,s;case 7:u=n.sent,O.trace("response",u),r(u),n.next=16;break;case 12:n.prev=12,n.t0=n.catch(4),O.debug("get() error ".concat(n.t0)),i(n.t0);case 16:case"end":return n.stop()}}),n,null,[[4,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"post",value:function(e,r,i,a,o){var s=this,u={"X-Twilio-Token":this.config.token};"undefined"!=typeof FormData&&i instanceof FormData||!a||Object.assign(u,{"Content-Type":a});var c=new URL(e);return r&&c.searchParams.append("Category",r),o&&c.searchParams.append("Filename",o),new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(r,a,o){var l,f;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return l=s.transport.post(c.href,u,i),o((function(){return l.cancel()})),O.trace("sending POST request to ".concat(e," with headers ").concat(u)),n.prev=3,n.next=6,l;case 6:f=n.sent,n.next=17;break;case 9:if(n.prev=9,n.t0=n.catch(3),!(void 0===t.XMLHttpRequest&&i instanceof FormData)){n.next=14;break}return a(new TypeError("Posting FormData supported only with browser engine's FormData")),n.abrupt("return");case 14:return O.debug("post() error ".concat(n.t0)),a(n.t0),n.abrupt("return");case 17:O.trace("response",f),r(f);case 19:case"end":return n.stop()}}),n,null,[[3,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}}]),e}(),T=g.scope("");e.default=(_=function(){function Client(e,t,n){var r,i;sc(this,Client);var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};d.default(this,"transport",void 0),d.default(this,"options",void 0),d.default(this,"network",void 0),d.default(this,"config",void 0),this.options=a,this.options.logLevel=null!==(r=this.options.logLevel)&&void 0!==r?r:"silent",this.config=new w(e,t,n,this.options),T.setLevel(this.options.logLevel),this.options.transport=null!==(i=this.options.transport)&&void 0!==i?i:new S,this.transport=this.options.transport,this.network=new E(this.config,this.transport)}return oc(Client,[{key:"updateToken",value:function(e){T.info("updateToken"),this.config.updateToken(e)}},{key:"get",value:function(e){var t=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(r,i,a){var o,s;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=t.network.get("".concat(t.config.mediaUrl,"/").concat(e)),a((function(){return o.cancel()})),n.prev=2,n.next=5,o;case 5:s=n.sent,r(new Media(t.config,t.network,s.body)),n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),i(n.t0);case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"post",value:function(e,t,r,i){var a=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(o,s,u){var c,l;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return c=a.network.post(a.config.mediaUrl,null!=r?r:"media",t,e,i),u((function(){return c.cancel()})),n.prev=2,n.next=5,c;case 5:l=n.sent,o(new Media(a.config,a.network,l.body)),n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),s(n.t0);case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"postFormData",value:function(e,t){var r=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(i,a,o){var s,u;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s=r.network.post(r.config.mediaUrl,null!=t?t:"media",e),o((function(){return s.cancel()})),n.prev=2,n.next=5,s;case 5:u=n.sent,i(new Media(r.config,r.network,u.body)),n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),a(n.t0);case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"mediaSetGet",value:function(e){var t=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(r,i,a){var o,s,u,c;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o={command:"get",list:e.map((function(e){return{media_sid:e}}))},s=t.network.post("".concat(t.config.mediaSetUrl),null,o,"application/json"),a((function(){return s.cancel()})),n.prev=3,n.next=6,s;case 6:u=n.sent,c=u.body.map((function(e){if(200===e.code)return new Media(t.config,t.network,e.media_record);i("Failed to obtain detailed information about Media items (failed SID ".concat(e.media_record.sid,")"))})),r(c),n.next=14;break;case 11:n.prev=11,n.t0=n.catch(3),i(n.t0);case 14:case"end":return n.stop()}}),n,null,[[3,11]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"mediaSetGetContentUrls",value:function(e){var t=this;return new n.CancellablePromise(function(){var n=f.default(p.default.mark((function n(r,i,a){var o,s,u,c;return p.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o={command:"get",list:e.map((function(e){return{media_sid:e}}))},s=t.network.post("".concat(t.config.mediaSetUrl),null,o,"application/json"),a((function(){return s.cancel()})),n.prev=3,n.next=6,s;case 6:u=n.sent,c=new Map,u.body.forEach((function(e){200===e.code?c.set(e.media_record.sid,e.media_record.links.content_direct_temporary):i("Failed to obtain detailed information about Media items (failed SID ".concat(e.media_record.sid,")"))})),r(c),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(3),i(n.t0);case 15:case"end":return n.stop()}}),n,null,[[3,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}}]),Client}(),d.default(_,"version","0.6.2-rc.1"),_),v([u.validateTypes(u.nonEmptyString),y("design:type",Function),y("design:paramtypes",[String]),y("design:returntype",void 0)],e.default.prototype,"updateToken",null),v([u.validateTypesAsync(u.nonEmptyString),y("design:type",Function),y("design:paramtypes",[String]),y("design:returntype",n.CancellablePromise)],e.default.prototype,"get",null),e.default=v([u.validateConstructorTypes(u.nonEmptyString,u.nonEmptyString,[u.nonEmptyString,u.literal(null)],[u.pureObject,"undefined"]),y("design:paramtypes",[String,String,Object,Object])],e.default),Object.defineProperty(e,"CancellablePromise",{enumerable:!0,get:function(){return n.CancellablePromise}}),e.Client=e.default,e.McsClient=e.default,e.McsMedia=Media,e.Media=Media}(VU);var PN,jN,AN,MN={exports:{}},LN=DO,UN=s,NN=i,FN=W,DN=H,qN=Be,BN=ji,zN=ye,WN=Yt,$N=Yn,KN=Ct.f,HN=Q,GN=yv,VN=xc,YN=rt,JN=He,QN=jn.enforce,XN=jn.get,ZN=NN.Int8Array,eF=ZN&&ZN.prototype,tF=NN.Uint8ClampedArray,nF=tF&&tF.prototype,rF=ZN&&GN(ZN),iF=eF&&GN(eF),aF=Object.prototype,oF=NN.TypeError,sF=YN("toStringTag"),uF=JN("TYPED_ARRAY_TAG"),cF="TypedArrayConstructor",lF=LN&&!!VN&&"Opera"!==BN(NN.opera),fF=!1,dF={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},pF={BigInt64Array:8,BigUint64Array:8},hF=function(e){var t=GN(e);if(DN(t)){var n=XN(t);return n&&qN(n,cF)?n[cF]:hF(t)}},vF=function(e){if(!DN(e))return!1;var t=BN(e);return qN(dF,t)||qN(pF,t)};for(PN in dF)(AN=(jN=NN[PN])&&jN.prototype)?QN(AN)[cF]=jN:lF=!1;for(PN in pF)(AN=(jN=NN[PN])&&jN.prototype)&&(QN(AN)[cF]=jN);if((!lF||!FN(rF)||rF===Function.prototype)&&(rF=function(){throw oF("Incorrect invocation")},lF))for(PN in dF)NN[PN]&&VN(NN[PN],rF);if((!lF||!iF||iF===aF)&&(iF=rF.prototype,lF))for(PN in dF)NN[PN]&&VN(NN[PN].prototype,iF);if(lF&&GN(nF)!==iF&&VN(nF,iF),UN&&!qN(iF,sF))for(PN in fF=!0,KN(iF,sF,{get:function(){return DN(this)?this[uF]:void 0}}),dF)NN[PN]&&WN(NN[PN],uF,PN);var yF={NATIVE_ARRAY_BUFFER_VIEWS:lF,TYPED_ARRAY_TAG:fF&&uF,aTypedArray:function(e){if(vF(e))return e;throw oF("Target is not a typed array")},aTypedArrayConstructor:function(e){if(FN(e)&&(!VN||HN(rF,e)))return e;throw oF(zN(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(UN){if(n)for(var i in dF){var a=NN[i];if(a&&qN(a.prototype,e))try{delete a.prototype[e]}catch(n){try{a.prototype[e]=t}catch(e){}}}iF[e]&&!n||$N(iF,e,n?t:lF&&eF[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(UN){if(VN){if(n)for(r in dF)if((i=NN[r])&&qN(i,e))try{delete i[e]}catch(e){}if(rF[e]&&!n)return;try{return $N(rF,e,n?t:lF&&rF[e]||t)}catch(e){}}for(r in dF)!(i=NN[r])||i[e]&&!n||$N(i,e,t)}},getTypedArrayConstructor:hF,isView:function(e){if(!DN(e))return!1;var t=BN(e);return"DataView"===t||qN(dF,t)||qN(pF,t)},isTypedArray:vF,TypedArray:rF,TypedArrayPrototype:iF},mF=i,gF=o,bF=Hd,wF=yF.NATIVE_ARRAY_BUFFER_VIEWS,kF=mF.ArrayBuffer,xF=mF.Int8Array,_F=!wF||!gF((function(){xF(1)}))||!gF((function(){new xF(-1)}))||!bF((function(e){new xF,new xF(null),new xF(1.5),new xF(e)}),!0)||gF((function(){return 1!==new xF(new kF(2),1,void 0).length})),SF=tr,OF=RangeError,EF=function(e){var t=SF(e);if(t<0)throw OF("The argument can't be less than 0");return t},TF=RangeError,RF=function(e,t){var n=EF(e);if(n%t)throw TF("Wrong offset");return n},IF=ji,CF=_("".slice),PF=ft,jF=TypeError,AF=function(e){var t=PF(e,"number");if("number"==typeof t)throw jF("Can't convert number to bigint");return BigInt(t)},MF=xo,LF=f,UF=Ji,NF=Fe,FF=lr,DF=_d,qF=yd,BF=ld,zF=function(e){return"Big"===CF(IF(e),0,3)},WF=yF.aTypedArrayConstructor,$F=AF,KF=Zr,HF=i,GF=f,VF=s,YF=_F,JF=yF,QF=nT,XF=Cc,ZF=g,eD=Yt,tD=uk,nD=ur,rD=WO,iD=RF,aD=ht,oD=Be,sD=ji,uD=H,cD=he,lD=xa,fD=Q,dD=xc,pD=Jn.f,hD=function(e){var t,n,r,i,a,o,s,u,c=UF(this),l=NF(e),f=arguments.length,d=f>1?arguments[1]:void 0,p=void 0!==d,h=qF(l);if(h&&!BF(h))for(u=(s=DF(l,h)).next,l=[];!(o=LF(u,s)).done;)l.push(o.value);for(p&&f>2&&(d=MF(d,arguments[2])),n=FF(l),r=new(WF(c))(n),i=zF(r),t=0;n>t;t++)a=p?d(l[t],t):l[t],r[t]=i?$F(a):+a;return r},vD=Do.forEach,yD=Tc,mD=Ct,gD=a,bD=cm,wD=jn.get,kD=jn.set,xD=jn.enforce,_D=mD.f,SD=gD.f,OD=Math.round,ED=HF.RangeError,TD=QF.ArrayBuffer,RD=TD.prototype,ID=QF.DataView,CD=JF.NATIVE_ARRAY_BUFFER_VIEWS,PD=JF.TYPED_ARRAY_TAG,jD=JF.TypedArray,AD=JF.TypedArrayPrototype,MD=JF.aTypedArrayConstructor,LD=JF.isTypedArray,UD="BYTES_PER_ELEMENT",ND="Wrong length",FD=function(e,t){MD(e);for(var n=0,r=t.length,i=new e(r);r>n;)i[n]=t[n++];return i},DD=function(e,t){_D(e,t,{get:function(){return wD(this)[t]}})},qD=function(e){var t;return fD(RD,e)||"ArrayBuffer"==(t=sD(e))||"SharedArrayBuffer"==t},BD=function(e,t){return LD(e)&&!cD(t)&&t in e&&tD(+t)&&t>=0},zD=function(e,t){return t=aD(t),BD(e,t)?ZF(2,e[t]):SD(e,t)},WD=function(e,t,n){return t=aD(t),!(BD(e,t)&&uD(n)&&oD(n,"value"))||oD(n,"get")||oD(n,"set")||n.configurable||oD(n,"writable")&&!n.writable||oD(n,"enumerable")&&!n.enumerable?_D(e,t,n):(e[t]=n.value,e)};VF?(CD||(gD.f=zD,mD.f=WD,DD(AD,"buffer"),DD(AD,"byteOffset"),DD(AD,"byteLength"),DD(AD,"length")),KF({target:"Object",stat:!0,forced:!CD},{getOwnPropertyDescriptor:zD,defineProperty:WD}),MN.exports=function(e,t,n){var r=e.match(/\d+$/)[0]/8,i=e+(n?"Clamped":"")+"Array",a="get"+e,o="set"+e,s=HF[i],u=s,c=u&&u.prototype,l={},f=function(e,t){_D(e,t,{get:function(){return function(e,t){var n=wD(e);return n.view[a](t*r+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var a=wD(e);n&&(i=(i=OD(i))<0?0:i>255?255:255&i),a.view[o](t*r+a.byteOffset,i,!0)}(this,t,e)},enumerable:!0})};CD?YF&&(u=t((function(e,t,n,i){return XF(e,c),bD(uD(t)?qD(t)?void 0!==i?new s(t,iD(n,r),i):void 0!==n?new s(t,iD(n,r)):new s(t):LD(t)?FD(u,t):GF(hD,u,t):new s(rD(t)),e,u)})),dD&&dD(u,jD),vD(pD(s),(function(e){e in u||eD(u,e,s[e])})),u.prototype=c):(u=t((function(e,t,n,i){XF(e,c);var a,o,s,l=0,d=0;if(uD(t)){if(!qD(t))return LD(t)?FD(u,t):GF(hD,u,t);a=t,d=iD(n,r);var p=t.byteLength;if(void 0===i){if(p%r)throw ED(ND);if((o=p-d)<0)throw ED(ND)}else if((o=nD(i)*r)+d>p)throw ED(ND);s=o/r}else s=rD(t),a=new TD(o=s*r);for(kD(e,{buffer:a,byteOffset:d,byteLength:o,length:s,view:new ID(a)});l<s;)f(e,l++)})),dD&&dD(u,jD),c=u.prototype=lD(AD)),c.constructor!==u&&eD(c,"constructor",u),xD(c).TypedArrayConstructor=u,PD&&eD(c,PD,i);var d=u!=s;l[i]=u,KF({global:!0,constructor:!0,forced:d,sham:!CD},l),UD in u||eD(u,UD,r),UD in c||eD(c,UD,r),yD(i)}):MN.exports=function(){},(0,MN.exports)("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}));var $D=lr,KD=tr,HD=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("at",(function(e){var t=HD(this),n=$D(t),r=KD(e),i=r>=0?r:n+r;return i<0||i>=n?void 0:t[i]}));var GD=ye,VD=TypeError,YD=function(e,t){if(!delete e[t])throw VD("Cannot delete property "+GD(t)+" of "+GD(e))},JD=Fe,QD=ar,XD=lr,ZD=YD,eq=Math.min,tq=[].copyWithin||function(e,t){var n=JD(this),r=XD(n),i=QD(e,r),a=QD(t,r),o=arguments.length>2?arguments[2]:void 0,s=eq((void 0===o?r:QD(o,r))-a,r-i),u=1;for(a<i&&i<a+s&&(u=-1,a+=s-1,i+=s-1);s-- >0;)a in n?n[i]=n[a]:ZD(n,i),i+=u,a+=u;return n},nq=yF,rq=_(tq),iq=nq.aTypedArray;(0,nq.exportTypedArrayMethod)("copyWithin",(function(e,t){return rq(iq(this),e,t,arguments.length>2?arguments[2]:void 0)}));var aq=Do.every,oq=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("every",(function(e){return aq(oq(this),e,arguments.length>1?arguments[1]:void 0)}));var sq=eE,uq=AF,cq=ji,lq=f,fq=o,dq=yF.aTypedArray,pq=yF.exportTypedArrayMethod,hq=_("".slice);pq("fill",(function(e){var t=arguments.length;dq(this);var n="Big"===hq(cq(this),0,3)?uq(e):+e;return lq(sq,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),fq((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})));var vq=lr,yq=Lc,mq=yF.aTypedArrayConstructor,gq=yF.getTypedArrayConstructor,bq=function(e){return mq(yq(e,gq(e)))},wq=function(e,t){for(var n=0,r=vq(t),i=new e(r);r>n;)i[n]=t[n++];return i},kq=bq,xq=Do.filter,_q=function(e,t){return wq(kq(e),t)},Sq=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("filter",(function(e){var t=xq(Sq(this),e,arguments.length>1?arguments[1]:void 0);return _q(this,t)}));var Oq=Do.find,Eq=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("find",(function(e){return Oq(Eq(this),e,arguments.length>1?arguments[1]:void 0)}));var Tq=Do.findIndex,Rq=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("findIndex",(function(e){return Tq(Rq(this),e,arguments.length>1?arguments[1]:void 0)}));var Iq=xo,Cq=j,Pq=Fe,jq=lr,Aq=function(e){var t=1==e;return function(n,r,i){for(var a,o=Pq(n),s=Cq(o),u=Iq(r,i),c=jq(s);c-- >0;)if(u(a=s[c],c,o))switch(e){case 0:return a;case 1:return c}return t?-1:void 0}},Mq={findLast:Aq(0),findLastIndex:Aq(1)},Lq=Mq.findLast,Uq=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("findLast",(function(e){return Lq(Uq(this),e,arguments.length>1?arguments[1]:void 0)}));var Nq=Mq.findLastIndex,Fq=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("findLastIndex",(function(e){return Nq(Fq(this),e,arguments.length>1?arguments[1]:void 0)}));var Dq=Do.forEach,qq=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("forEach",(function(e){Dq(qq(this),e,arguments.length>1?arguments[1]:void 0)}));var Bq=vr.includes,zq=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("includes",(function(e){return Bq(zq(this),e,arguments.length>1?arguments[1]:void 0)}));var Wq=vr.indexOf,$q=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("indexOf",(function(e){return Wq($q(this),e,arguments.length>1?arguments[1]:void 0)}));var Kq=i,Hq=o,Gq=_,Vq=yF,Yq=Gy,Jq=rt("iterator"),Qq=Kq.Uint8Array,Xq=Gq(Yq.values),Zq=Gq(Yq.keys),eB=Gq(Yq.entries),tB=Vq.aTypedArray,nB=Vq.exportTypedArrayMethod,rB=Qq&&Qq.prototype,iB=!Hq((function(){rB[Jq].call([1])})),aB=!!rB&&rB.values&&rB[Jq]===rB.values&&"values"===rB.values.name,oB=function(){return Xq(tB(this))};nB("entries",(function(){return eB(tB(this))}),iB),nB("keys",(function(){return Zq(tB(this))}),iB),nB("values",oB,iB||!aB,{name:"values"}),nB(Jq,oB,iB||!aB,{name:"values"});var sB=yF.aTypedArray,uB=yF.exportTypedArrayMethod,cB=_([].join);uB("join",(function(e){return cB(sB(this),e)}));var lB=li,fB=D,dB=tr,pB=lr,hB=Rp,vB=Math.min,yB=[].lastIndexOf,mB=!!yB&&1/[1].lastIndexOf(1,-0)<0,gB=hB("lastIndexOf"),bB=mB||!gB?function(e){if(mB)return lB(yB,this,arguments)||0;var t=fB(this),n=pB(t),r=n-1;for(arguments.length>1&&(r=vB(r,dB(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:yB,wB=li,kB=bB,xB=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("lastIndexOf",(function(e){var t=arguments.length;return wB(kB,xB(this),t>1?[e,arguments[1]]:[e])}));var _B=Do.map,SB=bq,OB=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("map",(function(e){return _B(OB(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(SB(e))(t)}))}));var EB=tN.left,TB=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("reduce",(function(e){var t=arguments.length;return EB(TB(this),e,t,t>1?arguments[1]:void 0)}));var RB=tN.right,IB=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("reduceRight",(function(e){var t=arguments.length;return RB(IB(this),e,t,t>1?arguments[1]:void 0)}));var CB=yF.aTypedArray,PB=yF.exportTypedArrayMethod,jB=Math.floor;PB("reverse",(function(){for(var e,t=this,n=CB(t).length,r=jB(n/2),i=0;i<r;)e=t[i],t[i++]=t[--n],t[n]=e;return t}));var AB=i,MB=f,LB=yF,UB=lr,NB=RF,FB=Fe,DB=o,qB=AB.RangeError,BB=AB.Int8Array,zB=BB&&BB.prototype,WB=zB&&zB.set,$B=LB.aTypedArray,KB=LB.exportTypedArrayMethod,HB=!DB((function(){var e=new Uint8ClampedArray(2);return MB(WB,e,{length:1,0:3},1),3!==e[1]})),GB=HB&&LB.NATIVE_ARRAY_BUFFER_VIEWS&&DB((function(){var e=new BB(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));KB("set",(function(e){$B(this);var t=NB(arguments.length>1?arguments[1]:void 0,1),n=FB(e);if(HB)return MB(WB,this,n,t);var r=this.length,i=UB(n),a=0;if(i+t>r)throw qB("Wrong length");for(;a<i;)this[t+a]=n[a++]}),!HB||GB);var VB=bq,YB=fi,JB=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("slice",(function(e,t){for(var n=YB(JB(this),e,t),r=VB(this),i=0,a=n.length,o=new r(a);a>i;)o[i]=n[i++];return o}),o((function(){new Int8Array(1).slice()})));var QB=Do.some,XB=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("some",(function(e){return QB(XB(this),e,arguments.length>1?arguments[1]:void 0)}));var ZB=X.match(/firefox\/(\d+)/i),ez=!!ZB&&+ZB[1],tz=/MSIE|Trident/.test(X),nz=X.match(/AppleWebKit\/(\d+)\./),rz=!!nz&&+nz[1],iz=go,az=o,oz=we,sz=XI,uz=ez,cz=tz,lz=ae,fz=rz,dz=yF.aTypedArray,pz=yF.exportTypedArrayMethod,hz=i.Uint16Array,vz=hz&&iz(hz.prototype.sort),yz=!(!vz||az((function(){vz(new hz(2),null)}))&&az((function(){vz(new hz(2),{})}))),mz=!!vz&&!az((function(){if(lz)return lz<74;if(uz)return uz<67;if(cz)return!0;if(fz)return fz<602;var e,t,n=new hz(516),r=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,r[e]=e-2*t+3;for(vz(n,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==r[e])return!0}));pz("sort",(function(e){return void 0!==e&&oz(e),mz?vz(this,e):sz(dz(this),function(e){return function(t,n){return void 0!==e?+e(t,n)||0:n!=n?-1:t!=t?1:0===t&&0===n?1/t>0&&1/n<0?1:-1:t>n}}(e))}),!mz||yz);var gz=ur,bz=ar,wz=bq,kz=yF.aTypedArray;(0,yF.exportTypedArrayMethod)("subarray",(function(e,t){var n=kz(this),r=n.length,i=bz(e,r);return new(wz(n))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,gz((void 0===t?r:bz(t,r))-i))}));var xz=li,_z=yF,Sz=o,Oz=fi,Ez=i.Int8Array,Tz=_z.aTypedArray,Rz=_z.exportTypedArrayMethod,Iz=[].toLocaleString,Cz=!!Ez&&Sz((function(){Iz.call(new Ez(1))}));Rz("toLocaleString",(function(){return xz(Iz,Cz?Oz(Tz(this)):Tz(this),Oz(arguments))}),Sz((function(){return[1,2].toLocaleString()!=new Ez([1,2]).toLocaleString()}))||!Sz((function(){Ez.prototype.toLocaleString.call([1,2])})));var Pz=yF.exportTypedArrayMethod,jz=o,Az=_,Mz=i.Uint8Array,Lz=Mz&&Mz.prototype||{},Uz=[].toString,Nz=Az([].join);jz((function(){Uz.call({})}))&&(Uz=function(){return Nz(this)});var Fz=Lz.toString!=Uz;function Dz(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}Pz("toString",Uz,Fz);var qz=yy.scope("Participant"),Participant=function(e){ec(Participant,e);var t,n,r,i=Dz(Participant);function Participant(e,t,n,r,a){var o,s,u;if(sc(this,Participant),uc(Xu(u=i.call(this)),"state",void 0),uc(Xu(u),"links",void 0),uc(Xu(u),"services",void 0),uc(Xu(u),"conversation",void 0),u.conversation=n,u.links=r,u.services=a,u.state={attributes:Fb(e.attributes,"Retrieved malformed attributes from the server for participant: "+t,qz),dateCreated:e.dateCreated?Nb(e.dateCreated):null,dateUpdated:e.dateCreated?Nb(e.dateUpdated):null,sid:t,typingTimeout:null,isTyping:!1,identity:e.identity,roleSid:null!==(o=e.roleSid)&&void 0!==o?o:"",lastReadMessageIndex:Number.isInteger(e.lastConsumedMessageIndex)?e.lastConsumedMessageIndex:null,lastReadTimestamp:e.lastConsumptionTimestamp?Nb(e.lastConsumptionTimestamp):null,type:e.type||"chat",userInfo:e.userInfo,bindings:null!==(s=e.bindings)&&void 0!==s?s:{}},!e.identity&&!e.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return u}return oc(Participant,[{key:"sid",get:function(){return this.state.sid}},{key:"attributes",get:function(){return this.state.attributes}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"identity",get:function(){return this.state.identity}},{key:"isTyping",get:function(){return this.state.isTyping}},{key:"lastReadMessageIndex",get:function(){return this.state.lastReadMessageIndex}},{key:"lastReadTimestamp",get:function(){return this.state.lastReadTimestamp}},{key:"roleSid",get:function(){return this.state.roleSid}},{key:"type",get:function(){return this.state.type}},{key:"bindings",get:function(){var e;return null!==(e=this.state.bindings)&&void 0!==e?e:{}}},{key:"_startTyping",value:function(e){var t=this;return this.state.typingTimeout&&clearTimeout(this.state.typingTimeout),this.state.isTyping=!0,this.emit("typingStarted",this),this.conversation.emit("typingStarted",this),this.state.typingTimeout=Number(setTimeout((function(){return t._endTyping()}),e)),this}},{key:"_endTyping",value:function(){this.state.typingTimeout&&(this.state.isTyping=!1,this.emit("typingEnded",this),this.conversation.emit("typingEnded",this),clearInterval(this.state.typingTimeout),this.state.typingTimeout=null)}},{key:"_update",value:function(e){var t=[],n=Fb(e.attributes,"Retrieved malformed attributes from the server for participant: "+this.state.sid,qz);e.attributes&&!Jx(this.state.attributes,n)&&(this.state.attributes=n,t.push("attributes"));var r=Nb(e.dateUpdated);e.dateUpdated&&(null==r?void 0:r.getTime())!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=r,t.push("dateUpdated"));var i=Nb(e.dateCreated);if(e.dateCreated&&(null==i?void 0:i.getTime())!==(this.state.dateCreated&&this.state.dateCreated.getTime())&&(this.state.dateCreated=i,t.push("dateCreated")),e.roleSid&&this.state.roleSid!==e.roleSid&&(this.state.roleSid=e.roleSid,t.push("roleSid")),!Number.isInteger(e.lastConsumedMessageIndex)&&null!==e.lastConsumedMessageIndex||this.state.lastReadMessageIndex===e.lastConsumedMessageIndex||(this.state.lastReadMessageIndex=e.lastConsumedMessageIndex,t.push("lastReadMessageIndex")),e.lastConsumptionTimestamp){var a=new Date(e.lastConsumptionTimestamp);this.state.lastReadTimestamp&&this.state.lastReadTimestamp.getTime()===a.getTime()||(this.state.lastReadTimestamp=a,t.push("lastReadTimestamp"))}return e.bindings&&!Jx(this.state.bindings,e.bindings)&&(this.state.bindings=e.bindings,t.push("bindings")),t.length>0&&this.emit("updated",{participant:this,updateReasons:t}),this}},{key:"getUser",value:(r=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("chat"==this.type){e.next=2;break}throw new Error("Getting User is not supported for this Participant type: "+this.type);case 2:return e.abrupt("return",this.services.users.getUser(this.state.identity,this.state.userInfo));case 3:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"remove",value:(n=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.conversation.removeParticipant(this));case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"updateAttributes",value:(t=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(t)});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),Participant}(Vx);function Bz(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}uc(Participant,"typingStarted","typingStarted"),uc(Participant,"typingEnded","typingEnded"),uc(Participant,"updated","updated"),yh([cx(lx),mh("design:type",Function),mh("design:paramtypes",[Object]),mh("design:returntype",Promise)],Participant.prototype,"updateAttributes",null);var zz=yy.scope("Participants"),Wz=function(e){ec(l,e);var t,n,r,i,a,o,s,u,c=Bz(l);function l(e,t,n,r,i){var a;return sc(this,l),uc(Xu(a=c.call(this)),"configuration",void 0),uc(Xu(a),"services",void 0),uc(Xu(a),"links",void 0),uc(Xu(a),"rosterEntityPromise",null),uc(Xu(a),"conversation",void 0),uc(Xu(a),"participants",void 0),a.conversation=e,a.participants=t,a.links=n,a.configuration=r,a.services=i,a}return oc(l,[{key:"unsubscribe",value:(u=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.rosterEntityPromise){e.next=6;break}return e.next=3,this.rosterEntityPromise;case 3:e.sent.close(),this.rosterEntityPromise=null;case 6:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"subscribe",value:function(e){var t=this,n="string"==typeof e?this.services.syncClient.map({id:e,mode:"open_existing"}):Promise.resolve(e);return this.rosterEntityPromise=this.rosterEntityPromise||n.then((function(e){e.on("itemAdded",(function(e){zz.debug(t.conversation.sid+" itemAdded: "+e.item.key),t.upsertParticipant(e.item.key,e.item.data).then((function(e){t.emit("participantJoined",e)}))})),e.on("itemRemoved",(function(e){zz.debug(t.conversation.sid+" itemRemoved: "+e.key);var n=e.key;if(t.participants.has(n)){var r=t.participants.get(n);t.participants.delete(n),r&&t.emit("participantLeft",r)}})),e.on("itemUpdated",(function(e){zz.debug(t.conversation.sid+" itemUpdated: "+e.item.key),t.upsertParticipant(e.item.key,e.item.data)}));var n=[];return e.getItems().then((function e(r){return r.items.forEach((function(e){n.push(t.upsertParticipant(e.key,e.data))})),r.hasNextPage?r.nextPage().then(e):null})).then((function(){return Promise.all(n)})).then((function(){return e}))})).catch((function(e){throw t.rosterEntityPromise=null,"disconnected"!=t.services.syncClient.connectionState&&zz.error("Failed to get roster object for conversation",t.conversation.sid,e),zz.debug("ERROR: Failed to get roster object for conversation",t.conversation.sid,e),e}))}},{key:"upsertParticipantFromResponse",value:(s=Qu(hh.mark((function e(t){var n,r,i,a,o,s,u,c;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.sid,i=t.attributes,a=t.date_created,o=t.date_updated,s=t.identity,u=t.role_sid,c=t.messaging_binding,e.next=3,this.upsertParticipant(r,{attributes:i,dateCreated:new Date(a),dateUpdated:new Date(o),identity:s,roleSid:u,lastConsumedMessageIndex:null,lastConsumptionTimestamp:null,type:null!==(n=null==c?void 0:c.type)&&void 0!==n?n:"chat"});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"upsertParticipant",value:(o=Qu(hh.mark((function e(t,n){var r,i,a=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.participants.get(t))){e.next=3;break}return e.abrupt("return",r._update(n));case 3:return i={self:"".concat(this.links.participants,"/").concat(t)},r=new Participant(n,t,this.conversation,i,this.services),this.participants.set(t,r),r.on("updated",(function(e){return a.emit("participantUpdated",e)})),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getParticipants",value:(a=Qu(hh.mark((function e(){var t=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then((function(){var e=[];return t.participants.forEach((function(t){return e.push(t)})),e})):[]);case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getParticipantBySid",value:(i=Qu(hh.mark((function e(t){var n=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then((function(){var e=n.participants.get(t);if(!e)throw new Error("Participant with SID "+t+" was not found");return e})):null);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getParticipantByIdentity",value:(r=Qu(hh.mark((function e(t){var n,r=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null,e.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then((function(){if(r.participants.forEach((function(e){e.identity===t&&(n=e)})),!n)throw new Error("Participant with identity "+t+" was not found");return n})):null);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"add",value:(n=Qu(hh.mark((function e(t,n){var r;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.participants,{identity:t,attributes:void 0!==n?JSON.stringify(n):void 0});case 2:return r=e.sent,e.next=5,this.upsertParticipantFromResponse(r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"addNonChatParticipant",value:(t=Qu(hh.mark((function e(t,n){var r,i,a,o,s,u=arguments;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=u.length>2&&void 0!==u[2]?u[2]:{},o=u.length>3&&void 0!==u[3]?u[3]:{},e.next=4,this.services.commandExecutor.mutateResource("post",this.links.participants,{attributes:void 0!==a?JSON.stringify(a):void 0,messaging_binding:{address:n,proxy_address:t,name:null==o||null===(r=o.email)||void 0===r?void 0:r.name,level:null==o||null===(i=o.email)||void 0===i?void 0:i.level}});case 4:return s=e.sent,e.next=7,this.upsertParticipantFromResponse(s);case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"remove",value:function(e){return this.services.commandExecutor.mutateResource("delete","".concat(this.links.participants,"/").concat(e))}}]),l}(Vx),$z=Zr,Kz=_,Hz=we,Gz=Fe,Vz=lr,Yz=YD,Jz=Ba,Qz=o,Xz=XI,Zz=Rp,eW=ez,tW=tz,nW=ae,rW=rz,iW=[],aW=Kz(iW.sort),oW=Kz(iW.push),sW=Qz((function(){iW.sort(void 0)})),uW=Qz((function(){iW.sort(null)})),cW=Zz("sort"),lW=!Qz((function(){if(nW)return nW<70;if(!(eW&&eW>3)){if(tW)return!0;if(rW)return rW<603;var e,t,n,r,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(r=0;r<47;r++)iW.push({k:t+r,v:n})}for(iW.sort((function(e,t){return t.v-e.v})),r=0;r<iW.length;r++)t=iW[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));$z({target:"Array",proto:!0,forced:sW||!uW||!cW||!lW},{sort:function(e){void 0!==e&&Hz(e);var t=Gz(this);if(lW)return void 0===e?aW(t):aW(t,e);var n,r,i=[],a=Vz(t);for(r=0;r<a;r++)r in t&&oW(i,t[r]);for(Xz(i,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:Jz(t)>Jz(n)?1:-1}}(e)),n=Vz(i),r=0;r<n;)t[r]=i[r++];for(;r<a;)Yz(t,r++);return t}});var fW=Zr,dW=ER,pW=U,hW=Ba,vW=RR,yW=_("".indexOf);fW({target:"String",proto:!0,forced:!vW("includes")},{includes:function(e){return!!~yW(hW(pW(this)),hW(dW(e)),arguments.length>1?arguments[1]:void 0)}});var Media=function(){function Media(e,t){sc(this,Media),uc(this,"state",void 0),uc(this,"services",void 0),uc(this,"mcsMedia",null),this.services=t,e instanceof VU.McsMedia&&(this.mcsMedia=e),this.state={sid:e.sid,category:e.category,filename:e.filename,contentType:e.contentType,size:e.size}}return oc(Media,[{key:"sid",get:function(){return this.state.sid}},{key:"filename",get:function(){return this.state.filename}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"category",get:function(){return this.state.category}},{key:"getContentTemporaryUrl",value:function(){var e=this;return new VU.CancellablePromise(function(){var t=Qu(hh.mark((function t(n,r,i){var a,o,s,u;return hh.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=e._fetchMcsMedia(),s=null===(a=e.mcsMedia)||void 0===a?void 0:a.getContentUrl(),i((function(){o.cancel(),s&&s.cancel()})),t.prev=3,e.mcsMedia){t.next=9;break}return t.next=7,o;case 7:u=t.sent,s=u.getContentUrl();case 9:if(t.t0=n,!s){t.next=16;break}return t.next=13,s;case 13:t.t1=t.sent,t.next=17;break;case 16:t.t1=null;case 17:t.t2=t.t1,(0,t.t0)(t.t2),t.next=24;break;case 21:t.prev=21,t.t3=t.catch(3),r(t.t3);case 24:case"end":return t.stop()}}),t,null,[[3,21]])})));return function(e,n,r){return t.apply(this,arguments)}}())}},{key:"_fetchMcsMedia",value:function(){var e=this;return new VU.CancellablePromise(function(){var t=Qu(hh.mark((function t(n,r,i){var a;return hh.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.services.mcsClient.get(e.state.sid),!e.services.mcsClient){t.next=14;break}return i((function(){return a.cancel()})),t.prev=3,t.next=6,a;case 6:e.mcsMedia=t.sent,n(e.mcsMedia),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(3),r(t.t0);case 13:return t.abrupt("return");case 14:r(new Error("Media Content Service is unavailable"));case 15:case"end":return t.stop()}}),t,null,[[3,10]])})));return function(e,n,r){return t.apply(this,arguments)}}())}}]),Media}(),AggregatedDeliveryReceipt=function(){function AggregatedDeliveryReceipt(e){sc(this,AggregatedDeliveryReceipt),uc(this,"state",void 0),this.state=e}return oc(AggregatedDeliveryReceipt,[{key:"total",get:function(){return this.state.total}},{key:"sent",get:function(){return this.state.sent}},{key:"delivered",get:function(){return this.state.delivered}},{key:"read",get:function(){return this.state.read}},{key:"undelivered",get:function(){return this.state.undelivered}},{key:"failed",get:function(){return this.state.failed}},{key:"_update",value:function(e){this.state=e}},{key:"_isEquals",value:function(e){var t=this.total===e.total,n=this.sent===e.sent,r=this.delivered===e.delivered,i=this.read===e.read,a=this.undelivered===e.undelivered,o=this.failed===e.failed;return t&&n&&r&&i&&a&&o}}]),AggregatedDeliveryReceipt}(),mW=function(){function e(t,n,r,i){sc(this,e),uc(this,"state",void 0),this.state={prevToken:r,nextToken:i,source:n,items:t}}return oc(e,[{key:"hasNextPage",get:function(){return!!this.state.nextToken}},{key:"hasPrevPage",get:function(){return!!this.state.prevToken}},{key:"items",get:function(){return this.state.items}},{key:"nextPage",value:function(){return this.hasNextPage?this.state.source(this.state.nextToken):Promise.reject(new Error("No next page"))}},{key:"prevPage",value:function(){return this.hasPrevPage?this.state.source(this.state.prevToken):Promise.reject(new Error("No previous page"))}}]),e}(),DetailedDeliveryReceipt=oc((function DetailedDeliveryReceipt(e){sc(this,DetailedDeliveryReceipt),uc(this,"sid",void 0),uc(this,"messageSid",void 0),uc(this,"conversationSid",void 0),uc(this,"channelMessageSid",void 0),uc(this,"participantSid",void 0),uc(this,"status",void 0),uc(this,"errorCode",void 0),uc(this,"dateCreated",void 0),uc(this,"dateUpdated",void 0),this.sid=e.sid,this.messageSid=e.message_sid,this.conversationSid=e.conversation_sid,this.channelMessageSid=e.channel_message_sid,this.participantSid=e.participant_sid,this.status=e.status||"queued",this.errorCode=e.error_code||0,this.dateCreated=e.date_created,this.dateUpdated=e.date_updated}));function gW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function bW(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gW(Object(n),!0).forEach((function(t){uc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gW(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function wW(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}var kW=yy.scope("Message"),Message=function(e){ec(Message,e);var t,n,r,i,a,o,s=wW(Message);function Message(e,t,n,r,i,a){var o,u,c,l,f;return sc(this,Message),uc(Xu(f=s.call(this)),"conversation",void 0),uc(Xu(f),"links",void 0),uc(Xu(f),"configuration",void 0),uc(Xu(f),"services",void 0),uc(Xu(f),"state",void 0),f.conversation=n,f.links=r,f.configuration=i,f.services=a,f.state={sid:t.sid,index:e,author:t.author,subject:t.subject,body:null!==(o=t.text)&&void 0!==o?o:null,timestamp:t.timestamp?new Date(t.timestamp):null,dateUpdated:t.dateUpdated?new Date(t.dateUpdated):null,lastUpdatedBy:null!==(u=t.lastUpdatedBy)&&void 0!==u?u:null,attributes:Fb(t.attributes,"Got malformed attributes for the message ".concat(t.sid),kW),type:null!==(c=t.type)&&void 0!==c?c:"text",media:"media"===t.type&&t.media?new Media(t.media,f.services):null,medias:"media"===t.type&&t.medias?t.medias.map((function(e){return new Media(e,f.services)})):"media"===t.type&&t.media&&!t.medias?[new Media(bW(bW({},t.media),{},{category:"media"}),f.services)]:null,participantSid:null!==(l=t.memberSid)&&void 0!==l?l:null,aggregatedDeliveryReceipt:t.delivery?new AggregatedDeliveryReceipt(t.delivery):null},f}return oc(Message,[{key:"sid",get:function(){return this.state.sid}},{key:"author",get:function(){return this.state.author}},{key:"subject",get:function(){return this.state.subject}},{key:"body",get:function(){return this.state.body}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"index",get:function(){return this.state.index}},{key:"lastUpdatedBy",get:function(){return this.state.lastUpdatedBy}},{key:"dateCreated",get:function(){return this.state.timestamp}},{key:"attributes",get:function(){return this.state.attributes}},{key:"type",get:function(){return this.state.type}},{key:"media",get:function(){return this.state.media}},{key:"attachedMedia",get:function(){return this.getMediaByCategories(["media"])}},{key:"participantSid",get:function(){return this.state.participantSid}},{key:"aggregatedDeliveryReceipt",get:function(){return this.state.aggregatedDeliveryReceipt}},{key:"getMediaByCategories",value:function(e){var t;return(null!==(t=this.state.medias)&&void 0!==t?t:[]).filter((function(t){return e.includes(t.category)}))}},{key:"getEmailBody",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"text/plain";return null!==(e=null===(t=this.getMediaByCategories(["body"]))||void 0===t?void 0:t.filter((function(e){return e.contentType==n})).shift())&&void 0!==e?e:null}},{key:"getEmailHistory",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"text/plain";return null!==(e=null===(t=this.getMediaByCategories(["history"]))||void 0===t?void 0:t.filter((function(e){return e.contentType==n})).shift())&&void 0!==e?e:null}},{key:"_update",value:function(e){var t=[];!e.text&&"string"!=typeof e.text||e.text===this.state.body||(this.state.body=e.text,t.push("body")),e.subject&&e.subject!==this.state.subject&&(this.state.subject=e.subject,t.push("subject")),e.lastUpdatedBy&&e.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=e.lastUpdatedBy,t.push("lastUpdatedBy")),e.author&&e.author!==this.state.author&&(this.state.author=e.author,t.push("author")),e.dateUpdated&&new Date(e.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(e.dateUpdated),t.push("dateUpdated")),e.timestamp&&new Date(e.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(e.timestamp),t.push("dateCreated"));var n=Fb(e.attributes,"Got malformed attributes for the message ".concat(this.sid),kW);Jx(this.state.attributes,n)||(this.state.attributes=n,t.push("attributes"));var r=e.delivery,i=this.state.aggregatedDeliveryReceipt;!!(r&&r.total&&r.delivered&&r.failed&&r.read&&r.sent&&r.undelivered)&&(i?i._isEquals(r)||(i._update(r),t.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new AggregatedDeliveryReceipt(r),t.push("deliveryReceipt"))),t.length>0&&this.emit("updated",{message:this,updateReasons:t})}},{key:"getParticipant",value:(o=Qu(hh.mark((function e(){var t,n,r=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=null,!this.state.participantSid){e.next=5;break}return e.next=4,this.conversation.getParticipantBySid(this.state.participantSid).catch((function(){return kW.debug('Participant with sid "'.concat(r.participantSid,'" not found for message ').concat(r.sid)),null}));case 4:t=e.sent;case 5:if(t||!this.state.author){e.next=9;break}return e.next=8,this.conversation.getParticipantByIdentity(this.state.author).catch((function(){return kW.debug('Participant with identity "'.concat(r.author,'" not found for message ').concat(r.sid)),null}));case 8:t=e.sent;case 9:if(!t){e.next=11;break}return e.abrupt("return",t);case 11:throw n="Participant with ",this.state.participantSid&&(n+="SID '"+this.state.participantSid+"' "),this.state.author&&(this.state.participantSid&&(n+="or "),n+="identity '"+this.state.author+"' "),"Participant with "===n&&(n="Participant "),n+="was not found",new Error(n);case 17:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"getDetailedDeliveryReceipts",value:(a=Qu(hh.mark((function e(){var t,n;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getDetailedDeliveryReceiptsPaginator();case 2:t=e.sent,n=t.items;case 4:if(!t.hasNextPage){e.next=11;break}return e.next=7,t.nextPage();case 7:t=e.sent,n=[].concat(t_(n),t_(t.items)),e.next=4;break;case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"remove",value:(i=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("delete",this.links.self);case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"updateBody",value:(r=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{body:t});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"updateAttributes",value:(n=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:void 0!==t?JSON.stringify(t):void 0});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"getTemporaryContentUrlsForMedia",value:function(e){var t=e.map((function(e){return e.sid}));return this.getTemporaryContentUrlsForMediaSids(t)}},{key:"getTemporaryContentUrlsForMediaSids",value:function(e){var t=this;return new VU.CancellablePromise(function(){var n=Qu(hh.mark((function n(r,i,a){var o,s;return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o=t.services.mcsClient.mediaSetGetContentUrls(null!=e?e:[]),t.services.mcsClient&&e){n.next=4;break}return i(new Error("Media Content Service is unavailable")),n.abrupt("return");case 4:return a((function(){o.cancel()})),n.prev=5,n.next=8,o;case 8:s=n.sent,r(s),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(5),i(n.t0);case 15:case"end":return n.stop()}}),n,null,[[5,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForAttachedMedia",value:function(){var e,t=this.attachedMedia,n=null!==(e=null==t?void 0:t.map((function(e){return e.sid})))&&void 0!==e?e:[];return this.getTemporaryContentUrlsForMediaSids(n)}},{key:"_getDetailedDeliveryReceiptsPaginator",value:(t=Qu(hh.mark((function e(t){var n,r,i,a=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.configuration.links.messagesReceipts.replace("%s",this.conversation.sid).replace("%s",this.sid),r=new Db(n).arg("PageToken",null==t?void 0:t.pageToken).arg("PageSize",null==t?void 0:t.pageSize).build(),e.next=4,this.services.network.get(r);case 4:return i=e.sent,e.abrupt("return",new mW(i.body.delivery_receipts.map((function(e){return new DetailedDeliveryReceipt(e)})),(function(e,t){return a._getDetailedDeliveryReceiptsPaginator({pageToken:e,pageSize:t})}),i.body.meta.previous_token,i.body.meta.next_token));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),Message}(Vx);function xW(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return _W(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _W(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function _W(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function SW(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}uc(Message,"updated","updated"),yh([ux([rx,"undefined"]),mh("design:type",Function),mh("design:paramtypes",[Object]),mh("design:returntype",Media)],Message.prototype,"getEmailBody",null),yh([ux([rx,"undefined"]),mh("design:type",Function),mh("design:paramtypes",[Object]),mh("design:returntype",Media)],Message.prototype,"getEmailHistory",null),yh([cx("string"),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],Message.prototype,"updateBody",null),yh([cx(lx),mh("design:type",Function),mh("design:paramtypes",[Object]),mh("design:returntype",Promise)],Message.prototype,"updateAttributes",null),yh([cx(nx("media",Media)),mh("design:type",Function),mh("design:paramtypes",[Array]),mh("design:returntype",VU.CancellablePromise)],Message.prototype,"getTemporaryContentUrlsForMedia",null),yh([cx(nx("strings","string")),mh("design:type",Function),mh("design:paramtypes",[Array]),mh("design:returntype",VU.CancellablePromise)],Message.prototype,"getTemporaryContentUrlsForMediaSids",null);var OW=yy.scope("Messages"),EW=function(e){ec(u,e);var t,n,r,i,a,o,s=SW(u);function u(e,t,n){var r;return sc(this,u),uc(Xu(r=s.call(this)),"conversation",void 0),uc(Xu(r),"configuration",void 0),uc(Xu(r),"services",void 0),uc(Xu(r),"messagesByIndex",void 0),uc(Xu(r),"messagesListPromise",void 0),r.conversation=e,r.configuration=t,r.services=n,r.messagesByIndex=new Map,r.messagesListPromise=null,r}return oc(u,[{key:"subscribe",value:(o=Qu(hh.mark((function e(t){var n,r=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.messagesListPromise){e.next=2;break}return e.abrupt("return",this.messagesListPromise);case 2:return this.messagesListPromise="string"==typeof t?this.services.syncClient.list({id:t,mode:"open_existing"}):Promise.resolve(t),e.prev=3,e.next=6,this.messagesListPromise;case 6:return(n=e.sent).on("itemAdded",(function(e){OW.debug("".concat(r.conversation.sid," itemAdded: ").concat(e.item.index)),r._upsertMessage(e.item.index,e.item.data)})),n.on("itemRemoved",(function(e){OW.debug("#{this.conversation.sid} itemRemoved: ".concat(e.index));var t=e.index;if(r.messagesByIndex.has(t)){var n=r.messagesByIndex.get(t);if(!n)return;r.messagesByIndex.delete(n.index),n.removeAllListeners("updated"),r.emit("messageRemoved",n)}})),n.on("itemUpdated",(function(e){OW.debug("".concat(r.conversation.sid," itemUpdated: ").concat(e.item.index));var t=r.messagesByIndex.get(e.item.index);t&&t._update(e.item.data)})),e.abrupt("return",n);case 13:throw e.prev=13,e.t0=e.catch(3),this.messagesListPromise=null,"disconnected"!==this.services.syncClient.connectionState&&OW.error("Failed to get messages object for conversation",this.conversation.sid,e.t0),OW.debug("ERROR: Failed to get messages object for conversation",this.conversation.sid,e.t0),e.t0;case 19:case"end":return e.stop()}}),e,this,[[3,13]])}))),function(e){return o.apply(this,arguments)})},{key:"unsubscribe",value:(a=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.messagesListPromise){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.messagesListPromise;case 4:e.sent.close(),this.messagesListPromise=null;case 7:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"sendV2",value:function(e){var t=this;return OW.debug("Sending message V2",e.mediaContent,e.attributes,e.emailOptions),new VU.CancellablePromise(function(){var n=Qu(hh.mark((function n(r,i,a){var o,s,u,c,l,f,d,p,h,v,y,m;return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:s=[],u=[],a((function(){u.forEach((function(e){return e.cancel()}))})),c=xW(e.mediaContent),n.prev=4,c.s();case 6:if((l=c.n()).done){n.next=25;break}return f=n_(l.value,2),d=f[0],p=f[1],n.prev=8,OW.debug("Adding media to a message as ".concat(p instanceof FormData?"FormData":"SendMediaOptions"),p),y=p instanceof FormData?t.services.mcsClient.postFormData(p,d):t.services.mcsClient.post(null!==(h=p.contentType)&&void 0!==h?h:"",null!==(v=p.media)&&void 0!==v?v:"",d,p.filename),u.push(y),n.t0=s,n.next=15,y;case 15:n.t1=n.sent,n.t0.push.call(n.t0,n.t1),n.next=23;break;case 19:return n.prev=19,n.t2=n.catch(8),i(n.t2),n.abrupt("return");case 23:n.next=6;break;case 25:n.next=30;break;case 27:n.prev=27,n.t3=n.catch(4),c.e(n.t3);case 30:return n.prev=30,c.f(),n.finish(30);case 33:return m=t.services.commandExecutor.mutateResource("post",t.conversation._links.messages,{body:e.text,subject:null===(o=e.emailOptions)||void 0===o?void 0:o.subject,media_sids:s.map((function(e){return e.sid})),attributes:void 0!==e.attributes?JSON.stringify(e.attributes):void 0}),n.prev=34,n.t4=r,n.next=38,m;case 38:n.t5=n.sent,(0,n.t4)(n.t5),n.next=45;break;case 42:n.prev=42,n.t6=n.catch(34),i(n.t6);case 45:case"end":return n.stop()}}),n,null,[[4,27,30,33],[8,19],[34,42]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"send",value:(i=Qu(hh.mark((function e(t){var n,r,i=arguments;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:{},r=i.length>2?i[2]:void 0,OW.debug("Sending text message",t,n,r),e.abrupt("return",this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{body:null!=t?t:"",attributes:void 0!==n?JSON.stringify(n):void 0,subject:null==r?void 0:r.subject}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendMedia",value:(r=Qu(hh.mark((function e(t){var n,r,i,a,o,s=arguments;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=s.length>1&&void 0!==s[1]?s[1]:{},a=s.length>2?s[2]:void 0,OW.debug("Sending media message",t,i,a),OW.debug("Sending media message as ".concat(t instanceof FormData?"FormData":"SendMediaOptions"),t,i),!(t instanceof FormData)){e.next=10;break}return e.next=7,this.services.mcsClient.postFormData(t);case 7:e.t0=e.sent,e.next=13;break;case 10:return e.next=12,this.services.mcsClient.post(null!==(n=t.contentType)&&void 0!==n?n:"",null!==(r=t.media)&&void 0!==r?r:"","media",t.filename);case 12:e.t0=e.sent;case 13:return o=e.t0,e.next=16,this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{media_sids:[o.sid],attributes:void 0!==i?JSON.stringify(i):void 0});case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getMessages",value:(n=Qu(hh.mark((function e(t,n){var r,i=arguments;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>2&&void 0!==i[2]?i[2]:"backwards",e.abrupt("return",this._getMessages(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_wrapPaginator",value:function(e,t,n){var r=this,i="desc"===e,a=function(){return t.nextPage().then((function(t){return r._wrapPaginator(e,t,n)}))},o=function(){return t.prevPage().then((function(t){return r._wrapPaginator(e,t,n)}))};return n(t.items).then((function(e){return{items:e.sort((function(e,t){return e.index-t.index})),hasPrevPage:i?t.hasNextPage:t.hasPrevPage,hasNextPage:i?t.hasPrevPage:t.hasNextPage,prevPage:i?a:o,nextPage:i?o:a}}))}},{key:"_upsertMessage",value:function(e,t){var n=this,r=this.messagesByIndex.get(e);if(r)return OW.debug("Attempted to upsert a message, but it is already known and therefore ignored",this.conversation.sid),r;var i={self:"".concat(this.conversation._links.messages,"/").concat(t.sid),conversation:this.conversation._links.self,messages_receipts:"".concat(this.conversation._links.messages,"/").concat(t.sid,"/Receipts")},a=new Message(e,t,this.conversation,i,this.configuration,this.services);return this.messagesByIndex.set(a.index,a),a.on("updated",(function(e){return n.emit("messageUpdated",e)})),this.emit("messageAdded",a),a}},{key:"_getMessages",value:(t=Qu(hh.mark((function e(){var t,n,r,i,a,o,s=this,u=arguments;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:30,n=u.length>1&&void 0!==u[1]?u[1]:"end",r=u.length>2&&void 0!==u[2]?u[2]:"forward",i="backwards"===r?"desc":"asc",e.next=6,this.messagesListPromise;case 6:return a=e.sent,e.next=9,null==a?void 0:a.getItems({from:"end"!==n?n:void 0,pageSize:t,order:i,limit:t});case 9:return o=e.sent,e.next=12,this._wrapPaginator(i,o,(function(e){return Promise.all(e.map((function(e){return s._upsertMessage(e.index,e.data)})))}));case 12:return e.abrupt("return",e.sent);case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),u}(Vx),TW=function(){function e(t){sc(this,e),uc(this,"messagesEntity",void 0),uc(this,"text",void 0),uc(this,"attributes",{}),uc(this,"mediaContent",[]),uc(this,"emailOptions",{}),this.messagesEntity=t}return oc(e,[{key:"send",value:function(){var e=this;return new VU.CancellablePromise(function(){var t=Qu(hh.mark((function t(n,r,i){var a,o;return hh.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.messagesEntity.sendV2(e),i((function(){return a.cancel()})),t.prev=2,t.next=5,a;case 5:o=t.sent,n(Ub(o.index)),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),r(t.t0);case 12:case"end":return t.stop()}}),t,null,[[2,9]])})));return function(e,n,r){return t.apply(this,arguments)}}())}}]),e}(),RW=function(){function e(t,n){sc(this,e),uc(this,"limits",void 0),uc(this,"message",void 0),uc(this,"emailBodies",void 0),uc(this,"emailHistories",void 0),this.limits=t,this.message=new TW(n),this.emailBodies=new Map,this.emailHistories=new Map}return oc(e,[{key:"setBody",value:function(e){return this.message.text=e,this}},{key:"setSubject",value:function(e){return this.message.emailOptions.subject=e,this}},{key:"setAttributes",value:function(e){return this.message.attributes=e,this}},{key:"setEmailBody",value:function(e,t){return this.emailBodies.set(e,t),this}},{key:"setEmailHistory",value:function(e,t){return this.emailHistories.set(e,t),this}},{key:"addMedia",value:function(e){if("undefined"==typeof FormData&&e instanceof FormData)throw new Error("Could not add FormData content whilst not in a browser");if(!(e instanceof FormData)){var t=e;if(!t.contentType||!t.media)throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media")}return this.message.mediaContent.push(["media",e]),this}},{key:"build",value:function(){var e=this;if(this.emailBodies.forEach((function(t,n){if(!e.limits.emailBodiesAllowedContentTypes.includes(n))throw new Error("Unsupported email body content type ".concat(n))})),this.emailHistories.forEach((function(t,n){if(!e.limits.emailHistoriesAllowedContentTypes.includes(n))throw new Error("Unsupported email history content type ".concat(n))})),this.emailBodies.size>this.limits.emailBodiesAllowedContentTypes.length)throw new Error("Too many email bodies attached to the message (".concat(this.emailBodies.size," > ").concat(this.limits.emailBodiesAllowedContentTypes.length,")"));if(this.emailHistories.size>this.limits.emailHistoriesAllowedContentTypes.length)throw new Error("Too many email histories attached to the message (".concat(this.emailHistories.size," > ").concat(this.limits.emailHistoriesAllowedContentTypes.length,")"));if(this.message.mediaContent.length>this.limits.mediaAttachmentsCountLimit)throw new Error("Too many media attachments in the message (".concat(this.message.mediaContent.length," > ").concat(this.limits.mediaAttachmentsCountLimit,")"));return this.emailBodies.forEach((function(t){e.message.mediaContent.push(["body",t])})),this.emailHistories.forEach((function(t){e.message.mediaContent.push(["history",t])})),this.message}},{key:"buildAndSend",value:function(){return this.build().send()}},{key:"getPayloadContentType",value:function(e){return"undefined"!=typeof FormData&&e instanceof FormData?e.get("Content-Type"):e.contentType}}]),e}();function IW(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return CW(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return CW(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function CW(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function PW(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}var jW={lastMessage:"lastMessage",attributes:"attributes",createdBy:"createdBy",dateCreated:"dateCreated",dateUpdated:"dateUpdated",friendlyName:"friendlyName",lastConsumedMessageIndex:"lastConsumedMessageIndex",notificationLevel:"notificationLevel",sid:"sid",status:"status",uniqueName:"uniqueName",state:"state",bindings:"bindings"},Conversation=function(e){ec(Conversation,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v,y,m,g,b,w,k,x,_,S,O,E,T,R,I=PW(Conversation);function Conversation(e,t,n,r,i){var a,o,s;sc(this,Conversation),uc(Xu(s=I.call(this)),"sid",void 0),uc(Xu(s),"_links",void 0),uc(Xu(s),"_participants",void 0),uc(Xu(s),"_configuration",void 0),uc(Xu(s),"_services",void 0),uc(Xu(s),"_internalState",void 0),uc(Xu(s),"_entityName",void 0),uc(Xu(s),"_messagesEntity",void 0),uc(Xu(s),"_messagesList",void 0),uc(Xu(s),"_participantsEntity",void 0),uc(Xu(s),"_participantsMap",void 0),uc(Xu(s),"_dataSource",void 0),uc(Xu(s),"_entityPromise",void 0),uc(Xu(s),"_entity",void 0),s.sid=t,s._links=n,s._configuration=r,s._services=i,s._entityName=e.channel,s._internalState={uniqueName:e.uniqueName||null,status:"notParticipating",attributes:null!==(a=e.attributes)&&void 0!==a?a:{},createdBy:e.createdBy,dateCreated:Nb(e.dateCreated),dateUpdated:Nb(e.dateUpdated),friendlyName:e.friendlyName||null,lastReadMessageIndex:Number.isInteger(e.lastConsumedMessageIndex)?e.lastConsumedMessageIndex:null,bindings:null!==(o=e.bindings)&&void 0!==o?o:{}},e.notificationLevel&&(s._internalState.notificationLevel=e.notificationLevel);var u={participants:s._links.participants};return s._participants=new Map,s._participantsEntity=new Wz(Xu(s),s._participants,u,s._configuration,s._services),s._participantsEntity.on("participantJoined",(function(e){return s.emit("participantJoined",e)})),s._participantsEntity.on("participantLeft",(function(e){return s.emit("participantLeft",e)})),s._participantsEntity.on("participantUpdated",(function(e){return s.emit("participantUpdated",e)})),s._messagesEntity=new EW(Xu(s),r,i),s._messagesEntity.on("messageAdded",(function(e){return s._onMessageAdded(e)})),s._messagesEntity.on("messageUpdated",(function(e){return s.emit("messageUpdated",e)})),s._messagesEntity.on("messageRemoved",(function(e){return s.emit("messageRemoved",e)})),s}return oc(Conversation,[{key:"uniqueName",get:function(){return this._internalState.uniqueName}},{key:"status",get:function(){return this._internalState.status}},{key:"friendlyName",get:function(){return this._internalState.friendlyName}},{key:"dateUpdated",get:function(){return this._internalState.dateUpdated}},{key:"dateCreated",get:function(){return this._internalState.dateCreated}},{key:"createdBy",get:function(){var e;return null!==(e=this._internalState.createdBy)&&void 0!==e?e:""}},{key:"attributes",get:function(){return this._internalState.attributes}},{key:"lastReadMessageIndex",get:function(){return this._internalState.lastReadMessageIndex}},{key:"lastMessage",get:function(){var e;return null!==(e=this._internalState.lastMessage)&&void 0!==e?e:void 0}},{key:"notificationLevel",get:function(){var e;return null!==(e=this._internalState.notificationLevel)&&void 0!==e?e:"default"}},{key:"bindings",get:function(){return this._internalState.bindings}},{key:"limits",get:function(){return this._configuration.limits}},{key:"state",get:function(){return this._internalState.state}},{key:"_statusSource",get:function(){return this._dataSource}},{key:"add",value:(R=Qu(hh.mark((function e(t,n){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._participantsEntity.add(t,null!=n?n:{}));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"addNonChatParticipant",value:(T=Qu(hh.mark((function e(t,n){var r,i,a=arguments;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>2&&void 0!==a[2]?a[2]:{},i=a.length>3&&void 0!==a[3]?a[3]:{},e.abrupt("return",this._participantsEntity.addNonChatParticipant(t,n,null!=r?r:{},null!=i?i:{}));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return T.apply(this,arguments)})},{key:"advanceLastReadMessageIndex",value:(E=Qu(hh.mark((function e(t){var n;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:if(!(t<(null!==(n=this.lastReadMessageIndex)&&void 0!==n?n:0))){e.next=6;break}return e.next=5,this._setLastReadMessageIndex(this.lastReadMessageIndex);case 5:case 8:return e.abrupt("return",e.sent);case 6:return e.next=8,this._setLastReadMessageIndex(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"delete",value:(O=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("delete",this._links.self);case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(){return O.apply(this,arguments)})},{key:"getAttributes",value:(S=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribe();case 2:return e.abrupt("return",this.attributes);case 3:case"end":return e.stop()}}),e,this)}))),function(){return S.apply(this,arguments)})},{key:"getMessages",value:(_=Qu(hh.mark((function e(t,n,r){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this._messagesEntity.getMessages(t,n,r));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return _.apply(this,arguments)})},{key:"getParticipants",value:(x=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this._participantsEntity.getParticipants());case 3:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"getParticipantsCount",value:(k=Qu(hh.mark((function e(){var t,n,r;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Db(this._configuration.links.conversations).path(this.sid).build(),e.next=3,this._services.network.get(n);case 3:return r=e.sent,e.abrupt("return",null!==(t=r.body.participants_count)&&void 0!==t?t:0);case 5:case"end":return e.stop()}}),e,this)}))),function(){return k.apply(this,arguments)})},{key:"getParticipantBySid",value:(w=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._participantsEntity.getParticipantBySid(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"getParticipantByIdentity",value:(b=Qu(hh.mark((function e(){var t,n=arguments;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:"",e.abrupt("return",this._participantsEntity.getParticipantByIdentity(null!=t?t:""));case 2:case"end":return e.stop()}}),e,this)}))),function(){return b.apply(this,arguments)})},{key:"getMessagesCount",value:(g=Qu(hh.mark((function e(){var t,n,r;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Db(this._configuration.links.conversations).path(this.sid).build(),e.next=3,this._services.network.get(n);case 3:return r=e.sent,e.abrupt("return",null!==(t=r.body.messages_count)&&void 0!==t?t:0);case 5:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"getUnreadMessagesCount",value:(m=Qu(hh.mark((function e(){var t,n,r;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new Db(this._configuration.links.myConversations).path(this.sid).build(),e.next=3,this._services.network.get(t);case 3:if((n=e.sent).body.conversation_sid===this.sid){e.next=6;break}throw new Error("Conversation was not found in the user conversations list");case 6:if("number"!=typeof(r=n.body.unread_messages_count)){e.next=9;break}return e.abrupt("return",r);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"join",value:(y=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post",this._links.participants,{identity:this._configuration.userIdentity});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"leave",value:(v=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("joined"!==this._internalState.status){e.next=3;break}return e.next=3,this._services.commandExecutor.mutateResource("delete","".concat(this._links.participants,"/").concat(this._configuration.userIdentity));case 3:return e.abrupt("return",this);case 4:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"removeParticipant",value:(h=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._participantsEntity.remove("string"==typeof t?t:t.sid);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"sendMessage",value:(p=Qu(hh.mark((function e(t,n,r){var i,a,o,s;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t&&null!==t){e.next=6;break}return e.next=3,this._messagesEntity.send(t,n,r);case 3:e.t0=e.sent,e.next=9;break;case 6:return e.next=8,this._messagesEntity.sendMedia(t,n,r);case 8:e.t0=e.sent;case 9:i=e.t0,a="string"==typeof t||null===t?"text":"media";try{o=JSON.parse(i.attributes)}catch(e){}return s={sid:i.sid,text:i.body,type:a,author:i.author,subject:i.subject,lastUpdatedBy:i.participant_sid,attributes:o,dateUpdated:i.date_updated,timestamp:i.date_created,memberSid:i.participant_sid,medias:Array.isArray(i.media)?i.media.map((function(e){return{sid:e.sid,size:Number(e.size),category:e.category,filename:e.filename,contentType:e.content_type}})):null,media:i.media&&"object"===tc(i.media)&&!Array.isArray(i.media)?{sid:i.media.sid,size:Number(i.media.size),category:i.media.category,filename:i.media.filename,contentType:i.media.content_type}:null},e.abrupt("return",this._messagesEntity._upsertMessage(i.index,s));case 14:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return p.apply(this,arguments)})},{key:"prepareMessage",value:function(){return new RW(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:(d=Qu(hh.mark((function e(){var t;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.next=4,this.getMessages(1);case 4:if(!((t=e.sent).items.length>0)){e.next=7;break}return e.abrupt("return",this.advanceLastReadMessageIndex(t.items[0].index));case 7:return e.abrupt("return",0);case 8:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"setAllMessagesUnread",value:(f=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.next=4,this._setLastReadMessageIndex(null);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"setUserNotificationLevel",value:(l=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{notification_level:t});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"typing",value:function(){return this._services.typingIndicator.send(this.sid)}},{key:"updateAttributes",value:(c=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post",this._links.self,{attributes:void 0!==t?JSON.stringify(t):void 0});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"updateFriendlyName",value:(u=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._internalState.friendlyName===t){e.next=3;break}return e.next=3,this._services.commandExecutor.mutateResource("post",this._links.self,{friendly_name:t});case 3:return e.abrupt("return",this);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"updateLastReadMessageIndex",value:(s=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this._setLastReadMessageIndex(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"updateUniqueName",value:(o=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._internalState.uniqueName===t){e.next=4;break}return t||(t=""),e.next=4,this._services.commandExecutor.mutateResource("post",this._links.self,{unique_name:t});case 4:return e.abrupt("return",this);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_subscribe",value:(a=Qu(hh.mark((function e(){var t=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._entityPromise){e.next=2;break}return e.abrupt("return",this._entityPromise);case 2:return this._entityPromise=this._services.syncClient.document({id:this._entityName,mode:"open_existing"}),e.prev=3,e.next=6,this._entityPromise;case 6:return this._entity=e.sent,this._entity.on("updated",(function(e){return t._update(e.data)})),this._entity.on("removed",(function(){return t.emit("removed",t)})),this._update(this._entity.data),e.abrupt("return",this._entity);case 13:throw e.prev=13,e.t0=e.catch(3),this._entity=null,this._entityPromise=null,"disconnected"!=this._services.syncClient.connectionState&&Conversation._logger.error("Failed to get conversation object",e.t0),Conversation._logger.debug("ERROR: Failed to get conversation object",e.t0),e.t0;case 20:case"end":return e.stop()}}),e,this,[[3,13]])}))),function(){return a.apply(this,arguments)})},{key:"_fetchStreams",value:(i=Qu(hh.mark((function e(){var t,n,r;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribe();case 2:return Conversation._logger.trace("_streamsAvailable, this.entity.data=",null===(t=this._entity)||void 0===t?void 0:t.data),r=null===(n=this._entity)||void 0===n?void 0:n.data,e.next=6,this._services.syncClient.list({id:r.messages,mode:"open_existing"});case 6:return this._messagesList=e.sent,e.next=9,this._services.syncClient.map({id:r.roster,mode:"open_existing"});case 9:this._participantsMap=e.sent;case 10:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_subscribeStreams",value:(r=Qu(hh.mark((function e(){var t,n,r,i,a,o,s;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._subscribe();case 3:return Conversation._logger.trace("_subscribeStreams, this.entity.data=",null===(t=this._entity)||void 0===t?void 0:t.data),a=null===(n=this._entity)||void 0===n?void 0:n.data,o=a.messages,s=a.roster,e.next=9,Promise.all([this._messagesEntity.subscribe(null!==(r=this._messagesList)&&void 0!==r?r:o),this._participantsEntity.subscribe(null!==(i=this._participantsMap)&&void 0!==i?i:s)]);case 9:e.next=16;break;case 11:throw e.prev=11,e.t0=e.catch(0),"disconnected"!==this._services.syncClient.connectionState&&Conversation._logger.error("Failed to subscribe on conversation objects",this.sid,e.t0),Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects",this.sid,e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,11]])}))),function(){return r.apply(this,arguments)})},{key:"_unsubscribe",value:(n=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._entity){e.next=5;break}return e.next=3,this._entity.close();case 3:this._entity=null,this._entityPromise=null;case 5:return e.abrupt("return",Promise.all([this._participantsEntity.unsubscribe(),this._messagesEntity.unsubscribe()]));case 6:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_setStatus",value:function(e,t){var n=this;this._dataSource=t,this._internalState.status!==e&&(this._internalState.status=e,"joined"!==e?this._entityPromise&&this._unsubscribe().catch((function(t){if(Conversation._logger.debug("ERROR while setting conversation status "+e,t),"disconnected"!==n._services.syncClient.connectionState)throw t})):this._subscribeStreams().catch((function(t){if(Conversation._logger.debug("ERROR while setting conversation status "+e,t),"disconnected"!==n._services.syncClient.connectionState)throw t})))}},{key:"_update",value:function(e){var t,n,r,i,a;Conversation._logger.trace("_update",e),Conversation.preprocessUpdate(e,this.sid);for(var o=new Set,s=0,u=Object.keys(e);s<u.length;s++){var c=u[s],l=jW[c];if(l)switch(l){case jW.status:if(!e.status||"unknown"===e.status||this._internalState.status===e.status)break;this._internalState.status=e.status,o.add(l);break;case jW.attributes:if(Jx(this._internalState.attributes,e.attributes))break;this._internalState.attributes=e.attributes,o.add(l);break;case jW.lastConsumedMessageIndex:if(void 0===e.lastConsumedMessageIndex||e.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=e.lastConsumedMessageIndex,o.add("lastReadMessageIndex");break;case jW.lastMessage:if(this._internalState.lastMessage&&!e.lastMessage){delete this._internalState.lastMessage,o.add(l);break}this._internalState.lastMessage=this._internalState.lastMessage||{},void 0!==(null===(t=e.lastMessage)||void 0===t?void 0:t.index)&&e.lastMessage.index!==this._internalState.lastMessage.index&&(this._internalState.lastMessage.index=e.lastMessage.index,o.add(l)),void 0!==(null===(n=e.lastMessage)||void 0===n?void 0:n.timestamp)&&(null===(r=this._internalState.lastMessage)||void 0===r||null===(i=r.dateCreated)||void 0===i?void 0:i.getTime())!==e.lastMessage.timestamp.getTime()&&(this._internalState.lastMessage.dateCreated=e.lastMessage.timestamp,o.add(l)),Jx(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case jW.state:var f=e.state||void 0;if(void 0!==f&&(f.dateUpdated=new Date(f.dateUpdated)),Jx(this._internalState.state,f))break;this._internalState.state=f,o.add(l);break;case jW.bindings:if(Jx(this._internalState.bindings,e.bindings))break;this._internalState.bindings=e.bindings,o.add(l);break;default:var d=e[c]instanceof Date,p=d&&(null===(a=this._internalState[l])||void 0===a?void 0:a.getTime())===e[c].getTime(),h=!d&&this[l]===e[c];if(p||h)break;this._internalState[l]=e[c],o.add(l)}}o.size>0&&this.emit("updated",{conversation:this,updateReasons:t_(o)})}},{key:"_onMessageAdded",value:function(e){var t,n=IW(this._participants.values());try{for(n.s();!(t=n.n()).done;){var r=t.value;if(r.identity===e.author){r._endTyping();break}}}catch(e){n.e(e)}finally{n.f()}this.emit("messageAdded",e)}},{key:"_setLastReadMessageIndex",value:(t=Qu(hh.mark((function e(t){var n;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{last_read_message_index:t});case 2:return n=e.sent,e.abrupt("return",n.unread_messages_count);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}],[{key:"preprocessUpdate",value:function(e,t){try{"string"==typeof e.attributes?e.attributes=JSON.parse(e.attributes):e.attributes&&JSON.stringify(e.attributes)}catch(n){Conversation._logger.warn("Retrieved malformed attributes from the server for conversation: "+t),e.attributes={}}try{e.dateCreated&&(e.dateCreated=new Date(e.dateCreated))}catch(n){Conversation._logger.warn("Retrieved malformed dateCreated from the server for conversation: "+t),delete e.dateCreated}try{e.dateUpdated&&(e.dateUpdated=new Date(e.dateUpdated))}catch(n){Conversation._logger.warn("Retrieved malformed dateUpdated from the server for conversation: "+t),delete e.dateUpdated}try{e.lastMessage&&e.lastMessage.timestamp&&(e.lastMessage.timestamp=new Date(e.lastMessage.timestamp))}catch(n){Conversation._logger.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+t),delete e.lastMessage.timestamp}}}]),Conversation}(Vx);uc(Conversation,"participantJoined","participantJoined"),uc(Conversation,"participantLeft","participantLeft"),uc(Conversation,"participantUpdated","participantUpdated"),uc(Conversation,"messageAdded","messageAdded"),uc(Conversation,"messageRemoved","messageRemoved"),uc(Conversation,"messageUpdated","messageUpdated"),uc(Conversation,"typingEnded","typingEnded"),uc(Conversation,"typingStarted","typingStarted"),uc(Conversation,"updated","updated"),uc(Conversation,"removed","removed"),uc(Conversation,"_logger",yy.scope("Conversation")),yh([cx(rx,fx),mh("design:type",Function),mh("design:paramtypes",[String,Object]),mh("design:returntype",Promise)],Conversation.prototype,"add",null),yh([cx(rx,rx,fx),mh("design:type",Function),mh("design:paramtypes",[String,String,Object,Object]),mh("design:returntype",Promise)],Conversation.prototype,"addNonChatParticipant",null),yh([cx(ix),mh("design:type",Function),mh("design:paramtypes",[Number]),mh("design:returntype",Promise)],Conversation.prototype,"advanceLastReadMessageIndex",null),yh([cx(["undefined",ix],["undefined",ix],["undefined",tx("backwards","forward")]),mh("design:type",Function),mh("design:paramtypes",[Number,Number,String]),mh("design:returntype",Promise)],Conversation.prototype,"getMessages",null),yh([cx(rx),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],Conversation.prototype,"getParticipantBySid",null),yh([cx(rx),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],Conversation.prototype,"getParticipantByIdentity",null),yh([cx([rx,Participant]),mh("design:type",Function),mh("design:paramtypes",[Object]),mh("design:returntype",Promise)],Conversation.prototype,"removeParticipant",null),yh([cx(["string",FormData,tx(null),ax("media options",{contentType:rx,media:ex((function(e){var t="string"==typeof e&&e.length>0||e instanceof Uint8Array||e instanceof ArrayBuffer;return"function"==typeof Blob&&(t=t||e instanceof Blob),[t,"a non-empty string, an instance of Buffer or an instance of Blob"]}))})],fx,["undefined",tx(null),ax("email attributes",{subject:[rx,"undefined"]})]),mh("design:type",Function),mh("design:paramtypes",[Object,Object,Object]),mh("design:returntype",Promise)],Conversation.prototype,"sendMessage",null),yh([cx(tx("default","muted")),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],Conversation.prototype,"setUserNotificationLevel",null),yh([cx(lx),mh("design:type",Function),mh("design:paramtypes",[Object]),mh("design:returntype",Promise)],Conversation.prototype,"updateAttributes",null),yh([cx("string"),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],Conversation.prototype,"updateFriendlyName",null),yh([cx([tx(null),ix]),mh("design:type",Function),mh("design:paramtypes",[Number]),mh("design:returntype",Promise)],Conversation.prototype,"updateLastReadMessageIndex",null),yh([cx(["string",tx(null)]),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],Conversation.prototype,"updateUniqueName",null);var AW=function(){function e(){var t=this;sc(this,e),uc(this,"_promise",void 0),uc(this,"_resolve",void 0),uc(this,"_reject",void 0),uc(this,"current",void 0),this._promise=new Promise((function(e,n){t._resolve=e,t._reject=n}))}return oc(e,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(e){this._resolve(e)}},{key:"set",value:function(e){this.current=e,this._resolve(e)}},{key:"fail",value:function(e){this._reject(e)}}]),e}();function MW(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return LW(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return LW(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function LW(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function UW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function NW(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?UW(Object(n),!0).forEach((function(t){uc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):UW(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function FW(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}var DW=yy.scope("Conversations"),qW=function(e){ec(p,e);var t,n,r,i,a,o,s,u,c,l,f,d=FW(p);function p(e,t){var n;return sc(this,p),uc(Xu(n=d.call(this)),"conversations",new Map),uc(Xu(n),"myConversationsRead",new AW),uc(Xu(n),"configuration",void 0),uc(Xu(n),"services",void 0),uc(Xu(n),"tombstones",new Set),uc(Xu(n),"myConversationsFetched",!1),n.configuration=e,n.services=t,n}return oc(p,[{key:"addConversation",value:(f=Qu(hh.mark((function e(t){var n,r,i,a,o,s,u,c,l,f;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=void 0!==(null==t?void 0:t.attributes)?t.attributes:{},e.next=3,this.services.commandExecutor.mutateResource("post",this.configuration.links.conversations,{friendly_name:t.friendlyName,unique_name:t.uniqueName,attributes:void 0!==a?JSON.stringify(a):void 0});case 3:if(o=e.sent,s=null!==(n=o.sid)&&void 0!==n?n:null,u=null!==(r=null===(i=o.sync_objects)||void 0===i?void 0:i.conversation)&&void 0!==r?r:null,c=NW({self:o.url},o.links),!(l=this.conversations.get(s))){e.next=12;break}return e.next=11,l._subscribe();case 11:return e.abrupt("return",l);case 12:return f=new Conversation({channel:u,entityName:"",uniqueName:"",attributes:null,createdBy:"",friendlyName:"",lastConsumedMessageIndex:0,dateCreated:null,dateUpdated:null},s,c,this.configuration,this.services),this.conversations.set(f.sid,f),this._registerForEvents(f),e.next=17,f._subscribe();case 17:return this.emit("conversationAdded",f),e.abrupt("return",f);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"fetchConversations",value:(l=Qu(hh.mark((function e(){var t,n,r,i,a,o,s,u=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._getMap();case 3:return(t=e.sent).on("itemAdded",(function(e){DW.debug("itemAdded: ".concat(e.item.key)),u._upsertConversation("sync",e.item.key,e.item.data)})),t.on("itemRemoved",(function(e){DW.debug("itemRemoved: ".concat(e.key));var t=e.key;u.myConversationsFetched||u.tombstones.add(t);var n=u.conversations.get(t);n&&("joined"===n.status&&(n._setStatus("notParticipating","sync"),u.emit("conversationLeft",n)),u.conversations.delete(t),u.emit("conversationRemoved",n),n.emit("removed",n))})),t.on("itemUpdated",(function(e){DW.debug("itemUpdated: ".concat(e.item.key)),u._upsertConversation("sync",e.item.key,e.item.data)})),e.next=9,this._fetchMyConversations();case 9:n=e.sent,r=[],i=MW(n);try{for(i.s();!(a=i.n()).done;)o=a.value,r.push(this._upsertConversation("rest",o.channel_sid,o))}catch(e){i.e(e)}finally{i.f()}return this.myConversationsRead.set(!0),e.next=16,Promise.all(r);case 16:return this.myConversationsFetched=!0,this.tombstones.clear(),DW.debug("The conversations list has been successfully fetched"),e.abrupt("return",this);case 22:throw e.prev=22,e.t0=e.catch(0),s="Failed to fetch the conversations list","disconnected"!==this.services.syncClient.connectionState&&DW.error(s,e.t0),DW.debug("ERROR: ".concat(s),e.t0),e.t0;case 28:case"end":return e.stop()}}),e,this,[[0,22]])}))),function(){return l.apply(this,arguments)})},{key:"getConversations",value:(c=Qu(hh.mark((function e(){var t,n,r=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getMap();case 2:return t=e.sent,e.next=5,t.getItems();case 5:return n=e.sent,e.abrupt("return",this._wrapPaginator(n,(function(e){return Promise.all(e.map((function(e){return r._upsertConversation("sync",e.key,e.data)})))})));case 7:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"getConversation",value:(u=Qu(hh.mark((function e(t){var n,r,i,a=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getMap();case 2:return n=e.sent,e.next=5,n.getItems({key:t});case 5:return r=e.sent,i=r.items.map((function(e){return a._upsertConversation("sync",e.key,e.data)})),e.abrupt("return",i.length>0?i[0]:null);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"getConversationByUniqueName",value:(s=Qu(hh.mark((function e(t){var n,r,i,a,o;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Db(this.configuration.links.myConversations).path(t).build(),e.next=3,this.services.network.get(n);case 3:return r=e.sent,i=r.body,a=i.conversation_sid,o={entityName:null,lastConsumedMessageIndex:i.last_read_message_index,status:(null==i?void 0:i.status)||"unknown",friendlyName:i.friendly_name,dateUpdated:i.date_updated,dateCreated:i.date_created,uniqueName:i.unique_name,createdBy:i.created_by,attributes:i.attributes,channel:i.sync_objects.conversation,notificationLevel:null==i?void 0:i.notification_level,sid:a},e.abrupt("return",a?this._upsertConversation("sync",a,o):null);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"peekConversation",value:(o=Qu(hh.mark((function e(t){var n,r,i,a;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Db(this.configuration.links.conversations).path(t).build(),e.next=3,this.services.network.get(n);case 3:return r=e.sent,i=r.body,a={entityName:null,status:(null==i?void 0:i.status)||"unknown",friendlyName:i.friendly_name,dateUpdated:i.date_updated,dateCreated:i.date_created,uniqueName:i.unique_name,createdBy:i.created_by,attributes:i.attributes,channel:"".concat(t,".channel"),sid:t},e.abrupt("return",this._upsertConversation("sync",t,a));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_getMap",value:(a=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.syncClient.map({id:this.configuration.myConversations,mode:"open_existing"});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_wrapPaginator",value:(i=Qu(hh.mark((function e(t,n){var r,i=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(t.items);case 2:return r=e.sent,e.abrupt("return",{items:r.filter((function(e){return null!==e})),hasNextPage:t.hasNextPage,hasPrevPage:t.hasPrevPage,nextPage:function(){return t.nextPage().then((function(e){return i._wrapPaginator(e,n)}))},prevPage:function(){return t.prevPage().then((function(e){return i._wrapPaginator(e,n)}))}});case 4:case"end":return e.stop()}}),e)}))),function(e,t){return i.apply(this,arguments)})},{key:"_updateConversation",value:(r=Qu(hh.mark((function e(t,n,r){var i,a,o;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=void 0!==n._statusSource&&t!==n._statusSource,a="rest"!==t||"sync"===n._statusSource,!i||!a||"sync"===t){e.next=5;break}return DW.trace("upsertConversation: conversation is known from sync and came from REST, ignoring",{sid:n.sid,data:r.status,conversation:n.status}),e.abrupt("return");case 5:if("joined"!==r.status||"joined"===n.status){e.next=15;break}return n._setStatus("joined",t),o={},void 0!==r.notificationLevel&&(o.notificationLevel=r.notificationLevel),void 0!==r.lastConsumedMessageIndex&&(o.lastConsumedMessageIndex=r.lastConsumedMessageIndex),Jx(o,{})||n._update(o),e.next=13,n._subscribe();case 13:return this.emit("conversationJoined",n),e.abrupt("return");case 15:if("notParticipating"!==r.status||"joined"!==n.status){e.next=22;break}return n._setStatus("notParticipating",t),n._update(r),e.next=20,n._subscribe();case 20:return this.emit("conversationLeft",n),e.abrupt("return");case 22:if("notParticipating"!==r.status){e.next=26;break}return e.next=25,n._subscribe();case 25:return e.abrupt("return");case 26:n._update(r);case 27:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"_upsertConversation",value:(n=Qu(hh.mark((function e(t,n,r){var i,a,o,s;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(DW.trace("upsertConversation called for ".concat(n),r),!(i=this.conversations.get(n))){e.next=9;break}return DW.trace("upsertConversation: the conversation ".concat(i.sid," is known;")+"its status is known from the source ".concat(i._statusSource," ")+"and the update came from the source ".concat(t),i),e.next=6,this._updateConversation(t,i,r);case 6:return e.next=8,i._subscribe();case 8:return e.abrupt("return",i);case 9:if("rest"!==t||!this.tombstones.has(n)){e.next=12;break}return DW.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring",n),e.abrupt("return",null);case 12:return DW.trace("upsertConversation: creating a local conversation object with sid "+n,r),a="".concat(this.configuration.links.conversations,"/").concat(n),o={self:a,messages:"".concat(a,"/Messages"),participants:"".concat(a,"/Participants")},s=new Conversation(r,n,o,this.configuration,this.services),this.conversations.set(n,s),e.prev=17,e.next=20,s._subscribe();case 20:if("joined"!==r.status){e.next=23;break}return e.next=23,s._fetchStreams();case 23:e.next=32;break;case 25:if(e.prev=25,e.t0=e.catch(17),"SyncError"===e.t0.name){e.next=29;break}throw e.t0;case 29:return DW.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring",n,e.t0),this.conversations.delete(n),e.abrupt("return",null);case 32:return this._registerForEvents(s),this.emit("conversationAdded",s),"joined"===r.status&&(s._setStatus("joined",t),this.emit("conversationJoined",s)),e.abrupt("return",s);case 36:case"end":return e.stop()}}),e,this,[[17,25]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"_fetchMyConversations",value:(t=Qu(hh.mark((function e(){var t,n,r,i,a,o;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],n=null;case 2:return i=new Db(this.configuration.links.myConversations),n&&i.arg("PageToken",n),e.next=6,this.services.network.get(i.build());case 6:a=e.sent,o=null===(r=a.body)||void 0===r?void 0:r.conversations.map((function(e){return{descriptor:e,channel_sid:e.conversation_sid,status:e.status,channel:e.sync_objects.conversation,messages:e.sync_objects.messages,roster:"".concat(e.conversation_sid,".roster"),lastConsumedMessageIndex:e.last_read_message_index,notificationLevel:e.notification_level}})),n=a.body.meta.next_token,t=[].concat(t_(t),t_(o));case 10:if(n){e.next=2;break}case 11:return e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_onConversationRemoved",value:function(e){var t=this.conversations.get(e);t&&(this.conversations.delete(e),this.emit("conversationRemoved",t))}},{key:"_registerForEvents",value:function(e){var t=this;e.on("removed",(function(){return t._onConversationRemoved(e.sid)})),e.on("updated",(function(e){return t.emit("conversationUpdated",e)})),e.on("participantJoined",(function(e){return t.emit("participantJoined",e)})),e.on("participantLeft",(function(e){return t.emit("participantLeft",e)})),e.on("participantUpdated",(function(e){return t.emit("participantUpdated",e)})),e.on("messageAdded",(function(e){return t.emit("messageAdded",e)})),e.on("messageUpdated",(function(e){return t.emit("messageUpdated",e)})),e.on("messageRemoved",(function(e){return t.emit("messageRemoved",e)})),e.on("typingStarted",(function(e){return t.emit("typingStarted",e)})),e.on("typingEnded",(function(e){return t.emit("typingEnded",e)}))}}]),p}(Vx),BW=Zr,zW=Do.find,WW=Ly,$W="find",KW=!0;$W in[]&&Array(1)[$W]((function(){KW=!1})),BW({target:"Array",proto:!0,forced:KW},{find:function(e){return zW(this,e,arguments.length>1?arguments[1]:void 0)}}),WW($W);var HW=s,GW=So,VW=TypeError,YW=Object.getOwnPropertyDescriptor,JW=HW&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),QW=Zr,XW=Fe,ZW=ar,e$=tr,t$=lr,n$=JW?function(e,t){if(GW(e)&&!YW(e,"length").writable)throw VW("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},r$=bh,i$=Po,a$=Ha,o$=YD,s$=Fu("splice"),u$=Math.max,c$=Math.min;function l$(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}QW({target:"Array",proto:!0,forced:!s$},{splice:function(e,t){var n,r,i,a,o,s,u=XW(this),c=t$(u),l=ZW(e,c),f=arguments.length;for(0===f?n=r=0:1===f?(n=0,r=c-l):(n=f-2,r=c$(u$(e$(t),0),c-l)),r$(c+n-r),i=i$(u,r),a=0;a<r;a++)(o=l+a)in u&&a$(i,a,u[o]);if(i.length=r,n<r){for(a=l;a<c-r;a++)s=a+n,(o=a+r)in u?u[s]=u[o]:o$(u,s);for(a=c;a>c-r+n;a--)o$(u,a-1)}else if(n>r)for(a=c-r;a>l;a--)s=a+n-1,(o=a+r-1)in u?u[s]=u[o]:o$(u,s);for(a=0;a<n;a++)u[a+l]=arguments[a+2];return n$(u,c-r+n),i}});var f$=function(e){ec(a,e);var t,n,r,i=l$(a);function a(e,t,n){var r;return sc(this,a),uc(Xu(r=i.call(this)),"configuration",void 0),uc(Xu(r),"services",void 0),uc(Xu(r),"subscribedUsers",void 0),uc(Xu(r),"fifoStack",void 0),uc(Xu(r),"myself",void 0),r.configuration=t,r.services=n,r.fifoStack=[],r.myself=e,r.myself.on("updated",(function(e){return r.emit("userUpdated",e)})),r.myself.on("userSubscribed",(function(){return r.emit("userSubscribed",r.myself)})),r.myself.on("userUnsubscribed",(function(){r.emit("userUnsubscribed",r.myself),r.myself._ensureFetched()})),r.subscribedUsers=new Map,r}return oc(a,[{key:"handleUnsubscribeUser",value:function(e){this.subscribedUsers.has(e.identity)&&this.subscribedUsers.delete(e.identity);var t=0;this.fifoStack.find((function(n,r){return n==e.identity&&(t=r,!0)}))&&this.fifoStack.splice(t,1),this.emit("userUnsubscribed",e)}},{key:"handleSubscribeUser",value:function(e){if(!this.subscribedUsers.has(e.identity)){if(this.fifoStack.length>=this.configuration.userInfosToSubscribe){var t,n,r=this.fifoStack.shift();null===(t=this.subscribedUsers)||void 0===t||null===(n=t.get(r))||void 0===n||n.unsubscribe()}this.fifoStack.push(e.identity),this.subscribedUsers.set(e.identity,e),this.emit("userSubscribed",e)}}},{key:"getUser",value:(r=Qu(hh.mark((function e(t,n){var r,i,a,o=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.myself._ensureFetched();case 2:if(t!=this.myself.identity){e.next=4;break}return e.abrupt("return",this.myself);case 4:if(!(i=this.subscribedUsers.get(t))){e.next=7;break}return e.abrupt("return",i);case 7:if(null===(r=n)||void 0===r){e.next=11;break}e.next=14;break;case 11:return e.next=13,this.getSyncUniqueName(t);case 13:n=e.sent;case 14:return(a=new User(t,n,this.configuration,this.services)).on("updated",(function(e){return o.emit("userUpdated",e)})),a.on("userSubscribed",(function(){return o.handleSubscribeUser(a)})),a.on("userUnsubscribed",(function(){return o.handleUnsubscribeUser(a)})),e.next=20,a._ensureFetched();case 20:return e.abrupt("return",a);case 21:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"getSubscribedUsers",value:(n=Qu(hh.mark((function e(){var t;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.myself._ensureFetched();case 2:return t=[this.myself],this.subscribedUsers.forEach((function(e){return t.push(e)})),e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getSyncUniqueName",value:(t=Qu(hh.mark((function e(t){var n,r,i;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new Db(this.configuration.links.users).path(t).build(),e.next=3,this.services.network.get(r);case 3:return i=e.sent,e.abrupt("return",null!==(n=i.body.sync_objects.user_info_map)&&void 0!==n?n:"");case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),a}(Vx),d$=yy.scope("TypingIndicator"),p$=function(){function e(t,n,r){sc(this,e),uc(this,"services",void 0),uc(this,"configuration",void 0),uc(this,"sentUpdates",void 0),uc(this,"getConversation",void 0),uc(this,"serviceTypingTimeout",void 0),this.configuration=n,this.services=r,this.getConversation=t,this.serviceTypingTimeout=null,this.sentUpdates=new Map}var t;return oc(e,[{key:"typingTimeout",get:function(){return this.configuration.typingIndicatorTimeoutOverride||this.serviceTypingTimeout||this.configuration.typingIndicatorTimeoutDefault}},{key:"initialize",value:function(){var e=this;this.services.notificationClient.on("message",function(){var t=Qu(hh.mark((function t(n,r){return hh.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==lA.TYPING_INDICATOR){t.next=3;break}return t.next=3,e._handleRemoteTyping(JSON.parse(r));case 3:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}())}},{key:"_handleRemoteTyping",value:(t=Qu(hh.mark((function e(t){var n=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:d$.trace("Got new typing indicator ",t),this.getConversation(t.channel_sid).then((function(e){e&&e._participants.forEach((function(e){if(e.identity===t.identity){var r=n.configuration.typingIndicatorTimeoutOverride?n.configuration.typingIndicatorTimeoutOverride+1e3:1e3*t.typing_timeout;e._startTyping(r)}}))})).catch((function(e){throw d$.error(e),e}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"send",value:function(e){var t=this.sentUpdates.get(e);return t&&t>Date.now()-this.typingTimeout?Promise.resolve():(this.sentUpdates.set(e,Date.now()),this._send(e))}},{key:"_send",value:function(e){var t=this;d$.trace("Sending typing indicator");var n=this.configuration.links.typing,r="ChannelSid=".concat(e);return this.services.twilsockClient.sendRequest(new BS.HttpRequest({method:"POST",url:n,headers:{"Content-Type":"application/x-www-form-urlencoded"},payload:r,grant:this.configuration.productId})).then((function(e){var n=JSON.parse(e.payload);n.hasOwnProperty("typing_timeout")&&(t.serviceTypingTimeout=1e3*n.typing_timeout)})).catch((function(e){throw d$.error("Failed to send typing indicator:",e),e}))}}]),e}(),PushNotification=oc((function PushNotification(e){sc(this,PushNotification),uc(this,"title",void 0),uc(this,"body",void 0),uc(this,"sound",void 0),uc(this,"badge",void 0),uc(this,"action",void 0),uc(this,"type",void 0),uc(this,"data",void 0),this.title=e.title||null,this.body=e.body||null,this.sound=e.sound||null,this.badge=e.badge||null,this.action=e.action||null,this.type=e.type||null,this.data=e.data||{}})),h$="3.0.0-rc.1";function v$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function y$(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?v$(Object(n),!0).forEach((function(t){uc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v$(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var m$,g$,b$=function(e){return e.replace(/(^\/+|\/+$)/g,"")},w$=function(){function e(t,n,r){sc(this,e),uc(this,"_serviceUrl",void 0),uc(this,"_services",void 0),uc(this,"_productId",void 0),this._serviceUrl=t,this._services=n,this._productId=r}var t,n,r;return oc(e,[{key:"_preProcessUrl",value:function(e){var t=b$(e);return/^https?:\/\//.test(e)?t:"".concat(b$(this._serviceUrl),"/").concat(t)}},{key:"_makeRequest",value:(r=Qu(hh.mark((function e(t,n,r,i){var a,o,s,u;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=this._preProcessUrl(n),o=y$({"Content-Type":"application/json; charset=utf-8"},i||{}),e.t0=t,e.next="get"===e.t0?5:"post"===e.t0?11:"delete"===e.t0?15:19;break;case 5:return u=a,r&&(u+="?"+Object.entries(r).map((function(e){return e.map((function(e){return encodeURIComponent(String(e))})).join("=")})).join("&")),e.next=9,this._services.transport.sendRequest(new BS.HttpRequest({url:u,headers:o,grant:this._productId}));case 9:case 13:case 17:return s=e.sent,e.abrupt("break",19);case 11:return e.next=13,this._services.transport.sendRequest(new BS.HttpRequest({method:"POST",url:a,headers:o,payload:JSON.stringify(r),grant:this._productId}));case 15:return e.next=17,this._services.transport.sendRequest(new BS.HttpRequest({method:"DELETE",url:a,headers:o,grant:this._productId}));case 19:if(!(s.statusCode<200||s.statusCode>=300)){e.next=21;break}throw new Error("Request responded with a non-success code ".concat(s.statusCode));case 21:return e.abrupt("return",s);case 22:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"fetchResource",value:(n=Qu(hh.mark((function e(t,n){var r,i=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=1,e.next=4,new DS({min:50,max:1600,maxAttemptsCount:6}).run((function(){return i._makeRequest("get",t,n)}));case 4:return r=e.sent,e.abrupt("return",JSON.parse(r.payload));case 8:throw e.prev=8,e.t0=e.catch(1),new Error('Fetch resource from "'.concat(t,'" failed.'));case 11:case"end":return e.stop()}}),e,null,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"mutateResource",value:(t=Qu(hh.mark((function e(t,n,r){var i,a;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequest(t,n,r,{"X-Twilio-Mutation-Id":QS()});case 2:i=e.sent,a={};try{a=JSON.parse(i.payload)}catch(e){}if(202!==i.statusCode){e.next=9;break}return e.next=8,this.fetchResource(a.resource_url);case 8:return e.abrupt("return",e.sent);case 9:return e.abrupt("return",a);case 10:case"end":return e.stop()}}),e,this)}))),function(e,n,r){return t.apply(this,arguments)})}]),e}();function k$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function x$(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?k$(Object(n),!0).forEach((function(t){uc(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k$(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _$(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=rc(e);if(t){var i=rc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return nc(this,n)}}var S$=oc((function e(){sc(this,e),uc(this,"commandExecutor",void 0),uc(this,"twilsockClient",void 0),uc(this,"users",void 0),uc(this,"notificationClient",void 0),uc(this,"network",void 0),uc(this,"typingIndicator",void 0),uc(this,"syncClient",void 0),uc(this,"mcsClient",void 0),uc(this,"transport",void 0)}));return e.Client=(m$=function(e){ec(Client,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v=_$(Client);function Client(e){var t,n,r,i,a,o,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(sc(this,Client),uc(Xu(o=v.call(this)),"version",h$),uc(Xu(o),"connectionState","unknown"),uc(Xu(o),"_ensureReady",void 0),uc(Xu(o),"_options",void 0),uc(Xu(o),"_services",void 0),uc(Xu(o),"_myself",void 0),uc(Xu(o),"_resolveEnsureReady",void 0),uc(Xu(o),"_rejectEnsureReady",void 0),uc(Xu(o),"_fpaToken",void 0),uc(Xu(o),"_configuration",void 0),uc(Xu(o),"_conversationsEntity",void 0),uc(Xu(o),"_conversationsPromise",void 0),uc(Xu(o),"parsePushNotification",g$.parsePushNotification),o._fpaToken=null!=e?e:"",o._options=null!=s?s:{},!o._options.disableDeepClone){var u=x$(x$({},o._options),{},{transport:void 0,twilsockClient:void 0});(u=Lb(u)).transport=o._options.transport,u.twilsockClient=o._options.twilsockClient,o._options=u}o._options.logLevel=null!==(t=o._options.logLevel)&&void 0!==t?t:"silent",g$._logger.setLevel(o._options.logLevel);var c=o._options.productId="ip_messaging";if(o._options.clientMetadata=o._options.clientMetadata||{},o._options.clientMetadata.hasOwnProperty("type")||(o._options.clientMetadata.type="conversations"),o._options.clientMetadata.hasOwnProperty("sdk")||(o._options.clientMetadata.sdk="JS",o._options.clientMetadata.sdkv=h$),o._options.Sync=o._options.Sync||{},void 0===o._options.Sync.enableSessionStorage&&(o._options.Sync.enableSessionStorage=!0),o._options.region&&(o._options.Sync.region=o._options.region),!e)throw new Error("A valid Twilio token should be provided");o._services=new S$,o._myself=new User("","",null,o._services);var l=!o._options.twilsockClient;if(!o._options.initRegistrations){var f=new BS.InitRegistration(c);g$.populateInitRegistrations(f),o._options.initRegistrations=[f]}o._services.twilsockClient=o._options.twilsockClient=null!==(n=o._options.twilsockClient)&&void 0!==n?n:new BS.TwilsockClient(e,c,o._options),o._services.twilsockClient.on("tokenAboutToExpire",(function(){return o.emit("tokenAboutToExpire")})),o._services.twilsockClient.on("tokenExpired",(function(){return o.emit("tokenExpired")})),o._services.twilsockClient.on("disconnected",(function(){g$._logger.debug("Handling stateChanged for ConversationsClient: new state disconnected"),"disconnected"!==o.connectionState&&(o.connectionState="disconnected",o.emit("connectionStateChanged",o.connectionState))})),o._services.twilsockClient.on("connecting",(function(){g$._logger.debug("Handling stateChanged for ConversationsClient: new state connecting"),"connecting"!==o.connectionState&&(o.connectionState="connecting",o.emit("connectionStateChanged",o.connectionState))})),o._services.twilsockClient.on("connected",(function(){g$._logger.debug("Handling stateChanged for ConversationsClient: new state connected"),"connected"!==o.connectionState&&(o.connectionState="connected",o.emit("connectionStateChanged",o.connectionState))})),o._services.transport=o._options.transport=null!==(r=o._options.transport)&&void 0!==r?r:o._options.twilsockClient,o._services.notificationClient=o._options.notificationsClient=null!==(i=o._options.notificationsClient)&&void 0!==i?i:new fA.Notifications(e,o._options),o._services.syncClient=o._options.syncClient=null!==(a=o._options.syncClient)&&void 0!==a?a:new GU(e,o._options);var d=(null==s?void 0:s.Chat)||(null==s?void 0:s.IPMessaging)||s||{},p=d.region||(null==s?void 0:s.region),h=d.apiUri||d.typingUri||"https://aim.".concat(p||"us1",".twilio.com");o._services.commandExecutor=new w$(h,{transport:o._options.transport},c);var y=function(e){o._rejectEnsureReady(e),o.emit("initFailed",{error:e})},m=function(){y({terminal:!0,message:"Twilsock has disconnected."})};return o._services.twilsockClient.once("disconnected",m),o._services.twilsockClient.once("connected",Qu(hh.mark((function e(){var t;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return g$._logger.debug("ConversationsClient started INITIALIZING"),o._services.twilsockClient.off("disconnected",m),e.prev=2,e.next=6,o._initialize();case 6:e.next=13;break;case 8:e.prev=8,e.t0=e.catch(2),t={terminal:!0,message:e.t0.message},o._rejectEnsureReady(t),o.emit("initFailed",{error:t});case 13:case"end":return e.stop()}}),e,null,[[2,8]])})))),o._ensureReady=new Promise((function(e,t){o._resolveEnsureReady=e,o._rejectEnsureReady=t})).catch((function(){})),l&&o._services.twilsockClient.connect(),o}return oc(Client,[{key:"user",get:function(){return this._myself}},{key:"reachabilityEnabled",get:function(){if(!this._configuration)throw new Error("Reachability information could not yet be accessed as the client has not yet been initialized. Subscribe to 'initialized' and 'initFailed' events to properly react to the client initialization.");return this._configuration.reachabilityEnabled}},{key:"shutdown",value:(h=Qu(hh.mark((function e(){var t;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,null===(t=this._services.network)||void 0===t?void 0:t.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"updateToken",value:(p=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:if(g$._logger.info("updateToken"),this._fpaToken!==t){e.next=5;break}return e.abrupt("return",this);case 5:return e.next=7,this._services.twilsockClient.updateToken(t);case 7:return e.next=9,this._services.notificationClient.updateToken(t);case 9:return e.next=11,this._services.mcsClient.updateToken(t);case 11:return this._fpaToken=t,e.abrupt("return",this);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"getConversationBySid",value:(d=Qu(hh.mark((function e(t){var n;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return e.next=6,this._conversationsEntity.getConversation(t);case 6:if(n=e.sent){e.next=9;break}throw new Error("Conversation with SID ".concat(t," was not found."));case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"peekConversationBySid",value:(f=Qu(hh.mark((function e(t){var n;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._conversationsEntity.peekConversation(t);case 4:if(n=e.sent){e.next=7;break}throw new Error("Conversation with SID ".concat(t," was not found."));case 7:return e.abrupt("return",n);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"getConversationByUniqueName",value:(l=Qu(hh.mark((function e(t){var n;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return e.next=6,this._conversationsEntity.getConversationByUniqueName(t);case 6:if(n=e.sent){e.next=9;break}throw new Error("Conversation with unique name ".concat(t," was not found."));case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"getSubscribedConversations",value:(c=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.abrupt("return",this._conversationsPromise.then((function(e){return e.getConversations()})));case 3:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"createConversation",value:(u=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return t=t||{},e.abrupt("return",this._conversationsPromise.then((function(e){return e.addConversation(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"setPushRegistrationId",value:(s=Qu(hh.mark((function e(t,n){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return this._subscribeToPushNotifications(t),this._services.notificationClient.setPushRegistrationId(t,n),e.next=6,this._services.notificationClient.commitChanges();case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"unsetPushRegistrationId",value:(o=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return this._unsubscribeFromPushNotifications(t),e.next=5,this._services.notificationClient.commitChanges();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"removePushRegistrations",value:(a=Qu(hh.mark((function e(t,n){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.notificationClient.removeRegistrations(t,n);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handlePushNotification",value:(i=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:g$._logger.debug("handlePushNotification, notificationPayload=",t),this.emit("pushNotification",g$.parsePushNotification(t));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getUser",value:(r=Qu(hh.mark((function e(t){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.abrupt("return",this._services.users.getUser(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getSubscribedUsers",value:(n=Qu(hh.mark((function e(){return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.abrupt("return",this._services.users.getSubscribedUsers());case 3:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getTemporaryContentUrlsForMediaSids",value:function(e){var t=this;return new VU.CancellablePromise(function(){var n=Qu(hh.mark((function n(r,i,a){var o,s;return hh.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(t._services.mcsClient&&e){n.next=3;break}return i(new Error("Media Content Service is unavailable")),n.abrupt("return");case 3:return o=t._services.mcsClient.mediaSetGetContentUrls(e),a((function(){o.cancel()})),n.prev=5,n.next=8,o;case 8:s=n.sent,r(s),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(5),i(n.t0);case 15:case"end":return n.stop()}}),n,null,[[5,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForMedia",value:function(e){var t=e.map((function(e){return e.sid}));return this.getTemporaryContentUrlsForMediaSids(t)}},{key:"_initialize",value:(t=Qu(hh.mark((function e(){var t,n=this;return hh.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.fetchResource("Client/v2/Configuration");case 2:return t=e.sent,this._configuration=new Iy(this._options,t,g$._logger),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new p$(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new cA(this._configuration,this._services),this._services.users=new f$(this._myself,this._configuration,this._services),this._services.users.on("userSubscribed",(function(e){n.emit("userSubscribed",e)})),this._services.users.on("userUpdated",(function(e){return n.emit("userUpdated",e)})),this._services.users.on("userUnsubscribed",(function(e){n.emit("userUnsubscribed",e)})),this._conversationsEntity=new qW(this._configuration,this._services),this._conversationsEntity.on("conversationAdded",(function(e){n.emit("conversationAdded",e)})),this._conversationsEntity.on("conversationRemoved",(function(e){n.emit("conversationRemoved",e)})),this._conversationsEntity.on("conversationJoined",(function(e){n.emit("conversationJoined",e)})),this._conversationsEntity.on("conversationLeft",(function(e){n.emit("conversationLeft",e)})),this._conversationsEntity.on("conversationUpdated",(function(e){return n.emit("conversationUpdated",e)})),this._conversationsEntity.on("participantJoined",(function(e){n.emit("participantJoined",e)})),this._conversationsEntity.on("participantLeft",(function(e){n.emit("participantLeft",e)})),this._conversationsEntity.on("participantUpdated",(function(e){return n.emit("participantUpdated",e)})),this._conversationsEntity.on("messageAdded",(function(e){return n.emit("messageAdded",e)})),this._conversationsEntity.on("messageUpdated",(function(e){return n.emit("messageUpdated",e)})),this._conversationsEntity.on("messageRemoved",(function(e){return n.emit("messageRemoved",e)})),this._conversationsEntity.on("typingStarted",(function(e){return n.emit("typingStarted",e)})),this._conversationsEntity.on("typingEnded",(function(e){return n.emit("typingEnded",e)})),this._conversationsPromise=this._conversationsEntity.fetchConversations().then((function(){return n._conversationsEntity})).catch((function(e){if("Client has been shut down."===e.message)return n._conversationsEntity;throw e})),e.next=28,this._services.users.myself._ensureFetched();case 28:g$._supportedPushChannels.forEach((function(e){return n._subscribeToPushNotifications(e)})),this._services.typingIndicator.initialize(),this._services.mcsClient=new VU.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,x$(x$({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit("initialized");case 33:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_subscribeToPushNotifications",value:function(e){var t=this;[lA.NEW_MESSAGE,lA.ADDED_TO_CONVERSATION,lA.REMOVED_FROM_CONVERSATION,lA.TYPING_INDICATOR,lA.CONSUMPTION_UPDATE].forEach((function(n){t._services.notificationClient.subscribe(e,n)}))}},{key:"_unsubscribeFromPushNotifications",value:function(e){var t=this;[lA.NEW_MESSAGE,lA.ADDED_TO_CONVERSATION,lA.REMOVED_FROM_CONVERSATION,lA.TYPING_INDICATOR,lA.CONSUMPTION_UPDATE].forEach((function(n){t._services.notificationClient.unsubscribe(e,n)}))}}],[{key:"parsePushNotification",value:function(e){if(g$._logger.debug("parsePushNotification, notificationPayload=",e),void 0!==e.aps){if(!e.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var t,n,r,i=g$._parsePushNotificationChatData(e),a=e.aps,o=null;if("string"==typeof a.alert)t=a.alert||null;else t=(null===(n=a.alert)||void 0===n?void 0:n.body)||null,o=(null===(r=a.alert)||void 0===r?void 0:r.title)||null;return new PushNotification({title:o,body:t,sound:a.sound||null,badge:a.badge||null,action:a.category||null,type:e.twi_message_type,data:i})}if(void 0!==e.data){var s=e.data;if(!s.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var u=g$._parsePushNotificationChatData(e.data);return new PushNotification({title:s.twi_title||null,body:s.twi_body||null,sound:s.twi_sound||null,badge:null,action:s.twi_action||null,type:s.twi_message_type,data:u})}throw new Error("Provided push notification payload is not Programmable Chat notification")}},{key:"_parsePushNotificationChatData",value:function(e){var t={};for(var n in g$._supportedPushDataFields){var r=e[n];if(null!=r)if("message_index"!==n&&"media_count"!==n){if("media"!==n)t[g$._supportedPushDataFields[n]]=r;else if("string"==typeof r)try{t[g$._supportedPushDataFields[n]]=JSON.parse(r)}catch(e){g$._logger.debug("Media message notification parsing error")}}else{var i=Ub(r);null!==i&&(t[g$._supportedPushDataFields[n]]=i)}}return t}},{key:"populateInitRegistrations",value:function(e){}}]),Client}(Vx),uc(m$,"conversationAdded","conversationAdded"),uc(m$,"conversationJoined","conversationJoined"),uc(m$,"conversationLeft","conversationLeft"),uc(m$,"conversationRemoved","conversationRemoved"),uc(m$,"conversationUpdated","conversationUpdated"),uc(m$,"participantJoined","participantJoined"),uc(m$,"participantLeft","participantLeft"),uc(m$,"participantUpdated","participantUpdated"),uc(m$,"messageAdded","messageAdded"),uc(m$,"messageRemoved","messageRemoved"),uc(m$,"messageUpdated","messageUpdated"),uc(m$,"tokenAboutToExpire","tokenAboutToExpire"),uc(m$,"tokenExpired","tokenExpired"),uc(m$,"typingEnded","typingEnded"),uc(m$,"typingStarted","typingStarted"),uc(m$,"pushNotification","pushNotification"),uc(m$,"userSubscribed","userSubscribed"),uc(m$,"userUnsubscribed","userUnsubscribed"),uc(m$,"userUpdated","userUpdated"),uc(m$,"initialized","initialized"),uc(m$,"initFailed","initFailed"),uc(m$,"connectionStateChanged","connectionStateChanged"),uc(m$,"connectionError","connectionError"),uc(m$,"version",h$),uc(m$,"_logger",yy.scope("Client")),uc(m$,"_supportedPushChannels",["fcm","apn"]),uc(m$,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),g$=m$),yh([cx(rx),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],e.Client.prototype,"updateToken",null),yh([cx(rx),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],e.Client.prototype,"getConversationBySid",null),yh([cx(rx),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],e.Client.prototype,"peekConversationBySid",null),yh([cx(rx),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],e.Client.prototype,"getConversationByUniqueName",null),yh([cx(["undefined",ax("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),mh("design:type",Function),mh("design:paramtypes",[Object]),mh("design:returntype",Promise)],e.Client.prototype,"createConversation",null),yh([cx(tx("fcm","apn"),"string"),mh("design:type",Function),mh("design:paramtypes",[String,String]),mh("design:returntype",Promise)],e.Client.prototype,"setPushRegistrationId",null),yh([cx(tx("fcm","apn")),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],e.Client.prototype,"unsetPushRegistrationId",null),yh([cx(tx("fcm","apn"),rx),mh("design:type",Function),mh("design:paramtypes",[String,String]),mh("design:returntype",Promise)],e.Client.prototype,"removePushRegistrations",null),yh([cx(ox),mh("design:type",Function),mh("design:paramtypes",[Object]),mh("design:returntype",Promise)],e.Client.prototype,"handlePushNotification",null),yh([cx(rx),mh("design:type",Function),mh("design:paramtypes",[String]),mh("design:returntype",Promise)],e.Client.prototype,"getUser",null),yh([cx(nx("strings","string")),mh("design:type",Function),mh("design:paramtypes",[Array]),mh("design:returntype",VU.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),yh([cx(nx("media",Media)),mh("design:type",Function),mh("design:paramtypes",[Array]),mh("design:returntype",VU.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMedia",null),yh([ux(ox),mh("design:type",Function),mh("design:paramtypes",[Object]),mh("design:returntype",PushNotification)],e.Client,"parsePushNotification",null),e.Client=g$=yh([sx(rx,[ox,"undefined"]),mh("design:paramtypes",[String,Object])],e.Client),e.AggregatedDeliveryReceipt=AggregatedDeliveryReceipt,e.CancellablePromise=VU.CancellablePromise,e.Conversation=Conversation,e.DetailedDeliveryReceipt=DetailedDeliveryReceipt,e.Media=Media,e.Message=Message,e.MessageBuilder=RW,e.NotificationTypes=lA,e.Participant=Participant,e.PushNotification=PushNotification,e.RestPaginator=mW,e.UnsentMessage=TW,e.User=User,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|