@acrobits/ipc-sdk 0.1.7 → 0.2.0
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/docs/assets/search.js +1 -1
- package/docs/classes/IPCManager.html +38 -23
- package/docs/interfaces/BaseContactItem.html +10 -0
- package/docs/interfaces/CloudUsernameContactItem.html +14 -3
- package/docs/interfaces/DetailedContactItem.html +17 -7
- package/docs/interfaces/UriContactItem.html +14 -3
- package/docs/types/ContactItem.html +1 -1
- package/docs/types/ContactLabel.html +1 -1
- package/docs/types/ContactType.html +1 -1
- package/docs/types/ContactURI.html +1 -1
- package/docs/types/HostType.html +1 -1
- package/docs/types/IpcProtocolVersion.html +1 -1
- package/lib/index.d.ts +14 -2
- package/lib/ipc-sdk.js +216 -190
- package/lib/ipc-sdk.js.map +1 -1
- package/lib/ipc-sdk.umd.cjs +3 -3
- package/lib/ipc-sdk.umd.cjs.map +1 -1
- package/package.json +2 -2
package/lib/ipc-sdk.umd.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(y,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(y=typeof globalThis<"u"?globalThis:y||self,p(y["@acrobits/ipc-sdk"]={}))})(this,function(y){"use strict";var Mt=Object.defineProperty;var It=(y,p,
|
|
1
|
+
(function(y,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(y=typeof globalThis<"u"?globalThis:y||self,p(y["@acrobits/ipc-sdk"]={}))})(this,function(y){"use strict";var Mt=Object.defineProperty;var It=(y,p,E)=>p in y?Mt(y,p,{enumerable:!0,configurable:!0,writable:!0,value:E}):y[p]=E;var O=(y,p,E)=>(It(y,typeof p!="symbol"?p+"":p,E),E);var p=(n=>(n.BadgeQuery="BADGE QUERY",n.HostInForeground="HOST IN FOREGROUND",n))(p||{}),E=function(n,t){return E=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])},E(n,t)};function _(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");E(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function k(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 I(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o}function P(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return n.concat(o||Array.prototype.slice.call(t))}function m(n){return typeof n=="function"}function B(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 q=B(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 R(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,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=k(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(d){t={error:d}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else s.remove(this);var v=this.initialTeardown;if(m(v))try{v()}catch(d){o=d instanceof q?d.errors:[d]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var x=k(g),S=x.next();!S.done;S=x.next()){var oe=S.value;try{ce(oe)}catch(d){o=o??[],d instanceof q?o=O(O([],I(o)),I(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{S&&!S.done&&(i=x.return)&&i.call(x)}finally{if(r)throw r.error}}}if(o)throw new q(o)}},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)&&R(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&R(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 ue(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 ae={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Q={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=Q.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,O([n,t],I(e))):setTimeout.apply(void 0,O([n,t],I(e)))},clearTimeout:function(n){var t=Q.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Ae(n){Q.setTimeout(function(){throw n})}function le(){}function U(n){n()}var G=function(n){_(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,ue(e)&&e.add(r)):r.destination=je,r}return t.create=function(e,r,i){return new $(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),Re=Function.prototype.bind;function z(n,t){return Re.call(n,t)}var Ue=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}(),$=function(n){_(t,n);function t(e,r,i){var o=n.call(this)||this,s;if(m(e)||!e)s={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;o&&ae.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&z(e.next,c),error:e.error&&z(e.error,c),complete:e.complete&&z(e.complete,c)}):s=e}return o.destination=new Ue(s),o}return t}(G);function j(n){Ae(n)}function $e(n){throw n}var je={closed:!0,next:le,error:$e,complete:le},Ve=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function he(n){return n}function Le(n){return n.length===0?he:n.length===1?n[0]:function(e){return n.reduce(function(r,i){return i(r)},e)}}var Y=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,o=He(t)?t:new $(t,e,r);return U(function(){var s=i,c=s.operator,u=s.source;o.add(c?c.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},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,o){var s=new $({next:function(c){try{t(c)}catch(u){o(u),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[Ve]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Le(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=de(t),new t(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},n.create=function(t){return new n(t)},n}();function de(n){var t;return(t=n??ae.Promise)!==null&&t!==void 0?t:Promise}function Fe(n){return n&&m(n.next)&&m(n.error)&&m(n.complete)}function He(n){return n&&n instanceof G||Fe(n)&&ue(n)}function De(n){return m(n==null?void 0:n.lift)}function pe(n){return function(t){if(De(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){_(t,n);function t(e,r,i,o,s,c){var u=n.call(this,e)||this;return u.onFinalize=s,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,u._error=o?function(a){try{o(a)}catch(v){e.error(v)}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}(G),ke=B(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ve=function(n){_(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 ge(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new ke},t.prototype.next=function(e){var r=this;U(function(){var i,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=k(r.currentObservers),c=s.next();!c.done;c=s.next()){var u=c.value;u.next(e)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var r=this;U(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;U(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,o=i.hasError,s=i.isStopped,c=i.observers;return o||s?se:(this.currentObservers=null,c.push(e),new P(function(){r.currentObservers=null,R(c,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,o=r.thrownError,s=r.isStopped;i?e.error(o):s&&e.complete()},t.prototype.asObservable=function(){var e=new Y;return e.source=this,e},t.create=function(e,r){return new ge(e,r)},t}(Y),ge=function(n){_(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}(ve),be={now:function(){return(be.delegate||Date).now()},delegate:void 0},Be=function(n){_(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(P),V={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=V.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,O([n,t],I(e))):setInterval.apply(void 0,O([n,t],I(e)))},clearInterval:function(n){var t=V.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},qe=function(n){_(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 o=this.id,s=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(s,o,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(s,this.id,r),this},t.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),V.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&&V.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,o;try{this.work(e)}catch(s){i=!0,o=s||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,o=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,R(o,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Be),ye=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=be.now,n}(),Qe=function(n){_(t,n);function t(e,r){r===void 0&&(r=ye.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}(ye),Ge=new Qe(qe),ze=Ge;function Ye(n){return n&&m(n.schedule)}var Je=B(function(n){return function(){n(this),this.name="EmptyError",this.message="no elements in sequence"}});function A(n,t){var e=typeof t=="object";return new Promise(function(r,i){var o=new $({next:function(s){r(s),o.unsubscribe()},error:i,complete:function(){e?r(t.defaultValue):i(new Je)}});n.subscribe(o)})}function We(n){return n instanceof Date&&!isNaN(n)}function L(n,t){return pe(function(e,r){var i=0;e.subscribe(fe(r,function(o){r.next(n.call(t,o,i++))}))})}function Ke(n,t,e){n===void 0&&(n=0),e===void 0&&(e=ze);var r=-1;return t!=null&&(Ye(t)?e=t:r=t),new Y(function(i){var o=We(n)?+n-e.now():n;o<0&&(o=0);var s=0;return e.schedule(function(){i.closed||(i.next(s++),0<=r?this.schedule(void 0,r):i.complete())},o)})}function Xe(n,t,e){var r=m(n)||t||e?{next:n,error:t,complete:e}:n;return r?pe(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;i.subscribe(fe(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.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,M=(n,t,e)=>(et(n,typeof t!="symbol"?t+"":t,e),e);class h extends Error{constructor(t){super(`Incorrect context (${t}). Cannot perform the requested operation.`),M(this,"context"),this.context=t}}class F 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 me extends Error{constructor(t){super(`${t} needs to be initialized before it can be used.`)}}class we 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 w(n){return typeof n=="function"}function nt(n){return w(n==null?void 0:n.lift)}function H(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 J=function(n,t){return J=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])},J(n,t)};function W(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");J(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function Se(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 K(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o}function X(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return n.concat(o||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 Z=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 T(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var A=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,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=k(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(d){t={error:d}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else s.remove(this);var v=this.initialTeardown;if(m(v))try{v()}catch(d){o=d instanceof q?d.errors:[d]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var x=k(b),S=x.next();!S.done;S=x.next()){var oe=S.value;try{ce(oe)}catch(d){o=o??[],d instanceof q?o=P(P([],I(o)),I(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{S&&!S.done&&(i=x.return)&&i.call(x)}finally{if(r)throw r.error}}}if(o)throw new q(o)}},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)&&T(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&T(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),se=A.EMPTY;function ue(n){return n instanceof A||n&&"closed"in n&&m(n.remove)&&m(n.add)&&m(n.unsubscribe)}function ce(n){m(n)?n():n.unsubscribe()}var ae={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Q={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=Q.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,P([n,t],I(e))):setTimeout.apply(void 0,P([n,t],I(e)))},clearTimeout:function(n){var t=Q.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Re(n){Q.setTimeout(function(){throw n})}function le(){}function U(n){n()}var G=function(n){_(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,ue(e)&&e.add(r)):r.destination=je,r}return t.create=function(e,r,i){return new $(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}(A),Te=Function.prototype.bind;function z(n,t){return Te.call(n,t)}var Ue=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}(),$=function(n){_(t,n);function t(e,r,i){var o=n.call(this)||this,s;if(m(e)||!e)s={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;o&&ae.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&z(e.next,c),error:e.error&&z(e.error,c),complete:e.complete&&z(e.complete,c)}):s=e}return o.destination=new Ue(s),o}return t}(G);function j(n){Re(n)}function $e(n){throw n}var je={closed:!0,next:le,error:$e,complete:le},Le=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function he(n){return n}function Ve(n){return n.length===0?he:n.length===1?n[0]:function(e){return n.reduce(function(r,i){return i(r)},e)}}var Y=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,o=He(t)?t:new $(t,e,r);return U(function(){var s=i,c=s.operator,u=s.source;o.add(c?c.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},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,o){var s=new $({next:function(c){try{t(c)}catch(u){o(u),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[Le]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Ve(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=de(t),new t(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},n.create=function(t){return new n(t)},n}();function de(n){var t;return(t=n??ae.Promise)!==null&&t!==void 0?t:Promise}function Fe(n){return n&&m(n.next)&&m(n.error)&&m(n.complete)}function He(n){return n&&n instanceof G||Fe(n)&&ue(n)}function De(n){return m(n==null?void 0:n.lift)}function pe(n){return function(t){if(De(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){_(t,n);function t(e,r,i,o,s,c){var u=n.call(this,e)||this;return u.onFinalize=s,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,u._error=o?function(a){try{o(a)}catch(v){e.error(v)}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}(G),ke=B(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ge=function(n){_(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 ke},t.prototype.next=function(e){var r=this;U(function(){var i,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=k(r.currentObservers),c=s.next();!c.done;c=s.next()){var u=c.value;u.next(e)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var r=this;U(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;U(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,o=i.hasError,s=i.isStopped,c=i.observers;return o||s?se:(this.currentObservers=null,c.push(e),new A(function(){r.currentObservers=null,T(c,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,o=r.thrownError,s=r.isStopped;i?e.error(o):s&&e.complete()},t.prototype.asObservable=function(){var e=new Y;return e.source=this,e},t.create=function(e,r){return new ve(e,r)},t}(Y),ve=function(n){_(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),be={now:function(){return(be.delegate||Date).now()},delegate:void 0},Be=function(n){_(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(A),L={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=L.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,P([n,t],I(e))):setInterval.apply(void 0,P([n,t],I(e)))},clearInterval:function(n){var t=L.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},qe=function(n){_(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 o=this.id,s=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(s,o,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(s,this.id,r),this},t.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),L.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&&L.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,o;try{this.work(e)}catch(s){i=!0,o=s||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,o=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,T(o,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Be),ye=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=be.now,n}(),Qe=function(n){_(t,n);function t(e,r){r===void 0&&(r=ye.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}(ye),Ge=new Qe(qe),ze=Ge;function Ye(n){return n&&m(n.schedule)}var Je=B(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 o=new $({next:function(s){r(s),o.unsubscribe()},error:i,complete:function(){e?r(t.defaultValue):i(new Je)}});n.subscribe(o)})}function We(n){return n instanceof Date&&!isNaN(n)}function V(n,t){return pe(function(e,r){var i=0;e.subscribe(fe(r,function(o){r.next(n.call(t,o,i++))}))})}function Ke(n,t,e){n===void 0&&(n=0),e===void 0&&(e=ze);var r=-1;return t!=null&&(Ye(t)?e=t:r=t),new Y(function(i){var o=We(n)?+n-e.now():n;o<0&&(o=0);var s=0;return e.schedule(function(){i.closed||(i.next(s++),0<=r?this.schedule(void 0,r):i.complete())},o)})}function Xe(n,t,e){var r=m(n)||t||e?{next:n,error:t,complete:e}:n;return r?pe(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;i.subscribe(fe(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.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,M=(n,t,e)=>(et(n,typeof t!="symbol"?t+"":t,e),e);class h extends Error{constructor(t){super(`Incorrect context (${t}). Cannot perform the requested operation.`),M(this,"context"),this.context=t}}class F 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 me extends Error{constructor(t){super(`${t} needs to be initialized before it can be used.`)}}class we 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 w(n){return typeof n=="function"}function nt(n){return w(n==null?void 0:n.lift)}function H(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 J=function(n,t){return J=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])},J(n,t)};function W(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");J(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function Se(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 K(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o}function X(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return n.concat(o||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 Z=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 Ce(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var ee=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,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=Se(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(d){t={error:d}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else s.remove(this);var v=this.initialTeardown;if(w(v))try{v()}catch(d){o=d instanceof Z?d.errors:[d]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var x=Se(g),S=x.next();!S.done;S=x.next()){var oe=S.value;try{xe(oe)}catch(d){o=o??[],d instanceof Z?o=X(X([],K(o)),K(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{S&&!S.done&&(i=x.return)&&i.call(x)}finally{if(r)throw r.error}}}if(o)throw new Z(o)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)xe(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)&&Ce(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&Ce(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}();ee.EMPTY;function Ee(n){return n instanceof ee||n&&"closed"in n&&w(n.remove)&&w(n.add)&&w(n.unsubscribe)}function xe(n){w(n)?n():n.unsubscribe()}var _e={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ot={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,X([n,t],K(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function st(n){ot.setTimeout(function(){throw n})}function Me(){}function ut(n){n()}var te=function(n){W(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 ne(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}(ee),ct=Function.prototype.bind;function re(n,t){return ct.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){D(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){D(r)}else D(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){D(e)}},n}(),ne=function(n){W(t,n);function t(e,r,i){var o=n.call(this)||this,s;if(w(e)||!e)s={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;o&&_e.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&re(e.next,c),error:e.error&&re(e.error,c),complete:e.complete&&re(e.complete,c)}):s=e}return o.destination=new at(s),o}return t}(te);function D(n){st(n)}function lt(n){throw n}var ht={closed:!0,next:Me,error:lt,complete:Me},dt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ie(n){return n}function pt(n){return n.length===0?Ie: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,o=gt(t)?t:new ne(t,e,r);return ut(function(){var s=i,c=s.operator,u=s.source;o.add(c?c.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},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=Oe(e),new e(function(i,o){var s=new ne({next:function(c){try{t(c)}catch(u){o(u),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},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=Oe(t),new t(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},n.create=function(t){return new n(t)},n}();function Oe(n){var t;return(t=n??_e.Promise)!==null&&t!==void 0?t:Promise}function vt(n){return n&&w(n.next)&&w(n.error)&&w(n.complete)}function gt(n){return n&&n instanceof te||vt(n)&&Ee(n)}function N(n,t,e,r,i){return new bt(n,t,e,r,i)}var bt=function(n){W(t,n);function t(e,r,i,o,s,c){var u=n.call(this,e)||this;return u.onFinalize=s,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,u._error=o?function(a){try{o(a)}catch(v){e.error(v)}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}(te);function l(n,t){return H(function(e,r){var i=0;e.subscribe(N(r,function(o){r.next(n.call(t,o,i++))}))})}var yt=new ft(function(n){return n.complete()});function E(n){return n<=0?function(){return yt}:H(function(t,e){var r=0;t.subscribe(N(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function b(n,t){return H(function(e,r){var i=0;e.subscribe(N(r,function(o){return n.call(t,o,i++)&&r.next(o)}))})}function f(n,t,e){var r=w(n)||t||e?{next:n,error:t,complete:e}:n;return r?H(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;i.subscribe(N(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.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)}))}):Ie}const mt=/^(\d+)\.(\d+)$/;function wt(n){if(typeof n=="string"){const t=n.match(mt);if(t)return`${t[1]}.${t[2]}`}throw new rt(n)}function Te(n){const t=wt(n),[e,r]=t.split("."),[i,o]=[parseInt(e),parseInt(r)];return[i,o]}function ie(n,t){const[e,r]=Te(n),[i,o]=Te(t);return e<i?-1:e>i?1:r<o?-1:r>o?1:0}function St(n,t){return ie(n,t)===1}function Ct(n,t){return ie(n,t)>=0}const Pe="2.0";class Et{constructor(t,e){if(M(this,"negotiatedProtocolVersion"),M(this,"currentContext"),M(this,"incomingMessages$"),M(this,"inIframe",!1),M(this,"embeddedResult"),M(this,"iframePort1"),M(this,"iframePort2"),this.supportedVersions=t,this.logService=e,this.incomingMessages$=new ve,this.supportedVersions=t.filter(r=>Ct(r,Pe)),!this.supportedVersions.length)throw new we(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 me("port2");return this.iframePort2}else{if(!((e=(t=window.Acrobits)==null?void 0:t.messageChannel)!=null&&e.port2))throw new me("port2");return(i=(r=window.Acrobits)==null?void 0:r.messageChannel)==null?void 0:i.port2}}determineContext(){return Ke(1e3).pipe(l(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),E(1))}openBridge(){if(!this.isEmbedded())throw new h(this.currentContext);const t="HELLO",e=this.createMessage(t);e.protocolVersions=this.supportedVersions,this.logCreated(t,e);const r=this.incomingMessages$.pipe(b(i=>i.type===t&&i.replyTo===e.id),l(i=>i),f(this.logReceived(t)),l(i=>{if(this.supportedVersions.some(o=>St(o,i.protocolVersion)))throw new we(i.protocolVersion,this.supportedVersions[0]);return i}),f(i=>{this.negotiatedProtocolVersion=i.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),E(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 h(this.currentContext);const t="TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(b(i=>i.type===t&&i.replyTo===e.id),l(i=>i),f(this.logReceived(t)),E(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 h(this.currentContext);const{roomName:e,roomInvite:r,displayName:i,jwtToken:o,serverUrl:s,region:c,joinMicMuted:u,joinWithoutCamera:a}=t,v="JOINING ROOM",g=this.createMessage(v,!1);g.roomName=e,g.jwtToken=o,g.serverUrl=s,g.region=c,g.roomInvite=r,g.joinMicMuted=u??!1,g.joinWithoutCamera=a??!1,g.displayName=i,this.logCreated(v,g),this.port2.postMessage(g),this.logSent(v,g)}sendLeavingRoomMessage(t){if(!this.isEmbedded())throw new h(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 h(this.currentContext);const t="JOIN ROOM";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)),l(e=>e))}onLeaveRoomMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="LEAVE ROOM";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)),l(e=>e))}onConfigMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="CONFIG";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)),l(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 h(this.currentContext);const e="SCREENSHARE SOURCE",r=this.createMessage(e);r.sourceTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(b(o=>o.type===e&&o.replyTo===r.id),l(o=>o),f(this.logReceived(e)),l(o=>o),E(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 h(this.currentContext);const i="LAYOUT CHANGE";let o,s;if(e&&r?(o=this.createMessage(i,!1,r),o.result=e):(o=this.createMessage(i),s=this.incomingMessages$.pipe(b(c=>c.type===i&&c.replyTo===o.id),l(c=>c),f(this.logReceived(i)),l(c=>c),E(1)),this.logService.debug(`Created ${i} Reply handler`)),o.layout=t,this.logCreated(i,o),this.port2.postMessage(o),this.logSent(i,o),s)return s}onLayoutChangeMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="LAYOUT CHANGE";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"&&e.replyTo===null),l(e=>e),f(this.logReceived(t)),l(e=>e))}requestOAuthToken(t){if(!this.isEmbedded())throw new h(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(b(o=>o.type===e&&o.replyTo===r.id),l(o=>o),f(this.logReceived(e)),E(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 h(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){if(!this.isEmbedded())throw new h(this.currentContext);if(e==="group"&&r===void 0)throw new F("currentContacts",r,"currentContacts is required for group streams");if(e==="direct"&&r!==void 0)throw new F("currentContacts",r,"currentContacts should not be passed for direct streams");const i="SELECT CONTACTS",o=this.createMessage(i,!0);o.streamType=e,o.streamId=t,o.currentContacts=r,this.logCreated(i,o);const s=this.incomingMessages$.pipe(b(c=>c.type===i&&c.replyTo===o.id),f(this.logReceived(i)),l(c=>{const u=c;if(u.streamId!==t)throw new tt(u.streamId,t);return e==="direct"&&u.contacts.length>1&&(u.contacts=[u.contacts[0]]),u}),E(1));return this.logService.debug(`Created ${i} Reply handler`),this.port2.postMessage(o),this.logSent(i,o),s}matchContacts(t){if(!this.isEmbedded())throw new h(this.currentContext);if(!t.length)throw new F("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(b(o=>o.type===e&&o.replyTo===r.id),f(this.logReceived(e)),l(o=>o),E(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}onPushMessageMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="PUSH MESSAGE";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)))}requestPushToken(){if(!this.isEmbedded())throw new h(this.currentContext);const t="PUSH TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(b(i=>i.type===t&&i.replyTo===e.id),f(this.logReceived(t)),l(i=>i),E(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}onBadgeQueryMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="BADGE QUERY";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)))}sendBadgeUpdateMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="BADGE UPDATE",i=this.createMessage(r,!1,e);i.count=t,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onHostInForegroundMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="HOST IN FOREGROUND";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)))}sendLifecycleMessage(t,e){if(!this.isEmbedded())throw new h(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)}sendLogMessage(t,e){if(!this.isEmbedded())throw new h(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 h(this.currentContext);const t="REQUEST LOGS";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)))}sendViewTransitionMessage(t,e){if(!this.isEmbedded())throw new h(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)}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 ie(this.negotiatedProtocolVersion,t)}logReceived(t,e){const r=i=>this.logService.debug(`[IPC] Received ${t} message`,i);return e&&r(e),r}logSent(t,e){this.logService.debug(`[IPC] Sent ${t} message`,e)}logCreated(t,e){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 o=0;o<t;o++)i.push(r[Math.floor(Math.random()*r.length)]);return i.join("")}}const xt=["2.0"];class _t{constructor(t){T(this,"host");T(this,"cloudId");T(this,"logger");T(this,"helper");T(this,"listeners");this.logger=t??console,this.helper=new Et(xt,this.logger),this.listeners=new Map,this.listeners.set(p.BadgeQuery,new Set),this.listeners.set(p.HostInForeground,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 A(this.helper.determineContext(),{defaultValue:"guest"});return this.evaluateContext(t)}initiateConnection(){return A(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(p.BadgeQuery))==null?void 0:r.values())??[])i()}),this.helper.onHostInForegroundMessage().subscribe(e=>{var r;this.logger.debug("Received Host In Foreground: ",e);for(const i of((r=this.listeners.get(p.HostInForeground))==null?void 0:r.values())??[])i()}),this.cloudId=t.cloudId,this.host=t.host}),L(()=>{})))}selectContacts(t,e,r){this.logger.debug("Selecting Contacts: ",...arguments);let i;if(e==="multi"){if(!r)throw new F("currentContacts",r,"currentContacts is required for group streams");i=this.helper.selectContacts(t.toString(),"group",r)}else i=this.helper.selectContacts(t.toString(),"direct");return A(i.pipe(L(o=>o.contacts)))}matchContacts(t){return this.logger.debug("Match Contacts: ",t),A(this.helper.matchContacts(t).pipe(L(e=>e.contacts)))}requestPushToken(){return this.logger.debug("Requesting Push Token"),A(this.helper.requestPushToken().pipe(L(t=>t.pushToken)))}badgeUpdate(t){this.logger.debug("Sending Badge Update: ",t),this.helper.sendBadgeUpdateMessage(t)}onBadgeQueryRequest(t){var e;return this.logger.debug("Registering for Badge Query"),(e=this.listeners.get(p.BadgeQuery))==null||e.add(t),()=>{var r;return(r=this.listeners.get(p.BadgeQuery))==null?void 0:r.delete(t)}}onHostInForeground(t){var e;return this.logger.debug("Registering for Host In Foreground"),(e=this.listeners.get(p.HostInForeground))==null||e.add(t),()=>{var r;return(r=this.listeners.get(p.HostInForeground))==null?void 0:r.delete(t)}}evaluateContext(t){if(t==="user")return"host";if(t==="guest")return"standalone"}}y.IPCEvents=p,y.IPCManager=_t,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|
|
5
|
+
`):"",this.name="UnsubscriptionError",this.errors=t}});function Ee(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var ee=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,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=Se(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(d){t={error:d}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else s.remove(this);var v=this.initialTeardown;if(w(v))try{v()}catch(d){o=d instanceof Z?d.errors:[d]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var x=Se(b),S=x.next();!S.done;S=x.next()){var oe=S.value;try{xe(oe)}catch(d){o=o??[],d instanceof Z?o=X(X([],K(o)),K(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{S&&!S.done&&(i=x.return)&&i.call(x)}finally{if(r)throw r.error}}}if(o)throw new Z(o)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)xe(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)&&Ee(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&Ee(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}();ee.EMPTY;function Ce(n){return n instanceof ee||n&&"closed"in n&&w(n.remove)&&w(n.add)&&w(n.unsubscribe)}function xe(n){w(n)?n():n.unsubscribe()}var _e={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ot={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,X([n,t],K(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function st(n){ot.setTimeout(function(){throw n})}function Me(){}function ut(n){n()}var te=function(n){W(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,Ce(e)&&e.add(r)):r.destination=ht,r}return t.create=function(e,r,i){return new ne(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}(ee),ct=Function.prototype.bind;function re(n,t){return ct.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){D(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){D(r)}else D(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){D(e)}},n}(),ne=function(n){W(t,n);function t(e,r,i){var o=n.call(this)||this,s;if(w(e)||!e)s={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;o&&_e.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&re(e.next,c),error:e.error&&re(e.error,c),complete:e.complete&&re(e.complete,c)}):s=e}return o.destination=new at(s),o}return t}(te);function D(n){st(n)}function lt(n){throw n}var ht={closed:!0,next:Me,error:lt,complete:Me},dt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ie(n){return n}function pt(n){return n.length===0?Ie: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,o=vt(t)?t:new ne(t,e,r);return ut(function(){var s=i,c=s.operator,u=s.source;o.add(c?c.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},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=Pe(e),new e(function(i,o){var s=new ne({next:function(c){try{t(c)}catch(u){o(u),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},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=Pe(t),new t(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},n.create=function(t){return new n(t)},n}();function Pe(n){var t;return(t=n??_e.Promise)!==null&&t!==void 0?t:Promise}function gt(n){return n&&w(n.next)&&w(n.error)&&w(n.complete)}function vt(n){return n&&n instanceof te||gt(n)&&Ce(n)}function N(n,t,e,r,i){return new bt(n,t,e,r,i)}var bt=function(n){W(t,n);function t(e,r,i,o,s,c){var u=n.call(this,e)||this;return u.onFinalize=s,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,u._error=o?function(a){try{o(a)}catch(v){e.error(v)}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}(te);function l(n,t){return H(function(e,r){var i=0;e.subscribe(N(r,function(o){r.next(n.call(t,o,i++))}))})}var yt=new ft(function(n){return n.complete()});function C(n){return n<=0?function(){return yt}:H(function(t,e){var r=0;t.subscribe(N(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function g(n,t){return H(function(e,r){var i=0;e.subscribe(N(r,function(o){return n.call(t,o,i++)&&r.next(o)}))})}function f(n,t,e){var r=w(n)||t||e?{next:n,error:t,complete:e}:n;return r?H(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;i.subscribe(N(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.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)}))}):Ie}const mt=/^(\d+)\.(\d+)$/;function wt(n){if(typeof n=="string"){const t=n.match(mt);if(t)return`${t[1]}.${t[2]}`}throw new rt(n)}function Oe(n){const t=wt(n),[e,r]=t.split("."),[i,o]=[parseInt(e),parseInt(r)];return[i,o]}function ie(n,t){const[e,r]=Oe(n),[i,o]=Oe(t);return e<i?-1:e>i?1:r<o?-1:r>o?1:0}function St(n,t){return ie(n,t)===1}function Et(n,t){return ie(n,t)>=0}const Ae="2.0";class Ct{constructor(t,e){if(M(this,"negotiatedProtocolVersion"),M(this,"currentContext"),M(this,"incomingMessages$"),M(this,"inIframe",!1),M(this,"embeddedResult"),M(this,"iframePort1"),M(this,"iframePort2"),this.supportedVersions=t,this.logService=e,this.incomingMessages$=new ge,this.supportedVersions=t.filter(r=>Et(r,Ae)),!this.supportedVersions.length)throw new we(t,Ae);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 me("port2");return this.iframePort2}else{if(!((e=(t=window.Acrobits)==null?void 0:t.messageChannel)!=null&&e.port2))throw new me("port2");return(i=(r=window.Acrobits)==null?void 0:r.messageChannel)==null?void 0:i.port2}}determineContext(){return Ke(1e3).pipe(l(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),C(1))}openBridge(){if(!this.isEmbedded())throw new h(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),l(i=>i),f(this.logReceived(t)),l(i=>{if(this.supportedVersions.some(o=>St(o,i.protocolVersion)))throw new we(i.protocolVersion,this.supportedVersions[0]);return i}),f(i=>{this.negotiatedProtocolVersion=i.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),C(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 h(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),l(i=>i),f(this.logReceived(t)),C(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 h(this.currentContext);const{roomName:e,roomInvite:r,displayName:i,jwtToken:o,serverUrl:s,region:c,joinMicMuted:u,joinWithoutCamera:a}=t,v="JOINING ROOM",b=this.createMessage(v,!1);b.roomName=e,b.jwtToken=o,b.serverUrl=s,b.region=c,b.roomInvite=r,b.joinMicMuted=u??!1,b.joinWithoutCamera=a??!1,b.displayName=i,this.logCreated(v,b),this.port2.postMessage(b),this.logSent(v,b)}sendLeavingRoomMessage(t){if(!this.isEmbedded())throw new h(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 h(this.currentContext);const t="JOIN ROOM";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)),l(e=>e))}onLeaveRoomMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="LEAVE ROOM";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)),l(e=>e))}onConfigMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="CONFIG";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)),l(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 h(this.currentContext);const e="SCREENSHARE SOURCE",r=this.createMessage(e);r.sourceTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(g(o=>o.type===e&&o.replyTo===r.id),l(o=>o),f(this.logReceived(e)),l(o=>o),C(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 h(this.currentContext);const i="LAYOUT CHANGE";let o,s;if(e&&r?(o=this.createMessage(i,!1,r),o.result=e):(o=this.createMessage(i),s=this.incomingMessages$.pipe(g(c=>c.type===i&&c.replyTo===o.id),l(c=>c),f(this.logReceived(i)),l(c=>c),C(1)),this.logService.debug(`Created ${i} Reply handler`)),o.layout=t,this.logCreated(i,o),this.port2.postMessage(o),this.logSent(i,o),s)return s}onLayoutChangeMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="LAYOUT CHANGE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),l(e=>e),f(this.logReceived(t)),l(e=>e))}requestOAuthToken(t){if(!this.isEmbedded())throw new h(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(o=>o.type===e&&o.replyTo===r.id),l(o=>o),f(this.logReceived(e)),C(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 h(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 h(this.currentContext);if(e==="group"&&i===void 0)throw new F("currentContacts",i,"currentContacts is required for group streams");if(e==="direct"&&i!==void 0)throw new F("currentContacts",i,"currentContacts should not be passed for direct streams");const o="SELECT CONTACTS",s=this.createMessage(o,!0);s.streamType=e,s.streamId=t,s.contactType=r,s.currentContacts=i,this.logCreated(o,s);const c=this.incomingMessages$.pipe(g(u=>u.type===o&&u.replyTo===s.id),f(this.logReceived(o)),l(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}),C(1));return this.logService.debug(`Created ${o} Reply handler`),this.port2.postMessage(s),this.logSent(o,s),c}matchContacts(t){if(!this.isEmbedded())throw new h(this.currentContext);if(!t.length)throw new F("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(o=>o.type===e&&o.replyTo===r.id),f(this.logReceived(e)),l(o=>o),C(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}onPushMessageMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="PUSH MESSAGE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)))}requestPushToken(){if(!this.isEmbedded())throw new h(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),f(this.logReceived(t)),l(i=>i),C(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}onBadgeQueryMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="BADGE QUERY";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)))}sendBadgeUpdateMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="BADGE UPDATE",i=this.createMessage(r,!1,e);i.count=t,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onHostInForegroundMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="HOST IN FOREGROUND";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)))}sendLifecycleMessage(t,e){if(!this.isEmbedded())throw new h(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 h(this.currentContext);const t="LIFECYCLE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)))}sendLogMessage(t,e){if(!this.isEmbedded())throw new h(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 h(this.currentContext);const t="REQUEST LOGS";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),l(e=>e),f(this.logReceived(t)))}sendViewTransitionMessage(t,e){if(!this.isEmbedded())throw new h(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)}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 ie(this.negotiatedProtocolVersion,t)}logReceived(t,e){const r=i=>this.logService.debug(`[IPC] Received ${t} message`,i);return e&&r(e),r}logSent(t,e){this.logService.debug(`[IPC] Sent ${t} message`,e)}logCreated(t,e){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 o=0;o<t;o++)i.push(r[Math.floor(Math.random()*r.length)]);return i.join("")}}const xt=["2.0"];class _t{constructor(t){O(this,"host");O(this,"cloudId");O(this,"logger");O(this,"helper");O(this,"listeners");this.logger=t??console,this.helper=new Ct(xt,this.logger),this.listeners=new Map,this.listeners.set(p.BadgeQuery,new Set),this.listeners.set(p.HostInForeground,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(p.BadgeQuery))==null?void 0:r.values())??[])i()}),this.helper.onHostInForegroundMessage().subscribe(e=>{var r;this.logger.debug("Received Host In Foreground: ",e);for(const i of((r=this.listeners.get(p.HostInForeground))==null?void 0:r.values())??[])i()}),this.cloudId=t.cloudId,this.host=t.host}),V(()=>{})))}selectContacts(t,e,r,i){this.logger.debug("Selecting Contacts: ",...arguments);let o;if(e==="multi"){if(!r||!Array.isArray(r))throw new F("currentContacts",r,"currentContacts is required for group streams");i||(i="cloudUsername"),o=this.helper.selectContacts(t.toString(),"group",i,r)}else r?i=r:i="cloudUsername",o=this.helper.selectContacts(t.toString(),"direct",i);return R(o.pipe(V(s=>s.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){this.logger.debug("Sending Badge Update: ",t),this.helper.sendBadgeUpdateMessage(t)}onBadgeQueryRequest(t){var e;return this.logger.debug("Registering for Badge Query"),(e=this.listeners.get(p.BadgeQuery))==null||e.add(t),()=>{var r;return(r=this.listeners.get(p.BadgeQuery))==null?void 0:r.delete(t)}}onHostInForeground(t){var e;return this.logger.debug("Registering for Host In Foreground"),(e=this.listeners.get(p.HostInForeground))==null||e.add(t),()=>{var r;return(r=this.listeners.get(p.HostInForeground))==null?void 0:r.delete(t)}}evaluateContext(t){if(t==="user")return"host";if(t==="guest")return"standalone"}}y.IPCEvents=p,y.IPCManager=_t,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|