@therms/rpc-client
Advanced tools
Comparing version 2.19.0 to 2.19.1
@@ -934,2 +934,3 @@ 'use strict'; | ||
deadlineMs: options.deadlineMs || RPCClient.DEFAULT_DEADLINE_MS, | ||
onTransportRequestError: options.onTransportRequestError, | ||
requestInterceptor: options.requestInterceptor, | ||
@@ -936,0 +937,0 @@ responseInterceptor: options.responseInterceptor, |
@@ -932,2 +932,3 @@ import stringify from 'fast-json-stable-stringify'; | ||
deadlineMs: options.deadlineMs || RPCClient.DEFAULT_DEADLINE_MS, | ||
onTransportRequestError: options.onTransportRequestError, | ||
requestInterceptor: options.requestInterceptor, | ||
@@ -934,0 +935,0 @@ responseInterceptor: options.responseInterceptor, |
@@ -23,3 +23,2 @@ import { CallRequestDTO } from './CallRequestDTO'; | ||
makeProcedure<Args = any, Data = any>(request: CallRequestDTO<Args> | string): (args?: any) => Promise<CallResponseDTO<Data>>; | ||
onTransportRequestError?: ClientManagerOptions['onTransportRequestError']; | ||
registerResponseInterceptor(responseInterceptor: CallResponseInterceptor): UnsubscribeCallback; | ||
@@ -54,2 +53,3 @@ registerRequestInterceptor(requestInterceptor: CallRequestInterceptor): UnsubscribeCallback; | ||
}; | ||
onTransportRequestError?: ClientManagerOptions['onTransportRequestError']; | ||
onWebSocketConnectionStatusChange?: (connected: boolean) => void; | ||
@@ -56,0 +56,0 @@ requestInterceptor?: CallRequestInterceptor; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RPCClient={})}(this,(function(t){"use strict";function e(t,e,s,i){return new(s||(s=Promise))((function(n,r){function o(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,s=e&&t[e],i=0;if(s)return s.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,i=t[Symbol.asyncIterator];return i?i.call(t):(t=s(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=t[s]&&function(e){return new Promise((function(i,n){(function(t,e,s,i){Promise.resolve(i).then((function(e){t({value:e,done:s})}),e)})(i,n,(e=t[s](e)).done,e.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(t){const{args:e,correlationId:s,identity:i,procedure:n,scope:r,version:o}=t;if(this.args=e,s&&"string"!=typeof s)throw new Error("correlationId must be a string");if(this.correlationId=s||Math.random().toString(),i){if("object"!=typeof i)throw new Error("identity must be an object");if(i.authorization&&"string"!=typeof i.authorization)throw new Error("identity.authorization must be a string");if(i.deviceName&&"string"!=typeof i.deviceName)throw new Error("identity.deviceName must be a string");if(i.metadata&&"object"!=typeof i.metadata)throw new Error("identity.metadata must be a object");this.identity=i}if(n&&"string"!=typeof n)throw new Error("procedure must be string");if(this.procedure=n,r&&"string"!=typeof r)throw new Error("scope must be string");if(this.scope=r,o&&"string"!=typeof o)throw new Error("version must be string");this.version=o}}class r extends Error{}function o(t){if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}const a=t=>t.args?`${t.scope}${t.procedure}${t.version}${function(t,e){e||(e={}),"function"==typeof e&&(e={cmp:e});var s,i="boolean"==typeof e.cycles&&e.cycles,n=e.cmp&&(s=e.cmp,function(t){return function(e,i){var n={key:e,value:t[e]},r={key:i,value:t[i]};return s(n,r)}}),r=[];return function t(e){if(e&&e.toJSON&&"function"==typeof e.toJSON&&(e=e.toJSON()),void 0!==e){if("number"==typeof e)return isFinite(e)?""+e:"null";if("object"!=typeof e)return JSON.stringify(e);var s,o;if(Array.isArray(e)){for(o="[",s=0;s<e.length;s++)s&&(o+=","),o+=t(e[s])||"null";return o+"]"}if(null===e)return"null";if(-1!==r.indexOf(e)){if(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=r.push(e)-1,c=Object.keys(e).sort(n&&n(e));for(o="",s=0;s<c.length;s++){var h=c[s],l=t(e[h]);l&&(o&&(o+=","),o+=JSON.stringify(h)+":"+l)}return r.splice(a,1),"{"+o+"}"}}(t)}(function(t,e={}){if(!o(t)&&!Array.isArray(t))throw new TypeError("Expected a plain object or array");const{deep:s,compare:i}=e,n=[],r=[],a=t=>{const e=n.indexOf(t);if(-1!==e)return r[e];const s=[];return n.push(t),r.push(s),s.push(...t.map((t=>Array.isArray(t)?a(t):o(t)?c(t):t))),s},c=t=>{const e=n.indexOf(t);if(-1!==e)return r[e];const h={},l=Object.keys(t).sort(i);n.push(t),r.push(h);for(const e of l){const i=t[e];let n;n=s&&Array.isArray(i)?a(i):s&&o(i)?c(i):i,Object.defineProperty(h,e,Object.assign(Object.assign({},Object.getOwnPropertyDescriptor(t,e)),{value:n}))}return h};return Array.isArray(t)?s?a(t):t.slice():c(t)}(t.args||{},{deep:!0}))}`:`${t.scope}${t.procedure}${t.version}`;var c="object"==typeof global&&global&&global.Object===Object&&global,h="object"==typeof self&&self&&self.Object===Object&&self,l=c||h||Function("return this")(),u=l.Symbol,d=Object.prototype,p=d.hasOwnProperty,f=d.toString,v=u?u.toStringTag:void 0;var y=Object.prototype.toString;var g="[object Null]",b="[object Undefined]",w=u?u.toStringTag:void 0;function m(t){return null==t?void 0===t?b:g:w&&w in Object(t)?function(t){var e=p.call(t,v),s=t[v];try{t[v]=void 0;var i=!0}catch(t){}var n=f.call(t);return i&&(e?t[v]=s:delete t[v]),n}(t):function(t){return y.call(t)}(t)}function S(t){return null!=t&&"object"==typeof t}var _=Array.isArray;function T(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function C(t){return t}var j="[object AsyncFunction]",O="[object Function]",A="[object GeneratorFunction]",k="[object Proxy]";function F(t){if(!T(t))return!1;var e=m(t);return e==O||e==A||e==j||e==k}var R,E=l["__core-js_shared__"],z=(R=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+R:"";var x=Function.prototype.toString;function M(t){if(null!=t){try{return x.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var I=/^\[object .+?Constructor\]$/,L=Function.prototype,P=Object.prototype,D=L.toString,W=P.hasOwnProperty,q=RegExp("^"+D.call(W).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function U(t){return!(!T(t)||(e=t,z&&z in e))&&(F(t)?q:I).test(M(t));var e}function B(t,e){var s=function(t,e){return null==t?void 0:t[e]}(t,e);return U(s)?s:void 0}var N=B(l,"WeakMap"),$=Object.create,H=function(){function t(){}return function(e){if(!T(e))return{};if($)return $(e);t.prototype=e;var s=new t;return t.prototype=void 0,s}}();function G(t,e){var s=-1,i=t.length;for(e||(e=Array(i));++s<i;)e[s]=t[s];return e}var J=Date.now;var V,X,K,Z=function(){try{var t=B(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Q=Z?function(t,e){return Z(t,"toString",{configurable:!0,enumerable:!1,value:(s=e,function(){return s}),writable:!0});var s}:C,Y=(V=Q,X=0,K=0,function(){var t=J(),e=16-(t-K);if(K=t,e>0){if(++X>=800)return arguments[0]}else X=0;return V.apply(void 0,arguments)});var tt=9007199254740991,et=/^(?:0|[1-9]\d*)$/;function st(t,e){var s=typeof t;return!!(e=null==e?tt:e)&&("number"==s||"symbol"!=s&&et.test(t))&&t>-1&&t%1==0&&t<e}function it(t,e,s){"__proto__"==e&&Z?Z(t,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[e]=s}function nt(t,e){return t===e||t!=t&&e!=e}var rt=Object.prototype.hasOwnProperty;function ot(t,e,s){var i=t[e];rt.call(t,e)&&nt(i,s)&&(void 0!==s||e in t)||it(t,e,s)}function at(t,e,s,i){var n=!s;s||(s={});for(var r=-1,o=e.length;++r<o;){var a=e[r],c=i?i(s[a],t[a],a,s,t):void 0;void 0===c&&(c=t[a]),n?it(s,a,c):ot(s,a,c)}return s}var ct=Math.max;function ht(t,e){return Y(function(t,e,s){return e=ct(void 0===e?t.length-1:e,0),function(){for(var i=arguments,n=-1,r=ct(i.length-e,0),o=Array(r);++n<r;)o[n]=i[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=i[n];return a[e]=s(o),function(t,e,s){switch(s.length){case 0:return t.call(e);case 1:return t.call(e,s[0]);case 2:return t.call(e,s[0],s[1]);case 3:return t.call(e,s[0],s[1],s[2])}return t.apply(e,s)}(t,this,a)}}(t,e,C),t+"")}var lt=9007199254740991;function ut(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=lt}function dt(t){return null!=t&&ut(t.length)&&!F(t)}var pt=Object.prototype;function ft(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||pt)}function vt(t){return S(t)&&"[object Arguments]"==m(t)}var yt=Object.prototype,gt=yt.hasOwnProperty,bt=yt.propertyIsEnumerable,wt=vt(function(){return arguments}())?vt:function(t){return S(t)&>.call(t,"callee")&&!bt.call(t,"callee")};var mt="object"==typeof t&&t&&!t.nodeType&&t,St=mt&&"object"==typeof module&&module&&!module.nodeType&&module,_t=St&&St.exports===mt?l.Buffer:void 0,Tt=(_t?_t.isBuffer:void 0)||function(){return!1},Ct={};function jt(t){return function(e){return t(e)}}Ct["[object Float32Array]"]=Ct["[object Float64Array]"]=Ct["[object Int8Array]"]=Ct["[object Int16Array]"]=Ct["[object Int32Array]"]=Ct["[object Uint8Array]"]=Ct["[object Uint8ClampedArray]"]=Ct["[object Uint16Array]"]=Ct["[object Uint32Array]"]=!0,Ct["[object Arguments]"]=Ct["[object Array]"]=Ct["[object ArrayBuffer]"]=Ct["[object Boolean]"]=Ct["[object DataView]"]=Ct["[object Date]"]=Ct["[object Error]"]=Ct["[object Function]"]=Ct["[object Map]"]=Ct["[object Number]"]=Ct["[object Object]"]=Ct["[object RegExp]"]=Ct["[object Set]"]=Ct["[object String]"]=Ct["[object WeakMap]"]=!1;var Ot="object"==typeof t&&t&&!t.nodeType&&t,At=Ot&&"object"==typeof module&&module&&!module.nodeType&&module,kt=At&&At.exports===Ot&&c.process,Ft=function(){try{var t=At&&At.require&&At.require("util").types;return t||kt&&kt.binding&&kt.binding("util")}catch(t){}}(),Rt=Ft&&Ft.isTypedArray,Et=Rt?jt(Rt):function(t){return S(t)&&ut(t.length)&&!!Ct[m(t)]},zt=Object.prototype.hasOwnProperty;function xt(t,e){var s=_(t),i=!s&&wt(t),n=!s&&!i&&Tt(t),r=!s&&!i&&!n&&Et(t),o=s||i||n||r,a=o?function(t,e){for(var s=-1,i=Array(t);++s<t;)i[s]=e(s);return i}(t.length,String):[],c=a.length;for(var h in t)!e&&!zt.call(t,h)||o&&("length"==h||n&&("offset"==h||"parent"==h)||r&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||st(h,c))||a.push(h);return a}function Mt(t,e){return function(s){return t(e(s))}}var It=Mt(Object.keys,Object),Lt=Object.prototype.hasOwnProperty;function Pt(t){return dt(t)?xt(t):function(t){if(!ft(t))return It(t);var e=[];for(var s in Object(t))Lt.call(t,s)&&"constructor"!=s&&e.push(s);return e}(t)}var Dt=Object.prototype.hasOwnProperty;function Wt(t){if(!T(t))return function(t){var e=[];if(null!=t)for(var s in Object(t))e.push(s);return e}(t);var e=ft(t),s=[];for(var i in t)("constructor"!=i||!e&&Dt.call(t,i))&&s.push(i);return s}function qt(t){return dt(t)?xt(t,!0):Wt(t)}var Ut=B(Object,"create");var Bt=Object.prototype.hasOwnProperty;var Nt=Object.prototype.hasOwnProperty;function $t(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}function Ht(t,e){for(var s=t.length;s--;)if(nt(t[s][0],e))return s;return-1}$t.prototype.clear=function(){this.__data__=Ut?Ut(null):{},this.size=0},$t.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},$t.prototype.get=function(t){var e=this.__data__;if(Ut){var s=e[t];return"__lodash_hash_undefined__"===s?void 0:s}return Bt.call(e,t)?e[t]:void 0},$t.prototype.has=function(t){var e=this.__data__;return Ut?void 0!==e[t]:Nt.call(e,t)},$t.prototype.set=function(t,e){var s=this.__data__;return this.size+=this.has(t)?0:1,s[t]=Ut&&void 0===e?"__lodash_hash_undefined__":e,this};var Gt=Array.prototype.splice;function Jt(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}Jt.prototype.clear=function(){this.__data__=[],this.size=0},Jt.prototype.delete=function(t){var e=this.__data__,s=Ht(e,t);return!(s<0)&&(s==e.length-1?e.pop():Gt.call(e,s,1),--this.size,!0)},Jt.prototype.get=function(t){var e=this.__data__,s=Ht(e,t);return s<0?void 0:e[s][1]},Jt.prototype.has=function(t){return Ht(this.__data__,t)>-1},Jt.prototype.set=function(t,e){var s=this.__data__,i=Ht(s,t);return i<0?(++this.size,s.push([t,e])):s[i][1]=e,this};var Vt=B(l,"Map");function Xt(t,e){var s,i,n=t.__data__;return("string"==(i=typeof(s=e))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==s:null===s)?n["string"==typeof e?"string":"hash"]:n.map}function Kt(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}function Zt(t,e){for(var s=-1,i=e.length,n=t.length;++s<i;)t[n+s]=e[s];return t}Kt.prototype.clear=function(){this.size=0,this.__data__={hash:new $t,map:new(Vt||Jt),string:new $t}},Kt.prototype.delete=function(t){var e=Xt(this,t).delete(t);return this.size-=e?1:0,e},Kt.prototype.get=function(t){return Xt(this,t).get(t)},Kt.prototype.has=function(t){return Xt(this,t).has(t)},Kt.prototype.set=function(t,e){var s=Xt(this,t),i=s.size;return s.set(t,e),this.size+=s.size==i?0:1,this};var Qt=Mt(Object.getPrototypeOf,Object),Yt="[object Object]",te=Function.prototype,ee=Object.prototype,se=te.toString,ie=ee.hasOwnProperty,ne=se.call(Object);function re(t){var e=this.__data__=new Jt(t);this.size=e.size}re.prototype.clear=function(){this.__data__=new Jt,this.size=0},re.prototype.delete=function(t){var e=this.__data__,s=e.delete(t);return this.size=e.size,s},re.prototype.get=function(t){return this.__data__.get(t)},re.prototype.has=function(t){return this.__data__.has(t)},re.prototype.set=function(t,e){var s=this.__data__;if(s instanceof Jt){var i=s.__data__;if(!Vt||i.length<199)return i.push([t,e]),this.size=++s.size,this;s=this.__data__=new Kt(i)}return s.set(t,e),this.size=s.size,this};var oe="object"==typeof t&&t&&!t.nodeType&&t,ae=oe&&"object"==typeof module&&module&&!module.nodeType&&module,ce=ae&&ae.exports===oe?l.Buffer:void 0,he=ce?ce.allocUnsafe:void 0;function le(t,e){if(e)return t.slice();var s=t.length,i=he?he(s):new t.constructor(s);return t.copy(i),i}function ue(){return[]}var de=Object.prototype.propertyIsEnumerable,pe=Object.getOwnPropertySymbols,fe=pe?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var s=-1,i=null==t?0:t.length,n=0,r=[];++s<i;){var o=t[s];e(o,s,t)&&(r[n++]=o)}return r}(pe(t),(function(e){return de.call(t,e)})))}:ue;var ve=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Zt(e,fe(t)),t=Qt(t);return e}:ue;function ye(t,e,s){var i=e(t);return _(t)?i:Zt(i,s(t))}function ge(t){return ye(t,Pt,fe)}function be(t){return ye(t,qt,ve)}var we=B(l,"DataView"),me=B(l,"Promise"),Se=B(l,"Set"),_e="[object Map]",Te="[object Promise]",Ce="[object Set]",je="[object WeakMap]",Oe="[object DataView]",Ae=M(we),ke=M(Vt),Fe=M(me),Re=M(Se),Ee=M(N),ze=m;(we&&ze(new we(new ArrayBuffer(1)))!=Oe||Vt&&ze(new Vt)!=_e||me&&ze(me.resolve())!=Te||Se&&ze(new Se)!=Ce||N&&ze(new N)!=je)&&(ze=function(t){var e=m(t),s="[object Object]"==e?t.constructor:void 0,i=s?M(s):"";if(i)switch(i){case Ae:return Oe;case ke:return _e;case Fe:return Te;case Re:return Ce;case Ee:return je}return e});var xe=ze,Me=Object.prototype.hasOwnProperty;var Ie=l.Uint8Array;function Le(t){var e=new t.constructor(t.byteLength);return new Ie(e).set(new Ie(t)),e}var Pe=/\w*$/;var De=u?u.prototype:void 0,We=De?De.valueOf:void 0;function qe(t,e){var s=e?Le(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}var Ue="[object Boolean]",Be="[object Date]",Ne="[object Map]",$e="[object Number]",He="[object RegExp]",Ge="[object Set]",Je="[object String]",Ve="[object Symbol]",Xe="[object ArrayBuffer]",Ke="[object DataView]",Ze="[object Float32Array]",Qe="[object Float64Array]",Ye="[object Int8Array]",ts="[object Int16Array]",es="[object Int32Array]",ss="[object Uint8Array]",is="[object Uint8ClampedArray]",ns="[object Uint16Array]",rs="[object Uint32Array]";function os(t,e,s){var i,n,r,o=t.constructor;switch(e){case Xe:return Le(t);case Ue:case Be:return new o(+t);case Ke:return function(t,e){var s=e?Le(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}(t,s);case Ze:case Qe:case Ye:case ts:case es:case ss:case is:case ns:case rs:return qe(t,s);case Ne:return new o;case $e:case Je:return new o(t);case He:return(r=new(n=t).constructor(n.source,Pe.exec(n))).lastIndex=n.lastIndex,r;case Ge:return new o;case Ve:return i=t,We?Object(We.call(i)):{}}}function as(t){return"function"!=typeof t.constructor||ft(t)?{}:H(Qt(t))}var cs=Ft&&Ft.isMap,hs=cs?jt(cs):function(t){return S(t)&&"[object Map]"==xe(t)};var ls=Ft&&Ft.isSet,us=ls?jt(ls):function(t){return S(t)&&"[object Set]"==xe(t)},ds=1,ps=2,fs=4,vs="[object Arguments]",ys="[object Function]",gs="[object GeneratorFunction]",bs="[object Object]",ws={};function ms(t,e,s,i,n,r){var o,a=e&ds,c=e&ps,h=e&fs;if(s&&(o=n?s(t,i,n,r):s(t)),void 0!==o)return o;if(!T(t))return t;var l=_(t);if(l){if(o=function(t){var e=t.length,s=new t.constructor(e);return e&&"string"==typeof t[0]&&Me.call(t,"index")&&(s.index=t.index,s.input=t.input),s}(t),!a)return G(t,o)}else{var u=xe(t),d=u==ys||u==gs;if(Tt(t))return le(t,a);if(u==bs||u==vs||d&&!n){if(o=c||d?{}:as(t),!a)return c?function(t,e){return at(t,ve(t),e)}(t,function(t,e){return t&&at(e,qt(e),t)}(o,t)):function(t,e){return at(t,fe(t),e)}(t,function(t,e){return t&&at(e,Pt(e),t)}(o,t))}else{if(!ws[u])return n?t:{};o=os(t,u,a)}}r||(r=new re);var p=r.get(t);if(p)return p;r.set(t,o),us(t)?t.forEach((function(i){o.add(ms(i,e,s,i,t,r))})):hs(t)&&t.forEach((function(i,n){o.set(n,ms(i,e,s,n,t,r))}));var f=l?void 0:(h?c?be:ge:c?qt:Pt)(t);return function(t,e){for(var s=-1,i=null==t?0:t.length;++s<i&&!1!==e(t[s],s,t););}(f||t,(function(i,n){f&&(i=t[n=i]),ot(o,n,ms(i,e,s,n,t,r))})),o}ws[vs]=ws["[object Array]"]=ws["[object ArrayBuffer]"]=ws["[object DataView]"]=ws["[object Boolean]"]=ws["[object Date]"]=ws["[object Float32Array]"]=ws["[object Float64Array]"]=ws["[object Int8Array]"]=ws["[object Int16Array]"]=ws["[object Int32Array]"]=ws["[object Map]"]=ws["[object Number]"]=ws[bs]=ws["[object RegExp]"]=ws["[object Set]"]=ws["[object String]"]=ws["[object Symbol]"]=ws["[object Uint8Array]"]=ws["[object Uint8ClampedArray]"]=ws["[object Uint16Array]"]=ws["[object Uint32Array]"]=!0,ws["[object Error]"]=ws[ys]=ws["[object WeakMap]"]=!1;function Ss(t){return ms(t,5)}var _s,Ts=function(t,e,s){for(var i=-1,n=Object(t),r=s(t),o=r.length;o--;){var a=r[_s?o:++i];if(!1===e(n[a],a,n))break}return t};function Cs(t,e,s){(void 0!==s&&!nt(t[e],s)||void 0===s&&!(e in t))&&it(t,e,s)}function js(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Os(t,e,s,i,n,r,o){var a=js(t,s),c=js(e,s),h=o.get(c);if(h)Cs(t,s,h);else{var l,u=r?r(a,c,s+"",t,e,o):void 0,d=void 0===u;if(d){var p=_(c),f=!p&&Tt(c),v=!p&&!f&&Et(c);u=c,p||f||v?_(a)?u=a:S(l=a)&&dt(l)?u=G(a):f?(d=!1,u=le(c,!0)):v?(d=!1,u=qe(c,!0)):u=[]:function(t){if(!S(t)||m(t)!=Yt)return!1;var e=Qt(t);if(null===e)return!0;var s=ie.call(e,"constructor")&&e.constructor;return"function"==typeof s&&s instanceof s&&se.call(s)==ne}(c)||wt(c)?(u=a,wt(a)?u=function(t){return at(t,qt(t))}(a):T(a)&&!F(a)||(u=as(c))):d=!1}d&&(o.set(c,u),n(u,c,i,r,o),o.delete(c)),Cs(t,s,u)}}function As(t,e,s,i,n){t!==e&&Ts(e,(function(r,o){if(n||(n=new re),T(r))Os(t,e,o,s,As,i,n);else{var a=i?i(js(t,o),r,o+"",t,e,n):void 0;void 0===a&&(a=r),Cs(t,o,a)}}),qt)}var ks,Fs=(ks=function(t,e,s){As(t,e,s)},ht((function(t,e){var s=-1,i=e.length,n=i>1?e[i-1]:void 0,r=i>2?e[2]:void 0;for(n=ks.length>3&&"function"==typeof n?(i--,n):void 0,r&&function(t,e,s){if(!T(s))return!1;var i=typeof e;return!!("number"==i?dt(s)&&st(e,s.length):"string"==i&&e in s)&&nt(s[e],t)}(e[0],e[1],r)&&(n=i<3?void 0:n,i=1),t=Object(t);++s<i;){var o=e[s];o&&ks(t,o,s,n)}return t})));let Rs=null;try{Rs=localStorage.getItem("debug")||""}catch(t){"undefined"!=typeof window&&"undefined"!=typeof localStorage&&console.warn("Error checking window.debug")}const Es=t=>Rs&&new RegExp(Rs).test(t)?(...e)=>console.log(t,...e):()=>{};class zs extends Error{}class xs extends Error{}const Ms=Es("rpc:ClientManager");class Is{constructor(t){this.options=t,this.inflightCallsByKey={},this.interceptors={request:[],response:[]},this.addResponseInterceptor=t=>{if("function"!=typeof t)throw new Error("cannot add interceptor that is not a function");return this.interceptors.response.push(t),()=>{this.interceptors.response=this.interceptors.response.filter((e=>e!==t))}},this.addRequestInterceptor=t=>{if("function"!=typeof t)throw new Error("cannot add interceptor that is not a function");return this.interceptors.request.push(t),()=>{this.interceptors.request=this.interceptors.request.filter((e=>e!==t))}},this.clearCache=t=>{Ms("clearCache"),this.cache&&this.cache.clearCache(t)},this.getCachedResponse=t=>{var e;return Ms("getCachedResponse",t),null===(e=null==this?void 0:this.cache)||void 0===e?void 0:e.getCachedResponse(t)},this.getInFlightCallCount=()=>(Ms("getInFlightCallCount"),Object.keys(this.inflightCallsByKey).length),this.manageClientRequest=(t,s)=>e(this,void 0,void 0,(function*(){Ms("manageClientRequest",t);const i=yield this.interceptRequestMutator(t),n=a(i);if(this.inflightCallsByKey.hasOwnProperty(n))return Ms("manageClientRequest using an existing in-flight call",n),this.inflightCallsByKey[n].then((e=>{const s=Ss(e);return t.correlationId&&(s.correlationId=t.correlationId),s}));const r=(()=>e(this,void 0,void 0,(function*(){const t=yield this.sendRequestWithTransport(i,s),e=yield this.interceptResponseMutator(t,i);return this.cache&&e&&this.cache.setCachedResponse(i,e),e})))().finally((()=>{delete this.inflightCallsByKey[n]}));return this.inflightCallsByKey[n]=r,yield r})),this.setIdentity=t=>{Ms("setIdentity",t),this.transports.forEach((e=>e.setIdentity(t)))},this.interceptRequestMutator=t=>e(this,void 0,void 0,(function*(){var e,s,n,r;let o=t;if(this.interceptors.request.length){Ms("interceptRequestMutator(), original request:",t);try{for(var a,c=!0,h=i(this.interceptors.request);!(e=(a=yield h.next()).done);c=!0){r=a.value,c=!1;const t=r;o=yield t(o)}}catch(t){s={error:t}}finally{try{c||e||!(n=h.return)||(yield n.call(h))}finally{if(s)throw s.error}}}return o})),this.interceptResponseMutator=(t,s)=>e(this,void 0,void 0,(function*(){let e=t;if(this.interceptors.response.length){Ms("interceptResponseMutator",s,t);for(const i of this.interceptors.response)try{e=yield i(e,s)}catch(i){throw Ms("caught response interceptor, request:",s,"original response:",t,"mutated response:",e),i}}return e})),this.sendRequestWithTransport=(t,s)=>e(this,void 0,void 0,(function*(){var e,i;let n;Ms("sendRequestWithTransport",t);let o=0,a=this.transports;if(null==s?void 0:s.transport){const t=this.transports.find((t=>t.type===s.transport));if(!t)throw new r(`Specified Transport "${s.transport}" not available`);a=[t]}for(;!n&&a[o];){const r=a[o];if(r.isConnected()){Ms(`sendRequestWithTransport trying ${this.transports[o].name}`,t);try{let e;const i=r.sendRequest(t,s||{}),o=new Promise(((i,n)=>{e=setTimeout((()=>{n(new zs(`Procedure ${t.procedure}`))}),(null==s?void 0:s.timeout)||this.options.deadlineMs)}));n=yield Promise.race([o,i]).finally((()=>{clearTimeout(e)}))}catch(s){if(null===(i=(e=this.options).onTransportRequestError)||void 0===i||i.call(e,s,t),!(s instanceof zs||s instanceof xs))throw s;console.warn(`RPCClient ClientManager#sendRequestWithTransport() sending request with ${a[o].name} failed ${a[o+1]?`trying next transport "${a[o+1].name}"`:"no more transports to try"}`),o++}}else o++}if(!n&&!this.transports[o])throw console.error(`RPCClient ClientManager#sendRequestWithTransport() ${t.scope}::${t.procedure}::${t.version} did not get a response from any transports`),new r(`Procedure ${t.procedure} did not get a response from any transports`);if(!n)throw new r(`Procedure ${t.procedure} did not get a response from the remote`);return n})),this.cache=t.cache,t.requestInterceptor&&this.interceptors.request.push(t.requestInterceptor),t.responseInterceptor&&this.interceptors.response.push(t.responseInterceptor),this.transports=t.transports}}class Ls{constructor(t){this.cacheOptions=t}clearCache(){}getCachedResponse(t){}setCachedResponse(t,e){}}Ls.DEFAULT_CACHE_MAX_AGE_MS=3e5,Ls.DEFAULT_CACHE_MAX_SIZE=100;var Ps,Ds=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.LRUCache=void 0;const s="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,i=new Set,n="object"==typeof process&&process?process:{},r=(t,e,s,i)=>{"function"==typeof n.emitWarning?n.emitWarning(t,e,s,i):console.error(`[${s}] ${e}: ${t}`)};let o=globalThis.AbortController,a=globalThis.AbortSignal;if(void 0===o){a=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},o=class{constructor(){e()}signal=new a;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==n.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,r("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}const c=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),h=t=>c(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?l:null:null;class l extends Array{constructor(t){super(t),this.fill(0)}}class u{heap;length;static#t=!1;static create(t){const e=h(t);if(!e)return[];u.#t=!0;const s=new u(t,e);return u.#t=!1,s}constructor(t,e){if(!u.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class d{#e;#s;#i;#n;#r;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#a;#c;#h;#l;#u;#d;#p;#f;#v;#y;#g;#b;#w;#m;#S;#_;static unsafeExposeInternals(t){return{starts:t.#b,ttls:t.#w,sizes:t.#g,keyMap:t.#c,keyList:t.#h,valList:t.#l,next:t.#u,prev:t.#d,get head(){return t.#p},get tail(){return t.#f},free:t.#v,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,s,i,n)=>t.#C(e,s,i,n),moveToTail:e=>t.#j(e),indexes:e=>t.#O(e),rindexes:e=>t.#A(e),isStale:e=>t.#k(e)}}get max(){return this.#e}get maxSize(){return this.#s}get calculatedSize(){return this.#a}get size(){return this.#o}get fetchMethod(){return this.#r}get dispose(){return this.#i}get disposeAfter(){return this.#n}constructor(t){const{max:e=0,ttl:s,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:p,dispose:f,disposeAfter:v,noDisposeOnSet:y,noUpdateTTL:g,maxSize:b=0,maxEntrySize:w=0,sizeCalculation:m,fetchMethod:S,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:C,allowStaleOnFetchAbort:j,ignoreFetchAbort:O}=t;if(0!==e&&!c(e))throw new TypeError("max option must be a nonnegative integer");const A=e?h(e):Array;if(!A)throw new Error("invalid max value: "+e);if(this.#e=e,this.#s=b,this.maxEntrySize=w||this.#s,this.sizeCalculation=m,this.sizeCalculation){if(!this.#s&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==S&&"function"!=typeof S)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=S,this.#S=!!S,this.#c=new Map,this.#h=new Array(e).fill(void 0),this.#l=new Array(e).fill(void 0),this.#u=new A(e),this.#d=new A(e),this.#p=0,this.#f=0,this.#v=u.create(e),this.#o=0,this.#a=0,"function"==typeof f&&(this.#i=f),"function"==typeof v?(this.#n=v,this.#y=[]):(this.#n=void 0,this.#y=void 0),this.#m=!!this.#i,this.#_=!!this.#n,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!C,this.allowStaleOnFetchAbort=!!j,this.ignoreFetchAbort=!!O,0!==this.maxEntrySize){if(0!==this.#s&&!c(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!c(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#F()}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=c(n)||0===n?n:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!c(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#R()}if(0===this.#e&&0===this.ttl&&0===this.#s)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#s){const t="LRU_CACHE_UNBOUNDED";if((t=>!i.has(t))(t)){i.add(t);r("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,d)}}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#R(){const t=new l(this.#e),e=new l(this.#e);this.#w=t,this.#b=e,this.#E=(i,n,r=s.now())=>{if(e[i]=0!==n?r:0,t[i]=n,0!==n&&this.ttlAutopurge){const t=setTimeout((()=>{this.#k(i)&&this.delete(this.#h[i])}),n+1);t.unref&&t.unref()}},this.#z=i=>{e[i]=0!==t[i]?s.now():0},this.#x=(s,r)=>{if(t[r]){const o=t[r],a=e[r];if(!o||!a)return;s.ttl=o,s.start=a,s.now=i||n();const c=s.now-a;s.remainingTTL=o-c}};let i=0;const n=()=>{const t=s.now();if(this.ttlResolution>0){i=t;const e=setTimeout((()=>i=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=s=>{const r=this.#c.get(s);if(void 0===r)return 0;const o=t[r],a=e[r];if(!o||!a)return 1/0;return o-((i||n())-a)},this.#k=s=>{const r=e[s],o=t[s];return!!o&&!!r&&(i||n())-r>o}}#z=()=>{};#x=()=>{};#E=()=>{};#k=()=>!1;#F(){const t=new l(this.#e);this.#a=0,this.#g=t,this.#M=e=>{this.#a-=t[e],t[e]=0},this.#I=(t,e,s,i)=>{if(this.#T(e))return 0;if(!c(s)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(s=i(e,t),!c(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return s},this.#L=(e,s,i)=>{if(t[e]=s,this.#s){const s=this.#s-t[e];for(;this.#a>s;)this.#P(!0)}this.#a+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#a)}}#M=t=>{};#L=(t,e,s)=>{};#I=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#f;this.#D(e)&&(!t&&this.#k(e)||(yield e),e!==this.#p);)e=this.#d[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#p;this.#D(e)&&(!t&&this.#k(e)||(yield e),e!==this.#f);)e=this.#u[e]}#D(t){return void 0!==t&&this.#c.get(this.#h[t])===t}*entries(){for(const t of this.#O())void 0===this.#l[t]||void 0===this.#h[t]||this.#T(this.#l[t])||(yield[this.#h[t],this.#l[t]])}*rentries(){for(const t of this.#A())void 0===this.#l[t]||void 0===this.#h[t]||this.#T(this.#l[t])||(yield[this.#h[t],this.#l[t]])}*keys(){for(const t of this.#O()){const e=this.#h[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#h[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*values(){for(const t of this.#O()){void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}}*rvalues(){for(const t of this.#A()){void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const s of this.#O()){const i=this.#l[s],n=this.#T(i)?i.__staleWhileFetching:i;if(void 0!==n&&t(n,this.#h[s],this))return this.get(this.#h[s],e)}}forEach(t,e=this){for(const s of this.#O()){const i=this.#l[s],n=this.#T(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#h[s],this)}}rforEach(t,e=this){for(const s of this.#A()){const i=this.#l[s],n=this.#T(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#h[s],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#k(e)&&(this.delete(this.#h[e]),t=!0);return t}info(t){const e=this.#c.get(t);if(void 0===e)return;const i=this.#l[e],n=this.#T(i)?i.__staleWhileFetching:i;if(void 0===n)return;const r={value:n};if(this.#w&&this.#b){const t=this.#w[e],i=this.#b[e];if(t&&i){const e=t-(s.now()-i);r.ttl=e,r.start=Date.now()}}return this.#g&&(r.size=this.#g[e]),r}dump(){const t=[];for(const e of this.#O({allowStale:!0})){const i=this.#h[e],n=this.#l[e],r=this.#T(n)?n.__staleWhileFetching:n;if(void 0===r||void 0===i)continue;const o={value:r};if(this.#w&&this.#b){o.ttl=this.#w[e];const t=s.now()-this.#b[e];o.start=Math.floor(Date.now()-t)}this.#g&&(o.size=this.#g[e]),t.unshift([i,o])}return t}load(t){this.clear();for(const[e,i]of t){if(i.start){const t=Date.now()-i.start;i.start=s.now()-t}this.set(e,i.value,i)}}set(t,e,s={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=s;let{noUpdateTTL:c=this.noUpdateTTL}=s;const h=this.#I(t,e,s.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let l=0===this.#o?void 0:this.#c.get(t);if(void 0===l)l=0===this.#o?this.#f:0!==this.#v.length?this.#v.pop():this.#o===this.#e?this.#P(!1):this.#o,this.#h[l]=t,this.#l[l]=e,this.#c.set(t,l),this.#u[this.#f]=l,this.#d[l]=this.#f,this.#f=l,this.#o++,this.#L(l,h,a),a&&(a.set="add"),c=!1;else{this.#j(l);const s=this.#l[l];if(e!==s){if(this.#S&&this.#T(s)){s.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=s;void 0===e||r||(this.#m&&this.#i?.(e,t,"set"),this.#_&&this.#y?.push([e,t,"set"]))}else r||(this.#m&&this.#i?.(s,t,"set"),this.#_&&this.#y?.push([s,t,"set"]));if(this.#M(l),this.#L(l,h,a),this.#l[l]=e,a){a.set="replace";const t=s&&this.#T(s)?s.__staleWhileFetching:s;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#w||this.#R(),this.#w&&(c||this.#E(l,i,n),a&&this.#x(a,l)),!r&&this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return this}pop(){try{for(;this.#o;){const t=this.#l[this.#p];if(this.#P(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}#P(t){const e=this.#p,s=this.#h[e],i=this.#l[e];return this.#S&&this.#T(i)?i.__abortController.abort(new Error("evicted")):(this.#m||this.#_)&&(this.#m&&this.#i?.(i,s,"evict"),this.#_&&this.#y?.push([i,s,"evict"])),this.#M(e),t&&(this.#h[e]=void 0,this.#l[e]=void 0,this.#v.push(e)),1===this.#o?(this.#p=this.#f=0,this.#v.length=0):this.#p=this.#u[e],this.#c.delete(s),this.#o--,e}has(t,e={}){const{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,n=this.#c.get(t);if(void 0!==n){const t=this.#l[n];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#k(n))return s&&this.#z(n),i&&(i.has="hit",this.#x(i,n)),!0;i&&(i.has="stale",this.#x(i,n))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:s=this.allowStale}=e,i=this.#c.get(t);if(void 0===i||!s&&this.#k(i))return;const n=this.#l[i];return this.#T(n)?n.__staleWhileFetching:n}#C(t,e,s,i){const n=void 0===e?void 0:this.#l[e];if(this.#T(n))return n;const r=new o,{signal:a}=s;a?.addEventListener("abort",(()=>r.abort(a.reason)),{signal:r.signal});const c={signal:r.signal,options:s,context:i},h=(i,n=!1)=>{const{aborted:o}=r.signal,a=s.ignoreFetchAbort&&void 0!==i;if(s.status&&(o&&!n?(s.status.fetchAborted=!0,s.status.fetchError=r.signal.reason,a&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),o&&!a&&!n)return l(r.signal.reason);const h=u;return this.#l[e]===u&&(void 0===i?h.__staleWhileFetching?this.#l[e]=h.__staleWhileFetching:this.delete(t):(s.status&&(s.status.fetchUpdated=!0),this.set(t,i,c.options))),i},l=i=>{const{aborted:n}=r.signal,o=n&&s.allowStaleOnFetchAbort,a=o||s.allowStaleOnFetchRejection,c=a||s.noDeleteOnFetchRejection,h=u;if(this.#l[e]===u){!c||void 0===h.__staleWhileFetching?this.delete(t):o||(this.#l[e]=h.__staleWhileFetching)}if(a)return s.status&&void 0!==h.__staleWhileFetching&&(s.status.returnedStale=!0),h.__staleWhileFetching;if(h.__returned===h)throw i};s.status&&(s.status.fetchDispatched=!0);const u=new Promise(((e,i)=>{const o=this.#r?.(t,n,c);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),i),r.signal.addEventListener("abort",(()=>{s.ignoreFetchAbort&&!s.allowStaleOnFetchAbort||(e(void 0),s.allowStaleOnFetchAbort&&(e=t=>h(t,!0)))}))})).then(h,(t=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=t),l(t)))),d=Object.assign(u,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return void 0===e?(this.set(t,d,{...c.options,status:void 0}),e=this.#c.get(t)):this.#l[e]=d,d}#T(t){if(!this.#S)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof o}async fetch(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:f,forceRefresh:v=!1,status:y,signal:g}=e;if(!this.#S)return y&&(y.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:n,status:y});const b={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:y,signal:g};let w=this.#c.get(t);if(void 0===w){y&&(y.fetch="miss");const e=this.#C(t,w,b,f);return e.__returned=e}{const e=this.#l[w];if(this.#T(e)){const t=s&&void 0!==e.__staleWhileFetching;return y&&(y.fetch="inflight",t&&(y.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const n=this.#k(w);if(!v&&!n)return y&&(y.fetch="hit"),this.#j(w),i&&this.#z(w),y&&this.#x(y,w),e;const r=this.#C(t,w,b,f),o=void 0!==r.__staleWhileFetching&&s;return y&&(y.fetch=n?"stale":"refresh",o&&n&&(y.returnedStale=!0)),o?r.__staleWhileFetching:r.__returned=r}}get(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=e,o=this.#c.get(t);if(void 0!==o){const e=this.#l[o],a=this.#T(e);return r&&this.#x(r,o),this.#k(o)?(r&&(r.get="stale"),a?(r&&s&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),s?e.__staleWhileFetching:void 0):(n||this.delete(t),r&&s&&(r.returnedStale=!0),s?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#j(o),i&&this.#z(o),e))}r&&(r.get="miss")}#W(t,e){this.#d[e]=t,this.#u[t]=e}#j(t){t!==this.#f&&(t===this.#p?this.#p=this.#u[t]:this.#W(this.#d[t],this.#u[t]),this.#W(this.#f,t),this.#f=t)}delete(t){let e=!1;if(0!==this.#o){const s=this.#c.get(t);if(void 0!==s)if(e=!0,1===this.#o)this.clear();else{this.#M(s);const e=this.#l[s];if(this.#T(e)?e.__abortController.abort(new Error("deleted")):(this.#m||this.#_)&&(this.#m&&this.#i?.(e,t,"delete"),this.#_&&this.#y?.push([e,t,"delete"])),this.#c.delete(t),this.#h[s]=void 0,this.#l[s]=void 0,s===this.#f)this.#f=this.#d[s];else if(s===this.#p)this.#p=this.#u[s];else{const t=this.#d[s];this.#u[t]=this.#u[s];const e=this.#u[s];this.#d[e]=this.#d[s]}this.#o--,this.#v.push(s)}}if(this.#_&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return e}clear(){for(const t of this.#A({allowStale:!0})){const e=this.#l[t];if(this.#T(e))e.__abortController.abort(new Error("deleted"));else{const s=this.#h[t];this.#m&&this.#i?.(e,s,"delete"),this.#_&&this.#y?.push([e,s,"delete"])}}if(this.#c.clear(),this.#l.fill(void 0),this.#h.fill(void 0),this.#w&&this.#b&&(this.#w.fill(0),this.#b.fill(0)),this.#g&&this.#g.fill(0),this.#p=0,this.#f=0,this.#v.length=0,this.#a=0,this.#o=0,this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}e.LRUCache=d}));(Ps=Ds)&&Ps.__esModule&&Object.prototype.hasOwnProperty.call(Ps,"default")&&Ps.default;var Ws=Ds.LRUCache;const qs=Es("rpc:InMemoryCache");class Us{constructor(t){this.clearCache=t=>{var e,s;qs("clearCache"),t?null===(e=this.cachedResponseByParams)||void 0===e||e.delete(a(t)):null===(s=this.cachedResponseByParams)||void 0===s||s.clear()},this.getCachedResponse=t=>{var e;qs("getCachedResponse, key: ",t);let s=null===(e=this.cachedResponseByParams)||void 0===e?void 0:e.get(a(t));return"string"==typeof s&&(s=JSON.parse(s)),s},this.setCachedResponse=(t,e)=>{var s,i;qs("setCachedResponse",t,e);const n=a(t);if(!e)return null===(s=this.cachedResponseByParams)||void 0===s?void 0:s.delete(n);const r=Object.assign({},e);delete r.correlationId,null===(i=this.cachedResponseByParams)||void 0===i||i.set(n,r?JSON.stringify(r):void 0)},this.cachedResponseByParams=new Ws({max:(null==t?void 0:t.cacheMaxSize)||Us.DEFAULT_CACHE_MAX_SIZE,ttl:(null==t?void 0:t.cacheMaxAgeMs)||Us.DEFAULT_CACHE_MAX_AGE_MS})}}var Bs;Us.DEFAULT_CACHE_MAX_AGE_MS=9e5,Us.DEFAULT_CACHE_MAX_SIZE=200,function(t){t.http="http",t.websocket="websocket"}(Bs||(Bs={}));class Ns{constructor(t){const{code:e,correlationId:s,data:i,message:n,success:r}=t;if("number"!=typeof e)throw new Error("code must be a number");if(this.code=e,s&&"string"!=typeof s)throw new Error("correlationId must be a string");if(this.correlationId=s,this.data=i,n&&"string"!=typeof n)throw new Error("message must be a string");if(this.message=n,"boolean"!=typeof r)throw new Error("success must be a boolean");this.success=r}}const $s=t=>`${t.scope}::${t.procedure}::${t.version}`,Hs=t=>{const e=t.split("::");return{procedure:e[1],scope:e[0]||"global",version:e[2]||"1"}},Gs=Es("rpc:HTTPTransport");class Js{constructor(t){this.options=t,this.networkIsConnected=!1,this.name="HttpTransport",this.type=Bs.http,this.isConnected=()=>{var t;return"undefined"!=typeof window?!!(null===(t=null===window||void 0===window?void 0:window.navigator)||void 0===t?void 0:t.onLine):this.networkIsConnected},this.sendRequest=(t,s)=>e(this,void 0,void 0,(function*(){Gs("sendRequest",t);try{const e=JSON.stringify(Object.assign({identity:this.identity},t)),s=yield null===window||void 0===window?void 0:window.fetch(this.host,{body:e,cache:"default",credentials:"omit",headers:{"Content-Type":"application/json"},method:"POST",mode:"cors",redirect:"follow",referrerPolicy:"origin"}),i=yield s.text();if(!i)throw new Error("No response received from remote");const n=JSON.parse(i);return new Ns(n)}catch(e){throw Gs("sendRequest() error",e),new xs(`HTTPTransport request error ${$s(t)}`)}})),this.setIdentity=t=>{Gs("setIdentity",t),this.identity=t},this.host=t.host}}class Vs{constructor(t,s){this.reject=t=>{this.rejectPromise&&this.rejectPromise(t)},this.resolve=t=>{this.resolvePromise&&this.resolvePromise(t)},this.promise=new Promise(((i,n)=>e(this,void 0,void 0,(function*(){const e=setTimeout((()=>{n(new Error(`PromiseWraper timeout: ${t}`))}),s||3e4);this.rejectPromise=t=>{clearTimeout(e),n(t)},this.resolvePromise=t=>{clearTimeout(e),i(t)}}))))}}const Xs=t=>new Promise((e=>setTimeout(e,t))),Ks=Es("rpc:WebSocketTransport");class Zs{constructor(t){this.options=t,this.connectedToRemote=!1,this.isWaitingForIdentityConfirmation=!1,this.pendingPromisesForResponse={},this.serverMessageHandlers=[],this.websocketId=void 0,this.name="WebSocketTransport",this.type=Bs.http,this.isConnected=()=>this.connectedToRemote&&!!this.websocket,this.connect=()=>{this._connect()},this.disconnect=()=>{this._disconnect("public disconnect() called")},this.sendClientMessageToServer=t=>{var e;let s=t;try{s=JSON.stringify({clientMessage:t})}catch(e){console.warn('WebSocketTransport.sendClientMessage() unable to stringify "msg"',t)}null===(e=this.websocket)||void 0===e||e.send(s)},this.sendRequest=(t,s)=>e(this,void 0,void 0,(function*(){for(Ks("sendRequest",t);this.isWaitingForIdentityConfirmation;)Ks("waiting for identity confirmation"),yield Xs(100);return this.sendCall(t,s)})),this.setIdentity=t=>e(this,void 0,void 0,(function*(){if(Ks("setIdentity",t),!t)return this.identity=void 0,void(yield this.resetConnection());this.identity=t,this.connectedToRemote?this.isWaitingForIdentityConfirmation?Ks('setIdentity returning early because "this.isWaitingForIdentityConfirmation=true"'):(this.isWaitingForIdentityConfirmation=!0,this.sendCall({identity:t},{}).then((()=>{Ks("setIdentity with remote complete")})).catch((t=>{Ks("setIdentity with remote error",t)})).finally((()=>{this.isWaitingForIdentityConfirmation=!1}))):Ks("setIdentity is not connected to remote")})),this.subscribeToServerMessages=t=>(this.serverMessageHandlers.push(t),()=>{this.serverMessageHandlers=this.serverMessageHandlers.filter((e=>e!==t))}),this.unsubscribeFromServerMessages=t=>{this.serverMessageHandlers=this.serverMessageHandlers.filter((e=>e!==t))},this._connect=()=>{if(Ks("connect",this.host),this.websocket)return void Ks("connect() returning early, websocket already exists");this.websocketId=Math.random(),this.websocket=new WebSocket(this.host);const t=this.websocket;t.onopen=()=>{console.info(`[${(new Date).toLocaleTimeString()}] WebSocket connected`),this.setConnectedToRemote(!0)},t.onmessage=t=>{this.handleWebSocketMsg(t)},t.onclose=t=>{this.connectedToRemote?console.info(`[${(new Date).toLocaleTimeString()}] WebSocket closed`,t.reason):Ks("WebSocket closed, it was not connected to the remote"),this.setConnectedToRemote(!1),this.isWaitingForIdentityConfirmation=!1,this.websocket=void 0,this.websocketId=void 0,Object.entries(this.pendingPromisesForResponse).forEach((([t,e])=>{e.reject(new xs("Websocket disconnected"))})),t.wasClean||setTimeout((()=>{this.connect()}),1e3)},t.onerror=e=>{this.connectedToRemote?console.error("WebSocket encountered error: ",e):Ks("WebSocket errored, it was not connected to the remote"),t.close()}},this._disconnect=t=>{var e;Ks("_disconnect"),this.setConnectedToRemote(!1),this.isWaitingForIdentityConfirmation=!1,null===(e=this.websocket)||void 0===e||e.close(1e3,t),this.websocket=void 0,this.websocketId=void 0},this.handleServerMessage=t=>{this.serverMessageHandlers.forEach((e=>{try{e(t.serverMessage)}catch(s){console.warn("WebSocketTransport.handleServerMessage() a serverMessageHandler errored when calling",t,"handler func:",e),console.error(s)}}))},this.handleWebSocketMsg=t=>{let e;Ks("handleWebSocketMsg",t);try{e=JSON.parse(t.data)}catch(t){console.error("error parsing WS msg",t)}if("serverMessage"in e)return void this.handleServerMessage(e);const s=new Ns(e);if(!s.correlationId)return void console.error("RPCClient WebSocketTransport received unexpected msg from the server, not correlationId found in response.",e);const i=this.pendingPromisesForResponse[s.correlationId];i?i.resolve(s):console.warn("rcvd WS msg/response that doesn't match any pending RPC's",e)},this.resetConnection=()=>e(this,void 0,void 0,(function*(){Ks("resetConnection"),this._disconnect("WebSocketTransport#resetConnection"),yield Xs(100),this._connect()})),this.sendCall=(t,s)=>e(this,void 0,void 0,(function*(){var e;Ks("sendCall",t);const i=Math.random().toString();t.correlationId=t.correlationId||i;let n=new Vs($s(t),s.timeout||this.options.rpcOptions.deadlineMs);return null===(e=this.websocket)||void 0===e||e.send(JSON.stringify(t)),this.pendingPromisesForResponse[t.correlationId]=n,yield n.promise.finally((()=>{delete this.pendingPromisesForResponse[t.correlationId]}))})),this.setConnectedToRemote=t=>{Ks(`setConnectedToRemote: ${t}`),this.connectedToRemote=t,this.options.onConnectionStatusChange&&this.options.onConnectionStatusChange(t),t&&this.identity&&this.setIdentity(this.identity)},Ks("new WebSocketTransport()"),this.host=t.host,this.connect()}}class Qs{constructor(){this.events={},this.publish=(t,s)=>e(this,void 0,void 0,(function*(){const e=this.events[t];e&&e.forEach((function(t){t.call(t,s)}))})),this.subscribe=(t,e)=>(this.events[t]||(this.events[t]=[]),this.events[t].push(e),()=>this.unsubscribe(t,e)),this.unsubscribe=(t,e)=>{if(!this.events[t])return;let s=this.events[t].indexOf(e);this.events[t].splice(s)}}}const Ys={HTTP_HOST_OR_TRANSPORT_REQUIRED:"http host or tansport is required",INTERCEPTOR_MUSTBE_FUNC:"interceptors must be a function"};class ti{constructor(t){var s,i,r,o,c,h;if(this.options=t,this.webSocketConnectionChangeListeners=[],this.vent=new Qs,this.onWebSocketConnectionStatusChange=t=>{this.options.onWebSocketConnectionStatusChange&&this.options.onWebSocketConnectionStatusChange(t),this.webSocketConnectionChangeListeners.forEach((e=>e(t)))},this.call=(t,s,i)=>e(this,void 0,void 0,(function*(){if(!t)throw new Error('RPCClient.call(request) requires a "request" param');let e;e="string"==typeof t?Hs(t):t,s&&(e.args=s);const r=new n(e);if(!r.procedure&&!r.identity)throw new TypeError('RPCClient#call requires a "identity" or "procedure" prop and received neither');r.identity||(r.identity={}),r.identity=Fs(Object.assign({},this.identity),r.identity);const o=yield this.callManager.manageClientRequest(r,i);if(!o.success)throw o;const c=a(e);return this.vent.publish(c,null==o?void 0:o.data),o})),this.clearCache=t=>{this.callManager.clearCache(t)},this.getCallCache=(t,e)=>{let s;s="string"==typeof t?Hs(t):t,e&&(s.args=e);const i=this.callManager.getCachedResponse(s);if(i)return i},this.getIdentity=()=>this.identity?Ss(this.identity):this.identity,this.getInFlightCallCount=()=>this.callManager.getInFlightCallCount(),this.getWebSocketConnected=()=>{var t;return!!(null===(t=null==this?void 0:this.webSocketTransport)||void 0===t?void 0:t.isConnected())},this.makeProcedure=t=>{const e=this;let s;return s="string"==typeof t?Hs(t):t,function(t){return e.call(Object.assign(Object.assign({},s),{args:t}))}},this.registerResponseInterceptor=t=>this.callManager.addResponseInterceptor(t),this.registerRequestInterceptor=t=>this.callManager.addRequestInterceptor(t),this.registerWebSocketConnectionStatusChangeListener=t=>(this.webSocketConnectionChangeListeners.push(t),()=>{this.webSocketConnectionChangeListeners=this.webSocketConnectionChangeListeners.filter((e=>e!==t))}),this.sendClientMessageToServer=t=>{this.webSocketTransport?this.webSocketTransport.isConnected()?this.webSocketTransport.sendClientMessageToServer(t):console.info("RPCClient.sendClientMessageToServer() cannot send because the websocket is not connected"):console.warn("RPCClient.sendClientMessageToServer() unable to send because RPCClient has no websocket configuration")},this.setIdentity=t=>{let e=Ss(t);this.identity=t,this.callManager.setIdentity(e)},this.setIdentityMetadata=t=>{var e;null!==(e=this.identity)&&void 0!==e||(this.identity={});const s=Ss(this.identity);s.metadata=t,this.identity.metadata=t,this.callManager.setIdentity(s)},this.transports=()=>({http:this.httpTransport,websocket:this.webSocketTransport}),!(null===(s=null==t?void 0:t.hosts)||void 0===s?void 0:s.http)&&!(null===(i=null==t?void 0:t.transports)||void 0===i?void 0:i.http))throw new Error(Ys.HTTP_HOST_OR_TRANSPORT_REQUIRED);if(t.requestInterceptor&&"function"!=typeof t.requestInterceptor)throw new Error(Ys.INTERCEPTOR_MUSTBE_FUNC);if(t.responseInterceptor&&"function"!=typeof t.responseInterceptor)throw new Error(Ys.INTERCEPTOR_MUSTBE_FUNC);let l;const u={cacheMaxAgeMs:null==t?void 0:t.cacheMaxAgeMs};l="browser"==t.cacheType?new Ls(u):new Us(u);const d=[];(null===(r=t.transports)||void 0===r?void 0:r.websocket)?d.push(t.transports.websocket):(null===(o=null==t?void 0:t.hosts)||void 0===o?void 0:o.websocket)&&(this.webSocketTransport=new Zs({host:t.hosts.websocket,onConnectionStatusChange:this.onWebSocketConnectionStatusChange,rpcOptions:t}),d.push(this.webSocketTransport)),(null===(c=t.transports)||void 0===c?void 0:c.http)?d.push(t.transports.http):(null===(h=null==t?void 0:t.hosts)||void 0===h?void 0:h.http)&&(this.httpTransport=new Js({host:t.hosts.http,rpcOptions:t}),d.push(this.httpTransport)),this.callManager=new Is({cache:l,deadlineMs:t.deadlineMs||ti.DEFAULT_DEADLINE_MS,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,transports:d})}subscribe(t,e){const s="string"==typeof t.request?Hs(t.request):t.request,i=a(Object.assign(Object.assign({},s),{args:t.args}));return this.vent.subscribe(i,e)}unsubscribe(t,e){const s="string"==typeof t.request?Hs(t.request):t.request,i=a(Object.assign(Object.assign({},s),{args:t.args}));this.vent.unsubscribe(i,e)}subscribeToServerMessages(t){return this.webSocketTransport?this.webSocketTransport.subscribeToServerMessages(t):(console.warn("RPCClient.subscribeToServerMessages() cannot subscribe because RPCClient has no websocket configuration"),()=>{})}unsubscribeFromServerMessages(t){var e;null===(e=this.webSocketTransport)||void 0===e||e.unsubscribeFromServerMessages(t)}}ti.DEFAULT_DEADLINE_MS=1e4,t.CallRequestTransportError=xs,t.CallRequestTransportTimeoutError=zs,t.RPCClient=ti,t.RPCResponse=Ns})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RPCClient={})}(this,(function(t){"use strict";function e(t,e,s,i){return new(s||(s=Promise))((function(n,r){function o(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,s=e&&t[e],i=0;if(s)return s.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,i=t[Symbol.asyncIterator];return i?i.call(t):(t=s(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=t[s]&&function(e){return new Promise((function(i,n){(function(t,e,s,i){Promise.resolve(i).then((function(e){t({value:e,done:s})}),e)})(i,n,(e=t[s](e)).done,e.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(t){const{args:e,correlationId:s,identity:i,procedure:n,scope:r,version:o}=t;if(this.args=e,s&&"string"!=typeof s)throw new Error("correlationId must be a string");if(this.correlationId=s||Math.random().toString(),i){if("object"!=typeof i)throw new Error("identity must be an object");if(i.authorization&&"string"!=typeof i.authorization)throw new Error("identity.authorization must be a string");if(i.deviceName&&"string"!=typeof i.deviceName)throw new Error("identity.deviceName must be a string");if(i.metadata&&"object"!=typeof i.metadata)throw new Error("identity.metadata must be a object");this.identity=i}if(n&&"string"!=typeof n)throw new Error("procedure must be string");if(this.procedure=n,r&&"string"!=typeof r)throw new Error("scope must be string");if(this.scope=r,o&&"string"!=typeof o)throw new Error("version must be string");this.version=o}}class r extends Error{}function o(t){if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}const a=t=>t.args?`${t.scope}${t.procedure}${t.version}${function(t,e){e||(e={}),"function"==typeof e&&(e={cmp:e});var s,i="boolean"==typeof e.cycles&&e.cycles,n=e.cmp&&(s=e.cmp,function(t){return function(e,i){var n={key:e,value:t[e]},r={key:i,value:t[i]};return s(n,r)}}),r=[];return function t(e){if(e&&e.toJSON&&"function"==typeof e.toJSON&&(e=e.toJSON()),void 0!==e){if("number"==typeof e)return isFinite(e)?""+e:"null";if("object"!=typeof e)return JSON.stringify(e);var s,o;if(Array.isArray(e)){for(o="[",s=0;s<e.length;s++)s&&(o+=","),o+=t(e[s])||"null";return o+"]"}if(null===e)return"null";if(-1!==r.indexOf(e)){if(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=r.push(e)-1,c=Object.keys(e).sort(n&&n(e));for(o="",s=0;s<c.length;s++){var h=c[s],l=t(e[h]);l&&(o&&(o+=","),o+=JSON.stringify(h)+":"+l)}return r.splice(a,1),"{"+o+"}"}}(t)}(function(t,e={}){if(!o(t)&&!Array.isArray(t))throw new TypeError("Expected a plain object or array");const{deep:s,compare:i}=e,n=[],r=[],a=t=>{const e=n.indexOf(t);if(-1!==e)return r[e];const s=[];return n.push(t),r.push(s),s.push(...t.map((t=>Array.isArray(t)?a(t):o(t)?c(t):t))),s},c=t=>{const e=n.indexOf(t);if(-1!==e)return r[e];const h={},l=Object.keys(t).sort(i);n.push(t),r.push(h);for(const e of l){const i=t[e];let n;n=s&&Array.isArray(i)?a(i):s&&o(i)?c(i):i,Object.defineProperty(h,e,Object.assign(Object.assign({},Object.getOwnPropertyDescriptor(t,e)),{value:n}))}return h};return Array.isArray(t)?s?a(t):t.slice():c(t)}(t.args||{},{deep:!0}))}`:`${t.scope}${t.procedure}${t.version}`;var c="object"==typeof global&&global&&global.Object===Object&&global,h="object"==typeof self&&self&&self.Object===Object&&self,l=c||h||Function("return this")(),u=l.Symbol,d=Object.prototype,p=d.hasOwnProperty,f=d.toString,v=u?u.toStringTag:void 0;var y=Object.prototype.toString;var g="[object Null]",b="[object Undefined]",w=u?u.toStringTag:void 0;function m(t){return null==t?void 0===t?b:g:w&&w in Object(t)?function(t){var e=p.call(t,v),s=t[v];try{t[v]=void 0;var i=!0}catch(t){}var n=f.call(t);return i&&(e?t[v]=s:delete t[v]),n}(t):function(t){return y.call(t)}(t)}function S(t){return null!=t&&"object"==typeof t}var _=Array.isArray;function T(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function C(t){return t}var j="[object AsyncFunction]",O="[object Function]",A="[object GeneratorFunction]",k="[object Proxy]";function F(t){if(!T(t))return!1;var e=m(t);return e==O||e==A||e==j||e==k}var R,E=l["__core-js_shared__"],z=(R=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+R:"";var x=Function.prototype.toString;function M(t){if(null!=t){try{return x.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var I=/^\[object .+?Constructor\]$/,L=Function.prototype,P=Object.prototype,D=L.toString,W=P.hasOwnProperty,q=RegExp("^"+D.call(W).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function U(t){return!(!T(t)||(e=t,z&&z in e))&&(F(t)?q:I).test(M(t));var e}function B(t,e){var s=function(t,e){return null==t?void 0:t[e]}(t,e);return U(s)?s:void 0}var N=B(l,"WeakMap"),$=Object.create,H=function(){function t(){}return function(e){if(!T(e))return{};if($)return $(e);t.prototype=e;var s=new t;return t.prototype=void 0,s}}();function G(t,e){var s=-1,i=t.length;for(e||(e=Array(i));++s<i;)e[s]=t[s];return e}var J=Date.now;var V,X,K,Z=function(){try{var t=B(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Q=Z?function(t,e){return Z(t,"toString",{configurable:!0,enumerable:!1,value:(s=e,function(){return s}),writable:!0});var s}:C,Y=(V=Q,X=0,K=0,function(){var t=J(),e=16-(t-K);if(K=t,e>0){if(++X>=800)return arguments[0]}else X=0;return V.apply(void 0,arguments)});var tt=9007199254740991,et=/^(?:0|[1-9]\d*)$/;function st(t,e){var s=typeof t;return!!(e=null==e?tt:e)&&("number"==s||"symbol"!=s&&et.test(t))&&t>-1&&t%1==0&&t<e}function it(t,e,s){"__proto__"==e&&Z?Z(t,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[e]=s}function nt(t,e){return t===e||t!=t&&e!=e}var rt=Object.prototype.hasOwnProperty;function ot(t,e,s){var i=t[e];rt.call(t,e)&&nt(i,s)&&(void 0!==s||e in t)||it(t,e,s)}function at(t,e,s,i){var n=!s;s||(s={});for(var r=-1,o=e.length;++r<o;){var a=e[r],c=i?i(s[a],t[a],a,s,t):void 0;void 0===c&&(c=t[a]),n?it(s,a,c):ot(s,a,c)}return s}var ct=Math.max;function ht(t,e){return Y(function(t,e,s){return e=ct(void 0===e?t.length-1:e,0),function(){for(var i=arguments,n=-1,r=ct(i.length-e,0),o=Array(r);++n<r;)o[n]=i[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=i[n];return a[e]=s(o),function(t,e,s){switch(s.length){case 0:return t.call(e);case 1:return t.call(e,s[0]);case 2:return t.call(e,s[0],s[1]);case 3:return t.call(e,s[0],s[1],s[2])}return t.apply(e,s)}(t,this,a)}}(t,e,C),t+"")}var lt=9007199254740991;function ut(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=lt}function dt(t){return null!=t&&ut(t.length)&&!F(t)}var pt=Object.prototype;function ft(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||pt)}function vt(t){return S(t)&&"[object Arguments]"==m(t)}var yt=Object.prototype,gt=yt.hasOwnProperty,bt=yt.propertyIsEnumerable,wt=vt(function(){return arguments}())?vt:function(t){return S(t)&>.call(t,"callee")&&!bt.call(t,"callee")};var mt="object"==typeof t&&t&&!t.nodeType&&t,St=mt&&"object"==typeof module&&module&&!module.nodeType&&module,_t=St&&St.exports===mt?l.Buffer:void 0,Tt=(_t?_t.isBuffer:void 0)||function(){return!1},Ct={};function jt(t){return function(e){return t(e)}}Ct["[object Float32Array]"]=Ct["[object Float64Array]"]=Ct["[object Int8Array]"]=Ct["[object Int16Array]"]=Ct["[object Int32Array]"]=Ct["[object Uint8Array]"]=Ct["[object Uint8ClampedArray]"]=Ct["[object Uint16Array]"]=Ct["[object Uint32Array]"]=!0,Ct["[object Arguments]"]=Ct["[object Array]"]=Ct["[object ArrayBuffer]"]=Ct["[object Boolean]"]=Ct["[object DataView]"]=Ct["[object Date]"]=Ct["[object Error]"]=Ct["[object Function]"]=Ct["[object Map]"]=Ct["[object Number]"]=Ct["[object Object]"]=Ct["[object RegExp]"]=Ct["[object Set]"]=Ct["[object String]"]=Ct["[object WeakMap]"]=!1;var Ot="object"==typeof t&&t&&!t.nodeType&&t,At=Ot&&"object"==typeof module&&module&&!module.nodeType&&module,kt=At&&At.exports===Ot&&c.process,Ft=function(){try{var t=At&&At.require&&At.require("util").types;return t||kt&&kt.binding&&kt.binding("util")}catch(t){}}(),Rt=Ft&&Ft.isTypedArray,Et=Rt?jt(Rt):function(t){return S(t)&&ut(t.length)&&!!Ct[m(t)]},zt=Object.prototype.hasOwnProperty;function xt(t,e){var s=_(t),i=!s&&wt(t),n=!s&&!i&&Tt(t),r=!s&&!i&&!n&&Et(t),o=s||i||n||r,a=o?function(t,e){for(var s=-1,i=Array(t);++s<t;)i[s]=e(s);return i}(t.length,String):[],c=a.length;for(var h in t)!e&&!zt.call(t,h)||o&&("length"==h||n&&("offset"==h||"parent"==h)||r&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||st(h,c))||a.push(h);return a}function Mt(t,e){return function(s){return t(e(s))}}var It=Mt(Object.keys,Object),Lt=Object.prototype.hasOwnProperty;function Pt(t){return dt(t)?xt(t):function(t){if(!ft(t))return It(t);var e=[];for(var s in Object(t))Lt.call(t,s)&&"constructor"!=s&&e.push(s);return e}(t)}var Dt=Object.prototype.hasOwnProperty;function Wt(t){if(!T(t))return function(t){var e=[];if(null!=t)for(var s in Object(t))e.push(s);return e}(t);var e=ft(t),s=[];for(var i in t)("constructor"!=i||!e&&Dt.call(t,i))&&s.push(i);return s}function qt(t){return dt(t)?xt(t,!0):Wt(t)}var Ut=B(Object,"create");var Bt=Object.prototype.hasOwnProperty;var Nt=Object.prototype.hasOwnProperty;function $t(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}function Ht(t,e){for(var s=t.length;s--;)if(nt(t[s][0],e))return s;return-1}$t.prototype.clear=function(){this.__data__=Ut?Ut(null):{},this.size=0},$t.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},$t.prototype.get=function(t){var e=this.__data__;if(Ut){var s=e[t];return"__lodash_hash_undefined__"===s?void 0:s}return Bt.call(e,t)?e[t]:void 0},$t.prototype.has=function(t){var e=this.__data__;return Ut?void 0!==e[t]:Nt.call(e,t)},$t.prototype.set=function(t,e){var s=this.__data__;return this.size+=this.has(t)?0:1,s[t]=Ut&&void 0===e?"__lodash_hash_undefined__":e,this};var Gt=Array.prototype.splice;function Jt(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}Jt.prototype.clear=function(){this.__data__=[],this.size=0},Jt.prototype.delete=function(t){var e=this.__data__,s=Ht(e,t);return!(s<0)&&(s==e.length-1?e.pop():Gt.call(e,s,1),--this.size,!0)},Jt.prototype.get=function(t){var e=this.__data__,s=Ht(e,t);return s<0?void 0:e[s][1]},Jt.prototype.has=function(t){return Ht(this.__data__,t)>-1},Jt.prototype.set=function(t,e){var s=this.__data__,i=Ht(s,t);return i<0?(++this.size,s.push([t,e])):s[i][1]=e,this};var Vt=B(l,"Map");function Xt(t,e){var s,i,n=t.__data__;return("string"==(i=typeof(s=e))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==s:null===s)?n["string"==typeof e?"string":"hash"]:n.map}function Kt(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}function Zt(t,e){for(var s=-1,i=e.length,n=t.length;++s<i;)t[n+s]=e[s];return t}Kt.prototype.clear=function(){this.size=0,this.__data__={hash:new $t,map:new(Vt||Jt),string:new $t}},Kt.prototype.delete=function(t){var e=Xt(this,t).delete(t);return this.size-=e?1:0,e},Kt.prototype.get=function(t){return Xt(this,t).get(t)},Kt.prototype.has=function(t){return Xt(this,t).has(t)},Kt.prototype.set=function(t,e){var s=Xt(this,t),i=s.size;return s.set(t,e),this.size+=s.size==i?0:1,this};var Qt=Mt(Object.getPrototypeOf,Object),Yt="[object Object]",te=Function.prototype,ee=Object.prototype,se=te.toString,ie=ee.hasOwnProperty,ne=se.call(Object);function re(t){var e=this.__data__=new Jt(t);this.size=e.size}re.prototype.clear=function(){this.__data__=new Jt,this.size=0},re.prototype.delete=function(t){var e=this.__data__,s=e.delete(t);return this.size=e.size,s},re.prototype.get=function(t){return this.__data__.get(t)},re.prototype.has=function(t){return this.__data__.has(t)},re.prototype.set=function(t,e){var s=this.__data__;if(s instanceof Jt){var i=s.__data__;if(!Vt||i.length<199)return i.push([t,e]),this.size=++s.size,this;s=this.__data__=new Kt(i)}return s.set(t,e),this.size=s.size,this};var oe="object"==typeof t&&t&&!t.nodeType&&t,ae=oe&&"object"==typeof module&&module&&!module.nodeType&&module,ce=ae&&ae.exports===oe?l.Buffer:void 0,he=ce?ce.allocUnsafe:void 0;function le(t,e){if(e)return t.slice();var s=t.length,i=he?he(s):new t.constructor(s);return t.copy(i),i}function ue(){return[]}var de=Object.prototype.propertyIsEnumerable,pe=Object.getOwnPropertySymbols,fe=pe?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var s=-1,i=null==t?0:t.length,n=0,r=[];++s<i;){var o=t[s];e(o,s,t)&&(r[n++]=o)}return r}(pe(t),(function(e){return de.call(t,e)})))}:ue;var ve=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Zt(e,fe(t)),t=Qt(t);return e}:ue;function ye(t,e,s){var i=e(t);return _(t)?i:Zt(i,s(t))}function ge(t){return ye(t,Pt,fe)}function be(t){return ye(t,qt,ve)}var we=B(l,"DataView"),me=B(l,"Promise"),Se=B(l,"Set"),_e="[object Map]",Te="[object Promise]",Ce="[object Set]",je="[object WeakMap]",Oe="[object DataView]",Ae=M(we),ke=M(Vt),Fe=M(me),Re=M(Se),Ee=M(N),ze=m;(we&&ze(new we(new ArrayBuffer(1)))!=Oe||Vt&&ze(new Vt)!=_e||me&&ze(me.resolve())!=Te||Se&&ze(new Se)!=Ce||N&&ze(new N)!=je)&&(ze=function(t){var e=m(t),s="[object Object]"==e?t.constructor:void 0,i=s?M(s):"";if(i)switch(i){case Ae:return Oe;case ke:return _e;case Fe:return Te;case Re:return Ce;case Ee:return je}return e});var xe=ze,Me=Object.prototype.hasOwnProperty;var Ie=l.Uint8Array;function Le(t){var e=new t.constructor(t.byteLength);return new Ie(e).set(new Ie(t)),e}var Pe=/\w*$/;var De=u?u.prototype:void 0,We=De?De.valueOf:void 0;function qe(t,e){var s=e?Le(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}var Ue="[object Boolean]",Be="[object Date]",Ne="[object Map]",$e="[object Number]",He="[object RegExp]",Ge="[object Set]",Je="[object String]",Ve="[object Symbol]",Xe="[object ArrayBuffer]",Ke="[object DataView]",Ze="[object Float32Array]",Qe="[object Float64Array]",Ye="[object Int8Array]",ts="[object Int16Array]",es="[object Int32Array]",ss="[object Uint8Array]",is="[object Uint8ClampedArray]",ns="[object Uint16Array]",rs="[object Uint32Array]";function os(t,e,s){var i,n,r,o=t.constructor;switch(e){case Xe:return Le(t);case Ue:case Be:return new o(+t);case Ke:return function(t,e){var s=e?Le(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}(t,s);case Ze:case Qe:case Ye:case ts:case es:case ss:case is:case ns:case rs:return qe(t,s);case Ne:return new o;case $e:case Je:return new o(t);case He:return(r=new(n=t).constructor(n.source,Pe.exec(n))).lastIndex=n.lastIndex,r;case Ge:return new o;case Ve:return i=t,We?Object(We.call(i)):{}}}function as(t){return"function"!=typeof t.constructor||ft(t)?{}:H(Qt(t))}var cs=Ft&&Ft.isMap,hs=cs?jt(cs):function(t){return S(t)&&"[object Map]"==xe(t)};var ls=Ft&&Ft.isSet,us=ls?jt(ls):function(t){return S(t)&&"[object Set]"==xe(t)},ds=1,ps=2,fs=4,vs="[object Arguments]",ys="[object Function]",gs="[object GeneratorFunction]",bs="[object Object]",ws={};function ms(t,e,s,i,n,r){var o,a=e&ds,c=e&ps,h=e&fs;if(s&&(o=n?s(t,i,n,r):s(t)),void 0!==o)return o;if(!T(t))return t;var l=_(t);if(l){if(o=function(t){var e=t.length,s=new t.constructor(e);return e&&"string"==typeof t[0]&&Me.call(t,"index")&&(s.index=t.index,s.input=t.input),s}(t),!a)return G(t,o)}else{var u=xe(t),d=u==ys||u==gs;if(Tt(t))return le(t,a);if(u==bs||u==vs||d&&!n){if(o=c||d?{}:as(t),!a)return c?function(t,e){return at(t,ve(t),e)}(t,function(t,e){return t&&at(e,qt(e),t)}(o,t)):function(t,e){return at(t,fe(t),e)}(t,function(t,e){return t&&at(e,Pt(e),t)}(o,t))}else{if(!ws[u])return n?t:{};o=os(t,u,a)}}r||(r=new re);var p=r.get(t);if(p)return p;r.set(t,o),us(t)?t.forEach((function(i){o.add(ms(i,e,s,i,t,r))})):hs(t)&&t.forEach((function(i,n){o.set(n,ms(i,e,s,n,t,r))}));var f=l?void 0:(h?c?be:ge:c?qt:Pt)(t);return function(t,e){for(var s=-1,i=null==t?0:t.length;++s<i&&!1!==e(t[s],s,t););}(f||t,(function(i,n){f&&(i=t[n=i]),ot(o,n,ms(i,e,s,n,t,r))})),o}ws[vs]=ws["[object Array]"]=ws["[object ArrayBuffer]"]=ws["[object DataView]"]=ws["[object Boolean]"]=ws["[object Date]"]=ws["[object Float32Array]"]=ws["[object Float64Array]"]=ws["[object Int8Array]"]=ws["[object Int16Array]"]=ws["[object Int32Array]"]=ws["[object Map]"]=ws["[object Number]"]=ws[bs]=ws["[object RegExp]"]=ws["[object Set]"]=ws["[object String]"]=ws["[object Symbol]"]=ws["[object Uint8Array]"]=ws["[object Uint8ClampedArray]"]=ws["[object Uint16Array]"]=ws["[object Uint32Array]"]=!0,ws["[object Error]"]=ws[ys]=ws["[object WeakMap]"]=!1;function Ss(t){return ms(t,5)}var _s,Ts=function(t,e,s){for(var i=-1,n=Object(t),r=s(t),o=r.length;o--;){var a=r[_s?o:++i];if(!1===e(n[a],a,n))break}return t};function Cs(t,e,s){(void 0!==s&&!nt(t[e],s)||void 0===s&&!(e in t))&&it(t,e,s)}function js(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Os(t,e,s,i,n,r,o){var a=js(t,s),c=js(e,s),h=o.get(c);if(h)Cs(t,s,h);else{var l,u=r?r(a,c,s+"",t,e,o):void 0,d=void 0===u;if(d){var p=_(c),f=!p&&Tt(c),v=!p&&!f&&Et(c);u=c,p||f||v?_(a)?u=a:S(l=a)&&dt(l)?u=G(a):f?(d=!1,u=le(c,!0)):v?(d=!1,u=qe(c,!0)):u=[]:function(t){if(!S(t)||m(t)!=Yt)return!1;var e=Qt(t);if(null===e)return!0;var s=ie.call(e,"constructor")&&e.constructor;return"function"==typeof s&&s instanceof s&&se.call(s)==ne}(c)||wt(c)?(u=a,wt(a)?u=function(t){return at(t,qt(t))}(a):T(a)&&!F(a)||(u=as(c))):d=!1}d&&(o.set(c,u),n(u,c,i,r,o),o.delete(c)),Cs(t,s,u)}}function As(t,e,s,i,n){t!==e&&Ts(e,(function(r,o){if(n||(n=new re),T(r))Os(t,e,o,s,As,i,n);else{var a=i?i(js(t,o),r,o+"",t,e,n):void 0;void 0===a&&(a=r),Cs(t,o,a)}}),qt)}var ks,Fs=(ks=function(t,e,s){As(t,e,s)},ht((function(t,e){var s=-1,i=e.length,n=i>1?e[i-1]:void 0,r=i>2?e[2]:void 0;for(n=ks.length>3&&"function"==typeof n?(i--,n):void 0,r&&function(t,e,s){if(!T(s))return!1;var i=typeof e;return!!("number"==i?dt(s)&&st(e,s.length):"string"==i&&e in s)&&nt(s[e],t)}(e[0],e[1],r)&&(n=i<3?void 0:n,i=1),t=Object(t);++s<i;){var o=e[s];o&&ks(t,o,s,n)}return t})));let Rs=null;try{Rs=localStorage.getItem("debug")||""}catch(t){"undefined"!=typeof window&&"undefined"!=typeof localStorage&&console.warn("Error checking window.debug")}const Es=t=>Rs&&new RegExp(Rs).test(t)?(...e)=>console.log(t,...e):()=>{};class zs extends Error{}class xs extends Error{}const Ms=Es("rpc:ClientManager");class Is{constructor(t){this.options=t,this.inflightCallsByKey={},this.interceptors={request:[],response:[]},this.addResponseInterceptor=t=>{if("function"!=typeof t)throw new Error("cannot add interceptor that is not a function");return this.interceptors.response.push(t),()=>{this.interceptors.response=this.interceptors.response.filter((e=>e!==t))}},this.addRequestInterceptor=t=>{if("function"!=typeof t)throw new Error("cannot add interceptor that is not a function");return this.interceptors.request.push(t),()=>{this.interceptors.request=this.interceptors.request.filter((e=>e!==t))}},this.clearCache=t=>{Ms("clearCache"),this.cache&&this.cache.clearCache(t)},this.getCachedResponse=t=>{var e;return Ms("getCachedResponse",t),null===(e=null==this?void 0:this.cache)||void 0===e?void 0:e.getCachedResponse(t)},this.getInFlightCallCount=()=>(Ms("getInFlightCallCount"),Object.keys(this.inflightCallsByKey).length),this.manageClientRequest=(t,s)=>e(this,void 0,void 0,(function*(){Ms("manageClientRequest",t);const i=yield this.interceptRequestMutator(t),n=a(i);if(this.inflightCallsByKey.hasOwnProperty(n))return Ms("manageClientRequest using an existing in-flight call",n),this.inflightCallsByKey[n].then((e=>{const s=Ss(e);return t.correlationId&&(s.correlationId=t.correlationId),s}));const r=(()=>e(this,void 0,void 0,(function*(){const t=yield this.sendRequestWithTransport(i,s),e=yield this.interceptResponseMutator(t,i);return this.cache&&e&&this.cache.setCachedResponse(i,e),e})))().finally((()=>{delete this.inflightCallsByKey[n]}));return this.inflightCallsByKey[n]=r,yield r})),this.setIdentity=t=>{Ms("setIdentity",t),this.transports.forEach((e=>e.setIdentity(t)))},this.interceptRequestMutator=t=>e(this,void 0,void 0,(function*(){var e,s,n,r;let o=t;if(this.interceptors.request.length){Ms("interceptRequestMutator(), original request:",t);try{for(var a,c=!0,h=i(this.interceptors.request);!(e=(a=yield h.next()).done);c=!0){r=a.value,c=!1;const t=r;o=yield t(o)}}catch(t){s={error:t}}finally{try{c||e||!(n=h.return)||(yield n.call(h))}finally{if(s)throw s.error}}}return o})),this.interceptResponseMutator=(t,s)=>e(this,void 0,void 0,(function*(){let e=t;if(this.interceptors.response.length){Ms("interceptResponseMutator",s,t);for(const i of this.interceptors.response)try{e=yield i(e,s)}catch(i){throw Ms("caught response interceptor, request:",s,"original response:",t,"mutated response:",e),i}}return e})),this.sendRequestWithTransport=(t,s)=>e(this,void 0,void 0,(function*(){var e,i;let n;Ms("sendRequestWithTransport",t);let o=0,a=this.transports;if(null==s?void 0:s.transport){const t=this.transports.find((t=>t.type===s.transport));if(!t)throw new r(`Specified Transport "${s.transport}" not available`);a=[t]}for(;!n&&a[o];){const r=a[o];if(r.isConnected()){Ms(`sendRequestWithTransport trying ${this.transports[o].name}`,t);try{let e;const i=r.sendRequest(t,s||{}),o=new Promise(((i,n)=>{e=setTimeout((()=>{n(new zs(`Procedure ${t.procedure}`))}),(null==s?void 0:s.timeout)||this.options.deadlineMs)}));n=yield Promise.race([o,i]).finally((()=>{clearTimeout(e)}))}catch(s){if(null===(i=(e=this.options).onTransportRequestError)||void 0===i||i.call(e,s,t),!(s instanceof zs||s instanceof xs))throw s;console.warn(`RPCClient ClientManager#sendRequestWithTransport() sending request with ${a[o].name} failed ${a[o+1]?`trying next transport "${a[o+1].name}"`:"no more transports to try"}`),o++}}else o++}if(!n&&!this.transports[o])throw console.error(`RPCClient ClientManager#sendRequestWithTransport() ${t.scope}::${t.procedure}::${t.version} did not get a response from any transports`),new r(`Procedure ${t.procedure} did not get a response from any transports`);if(!n)throw new r(`Procedure ${t.procedure} did not get a response from the remote`);return n})),this.cache=t.cache,t.requestInterceptor&&this.interceptors.request.push(t.requestInterceptor),t.responseInterceptor&&this.interceptors.response.push(t.responseInterceptor),this.transports=t.transports}}class Ls{constructor(t){this.cacheOptions=t}clearCache(){}getCachedResponse(t){}setCachedResponse(t,e){}}Ls.DEFAULT_CACHE_MAX_AGE_MS=3e5,Ls.DEFAULT_CACHE_MAX_SIZE=100;var Ps,Ds=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.LRUCache=void 0;const s="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,i=new Set,n="object"==typeof process&&process?process:{},r=(t,e,s,i)=>{"function"==typeof n.emitWarning?n.emitWarning(t,e,s,i):console.error(`[${s}] ${e}: ${t}`)};let o=globalThis.AbortController,a=globalThis.AbortSignal;if(void 0===o){a=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},o=class{constructor(){e()}signal=new a;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==n.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,r("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}const c=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),h=t=>c(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?l:null:null;class l extends Array{constructor(t){super(t),this.fill(0)}}class u{heap;length;static#t=!1;static create(t){const e=h(t);if(!e)return[];u.#t=!0;const s=new u(t,e);return u.#t=!1,s}constructor(t,e){if(!u.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class d{#e;#s;#i;#n;#r;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#a;#c;#h;#l;#u;#d;#p;#f;#v;#y;#g;#b;#w;#m;#S;#_;static unsafeExposeInternals(t){return{starts:t.#b,ttls:t.#w,sizes:t.#g,keyMap:t.#c,keyList:t.#h,valList:t.#l,next:t.#u,prev:t.#d,get head(){return t.#p},get tail(){return t.#f},free:t.#v,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,s,i,n)=>t.#C(e,s,i,n),moveToTail:e=>t.#j(e),indexes:e=>t.#O(e),rindexes:e=>t.#A(e),isStale:e=>t.#k(e)}}get max(){return this.#e}get maxSize(){return this.#s}get calculatedSize(){return this.#a}get size(){return this.#o}get fetchMethod(){return this.#r}get dispose(){return this.#i}get disposeAfter(){return this.#n}constructor(t){const{max:e=0,ttl:s,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:p,dispose:f,disposeAfter:v,noDisposeOnSet:y,noUpdateTTL:g,maxSize:b=0,maxEntrySize:w=0,sizeCalculation:m,fetchMethod:S,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:C,allowStaleOnFetchAbort:j,ignoreFetchAbort:O}=t;if(0!==e&&!c(e))throw new TypeError("max option must be a nonnegative integer");const A=e?h(e):Array;if(!A)throw new Error("invalid max value: "+e);if(this.#e=e,this.#s=b,this.maxEntrySize=w||this.#s,this.sizeCalculation=m,this.sizeCalculation){if(!this.#s&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==S&&"function"!=typeof S)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=S,this.#S=!!S,this.#c=new Map,this.#h=new Array(e).fill(void 0),this.#l=new Array(e).fill(void 0),this.#u=new A(e),this.#d=new A(e),this.#p=0,this.#f=0,this.#v=u.create(e),this.#o=0,this.#a=0,"function"==typeof f&&(this.#i=f),"function"==typeof v?(this.#n=v,this.#y=[]):(this.#n=void 0,this.#y=void 0),this.#m=!!this.#i,this.#_=!!this.#n,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!C,this.allowStaleOnFetchAbort=!!j,this.ignoreFetchAbort=!!O,0!==this.maxEntrySize){if(0!==this.#s&&!c(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!c(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#F()}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=c(n)||0===n?n:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!c(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#R()}if(0===this.#e&&0===this.ttl&&0===this.#s)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#s){const t="LRU_CACHE_UNBOUNDED";if((t=>!i.has(t))(t)){i.add(t);r("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,d)}}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#R(){const t=new l(this.#e),e=new l(this.#e);this.#w=t,this.#b=e,this.#E=(i,n,r=s.now())=>{if(e[i]=0!==n?r:0,t[i]=n,0!==n&&this.ttlAutopurge){const t=setTimeout((()=>{this.#k(i)&&this.delete(this.#h[i])}),n+1);t.unref&&t.unref()}},this.#z=i=>{e[i]=0!==t[i]?s.now():0},this.#x=(s,r)=>{if(t[r]){const o=t[r],a=e[r];if(!o||!a)return;s.ttl=o,s.start=a,s.now=i||n();const c=s.now-a;s.remainingTTL=o-c}};let i=0;const n=()=>{const t=s.now();if(this.ttlResolution>0){i=t;const e=setTimeout((()=>i=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=s=>{const r=this.#c.get(s);if(void 0===r)return 0;const o=t[r],a=e[r];if(!o||!a)return 1/0;return o-((i||n())-a)},this.#k=s=>{const r=e[s],o=t[s];return!!o&&!!r&&(i||n())-r>o}}#z=()=>{};#x=()=>{};#E=()=>{};#k=()=>!1;#F(){const t=new l(this.#e);this.#a=0,this.#g=t,this.#M=e=>{this.#a-=t[e],t[e]=0},this.#I=(t,e,s,i)=>{if(this.#T(e))return 0;if(!c(s)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(s=i(e,t),!c(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return s},this.#L=(e,s,i)=>{if(t[e]=s,this.#s){const s=this.#s-t[e];for(;this.#a>s;)this.#P(!0)}this.#a+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#a)}}#M=t=>{};#L=(t,e,s)=>{};#I=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#f;this.#D(e)&&(!t&&this.#k(e)||(yield e),e!==this.#p);)e=this.#d[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#p;this.#D(e)&&(!t&&this.#k(e)||(yield e),e!==this.#f);)e=this.#u[e]}#D(t){return void 0!==t&&this.#c.get(this.#h[t])===t}*entries(){for(const t of this.#O())void 0===this.#l[t]||void 0===this.#h[t]||this.#T(this.#l[t])||(yield[this.#h[t],this.#l[t]])}*rentries(){for(const t of this.#A())void 0===this.#l[t]||void 0===this.#h[t]||this.#T(this.#l[t])||(yield[this.#h[t],this.#l[t]])}*keys(){for(const t of this.#O()){const e=this.#h[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#h[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*values(){for(const t of this.#O()){void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}}*rvalues(){for(const t of this.#A()){void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const s of this.#O()){const i=this.#l[s],n=this.#T(i)?i.__staleWhileFetching:i;if(void 0!==n&&t(n,this.#h[s],this))return this.get(this.#h[s],e)}}forEach(t,e=this){for(const s of this.#O()){const i=this.#l[s],n=this.#T(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#h[s],this)}}rforEach(t,e=this){for(const s of this.#A()){const i=this.#l[s],n=this.#T(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#h[s],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#k(e)&&(this.delete(this.#h[e]),t=!0);return t}info(t){const e=this.#c.get(t);if(void 0===e)return;const i=this.#l[e],n=this.#T(i)?i.__staleWhileFetching:i;if(void 0===n)return;const r={value:n};if(this.#w&&this.#b){const t=this.#w[e],i=this.#b[e];if(t&&i){const e=t-(s.now()-i);r.ttl=e,r.start=Date.now()}}return this.#g&&(r.size=this.#g[e]),r}dump(){const t=[];for(const e of this.#O({allowStale:!0})){const i=this.#h[e],n=this.#l[e],r=this.#T(n)?n.__staleWhileFetching:n;if(void 0===r||void 0===i)continue;const o={value:r};if(this.#w&&this.#b){o.ttl=this.#w[e];const t=s.now()-this.#b[e];o.start=Math.floor(Date.now()-t)}this.#g&&(o.size=this.#g[e]),t.unshift([i,o])}return t}load(t){this.clear();for(const[e,i]of t){if(i.start){const t=Date.now()-i.start;i.start=s.now()-t}this.set(e,i.value,i)}}set(t,e,s={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=s;let{noUpdateTTL:c=this.noUpdateTTL}=s;const h=this.#I(t,e,s.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let l=0===this.#o?void 0:this.#c.get(t);if(void 0===l)l=0===this.#o?this.#f:0!==this.#v.length?this.#v.pop():this.#o===this.#e?this.#P(!1):this.#o,this.#h[l]=t,this.#l[l]=e,this.#c.set(t,l),this.#u[this.#f]=l,this.#d[l]=this.#f,this.#f=l,this.#o++,this.#L(l,h,a),a&&(a.set="add"),c=!1;else{this.#j(l);const s=this.#l[l];if(e!==s){if(this.#S&&this.#T(s)){s.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=s;void 0===e||r||(this.#m&&this.#i?.(e,t,"set"),this.#_&&this.#y?.push([e,t,"set"]))}else r||(this.#m&&this.#i?.(s,t,"set"),this.#_&&this.#y?.push([s,t,"set"]));if(this.#M(l),this.#L(l,h,a),this.#l[l]=e,a){a.set="replace";const t=s&&this.#T(s)?s.__staleWhileFetching:s;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#w||this.#R(),this.#w&&(c||this.#E(l,i,n),a&&this.#x(a,l)),!r&&this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return this}pop(){try{for(;this.#o;){const t=this.#l[this.#p];if(this.#P(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}#P(t){const e=this.#p,s=this.#h[e],i=this.#l[e];return this.#S&&this.#T(i)?i.__abortController.abort(new Error("evicted")):(this.#m||this.#_)&&(this.#m&&this.#i?.(i,s,"evict"),this.#_&&this.#y?.push([i,s,"evict"])),this.#M(e),t&&(this.#h[e]=void 0,this.#l[e]=void 0,this.#v.push(e)),1===this.#o?(this.#p=this.#f=0,this.#v.length=0):this.#p=this.#u[e],this.#c.delete(s),this.#o--,e}has(t,e={}){const{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,n=this.#c.get(t);if(void 0!==n){const t=this.#l[n];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#k(n))return s&&this.#z(n),i&&(i.has="hit",this.#x(i,n)),!0;i&&(i.has="stale",this.#x(i,n))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:s=this.allowStale}=e,i=this.#c.get(t);if(void 0===i||!s&&this.#k(i))return;const n=this.#l[i];return this.#T(n)?n.__staleWhileFetching:n}#C(t,e,s,i){const n=void 0===e?void 0:this.#l[e];if(this.#T(n))return n;const r=new o,{signal:a}=s;a?.addEventListener("abort",(()=>r.abort(a.reason)),{signal:r.signal});const c={signal:r.signal,options:s,context:i},h=(i,n=!1)=>{const{aborted:o}=r.signal,a=s.ignoreFetchAbort&&void 0!==i;if(s.status&&(o&&!n?(s.status.fetchAborted=!0,s.status.fetchError=r.signal.reason,a&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),o&&!a&&!n)return l(r.signal.reason);const h=u;return this.#l[e]===u&&(void 0===i?h.__staleWhileFetching?this.#l[e]=h.__staleWhileFetching:this.delete(t):(s.status&&(s.status.fetchUpdated=!0),this.set(t,i,c.options))),i},l=i=>{const{aborted:n}=r.signal,o=n&&s.allowStaleOnFetchAbort,a=o||s.allowStaleOnFetchRejection,c=a||s.noDeleteOnFetchRejection,h=u;if(this.#l[e]===u){!c||void 0===h.__staleWhileFetching?this.delete(t):o||(this.#l[e]=h.__staleWhileFetching)}if(a)return s.status&&void 0!==h.__staleWhileFetching&&(s.status.returnedStale=!0),h.__staleWhileFetching;if(h.__returned===h)throw i};s.status&&(s.status.fetchDispatched=!0);const u=new Promise(((e,i)=>{const o=this.#r?.(t,n,c);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),i),r.signal.addEventListener("abort",(()=>{s.ignoreFetchAbort&&!s.allowStaleOnFetchAbort||(e(void 0),s.allowStaleOnFetchAbort&&(e=t=>h(t,!0)))}))})).then(h,(t=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=t),l(t)))),d=Object.assign(u,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return void 0===e?(this.set(t,d,{...c.options,status:void 0}),e=this.#c.get(t)):this.#l[e]=d,d}#T(t){if(!this.#S)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof o}async fetch(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:f,forceRefresh:v=!1,status:y,signal:g}=e;if(!this.#S)return y&&(y.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:n,status:y});const b={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:y,signal:g};let w=this.#c.get(t);if(void 0===w){y&&(y.fetch="miss");const e=this.#C(t,w,b,f);return e.__returned=e}{const e=this.#l[w];if(this.#T(e)){const t=s&&void 0!==e.__staleWhileFetching;return y&&(y.fetch="inflight",t&&(y.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const n=this.#k(w);if(!v&&!n)return y&&(y.fetch="hit"),this.#j(w),i&&this.#z(w),y&&this.#x(y,w),e;const r=this.#C(t,w,b,f),o=void 0!==r.__staleWhileFetching&&s;return y&&(y.fetch=n?"stale":"refresh",o&&n&&(y.returnedStale=!0)),o?r.__staleWhileFetching:r.__returned=r}}get(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=e,o=this.#c.get(t);if(void 0!==o){const e=this.#l[o],a=this.#T(e);return r&&this.#x(r,o),this.#k(o)?(r&&(r.get="stale"),a?(r&&s&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),s?e.__staleWhileFetching:void 0):(n||this.delete(t),r&&s&&(r.returnedStale=!0),s?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#j(o),i&&this.#z(o),e))}r&&(r.get="miss")}#W(t,e){this.#d[e]=t,this.#u[t]=e}#j(t){t!==this.#f&&(t===this.#p?this.#p=this.#u[t]:this.#W(this.#d[t],this.#u[t]),this.#W(this.#f,t),this.#f=t)}delete(t){let e=!1;if(0!==this.#o){const s=this.#c.get(t);if(void 0!==s)if(e=!0,1===this.#o)this.clear();else{this.#M(s);const e=this.#l[s];if(this.#T(e)?e.__abortController.abort(new Error("deleted")):(this.#m||this.#_)&&(this.#m&&this.#i?.(e,t,"delete"),this.#_&&this.#y?.push([e,t,"delete"])),this.#c.delete(t),this.#h[s]=void 0,this.#l[s]=void 0,s===this.#f)this.#f=this.#d[s];else if(s===this.#p)this.#p=this.#u[s];else{const t=this.#d[s];this.#u[t]=this.#u[s];const e=this.#u[s];this.#d[e]=this.#d[s]}this.#o--,this.#v.push(s)}}if(this.#_&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return e}clear(){for(const t of this.#A({allowStale:!0})){const e=this.#l[t];if(this.#T(e))e.__abortController.abort(new Error("deleted"));else{const s=this.#h[t];this.#m&&this.#i?.(e,s,"delete"),this.#_&&this.#y?.push([e,s,"delete"])}}if(this.#c.clear(),this.#l.fill(void 0),this.#h.fill(void 0),this.#w&&this.#b&&(this.#w.fill(0),this.#b.fill(0)),this.#g&&this.#g.fill(0),this.#p=0,this.#f=0,this.#v.length=0,this.#a=0,this.#o=0,this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}e.LRUCache=d}));(Ps=Ds)&&Ps.__esModule&&Object.prototype.hasOwnProperty.call(Ps,"default")&&Ps.default;var Ws=Ds.LRUCache;const qs=Es("rpc:InMemoryCache");class Us{constructor(t){this.clearCache=t=>{var e,s;qs("clearCache"),t?null===(e=this.cachedResponseByParams)||void 0===e||e.delete(a(t)):null===(s=this.cachedResponseByParams)||void 0===s||s.clear()},this.getCachedResponse=t=>{var e;qs("getCachedResponse, key: ",t);let s=null===(e=this.cachedResponseByParams)||void 0===e?void 0:e.get(a(t));return"string"==typeof s&&(s=JSON.parse(s)),s},this.setCachedResponse=(t,e)=>{var s,i;qs("setCachedResponse",t,e);const n=a(t);if(!e)return null===(s=this.cachedResponseByParams)||void 0===s?void 0:s.delete(n);const r=Object.assign({},e);delete r.correlationId,null===(i=this.cachedResponseByParams)||void 0===i||i.set(n,r?JSON.stringify(r):void 0)},this.cachedResponseByParams=new Ws({max:(null==t?void 0:t.cacheMaxSize)||Us.DEFAULT_CACHE_MAX_SIZE,ttl:(null==t?void 0:t.cacheMaxAgeMs)||Us.DEFAULT_CACHE_MAX_AGE_MS})}}var Bs;Us.DEFAULT_CACHE_MAX_AGE_MS=9e5,Us.DEFAULT_CACHE_MAX_SIZE=200,function(t){t.http="http",t.websocket="websocket"}(Bs||(Bs={}));class Ns{constructor(t){const{code:e,correlationId:s,data:i,message:n,success:r}=t;if("number"!=typeof e)throw new Error("code must be a number");if(this.code=e,s&&"string"!=typeof s)throw new Error("correlationId must be a string");if(this.correlationId=s,this.data=i,n&&"string"!=typeof n)throw new Error("message must be a string");if(this.message=n,"boolean"!=typeof r)throw new Error("success must be a boolean");this.success=r}}const $s=t=>`${t.scope}::${t.procedure}::${t.version}`,Hs=t=>{const e=t.split("::");return{procedure:e[1],scope:e[0]||"global",version:e[2]||"1"}},Gs=Es("rpc:HTTPTransport");class Js{constructor(t){this.options=t,this.networkIsConnected=!1,this.name="HttpTransport",this.type=Bs.http,this.isConnected=()=>{var t;return"undefined"!=typeof window?!!(null===(t=null===window||void 0===window?void 0:window.navigator)||void 0===t?void 0:t.onLine):this.networkIsConnected},this.sendRequest=(t,s)=>e(this,void 0,void 0,(function*(){Gs("sendRequest",t);try{const e=JSON.stringify(Object.assign({identity:this.identity},t)),s=yield null===window||void 0===window?void 0:window.fetch(this.host,{body:e,cache:"default",credentials:"omit",headers:{"Content-Type":"application/json"},method:"POST",mode:"cors",redirect:"follow",referrerPolicy:"origin"}),i=yield s.text();if(!i)throw new Error("No response received from remote");const n=JSON.parse(i);return new Ns(n)}catch(e){throw Gs("sendRequest() error",e),new xs(`HTTPTransport request error ${$s(t)}`)}})),this.setIdentity=t=>{Gs("setIdentity",t),this.identity=t},this.host=t.host}}class Vs{constructor(t,s){this.reject=t=>{this.rejectPromise&&this.rejectPromise(t)},this.resolve=t=>{this.resolvePromise&&this.resolvePromise(t)},this.promise=new Promise(((i,n)=>e(this,void 0,void 0,(function*(){const e=setTimeout((()=>{n(new Error(`PromiseWraper timeout: ${t}`))}),s||3e4);this.rejectPromise=t=>{clearTimeout(e),n(t)},this.resolvePromise=t=>{clearTimeout(e),i(t)}}))))}}const Xs=t=>new Promise((e=>setTimeout(e,t))),Ks=Es("rpc:WebSocketTransport");class Zs{constructor(t){this.options=t,this.connectedToRemote=!1,this.isWaitingForIdentityConfirmation=!1,this.pendingPromisesForResponse={},this.serverMessageHandlers=[],this.websocketId=void 0,this.name="WebSocketTransport",this.type=Bs.http,this.isConnected=()=>this.connectedToRemote&&!!this.websocket,this.connect=()=>{this._connect()},this.disconnect=()=>{this._disconnect("public disconnect() called")},this.sendClientMessageToServer=t=>{var e;let s=t;try{s=JSON.stringify({clientMessage:t})}catch(e){console.warn('WebSocketTransport.sendClientMessage() unable to stringify "msg"',t)}null===(e=this.websocket)||void 0===e||e.send(s)},this.sendRequest=(t,s)=>e(this,void 0,void 0,(function*(){for(Ks("sendRequest",t);this.isWaitingForIdentityConfirmation;)Ks("waiting for identity confirmation"),yield Xs(100);return this.sendCall(t,s)})),this.setIdentity=t=>e(this,void 0,void 0,(function*(){if(Ks("setIdentity",t),!t)return this.identity=void 0,void(yield this.resetConnection());this.identity=t,this.connectedToRemote?this.isWaitingForIdentityConfirmation?Ks('setIdentity returning early because "this.isWaitingForIdentityConfirmation=true"'):(this.isWaitingForIdentityConfirmation=!0,this.sendCall({identity:t},{}).then((()=>{Ks("setIdentity with remote complete")})).catch((t=>{Ks("setIdentity with remote error",t)})).finally((()=>{this.isWaitingForIdentityConfirmation=!1}))):Ks("setIdentity is not connected to remote")})),this.subscribeToServerMessages=t=>(this.serverMessageHandlers.push(t),()=>{this.serverMessageHandlers=this.serverMessageHandlers.filter((e=>e!==t))}),this.unsubscribeFromServerMessages=t=>{this.serverMessageHandlers=this.serverMessageHandlers.filter((e=>e!==t))},this._connect=()=>{if(Ks("connect",this.host),this.websocket)return void Ks("connect() returning early, websocket already exists");this.websocketId=Math.random(),this.websocket=new WebSocket(this.host);const t=this.websocket;t.onopen=()=>{console.info(`[${(new Date).toLocaleTimeString()}] WebSocket connected`),this.setConnectedToRemote(!0)},t.onmessage=t=>{this.handleWebSocketMsg(t)},t.onclose=t=>{this.connectedToRemote?console.info(`[${(new Date).toLocaleTimeString()}] WebSocket closed`,t.reason):Ks("WebSocket closed, it was not connected to the remote"),this.setConnectedToRemote(!1),this.isWaitingForIdentityConfirmation=!1,this.websocket=void 0,this.websocketId=void 0,Object.entries(this.pendingPromisesForResponse).forEach((([t,e])=>{e.reject(new xs("Websocket disconnected"))})),t.wasClean||setTimeout((()=>{this.connect()}),1e3)},t.onerror=e=>{this.connectedToRemote?console.error("WebSocket encountered error: ",e):Ks("WebSocket errored, it was not connected to the remote"),t.close()}},this._disconnect=t=>{var e;Ks("_disconnect"),this.setConnectedToRemote(!1),this.isWaitingForIdentityConfirmation=!1,null===(e=this.websocket)||void 0===e||e.close(1e3,t),this.websocket=void 0,this.websocketId=void 0},this.handleServerMessage=t=>{this.serverMessageHandlers.forEach((e=>{try{e(t.serverMessage)}catch(s){console.warn("WebSocketTransport.handleServerMessage() a serverMessageHandler errored when calling",t,"handler func:",e),console.error(s)}}))},this.handleWebSocketMsg=t=>{let e;Ks("handleWebSocketMsg",t);try{e=JSON.parse(t.data)}catch(t){console.error("error parsing WS msg",t)}if("serverMessage"in e)return void this.handleServerMessage(e);const s=new Ns(e);if(!s.correlationId)return void console.error("RPCClient WebSocketTransport received unexpected msg from the server, not correlationId found in response.",e);const i=this.pendingPromisesForResponse[s.correlationId];i?i.resolve(s):console.warn("rcvd WS msg/response that doesn't match any pending RPC's",e)},this.resetConnection=()=>e(this,void 0,void 0,(function*(){Ks("resetConnection"),this._disconnect("WebSocketTransport#resetConnection"),yield Xs(100),this._connect()})),this.sendCall=(t,s)=>e(this,void 0,void 0,(function*(){var e;Ks("sendCall",t);const i=Math.random().toString();t.correlationId=t.correlationId||i;let n=new Vs($s(t),s.timeout||this.options.rpcOptions.deadlineMs);return null===(e=this.websocket)||void 0===e||e.send(JSON.stringify(t)),this.pendingPromisesForResponse[t.correlationId]=n,yield n.promise.finally((()=>{delete this.pendingPromisesForResponse[t.correlationId]}))})),this.setConnectedToRemote=t=>{Ks(`setConnectedToRemote: ${t}`),this.connectedToRemote=t,this.options.onConnectionStatusChange&&this.options.onConnectionStatusChange(t),t&&this.identity&&this.setIdentity(this.identity)},Ks("new WebSocketTransport()"),this.host=t.host,this.connect()}}class Qs{constructor(){this.events={},this.publish=(t,s)=>e(this,void 0,void 0,(function*(){const e=this.events[t];e&&e.forEach((function(t){t.call(t,s)}))})),this.subscribe=(t,e)=>(this.events[t]||(this.events[t]=[]),this.events[t].push(e),()=>this.unsubscribe(t,e)),this.unsubscribe=(t,e)=>{if(!this.events[t])return;let s=this.events[t].indexOf(e);this.events[t].splice(s)}}}const Ys={HTTP_HOST_OR_TRANSPORT_REQUIRED:"http host or tansport is required",INTERCEPTOR_MUSTBE_FUNC:"interceptors must be a function"};class ti{constructor(t){var s,i,r,o,c,h;if(this.options=t,this.webSocketConnectionChangeListeners=[],this.vent=new Qs,this.onWebSocketConnectionStatusChange=t=>{this.options.onWebSocketConnectionStatusChange&&this.options.onWebSocketConnectionStatusChange(t),this.webSocketConnectionChangeListeners.forEach((e=>e(t)))},this.call=(t,s,i)=>e(this,void 0,void 0,(function*(){if(!t)throw new Error('RPCClient.call(request) requires a "request" param');let e;e="string"==typeof t?Hs(t):t,s&&(e.args=s);const r=new n(e);if(!r.procedure&&!r.identity)throw new TypeError('RPCClient#call requires a "identity" or "procedure" prop and received neither');r.identity||(r.identity={}),r.identity=Fs(Object.assign({},this.identity),r.identity);const o=yield this.callManager.manageClientRequest(r,i);if(!o.success)throw o;const c=a(e);return this.vent.publish(c,null==o?void 0:o.data),o})),this.clearCache=t=>{this.callManager.clearCache(t)},this.getCallCache=(t,e)=>{let s;s="string"==typeof t?Hs(t):t,e&&(s.args=e);const i=this.callManager.getCachedResponse(s);if(i)return i},this.getIdentity=()=>this.identity?Ss(this.identity):this.identity,this.getInFlightCallCount=()=>this.callManager.getInFlightCallCount(),this.getWebSocketConnected=()=>{var t;return!!(null===(t=null==this?void 0:this.webSocketTransport)||void 0===t?void 0:t.isConnected())},this.makeProcedure=t=>{const e=this;let s;return s="string"==typeof t?Hs(t):t,function(t){return e.call(Object.assign(Object.assign({},s),{args:t}))}},this.registerResponseInterceptor=t=>this.callManager.addResponseInterceptor(t),this.registerRequestInterceptor=t=>this.callManager.addRequestInterceptor(t),this.registerWebSocketConnectionStatusChangeListener=t=>(this.webSocketConnectionChangeListeners.push(t),()=>{this.webSocketConnectionChangeListeners=this.webSocketConnectionChangeListeners.filter((e=>e!==t))}),this.sendClientMessageToServer=t=>{this.webSocketTransport?this.webSocketTransport.isConnected()?this.webSocketTransport.sendClientMessageToServer(t):console.info("RPCClient.sendClientMessageToServer() cannot send because the websocket is not connected"):console.warn("RPCClient.sendClientMessageToServer() unable to send because RPCClient has no websocket configuration")},this.setIdentity=t=>{let e=Ss(t);this.identity=t,this.callManager.setIdentity(e)},this.setIdentityMetadata=t=>{var e;null!==(e=this.identity)&&void 0!==e||(this.identity={});const s=Ss(this.identity);s.metadata=t,this.identity.metadata=t,this.callManager.setIdentity(s)},this.transports=()=>({http:this.httpTransport,websocket:this.webSocketTransport}),!(null===(s=null==t?void 0:t.hosts)||void 0===s?void 0:s.http)&&!(null===(i=null==t?void 0:t.transports)||void 0===i?void 0:i.http))throw new Error(Ys.HTTP_HOST_OR_TRANSPORT_REQUIRED);if(t.requestInterceptor&&"function"!=typeof t.requestInterceptor)throw new Error(Ys.INTERCEPTOR_MUSTBE_FUNC);if(t.responseInterceptor&&"function"!=typeof t.responseInterceptor)throw new Error(Ys.INTERCEPTOR_MUSTBE_FUNC);let l;const u={cacheMaxAgeMs:null==t?void 0:t.cacheMaxAgeMs};l="browser"==t.cacheType?new Ls(u):new Us(u);const d=[];(null===(r=t.transports)||void 0===r?void 0:r.websocket)?d.push(t.transports.websocket):(null===(o=null==t?void 0:t.hosts)||void 0===o?void 0:o.websocket)&&(this.webSocketTransport=new Zs({host:t.hosts.websocket,onConnectionStatusChange:this.onWebSocketConnectionStatusChange,rpcOptions:t}),d.push(this.webSocketTransport)),(null===(c=t.transports)||void 0===c?void 0:c.http)?d.push(t.transports.http):(null===(h=null==t?void 0:t.hosts)||void 0===h?void 0:h.http)&&(this.httpTransport=new Js({host:t.hosts.http,rpcOptions:t}),d.push(this.httpTransport)),this.callManager=new Is({cache:l,deadlineMs:t.deadlineMs||ti.DEFAULT_DEADLINE_MS,onTransportRequestError:t.onTransportRequestError,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,transports:d})}subscribe(t,e){const s="string"==typeof t.request?Hs(t.request):t.request,i=a(Object.assign(Object.assign({},s),{args:t.args}));return this.vent.subscribe(i,e)}unsubscribe(t,e){const s="string"==typeof t.request?Hs(t.request):t.request,i=a(Object.assign(Object.assign({},s),{args:t.args}));this.vent.unsubscribe(i,e)}subscribeToServerMessages(t){return this.webSocketTransport?this.webSocketTransport.subscribeToServerMessages(t):(console.warn("RPCClient.subscribeToServerMessages() cannot subscribe because RPCClient has no websocket configuration"),()=>{})}unsubscribeFromServerMessages(t){var e;null===(e=this.webSocketTransport)||void 0===e||e.unsubscribeFromServerMessages(t)}}ti.DEFAULT_DEADLINE_MS=1e4,t.CallRequestTransportError=xs,t.CallRequestTransportTimeoutError=zs,t.RPCClient=ti,t.RPCResponse=Ns})); |
{ | ||
"name": "@therms/rpc-client", | ||
"version": "2.19.0", | ||
"version": "2.19.1", | ||
"description": "RPC framework, browser client lib", | ||
@@ -5,0 +5,0 @@ "private": false, |
@@ -54,5 +54,2 @@ import { CallRequestDTO } from './CallRequestDTO' | ||
/** An optional callback when a Transport request fails */ | ||
onTransportRequestError?: ClientManagerOptions['onTransportRequestError'] | ||
registerResponseInterceptor( | ||
@@ -110,2 +107,4 @@ responseInterceptor: CallResponseInterceptor, | ||
} | ||
/** An optional callback when a Transport request fails */ | ||
onTransportRequestError?: ClientManagerOptions['onTransportRequestError'] | ||
onWebSocketConnectionStatusChange?: (connected: boolean) => void | ||
@@ -190,2 +189,3 @@ requestInterceptor?: CallRequestInterceptor | ||
deadlineMs: options.deadlineMs || RPCClient.DEFAULT_DEADLINE_MS, | ||
onTransportRequestError: options.onTransportRequestError, | ||
requestInterceptor: options.requestInterceptor, | ||
@@ -192,0 +192,0 @@ responseInterceptor: options.responseInterceptor, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
337016
3763