@acrobits/ipc-sdk 0.8.0-alpha.3 → 0.8.0-alpha.4
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/lib/ipc-sdk.umd.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(y,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(y=typeof globalThis<"u"?globalThis:y||self,d(y["@acrobits/ipc-sdk"]={}))})(this,function(y){"use strict";var Tt=Object.defineProperty;var Pt=(y,d,C)=>d in y?Tt(y,d,{enumerable:!0,configurable:!0,writable:!0,value:C}):y[d]=C;var T=(y,d,C)=>(Pt(y,typeof d!="symbol"?d+"":d,C),C);var d=(n=>(n.BadgeQuery="BADGE QUERY",n.Lifecycle="LIFECYCLE",n.PushToken="PUSH TOKEN",n))(d||{}),C=function(n,t){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},C(n,t)};function x(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");C(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function D(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function L(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return s}function U(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return n.concat(s||Array.prototype.slice.call(t))}function m(n){return typeof n=="function"}function q(n){var t=function(r){Error.call(r),r.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var B=q(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
2
2
|
`+e.map(function(r,i){return i+1+") "+r.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function $(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var P=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=D(o),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(f){t={error:f}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else o.remove(this);var b=this.initialTeardown;if(m(b))try{b()}catch(f){s=f instanceof B?f.errors:[f]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var M=D(v),E=M.next();!E.done;E=M.next()){var ie=E.value;try{ce(ie)}catch(f){s=s??[],f instanceof B?s=U(U([],L(s)),L(f.errors)):s.push(f)}}}catch(f){r={error:f}}finally{try{E&&!E.done&&(i=M.return)&&i.call(M)}finally{if(r)throw r.error}}}if(s)throw new B(s)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)ce(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&$(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&$(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),se=P.EMPTY;function oe(n){return n instanceof P||n&&"closed"in n&&m(n.remove)&&m(n.add)&&m(n.unsubscribe)}function ce(n){m(n)?n():n.unsubscribe()}var ue={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ae={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,U([n,t],L(e)))},clearTimeout:function(n){var t=ae.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Re(n){ae.setTimeout(function(){throw n})}function le(){}function k(n){n()}var H=function(n){x(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,oe(e)&&e.add(r)):r.destination=Ue,r}return t.create=function(e,r,i){return new j(e,r,i)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(P),Ae=Function.prototype.bind;function Q(n,t){return Ae.call(n,t)}var Oe=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){F(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){F(r)}else F(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){F(e)}},n}(),j=function(n){x(t,n);function t(e,r,i){var s=n.call(this)||this,o;if(m(e)||!e)o={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;s&&ue.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return s.unsubscribe()},o={next:e.next&&Q(e.next,c),error:e.error&&Q(e.error,c),complete:e.complete&&Q(e.complete,c)}):o=e}return s.destination=new Oe(o),s}return t}(H);function F(n){Re(n)}function Le(n){throw n}var Ue={closed:!0,next:le,error:Le,complete:le},$e=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function he(n){return n}function ke(n){return n.length===0?he:n.length===1?n[0]:function(e){return n.reduce(function(r,i){return i(r)},e)}}var z=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var i=this,s=Fe(t)?t:new j(t,e,r);return k(function(){var o=i,c=o.operator,u=o.source;s.add(c?c.call(s,u):u?i._subscribe(s):i._trySubscribe(s))}),s},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=de(e),new e(function(i,s){var o=new j({next:function(c){try{t(c)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[$e]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return ke(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=de(t),new t(function(r,i){var s;e.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},n.create=function(t){return new n(t)},n}();function de(n){var t;return(t=n??ue.Promise)!==null&&t!==void 0?t:Promise}function je(n){return n&&m(n.next)&&m(n.error)&&m(n.complete)}function Fe(n){return n&&n instanceof H||je(n)&&oe(n)}function Ve(n){return m(n==null?void 0:n.lift)}function pe(n){return function(t){if(Ve(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function fe(n,t,e,r,i){return new Ne(n,t,e,r,i)}var Ne=function(n){x(t,n);function t(e,r,i,s,o,c){var u=n.call(this,e)||this;return u.onFinalize=o,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(b){e.error(b)}}:n.prototype._next,u._error=s?function(a){try{s(a)}catch(b){e.error(b)}finally{this.unsubscribe()}}:n.prototype._error,u._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:n.prototype._complete,u}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(H),De=q(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ge=function(n){x(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var r=new ve(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new De},t.prototype.next=function(e){var r=this;k(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=D(r.currentObservers),c=o.next();!c.done;c=o.next()){var u=c.value;u.next(e)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var r=this;k(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var i=r.observers;i.length;)i.shift().error(e)}})},t.prototype.complete=function(){var e=this;k(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var r=this,i=this,s=i.hasError,o=i.isStopped,c=i.observers;return s||o?se:(this.currentObservers=null,c.push(e),new P(function(){r.currentObservers=null,$(c,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?e.error(s):o&&e.complete()},t.prototype.asObservable=function(){var e=new z;return e.source=this,e},t.create=function(e,r){return new ve(e,r)},t}(z),ve=function(n){x(t,n);function t(e,r){var i=n.call(this)||this;return i.destination=e,i.source=r,i}return t.prototype.next=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,e)},t.prototype.error=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,e)},t.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},t.prototype._subscribe=function(e){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&i!==void 0?i:se},t}(ge),qe={now:function(){return Date.now()},delegate:void 0},Be=function(n){x(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(P),Y={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,U([n,t],L(e)))},clearInterval:function(n){var t=Y.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},He=function(n){x(t,n);function t(e,r){var i=n.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(e,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),Y.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&Y.clearInterval(r)},t.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,r){var i=!1,s;try{this.work(e)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,$(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Be),be=function(){function n(t,e){e===void 0&&(e=n.now),this.schedulerActionCtor=t,this.now=e}return n.prototype.schedule=function(t,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},n.now=qe.now,n}(),Qe=function(n){x(t,n);function t(e,r){r===void 0&&(r=be.now);var i=n.call(this,e,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,i){for(;e=r.shift();)e.unsubscribe();throw i}},t}(be),ze=new Qe(He),Ye=ze;function Ge(n){return n&&m(n.schedule)}var Ke=q(function(n){return function(){n(this),this.name="EmptyError",this.message="no elements in sequence"}});function R(n,t){var e=typeof t=="object";return new Promise(function(r,i){var s=new j({next:function(o){r(o),s.unsubscribe()},error:i,complete:function(){e?r(t.defaultValue):i(new Ke)}});n.subscribe(s)})}function Je(n){return n instanceof Date&&!isNaN(n)}function V(n,t){return pe(function(e,r){var i=0;e.subscribe(fe(r,function(s){r.next(n.call(t,s,i++))}))})}function We(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Ye);var r=-1;return t!=null&&(Ge(t)?e=t:r=t),new z(function(i){var s=Je(n)?+n-e.now():n;s<0&&(s=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},s)})}function Xe(n,t,e){var r=m(n)||t||e?{next:n,error:t,complete:e}:n;return r?pe(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var c=!0;i.subscribe(fe(s,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),s.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),s.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),s.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):he}var Ze=Object.defineProperty,et=(n,t,e)=>t in n?Ze(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,_=(n,t,e)=>(et(n,typeof t!="symbol"?t+"":t,e),e);class l extends Error{constructor(t){super(`Incorrect context (${t}). Cannot perform the requested operation.`),_(this,"context"),this.context=t}}class I extends Error{constructor(t,e,r){super(`Invalid parameter (${t}). ${r}`),this.param=t,this.value=e,this.reason=r}}class tt extends Error{constructor(t,e){super(`'streamId' value of "${t}" is different from what we expected ("${e}")`),this.streamId=t,this.expectedStreamId=e}}class rt extends Error{constructor(t){super(`Invalid version format: ${t}`)}}class ye extends Error{constructor(t){super(`${t} needs to be initialized before it can be used.`)}}class me extends Error{constructor(t,e){let r=`Unsupported Protocol ${Array.isArray(t)?"versions":"version"}: (${t}).`;e&&(r+=` Minimum version supported is ${e}.`),super(r),this.version=t}}function S(n){return typeof n=="function"}function nt(n){return S(n==null?void 0:n.lift)}function A(n){return function(t){if(nt(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}var G=function(n,t){return G=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},G(n,t)};function K(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");G(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function we(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function J(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return s}function W(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return n.concat(s||Array.prototype.slice.call(t))}function it(n){var t=function(r){Error.call(r),r.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var X=it(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function $(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var P=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=D(o),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(f){t={error:f}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else o.remove(this);var b=this.initialTeardown;if(m(b))try{b()}catch(f){s=f instanceof B?f.errors:[f]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var M=D(v),E=M.next();!E.done;E=M.next()){var ie=E.value;try{ce(ie)}catch(f){s=s??[],f instanceof B?s=U(U([],L(s)),L(f.errors)):s.push(f)}}}catch(f){r={error:f}}finally{try{E&&!E.done&&(i=M.return)&&i.call(M)}finally{if(r)throw r.error}}}if(s)throw new B(s)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)ce(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&$(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&$(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),se=P.EMPTY;function oe(n){return n instanceof P||n&&"closed"in n&&m(n.remove)&&m(n.add)&&m(n.unsubscribe)}function ce(n){m(n)?n():n.unsubscribe()}var ue={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ae={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,U([n,t],L(e)))},clearTimeout:function(n){var t=ae.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Re(n){ae.setTimeout(function(){throw n})}function le(){}function k(n){n()}var H=function(n){x(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,oe(e)&&e.add(r)):r.destination=Ue,r}return t.create=function(e,r,i){return new F(e,r,i)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(P),Ae=Function.prototype.bind;function Q(n,t){return Ae.call(n,t)}var Oe=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){j(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){j(r)}else j(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){j(e)}},n}(),F=function(n){x(t,n);function t(e,r,i){var s=n.call(this)||this,o;if(m(e)||!e)o={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;s&&ue.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return s.unsubscribe()},o={next:e.next&&Q(e.next,c),error:e.error&&Q(e.error,c),complete:e.complete&&Q(e.complete,c)}):o=e}return s.destination=new Oe(o),s}return t}(H);function j(n){Re(n)}function Le(n){throw n}var Ue={closed:!0,next:le,error:Le,complete:le},$e=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function he(n){return n}function ke(n){return n.length===0?he:n.length===1?n[0]:function(e){return n.reduce(function(r,i){return i(r)},e)}}var z=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var i=this,s=je(t)?t:new F(t,e,r);return k(function(){var o=i,c=o.operator,u=o.source;s.add(c?c.call(s,u):u?i._subscribe(s):i._trySubscribe(s))}),s},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=de(e),new e(function(i,s){var o=new F({next:function(c){try{t(c)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[$e]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return ke(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=de(t),new t(function(r,i){var s;e.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},n.create=function(t){return new n(t)},n}();function de(n){var t;return(t=n??ue.Promise)!==null&&t!==void 0?t:Promise}function Fe(n){return n&&m(n.next)&&m(n.error)&&m(n.complete)}function je(n){return n&&n instanceof H||Fe(n)&&oe(n)}function Ve(n){return m(n==null?void 0:n.lift)}function pe(n){return function(t){if(Ve(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function fe(n,t,e,r,i){return new Ne(n,t,e,r,i)}var Ne=function(n){x(t,n);function t(e,r,i,s,o,c){var u=n.call(this,e)||this;return u.onFinalize=o,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(b){e.error(b)}}:n.prototype._next,u._error=s?function(a){try{s(a)}catch(b){e.error(b)}finally{this.unsubscribe()}}:n.prototype._error,u._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:n.prototype._complete,u}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(H),De=q(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ge=function(n){x(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var r=new ve(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new De},t.prototype.next=function(e){var r=this;k(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=D(r.currentObservers),c=o.next();!c.done;c=o.next()){var u=c.value;u.next(e)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var r=this;k(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var i=r.observers;i.length;)i.shift().error(e)}})},t.prototype.complete=function(){var e=this;k(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var r=this,i=this,s=i.hasError,o=i.isStopped,c=i.observers;return s||o?se:(this.currentObservers=null,c.push(e),new P(function(){r.currentObservers=null,$(c,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?e.error(s):o&&e.complete()},t.prototype.asObservable=function(){var e=new z;return e.source=this,e},t.create=function(e,r){return new ve(e,r)},t}(z),ve=function(n){x(t,n);function t(e,r){var i=n.call(this)||this;return i.destination=e,i.source=r,i}return t.prototype.next=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,e)},t.prototype.error=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,e)},t.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},t.prototype._subscribe=function(e){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&i!==void 0?i:se},t}(ge),qe={now:function(){return Date.now()},delegate:void 0},Be=function(n){x(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(P),Y={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,U([n,t],L(e)))},clearInterval:function(n){var t=Y.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},He=function(n){x(t,n);function t(e,r){var i=n.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(e,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),Y.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&Y.clearInterval(r)},t.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,r){var i=!1,s;try{this.work(e)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,$(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Be),be=function(){function n(t,e){e===void 0&&(e=n.now),this.schedulerActionCtor=t,this.now=e}return n.prototype.schedule=function(t,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},n.now=qe.now,n}(),Qe=function(n){x(t,n);function t(e,r){r===void 0&&(r=be.now);var i=n.call(this,e,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,i){for(;e=r.shift();)e.unsubscribe();throw i}},t}(be),ze=new Qe(He),Ye=ze;function Ge(n){return n&&m(n.schedule)}var Ke=q(function(n){return function(){n(this),this.name="EmptyError",this.message="no elements in sequence"}});function R(n,t){var e=typeof t=="object";return new Promise(function(r,i){var s=new F({next:function(o){r(o),s.unsubscribe()},error:i,complete:function(){e?r(t.defaultValue):i(new Ke)}});n.subscribe(s)})}function Je(n){return n instanceof Date&&!isNaN(n)}function V(n,t){return pe(function(e,r){var i=0;e.subscribe(fe(r,function(s){r.next(n.call(t,s,i++))}))})}function We(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Ye);var r=-1;return t!=null&&(Ge(t)?e=t:r=t),new z(function(i){var s=Je(n)?+n-e.now():n;s<0&&(s=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},s)})}function Xe(n,t,e){var r=m(n)||t||e?{next:n,error:t,complete:e}:n;return r?pe(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var c=!0;i.subscribe(fe(s,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),s.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),s.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),s.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):he}var Ze=Object.defineProperty,et=(n,t,e)=>t in n?Ze(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,_=(n,t,e)=>(et(n,typeof t!="symbol"?t+"":t,e),e);class l extends Error{constructor(t){super(`Incorrect context (${t}). Cannot perform the requested operation.`),_(this,"context"),this.context=t}}class I extends Error{constructor(t,e,r){super(`Invalid parameter (${t}). ${r}`),this.param=t,this.value=e,this.reason=r}}class tt extends Error{constructor(t,e){super(`'streamId' value of "${t}" is different from what we expected ("${e}")`),this.streamId=t,this.expectedStreamId=e}}class rt extends Error{constructor(t){super(`Invalid version format: ${t}`)}}class ye extends Error{constructor(t){super(`${t} needs to be initialized before it can be used.`)}}class me extends Error{constructor(t,e){let r=`Unsupported Protocol ${Array.isArray(t)?"versions":"version"}: (${t}).`;e&&(r+=` Minimum version supported is ${e}.`),super(r),this.version=t}}function S(n){return typeof n=="function"}function nt(n){return S(n==null?void 0:n.lift)}function A(n){return function(t){if(nt(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}var G=function(n,t){return G=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},G(n,t)};function K(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");G(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function we(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function J(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return s}function W(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return n.concat(s||Array.prototype.slice.call(t))}function it(n){var t=function(r){Error.call(r),r.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var X=it(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
4
4
|
`+t.map(function(e,r){return r+1+") "+e.toString()}).join(`
|
|
5
|
-
`):"",this.name="UnsubscriptionError",this.errors=t}});function Se(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var Z=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=we(o),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(f){t={error:f}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else o.remove(this);var b=this.initialTeardown;if(S(b))try{b()}catch(f){s=f instanceof X?f.errors:[f]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var M=we(v),E=M.next();!E.done;E=M.next()){var ie=E.value;try{Ce(ie)}catch(f){s=s??[],f instanceof X?s=W(W([],J(s)),J(f.errors)):s.push(f)}}}catch(f){r={error:f}}finally{try{E&&!E.done&&(i=M.return)&&i.call(M)}finally{if(r)throw r.error}}}if(s)throw new X(s)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Ce(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&Se(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&Se(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}();Z.EMPTY;function Ee(n){return n instanceof Z||n&&"closed"in n&&S(n.remove)&&S(n.add)&&S(n.unsubscribe)}function Ce(n){S(n)?n():n.unsubscribe()}var Me={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},st={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,W([n,t],J(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function ot(n){st.setTimeout(function(){throw n})}function xe(){}function ct(n){n()}var ee=function(n){K(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,Ee(e)&&e.add(r)):r.destination=ht,r}return t.create=function(e,r,i){return new re(e,r,i)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Z),ut=Function.prototype.bind;function te(n,t){return ut.call(n,t)}var at=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){N(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){N(r)}else N(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){N(e)}},n}(),re=function(n){K(t,n);function t(e,r,i){var s=n.call(this)||this,o;if(S(e)||!e)o={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;s&&Me.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return s.unsubscribe()},o={next:e.next&&te(e.next,c),error:e.error&&te(e.error,c),complete:e.complete&&te(e.complete,c)}):o=e}return s.destination=new at(o),s}return t}(ee);function N(n){ot(n)}function lt(n){throw n}var ht={closed:!0,next:xe,error:lt,complete:xe},dt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function _e(n){return n}function pt(n){return n.length===0?_e:n.length===1?n[0]:function(t){return n.reduce(function(e,r){return r(e)},t)}}var ft=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var i=this,s=vt(t)?t:new re(t,e,r);return ct(function(){var o=i,c=o.operator,u=o.source;s.add(c?c.call(s,u):u?i._subscribe(s):i._trySubscribe(s))}),s},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=Ie(e),new e(function(i,s){var o=new re({next:function(c){try{t(c)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[dt]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return pt(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Ie(t),new t(function(r,i){var s;e.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},n.create=function(t){return new n(t)},n}();function Ie(n){var t;return(t=n??Me.Promise)!==null&&t!==void 0?t:Promise}function gt(n){return n&&S(n.next)&&S(n.error)&&S(n.complete)}function vt(n){return n&&n instanceof ee||gt(n)&&Ee(n)}function O(n,t,e,r,i){return new bt(n,t,e,r,i)}var bt=function(n){K(t,n);function t(e,r,i,s,o,c){var u=n.call(this,e)||this;return u.onFinalize=o,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(b){e.error(b)}}:n.prototype._next,u._error=s?function(a){try{s(a)}catch(b){e.error(b)}finally{this.unsubscribe()}}:n.prototype._error,u._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:n.prototype._complete,u}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(ee);function h(n,t){return A(function(e,r){var i=0;e.subscribe(O(r,function(s){r.next(n.call(t,s,i++))}))})}var yt=new ft(function(n){return n.complete()});function w(n){return n<=0?function(){return yt}:A(function(t,e){var r=0;t.subscribe(O(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function g(n,t){return A(function(e,r){var i=0;e.subscribe(O(r,function(s){return n.call(t,s,i++)&&r.next(s)}))})}function mt(n,t){return t===void 0&&(t=!1),A(function(e,r){var i=0;e.subscribe(O(r,function(s){var o=n(s,i++);(o||t)&&r.next(s),!o&&r.complete()}))})}function p(n,t,e){var r=S(n)||t||e?{next:n,error:t,complete:e}:n;return r?A(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var c=!0;i.subscribe(O(s,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),s.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),s.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),s.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):_e}const wt=/^(\d+)\.(\d+)$/;function St(n){if(typeof n=="string"){const t=n.match(wt);if(t)return`${t[1]}.${t[2]}`}throw new rt(n)}function Te(n){const t=St(n),[e,r]=t.split("."),[i,s]=[parseInt(e),parseInt(r)];return[i,s]}function ne(n,t){const[e,r]=Te(n),[i,s]=Te(t);return e<i?-1:e>i?1:r<s?-1:r>s?1:0}function Et(n,t){return ne(n,t)===1}function Ct(n,t){return ne(n,t)>=0}const Pe="2.0";class Mt{constructor(t,e){if(_(this,"negotiatedProtocolVersion"),_(this,"currentContext"),_(this,"incomingMessages$"),_(this,"inIframe",!1),_(this,"embeddedResult"),_(this,"iframePort1"),_(this,"iframePort2"),this.supportedVersions=t,this.logService=e,this.incomingMessages$=new ge,this.supportedVersions=t.filter(r=>Ct(r,Pe)),!this.supportedVersions.length)throw new me(t,Pe);this.negotiatedProtocolVersion=this.supportedVersions[0],this.embeddedResult=null,this.iframePort2=null}get parent(){return window.parent}get self(){return window.self}get frameElement(){return window.frameElement}get port1(){var t,e;return this.inIframe?this.iframePort1:(e=(t=window.Acrobits)==null?void 0:t.messageChannel)==null?void 0:e.port1}get port2(){var t,e,r,i;if(this.inIframe){if(!this.iframePort2)throw new ye("port2");return this.iframePort2}else{if(!((e=(t=window.Acrobits)==null?void 0:t.messageChannel)!=null&&e.port2))throw new ye("port2");return(i=(r=window.Acrobits)==null?void 0:r.messageChannel)==null?void 0:i.port2}}determineContext(){return We(1e3).pipe(h(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),w(1))}openBridge(){if(!this.isEmbedded())throw new l(this.currentContext);const t="HELLO",e=this.createMessage(t);e.protocolVersions=this.supportedVersions,this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(i=>i.type===t&&i.replyTo===e.id),h(i=>i),p(this.logReceived(t)),h(i=>{if(this.supportedVersions.some(s=>Et(s,i.protocolVersion)))throw new me(i.protocolVersion,this.supportedVersions[0]);return i}),p(i=>{this.negotiatedProtocolVersion=i.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.inIframe?this.createIframeChannel().then(()=>this.finishIpcSetup(e)):this.finishIpcSetup(e),r}requestSSOToken(){if(!this.isEmbedded())throw new l(this.currentContext);const t="TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(i=>i.type===t&&i.replyTo===e.id),h(i=>i),p(this.logReceived(t)),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}sendJoiningRoomMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const{roomName:e,roomInvite:r,displayName:i,jwtToken:s,serverUrl:o,region:c,joinMicMuted:u,joinWithoutCamera:a}=t,b="JOINING ROOM",v=this.createMessage(b,!1);v.roomName=e,v.jwtToken=s,v.serverUrl=o,v.region=c,v.roomInvite=r,v.joinMicMuted=u??!1,v.joinWithoutCamera=a??!1,v.displayName=i,this.logCreated(b,v),this.port2.postMessage(v),this.logSent(b,v)}sendLeavingRoomMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="LEAVING ROOM",r=this.createMessage(e,!1);r.roomName=t,this.logCreated(e,r),this.port2.postMessage(r),this.logSent(e,r)}onJoinRoomMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="JOIN ROOM";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)),h(e=>e))}onLeaveRoomMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="LEAVE ROOM";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)),h(e=>e))}onConfigMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="CONFIG";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)),h(e=>({preferredCameraType:e.preferredCameraType,preferredMicType:e.preferredMicType,preferredOutputType:e.preferredOutputType,preferredCameraDeviceLabel:e.preferredCameraDeviceLabel,preferredMicDeviceLabel:e.preferredMicDeviceLabel,preferredOutputDeviceLabel:e.preferredOutputDeviceLabel,performanceProfile:e.performanceProfile,cloudUsername:e.cloudUsername,configuredOAuthProviders:e.configuredOAuthProviders,locales:e.locales?[...e.locales]:[]})))}sendScreenshareSourceMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="SCREENSHARE SOURCE",r=this.createMessage(e);r.sourceTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(g(s=>s.type===e&&s.replyTo===r.id),h(s=>s),p(this.logReceived(e)),h(s=>s),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}layoutChange(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="LAYOUT CHANGE";let s,o;if(e&&r?(s=this.createMessage(i,!1,r),s.result=e):(s=this.createMessage(i),o=this.incomingMessages$.pipe(g(c=>c.type===i&&c.replyTo===s.id),h(c=>c),p(this.logReceived(i)),h(c=>c),w(1)),this.logService.debug(`Created ${i} Reply handler`)),s.layout=t,this.logCreated(i,s),this.port2.postMessage(s),this.logSent(i,s),o)return o}onLayoutChangeMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="LAYOUT CHANGE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),h(e=>e),p(this.logReceived(t)),h(e=>e))}requestOAuthToken(t){if(!this.isEmbedded())throw new l(this.currentContext);Array.isArray(t)||(t=[t]);const e="OAUTH TOKEN",r=this.createMessage(e);r.providerTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(g(s=>s.type===e&&s.replyTo===r.id),h(s=>s),p(this.logReceived(e)),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}openUrl(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="OPEN URL",i=this.createMessage(r,!1);i.url=t,i.data=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}selectContacts(t,e,r,i){if(!this.isEmbedded())throw new l(this.currentContext);if(e==="group"&&i===void 0)throw new I("currentContacts",i,"currentContacts is required for group streams");if(e==="direct"&&i!==void 0)throw new I("currentContacts",i,"currentContacts should not be passed for direct streams");const s="SELECT CONTACTS",o=this.createMessage(s,!0);o.streamType=e,o.streamId=t,o.contactType=r,o.currentContacts=i,this.logCreated(s,o);const c=this.incomingMessages$.pipe(g(u=>u.type===s&&u.replyTo===o.id),p(this.logReceived(s)),h(u=>{const a=u;if(a.streamId!==t)throw new tt(a.streamId,t);return e==="direct"&&a.contacts.length>1&&(a.contacts=[a.contacts[0]]),a}),w(1));return this.logService.debug(`Created ${s} Reply handler`),this.port2.postMessage(o),this.logSent(s,o),c}matchContacts(t){if(!this.isEmbedded())throw new l(this.currentContext);if(!t.length)throw new I("contacts",t,"At least one contact is required");const e="MATCH CONTACTS",r=this.createMessage(e);r.contacts=[...t],this.logCreated(e,r);const i=this.incomingMessages$.pipe(g(s=>s.type===e&&s.replyTo===r.id),p(this.logReceived(e)),h(s=>s),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}onPushMessageMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="PUSH MESSAGE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}requestPushToken(){if(!this.isEmbedded())throw new l(this.currentContext);const t="PUSH TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(i=>i.type===t&&i.replyTo===e.id),p(this.logReceived(t)),h(i=>i),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}onPushTokenMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="PUSH TOKEN";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null&&e.expectReply===!1),h(e=>{if(e.pushToken&&e.selector&&e.appId)return e;throw new Error("PushTokenMessage is missing required PushTokenPayload fields")}),p(e=>e.pushToken),p(this.logReceived(t)))}onBadgeQueryMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="BADGE QUERY";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendBadgeUpdateMessage(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="BADGE UPDATE",s=this.createMessage(i,!1,r);s.count=t,s.activity=e??!1,this.logCreated(i,s),this.port2.postMessage(s),this.logSent(i,s)}sendLifecycleMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="LIFECYCLE",i=this.createMessage(r,!1);i.eventName=t,i.payload=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onLifecycleMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="LIFECYCLE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendLogMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="LOG",i=this.createMessage(r,!1);i.level=t,i.message=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onRequestLogsMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="REQUEST LOGS";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendViewTransitionMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="VIEW TRANSITION",i=this.createMessage(r,!1);i.transitionType=t,i.targetView=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}sendFileRequestMessage(t,e,r,i){if(!this.isEmbedded())throw new l(this.currentContext);const s="FILE REQUEST",o=this.createMessage(s);if(o.fileHash=t.toLowerCase(),o.intent=e,o.maxChunkSizeInBytes=i,e==="attachment"){if(!r)throw new I("streamId",r,"streamId is required for attachment intent");o.streamId=r}this.logCreated(s,o);let c=0;const u=this.incomingMessages$.pipe(g(a=>a.type===s&&a.replyTo===o.id),p(this.logReceived(s)),p(()=>c++),h(a=>(a.result==="success"&&(a.chunkHash=a.chunkHash.toLowerCase()),a)),mt(a=>a.result==="success"&&c<a.totalChunks,!0));return this.port2.postMessage(o),this.logSent(s,o),u}onFileRequestMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="FILE REQUEST";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),h(e=>(e.fileHash=e.fileHash.toLowerCase(),e)),p(this.logReceived(t)))}sendFileSelectionMessage(t="attachment",e,r,i,s){if(!this.isEmbedded())throw new l(this.currentContext);const o="FILE SELECTION",c=this.createMessage(o);if(c.intent=t,c.maxCount=r,c.maxFileSizeInBytes=i,c.mimeTypes=s,t==="attachment"){if(!e)throw new I("streamId",e,"streamId is required for attachment intent");c.streamId=e}this.logCreated(o,c);const u=this.incomingMessages$.pipe(g(a=>a.type===o&&a.replyTo===c.id),h(a=>{var b;return a.files=(b=a.files)==null?void 0:b.map(v=>(v.fileHash=v.fileHash.toLowerCase(),v)),a}),p(this.logReceived(o)),w(1));return this.port2.postMessage(c),this.logSent(o,c),u}sendFileDownloadMessage(t,e,r,i){if(!this.isEmbedded())throw new l(this.currentContext);const s="FILE DOWNLOAD",o=this.createMessage(s);o.url=t,o.key=e,o.fileName=r,o.mimeType=i,this.logCreated(s,o);const c=this.incomingMessages$.pipe(g(u=>u.type===s&&u.replyTo===o.id),p(this.logReceived(s)),h(u=>u),w(1));return this.port2.postMessage(o),this.logSent(s,o),c}sendFileUploadMessage(){throw new Error("Not implemented")}sendFileOpenMessage(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="FILE OPEN",s=this.createMessage(i,!1);s.fileHash=t.toLowerCase(),s.fileName=e,s.streamId=r,this.logCreated(i,s),this.port2.postMessage(s),this.logSent(i,s)}sendFileRemoveMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="FILE REMOVE",i=this.createMessage(r,!0);i.hash=t.toLowerCase(),i.streamId=e,this.logCreated(r,i);const s=this.incomingMessages$.pipe(g(o=>o.type===r&&o.replyTo===i.id),p(this.logReceived(r)),h(o=>o),w(1));return this.port2.postMessage(i),this.logSent(r,i),s}sendAppResetMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="APP RESET",e=this.createMessage(t,!1);this.logCreated(t,e),this.port2.postMessage(e),this.logSent(t,e)}sendMessageSentMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="MESSAGE SENT",i=this.createMessage(r,!1);i.streamId=t,i.attachments=(e==null?void 0:e.map(s=>s.toLowerCase()))??[],this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}sendSipCallMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="SIP CALL",r=this.createMessage(e,!1);r.contact=t,this.logCreated(e,r),this.port2.postMessage(r),this.logSent(e,r)}isEmbedded(){if(this.embeddedResult!==null)return this.embeddedResult;let t=!1;return this.logService.debug("Checking if running in iframe..."),t=!!this.frameElement,t||(t=this.self!==this.parent),t?(this.logService.debug("In iframe"),this.inIframe=!0,this.embeddedResult=!0,!0):(this.logService.debug("Not in iframe"),this.logService.debug("Checking if running in native app..."),!t&&(t=!!window.Acrobits,t)?(this.logService.debug("In native app"),this.embeddedResult=!0,t):(this.logService.debug("Not running in native app"),this.embeddedResult=!1,this.embeddedResult))}compareVersion(t){return ne(this.negotiatedProtocolVersion,t)}logReceived(t,e){e&&xt(e)&&(e={...e,data:"..."});const r=i=>this.logService.debug(`[IPC] Received ${t} message`,i);return e&&r(e),r}logSent(t,e){e.type==="FILE REQUEST"&&e.result==="success"&&(e={...e,data:"..."}),this.logService.debug(`[IPC] Sent ${t} message`,e)}logCreated(t,e){e.type==="FILE REQUEST"&&e.result==="success"&&(e={...e,data:"..."}),this.logService.debug(`[IPC] Created ${t} message`,e)}async createIframeChannel(){return new Promise(t=>{const e=r=>{r.data==="message channel port"&&(this.iframePort2=r.ports[0],this.self.removeEventListener("message",e),t())};this.self.addEventListener("message",e),this.parent.postMessage("get channel","*")})}finishIpcSetup(t){this.logService.debug("Registering listener on port2..."),this.port2.addEventListener("message",this.handleIpcMessage.bind(this)),this.port2.start(),this.logService.debug("Started listening on port2"),this.port2.postMessage(t),this.logSent("HELLO",t)}handleIpcMessage(t){const{data:e}=t;!e.id||e.target!=="client"||this.incomingMessages$.next(e)}createMessage(t,e=!0,r){return{type:t,id:this.generateId(),target:"host",expectReply:e,replyTo:r??null}}generateId(t=8,e=!1){let r="1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";const i=[];e&&(r=r.substr(0,r.indexOf("Q")));for(let s=0;s<t;s++)i.push(r[Math.floor(Math.random()*r.length)]);return i.join("")}}function xt(n){return n.type==="FILE REQUEST"&&n.replyTo!==null}const _t=["2.0"];class It{constructor(t){T(this,"host");T(this,"cloudId");T(this,"logger");T(this,"helper");T(this,"listeners");this.logger=t??console,this.helper=new Mt(_t,this.logger),this.listeners=new Map,this.listeners.set(d.BadgeQuery,new Set),this.listeners.set(d.Lifecycle,new Set),this.listeners.set(d.PushToken,new Set)}get context(){return this.evaluateContext(this.helper.currentContext)}get isConnected(){return!!(this.helper.currentContext==="user"&&this.host&&this.cloudId)}get negotiatedVersion(){return this.helper.negotiatedProtocolVersion}async determineContext(){const t=await R(this.helper.determineContext(),{defaultValue:"guest"});return this.evaluateContext(t)}initiateConnection(){return R(this.helper.openBridge().pipe(Xe(t=>{this.helper.onBadgeQueryMessage().subscribe(e=>{var r;this.logger.debug("Received Badge Query: ",e);for(const i of((r=this.listeners.get(d.BadgeQuery))==null?void 0:r.values())??[])i()}),this.helper.onLifecycleMessage().subscribe(e=>{var r;this.logger.debug("Received Lifecycle Event: ",e);for(const i of((r=this.listeners.get(d.Lifecycle))==null?void 0:r.values())??[])i(e.eventName,e.payload)}),this.helper.onPushTokenMessage().subscribe(e=>{var r;this.logger.debug("Received Push Token: ",e);for(const i of((r=this.listeners.get(d.PushToken))==null?void 0:r.values())??[])i(e.pushToken,e.appId,e.selector)}),this.cloudId=t.cloudId,this.host=t.host}),V(()=>{})))}selectContacts(t,e,r,i){this.logger.debug("Selecting Contacts: ",...arguments);let s;if(e==="multi"){if(!r||!Array.isArray(r))throw new I("currentContacts",r,"currentContacts is required for group streams");i||(i="cloudUsername"),s=this.helper.selectContacts(t.toString(),"group",i,r)}else r?i=r:i="cloudUsername",s=this.helper.selectContacts(t.toString(),"direct",i);return R(s.pipe(V(o=>o.contacts)))}matchContacts(t){return this.logger.debug("Match Contacts: ",t),R(this.helper.matchContacts(t).pipe(V(e=>e.contacts)))}requestPushToken(){return this.logger.debug("Requesting Push Token"),R(this.helper.requestPushToken().pipe(V(t=>t.pushToken)))}badgeUpdate(t,e=!1){this.logger.debug(`Sending Badge Update, count: ${t}, activity: ${e}`),this.helper.sendBadgeUpdateMessage(t,e)}requestAppReset(){this.logger.debug("Requesting App Reset"),this.helper.sendAppResetMessage()}openUrl(t,e){this.logger.debug("Opening URL: ",t),this.helper.openUrl(t,e)}sipCall(t){this.logger.debug("Initiating SIP Call: ",t),this.helper.sendSipCallMessage(t)}onBadgeQueryRequest(t){var e;return this.logger.debug("Registering for Badge Query"),(e=this.listeners.get(d.BadgeQuery))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.BadgeQuery))==null?void 0:r.delete(t)}}onLifecycleEvent(t){var e;return this.logger.debug("Registering for Lifecycle Event"),(e=this.listeners.get(d.Lifecycle))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.Lifecycle))==null?void 0:r.delete(t)}}onPushToken(t){var e;return this.logger.debug("Registering for Push Token"),(e=this.listeners.get(d.PushToken))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.PushToken))==null?void 0:r.delete(t)}}evaluateContext(t){if(t==="user")return"host";if(t==="guest")return"standalone"}}y.IPCEvents=d,y.IPCManager=It,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|
|
5
|
+
`):"",this.name="UnsubscriptionError",this.errors=t}});function Se(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var Z=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=we(o),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(f){t={error:f}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else o.remove(this);var b=this.initialTeardown;if(S(b))try{b()}catch(f){s=f instanceof X?f.errors:[f]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var M=we(v),E=M.next();!E.done;E=M.next()){var ie=E.value;try{Ce(ie)}catch(f){s=s??[],f instanceof X?s=W(W([],J(s)),J(f.errors)):s.push(f)}}}catch(f){r={error:f}}finally{try{E&&!E.done&&(i=M.return)&&i.call(M)}finally{if(r)throw r.error}}}if(s)throw new X(s)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Ce(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&Se(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&Se(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}();Z.EMPTY;function Ee(n){return n instanceof Z||n&&"closed"in n&&S(n.remove)&&S(n.add)&&S(n.unsubscribe)}function Ce(n){S(n)?n():n.unsubscribe()}var Me={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},st={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,W([n,t],J(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function ot(n){st.setTimeout(function(){throw n})}function xe(){}function ct(n){n()}var ee=function(n){K(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,Ee(e)&&e.add(r)):r.destination=ht,r}return t.create=function(e,r,i){return new re(e,r,i)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Z),ut=Function.prototype.bind;function te(n,t){return ut.call(n,t)}var at=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){N(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){N(r)}else N(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){N(e)}},n}(),re=function(n){K(t,n);function t(e,r,i){var s=n.call(this)||this,o;if(S(e)||!e)o={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;s&&Me.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return s.unsubscribe()},o={next:e.next&&te(e.next,c),error:e.error&&te(e.error,c),complete:e.complete&&te(e.complete,c)}):o=e}return s.destination=new at(o),s}return t}(ee);function N(n){ot(n)}function lt(n){throw n}var ht={closed:!0,next:xe,error:lt,complete:xe},dt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function _e(n){return n}function pt(n){return n.length===0?_e:n.length===1?n[0]:function(t){return n.reduce(function(e,r){return r(e)},t)}}var ft=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var i=this,s=vt(t)?t:new re(t,e,r);return ct(function(){var o=i,c=o.operator,u=o.source;s.add(c?c.call(s,u):u?i._subscribe(s):i._trySubscribe(s))}),s},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=Ie(e),new e(function(i,s){var o=new re({next:function(c){try{t(c)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[dt]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return pt(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Ie(t),new t(function(r,i){var s;e.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},n.create=function(t){return new n(t)},n}();function Ie(n){var t;return(t=n??Me.Promise)!==null&&t!==void 0?t:Promise}function gt(n){return n&&S(n.next)&&S(n.error)&&S(n.complete)}function vt(n){return n&&n instanceof ee||gt(n)&&Ee(n)}function O(n,t,e,r,i){return new bt(n,t,e,r,i)}var bt=function(n){K(t,n);function t(e,r,i,s,o,c){var u=n.call(this,e)||this;return u.onFinalize=o,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(b){e.error(b)}}:n.prototype._next,u._error=s?function(a){try{s(a)}catch(b){e.error(b)}finally{this.unsubscribe()}}:n.prototype._error,u._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:n.prototype._complete,u}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(ee);function h(n,t){return A(function(e,r){var i=0;e.subscribe(O(r,function(s){r.next(n.call(t,s,i++))}))})}var yt=new ft(function(n){return n.complete()});function w(n){return n<=0?function(){return yt}:A(function(t,e){var r=0;t.subscribe(O(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function g(n,t){return A(function(e,r){var i=0;e.subscribe(O(r,function(s){return n.call(t,s,i++)&&r.next(s)}))})}function mt(n,t){return t===void 0&&(t=!1),A(function(e,r){var i=0;e.subscribe(O(r,function(s){var o=n(s,i++);(o||t)&&r.next(s),!o&&r.complete()}))})}function p(n,t,e){var r=S(n)||t||e?{next:n,error:t,complete:e}:n;return r?A(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var c=!0;i.subscribe(O(s,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),s.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),s.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),s.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):_e}const wt=/^(\d+)\.(\d+)$/;function St(n){if(typeof n=="string"){const t=n.match(wt);if(t)return`${t[1]}.${t[2]}`}throw new rt(n)}function Te(n){const t=St(n),[e,r]=t.split("."),[i,s]=[parseInt(e),parseInt(r)];return[i,s]}function ne(n,t){const[e,r]=Te(n),[i,s]=Te(t);return e<i?-1:e>i?1:r<s?-1:r>s?1:0}function Et(n,t){return ne(n,t)===1}function Ct(n,t){return ne(n,t)>=0}const Pe="2.0";class Mt{constructor(t,e){if(_(this,"negotiatedProtocolVersion"),_(this,"currentContext"),_(this,"incomingMessages$"),_(this,"inIframe",!1),_(this,"embeddedResult"),_(this,"iframePort1"),_(this,"iframePort2"),this.supportedVersions=t,this.logService=e,this.incomingMessages$=new ge,this.supportedVersions=t.filter(r=>Ct(r,Pe)),!this.supportedVersions.length)throw new me(t,Pe);this.negotiatedProtocolVersion=this.supportedVersions[0],this.embeddedResult=null,this.iframePort2=null}get parent(){return window.parent}get self(){return window.self}get frameElement(){return window.frameElement}get port1(){var t,e;return this.inIframe?this.iframePort1:(e=(t=window.Acrobits)==null?void 0:t.messageChannel)==null?void 0:e.port1}get port2(){var t,e,r,i;if(this.inIframe){if(!this.iframePort2)throw new ye("port2");return this.iframePort2}else{if(!((e=(t=window.Acrobits)==null?void 0:t.messageChannel)!=null&&e.port2))throw new ye("port2");return(i=(r=window.Acrobits)==null?void 0:r.messageChannel)==null?void 0:i.port2}}determineContext(){return We(1e3).pipe(h(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),w(1))}openBridge(){if(!this.isEmbedded())throw new l(this.currentContext);const t="HELLO",e=this.createMessage(t);e.protocolVersions=this.supportedVersions,this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(i=>i.type===t&&i.replyTo===e.id),h(i=>i),p(this.logReceived(t)),h(i=>{if(this.supportedVersions.some(s=>Et(s,i.protocolVersion)))throw new me(i.protocolVersion,this.supportedVersions[0]);return i}),p(i=>{this.negotiatedProtocolVersion=i.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.inIframe?this.createIframeChannel().then(()=>this.finishIpcSetup(e)):this.finishIpcSetup(e),r}requestSSOToken(){if(!this.isEmbedded())throw new l(this.currentContext);const t="TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(i=>i.type===t&&i.replyTo===e.id),h(i=>i),p(this.logReceived(t)),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}sendJoiningRoomMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const{roomName:e,roomInvite:r,displayName:i,jwtToken:s,serverUrl:o,region:c,joinMicMuted:u,joinWithoutCamera:a}=t,b="JOINING ROOM",v=this.createMessage(b,!1);v.roomName=e,v.jwtToken=s,v.serverUrl=o,v.region=c,v.roomInvite=r,v.joinMicMuted=u??!1,v.joinWithoutCamera=a??!1,v.displayName=i,this.logCreated(b,v),this.port2.postMessage(v),this.logSent(b,v)}sendLeavingRoomMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="LEAVING ROOM",r=this.createMessage(e,!1);r.roomName=t,this.logCreated(e,r),this.port2.postMessage(r),this.logSent(e,r)}onJoinRoomMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="JOIN ROOM";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)),h(e=>e))}onLeaveRoomMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="LEAVE ROOM";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)),h(e=>e))}onConfigMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="CONFIG";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)),h(e=>({preferredCameraType:e.preferredCameraType,preferredMicType:e.preferredMicType,preferredOutputType:e.preferredOutputType,preferredCameraDeviceLabel:e.preferredCameraDeviceLabel,preferredMicDeviceLabel:e.preferredMicDeviceLabel,preferredOutputDeviceLabel:e.preferredOutputDeviceLabel,performanceProfile:e.performanceProfile,cloudUsername:e.cloudUsername,configuredOAuthProviders:e.configuredOAuthProviders,locales:e.locales?[...e.locales]:[]})))}sendScreenshareSourceMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="SCREENSHARE SOURCE",r=this.createMessage(e);r.sourceTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(g(s=>s.type===e&&s.replyTo===r.id),h(s=>s),p(this.logReceived(e)),h(s=>s),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}layoutChange(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="LAYOUT CHANGE";let s,o;if(e&&r?(s=this.createMessage(i,!1,r),s.result=e):(s=this.createMessage(i),o=this.incomingMessages$.pipe(g(c=>c.type===i&&c.replyTo===s.id),h(c=>c),p(this.logReceived(i)),h(c=>c),w(1)),this.logService.debug(`Created ${i} Reply handler`)),s.layout=t,this.logCreated(i,s),this.port2.postMessage(s),this.logSent(i,s),o)return o}onLayoutChangeMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="LAYOUT CHANGE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),h(e=>e),p(this.logReceived(t)),h(e=>e))}requestOAuthToken(t){if(!this.isEmbedded())throw new l(this.currentContext);Array.isArray(t)||(t=[t]);const e="OAUTH TOKEN",r=this.createMessage(e);r.providerTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(g(s=>s.type===e&&s.replyTo===r.id),h(s=>s),p(this.logReceived(e)),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}openUrl(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="OPEN URL",i=this.createMessage(r,!1);i.url=t,i.data=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}selectContacts(t,e,r,i){if(!this.isEmbedded())throw new l(this.currentContext);if(e==="group"&&i===void 0)throw new I("currentContacts",i,"currentContacts is required for group streams");if(e==="direct"&&i!==void 0)throw new I("currentContacts",i,"currentContacts should not be passed for direct streams");const s="SELECT CONTACTS",o=this.createMessage(s,!0);o.streamType=e,o.streamId=t,o.contactType=r,o.currentContacts=i,this.logCreated(s,o);const c=this.incomingMessages$.pipe(g(u=>u.type===s&&u.replyTo===o.id),p(this.logReceived(s)),h(u=>{const a=u;if(a.streamId!==t)throw new tt(a.streamId,t);return e==="direct"&&a.contacts.length>1&&(a.contacts=[a.contacts[0]]),a}),w(1));return this.logService.debug(`Created ${s} Reply handler`),this.port2.postMessage(o),this.logSent(s,o),c}matchContacts(t){if(!this.isEmbedded())throw new l(this.currentContext);if(!t.length)throw new I("contacts",t,"At least one contact is required");const e="MATCH CONTACTS",r=this.createMessage(e);r.contacts=[...t],this.logCreated(e,r);const i=this.incomingMessages$.pipe(g(s=>s.type===e&&s.replyTo===r.id),p(this.logReceived(e)),h(s=>s),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}onPushMessageMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="PUSH MESSAGE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}requestPushToken(){if(!this.isEmbedded())throw new l(this.currentContext);const t="PUSH TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(i=>i.type===t&&i.replyTo===e.id),p(this.logReceived(t)),h(i=>i),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}onPushTokenMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="PUSH TOKEN";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null&&e.expectReply===!1),h(e=>{if(e.pushToken&&e.selector&&e.appId)return e;throw new Error("PushTokenMessage is missing required PushTokenPayload fields")}),p(e=>e.pushToken),p(this.logReceived(t)))}onBadgeQueryMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="BADGE QUERY";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendBadgeUpdateMessage(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="BADGE UPDATE",s=this.createMessage(i,!1,r);s.count=t,s.activity=e??!1,this.logCreated(i,s),this.port2.postMessage(s),this.logSent(i,s)}sendLifecycleMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="LIFECYCLE",i=this.createMessage(r,!1);i.eventName=t,i.payload=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onLifecycleMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="LIFECYCLE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendLogMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="LOG",i=this.createMessage(r,!1);i.level=t,i.message=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onRequestLogsMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="REQUEST LOGS";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendViewTransitionMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="VIEW TRANSITION",i=this.createMessage(r,!1);i.transitionType=t,i.targetView=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}sendFileRequestMessage(t,e,r,i){if(!this.isEmbedded())throw new l(this.currentContext);const s="FILE REQUEST",o=this.createMessage(s);if(o.fileHash=t.toLowerCase(),o.intent=e,o.maxChunkSizeInBytes=i,e==="attachment"){if(!r)throw new I("streamId",r,"streamId is required for attachment intent");o.streamId=r}this.logCreated(s,o);let c=0;const u=this.incomingMessages$.pipe(g(a=>a.type===s&&a.replyTo===o.id),p(this.logReceived(s)),p(()=>c++),h(a=>(a.result==="success"&&(a.chunkHash=a.chunkHash.toLowerCase()),a)),mt(a=>a.result==="success"&&c<a.totalChunks,!0));return this.port2.postMessage(o),this.logSent(s,o),u}sendFileRequestMessageReply(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="FILE REQUEST",i=Object.assign(e,this.createMessage(r,!1,t.id));this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onFileRequestMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="FILE REQUEST";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),h(e=>(e.fileHash=e.fileHash.toLowerCase(),e)),p(this.logReceived(t)))}sendFileSelectionMessage(t="attachment",e,r,i,s){if(!this.isEmbedded())throw new l(this.currentContext);const o="FILE SELECTION",c=this.createMessage(o);if(c.intent=t,c.maxCount=r,c.maxFileSizeInBytes=i,c.mimeTypes=s,t==="attachment"){if(!e)throw new I("streamId",e,"streamId is required for attachment intent");c.streamId=e}this.logCreated(o,c);const u=this.incomingMessages$.pipe(g(a=>a.type===o&&a.replyTo===c.id),h(a=>{var b;return a.files=(b=a.files)==null?void 0:b.map(v=>(v.fileHash=v.fileHash.toLowerCase(),v)),a}),p(this.logReceived(o)),w(1));return this.port2.postMessage(c),this.logSent(o,c),u}sendFileDownloadMessage(t,e,r,i){if(!this.isEmbedded())throw new l(this.currentContext);const s="FILE DOWNLOAD",o=this.createMessage(s);o.url=t,o.key=e,o.fileName=r,o.mimeType=i,this.logCreated(s,o);const c=this.incomingMessages$.pipe(g(u=>u.type===s&&u.replyTo===o.id),p(this.logReceived(s)),h(u=>u),w(1));return this.port2.postMessage(o),this.logSent(s,o),c}sendFileUploadMessage(){throw new Error("Not implemented")}sendFileOpenMessage(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="FILE OPEN",s=this.createMessage(i,!1);s.fileHash=t.toLowerCase(),s.fileName=e,s.streamId=r,this.logCreated(i,s),this.port2.postMessage(s),this.logSent(i,s)}sendFileRemoveMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="FILE REMOVE",i=this.createMessage(r,!0);i.hash=t.toLowerCase(),i.streamId=e,this.logCreated(r,i);const s=this.incomingMessages$.pipe(g(o=>o.type===r&&o.replyTo===i.id),p(this.logReceived(r)),h(o=>o),w(1));return this.port2.postMessage(i),this.logSent(r,i),s}sendAppResetMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="APP RESET",e=this.createMessage(t,!1);this.logCreated(t,e),this.port2.postMessage(e),this.logSent(t,e)}sendMessageSentMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="MESSAGE SENT",i=this.createMessage(r,!1);i.streamId=t,i.attachments=(e==null?void 0:e.map(s=>s.toLowerCase()))??[],this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}sendSipCallMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="SIP CALL",r=this.createMessage(e,!1);r.contact=t,this.logCreated(e,r),this.port2.postMessage(r),this.logSent(e,r)}isEmbedded(){if(this.embeddedResult!==null)return this.embeddedResult;let t=!1;return this.logService.debug("Checking if running in iframe..."),t=!!this.frameElement,t||(t=this.self!==this.parent),t?(this.logService.debug("In iframe"),this.inIframe=!0,this.embeddedResult=!0,!0):(this.logService.debug("Not in iframe"),this.logService.debug("Checking if running in native app..."),!t&&(t=!!window.Acrobits,t)?(this.logService.debug("In native app"),this.embeddedResult=!0,t):(this.logService.debug("Not running in native app"),this.embeddedResult=!1,this.embeddedResult))}compareVersion(t){return ne(this.negotiatedProtocolVersion,t)}logReceived(t,e){e&&xt(e)&&(e={...e,data:"..."});const r=i=>this.logService.debug(`[IPC] Received ${t} message`,i);return e&&r(e),r}logSent(t,e){e.type==="FILE REQUEST"&&e.result==="success"&&(e={...e,data:"..."}),this.logService.debug(`[IPC] Sent ${t} message`,e)}logCreated(t,e){e.type==="FILE REQUEST"&&e.result==="success"&&(e={...e,data:"..."}),this.logService.debug(`[IPC] Created ${t} message`,e)}async createIframeChannel(){return new Promise(t=>{const e=r=>{r.data==="message channel port"&&(this.iframePort2=r.ports[0],this.self.removeEventListener("message",e),t())};this.self.addEventListener("message",e),this.parent.postMessage("get channel","*")})}finishIpcSetup(t){this.logService.debug("Registering listener on port2..."),this.port2.addEventListener("message",this.handleIpcMessage.bind(this)),this.port2.start(),this.logService.debug("Started listening on port2"),this.port2.postMessage(t),this.logSent("HELLO",t)}handleIpcMessage(t){const{data:e}=t;!e.id||e.target!=="client"||this.incomingMessages$.next(e)}createMessage(t,e=!0,r){return{type:t,id:this.generateId(),target:"host",expectReply:e,replyTo:r??null}}generateId(t=8,e=!1){let r="1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";const i=[];e&&(r=r.substr(0,r.indexOf("Q")));for(let s=0;s<t;s++)i.push(r[Math.floor(Math.random()*r.length)]);return i.join("")}}function xt(n){return n.type==="FILE REQUEST"&&n.replyTo!==null}const _t=["2.0"];class It{constructor(t){T(this,"host");T(this,"cloudId");T(this,"logger");T(this,"helper");T(this,"listeners");this.logger=t??console,this.helper=new Mt(_t,this.logger),this.listeners=new Map,this.listeners.set(d.BadgeQuery,new Set),this.listeners.set(d.Lifecycle,new Set),this.listeners.set(d.PushToken,new Set)}get context(){return this.evaluateContext(this.helper.currentContext)}get isConnected(){return!!(this.helper.currentContext==="user"&&this.host&&this.cloudId)}get negotiatedVersion(){return this.helper.negotiatedProtocolVersion}async determineContext(){const t=await R(this.helper.determineContext(),{defaultValue:"guest"});return this.evaluateContext(t)}initiateConnection(){return R(this.helper.openBridge().pipe(Xe(t=>{this.helper.onBadgeQueryMessage().subscribe(e=>{var r;this.logger.debug("Received Badge Query: ",e);for(const i of((r=this.listeners.get(d.BadgeQuery))==null?void 0:r.values())??[])i()}),this.helper.onLifecycleMessage().subscribe(e=>{var r;this.logger.debug("Received Lifecycle Event: ",e);for(const i of((r=this.listeners.get(d.Lifecycle))==null?void 0:r.values())??[])i(e.eventName,e.payload)}),this.helper.onPushTokenMessage().subscribe(e=>{var r;this.logger.debug("Received Push Token: ",e);for(const i of((r=this.listeners.get(d.PushToken))==null?void 0:r.values())??[])i(e.pushToken,e.appId,e.selector)}),this.cloudId=t.cloudId,this.host=t.host}),V(()=>{})))}selectContacts(t,e,r,i){this.logger.debug("Selecting Contacts: ",...arguments);let s;if(e==="multi"){if(!r||!Array.isArray(r))throw new I("currentContacts",r,"currentContacts is required for group streams");i||(i="cloudUsername"),s=this.helper.selectContacts(t.toString(),"group",i,r)}else r?i=r:i="cloudUsername",s=this.helper.selectContacts(t.toString(),"direct",i);return R(s.pipe(V(o=>o.contacts)))}matchContacts(t){return this.logger.debug("Match Contacts: ",t),R(this.helper.matchContacts(t).pipe(V(e=>e.contacts)))}requestPushToken(){return this.logger.debug("Requesting Push Token"),R(this.helper.requestPushToken().pipe(V(t=>t.pushToken)))}badgeUpdate(t,e=!1){this.logger.debug(`Sending Badge Update, count: ${t}, activity: ${e}`),this.helper.sendBadgeUpdateMessage(t,e)}requestAppReset(){this.logger.debug("Requesting App Reset"),this.helper.sendAppResetMessage()}openUrl(t,e){this.logger.debug("Opening URL: ",t),this.helper.openUrl(t,e)}sipCall(t){this.logger.debug("Initiating SIP Call: ",t),this.helper.sendSipCallMessage(t)}onBadgeQueryRequest(t){var e;return this.logger.debug("Registering for Badge Query"),(e=this.listeners.get(d.BadgeQuery))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.BadgeQuery))==null?void 0:r.delete(t)}}onLifecycleEvent(t){var e;return this.logger.debug("Registering for Lifecycle Event"),(e=this.listeners.get(d.Lifecycle))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.Lifecycle))==null?void 0:r.delete(t)}}onPushToken(t){var e;return this.logger.debug("Registering for Push Token"),(e=this.listeners.get(d.PushToken))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.PushToken))==null?void 0:r.delete(t)}}evaluateContext(t){if(t==="user")return"host";if(t==="guest")return"standalone"}}y.IPCEvents=d,y.IPCManager=It,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|