UNPKG

@taraai/read-write

Version:

Synchronous NoSQL/Firestore for React

2 lines 1.27 MB
/*! For license information please see read-write-test.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@reduxjs/toolkit"),require("react-redux"),require("react-dom")):"function"==typeof define&&define.amd?define("ReadWriteTest",["react","@reduxjs/toolkit","react-redux","react-dom"],t):"object"==typeof exports?exports.ReadWriteTest=t(require("react"),require("@reduxjs/toolkit"),require("react-redux"),require("react-dom")):e.ReadWriteTest=t(e.react,e["@reduxjs/toolkit"],e["react-redux"],e["react-dom"])}(global,((__WEBPACK_EXTERNAL_MODULE__8156__,__WEBPACK_EXTERNAL_MODULE__11106__,__WEBPACK_EXTERNAL_MODULE__34756__,__WEBPACK_EXTERNAL_MODULE__47111__)=>(()=>{var __webpack_modules__={87757:(e,t,r)=>{e.exports=r(35666)},71265:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addAdminServicesToServer=t.registerAdminService=void 0;const r=[];t.registerAdminService=function(e,t){r.push({getServiceDefinition:e,getHandlers:t})},t.addAdminServicesToServer=function(e){for(const{getServiceDefinition:t,getHandlers:n}of r)e.addService(t(),n())}},43510:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BackoffTimeout=void 0,t.BackoffTimeout=class{constructor(e,t){this.callback=e,this.initialDelay=1e3,this.multiplier=1.6,this.maxDelay=12e4,this.jitter=.2,this.running=!1,this.hasRef=!0,this.startTime=new Date,t&&(t.initialDelay&&(this.initialDelay=t.initialDelay),t.multiplier&&(this.multiplier=t.multiplier),t.jitter&&(this.jitter=t.jitter),t.maxDelay&&(this.maxDelay=t.maxDelay)),this.nextDelay=this.initialDelay,this.timerId=setTimeout((()=>{}),0),clearTimeout(this.timerId)}runTimer(e){var t,r;clearTimeout(this.timerId),this.timerId=setTimeout((()=>{this.callback(),this.running=!1}),e),this.hasRef||null===(r=(t=this.timerId).unref)||void 0===r||r.call(t)}runOnce(){this.running=!0,this.startTime=new Date,this.runTimer(this.nextDelay);const e=Math.min(this.nextDelay*this.multiplier,this.maxDelay),t=e*this.jitter;var r,n;this.nextDelay=e+(r=-t,n=t,Math.random()*(n-r)+r)}stop(){clearTimeout(this.timerId),this.running=!1}reset(){if(this.nextDelay=this.initialDelay,this.running){const e=new Date,t=this.startTime;t.setMilliseconds(t.getMilliseconds()+this.nextDelay),clearTimeout(this.timerId),e<t?this.runTimer(t.getTime()-e.getTime()):this.running=!1}}isRunning(){return this.running}ref(){var e,t;this.hasRef=!0,null===(t=(e=this.timerId).ref)||void 0===t||t.call(e)}unref(){var e,t;this.hasRef=!1,null===(t=(e=this.timerId).unref)||void 0===t||t.call(e)}}},42766:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CallCredentialsFilterFactory=t.CallCredentialsFilter=void 0;const n=r(56994),a=r(53189),i=r(95165);class s extends n.BaseFilter{constructor(e,t){var r,n;super(),this.channel=e,this.stream=t,this.channel=e,this.stream=t;const a=t.getMethod().split("/");let s="";a.length>=2&&(s=a[1]);const o=null!==(n=null===(r=i.splitHostPort(t.getHost()))||void 0===r?void 0:r.host)&&void 0!==n?n:"localhost";this.serviceUrl=`https://${o}/${s}`}async sendMetadata(e){const t=this.stream.getCredentials().generateMetadata({service_url:this.serviceUrl}),r=await e;try{r.merge(await t)}catch(e){return this.stream.cancelWithStatus(a.Status.UNAUTHENTICATED,`Failed to retrieve auth metadata with error: ${e.message}`),Promise.reject("Failed to retrieve auth metadata")}return r.get("authorization").length>1?(this.stream.cancelWithStatus(a.Status.INTERNAL,'"authorization" metadata cannot have multiple values'),Promise.reject('"authorization" metadata cannot have multiple values')):r}}t.CallCredentialsFilter=s,t.CallCredentialsFilterFactory=class{constructor(e){this.channel=e,this.channel=e}createFilter(e){return new s(this.channel,e)}}},69587:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CallCredentials=void 0;const n=r(14664);class a{static createFromMetadataGenerator(e){return new s(e)}static createFromGoogleCredential(e){return a.createFromMetadataGenerator(((t,r)=>{let a;var i;a="getRequestHeaders"in(i=e)&&"function"==typeof i.getRequestHeaders?e.getRequestHeaders(t.service_url):new Promise(((r,n)=>{e.getRequestMetadata(t.service_url,((e,t)=>{e?n(e):r(t)}))})),a.then((e=>{const t=new n.Metadata;for(const r of Object.keys(e))t.add(r,e[r]);r(null,t)}),(e=>{r(e)}))}))}static createEmpty(){return new o}}t.CallCredentials=a;class i extends a{constructor(e){super(),this.creds=e}async generateMetadata(e){const t=new n.Metadata,r=await Promise.all(this.creds.map((t=>t.generateMetadata(e))));for(const e of r)t.merge(e);return t}compose(e){return new i(this.creds.concat([e]))}_equals(e){return this===e||e instanceof i&&this.creds.every(((t,r)=>t._equals(e.creds[r])))}}class s extends a{constructor(e){super(),this.metadataGenerator=e}generateMetadata(e){return new Promise(((t,r)=>{this.metadataGenerator(e,((e,n)=>{void 0!==n?t(n):r(e)}))}))}compose(e){return new i([this,e])}_equals(e){return this===e||e instanceof s&&this.metadataGenerator===e.metadataGenerator}}class o extends a{generateMetadata(e){return Promise.resolve(new n.Metadata)}compose(e){return e}_equals(e){return e instanceof o}}},72526:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Http2CallStream=t.InterceptingListenerImpl=t.isInterceptingListener=void 0;const n=r(85158),a=r(22037),i=r(53189),s=r(14664),o=r(91524),l=r(48626),d=r(53189),{HTTP2_HEADER_STATUS:p,HTTP2_HEADER_CONTENT_TYPE:u,NGHTTP2_CANCEL:c}=n.constants;t.isInterceptingListener=function(e){return void 0!==e.onReceiveMetadata&&1===e.onReceiveMetadata.length},t.InterceptingListenerImpl=class{constructor(e,t){this.listener=e,this.nextListener=t,this.processingMetadata=!1,this.hasPendingMessage=!1,this.processingMessage=!1,this.pendingStatus=null}processPendingMessage(){this.hasPendingMessage&&(this.nextListener.onReceiveMessage(this.pendingMessage),this.pendingMessage=null,this.hasPendingMessage=!1)}processPendingStatus(){this.pendingStatus&&this.nextListener.onReceiveStatus(this.pendingStatus)}onReceiveMetadata(e){this.processingMetadata=!0,this.listener.onReceiveMetadata(e,(e=>{this.processingMetadata=!1,this.nextListener.onReceiveMetadata(e),this.processPendingMessage(),this.processPendingStatus()}))}onReceiveMessage(e){this.processingMessage=!0,this.listener.onReceiveMessage(e,(e=>{this.processingMessage=!1,this.processingMetadata?(this.pendingMessage=e,this.hasPendingMessage=!0):(this.nextListener.onReceiveMessage(e),this.processPendingStatus())}))}onReceiveStatus(e){this.listener.onReceiveStatus(e,(e=>{this.processingMetadata||this.processingMessage?this.pendingStatus=e:this.nextListener.onReceiveStatus(e)}))}},t.Http2CallStream=class{constructor(e,t,r,n,a,l){this.methodName=e,this.channel=t,this.options=r,this.channelCallCredentials=a,this.callNumber=l,this.http2Stream=null,this.pendingRead=!1,this.isWriteFilterPending=!1,this.pendingWrite=null,this.pendingWriteCallback=null,this.writesClosed=!1,this.decoder=new o.StreamDecoder,this.isReadFilterPending=!1,this.canPush=!1,this.readsClosed=!1,this.statusOutput=!1,this.unpushedReadMessages=[],this.unfilteredReadMessages=[],this.mappedStatusCode=i.Status.UNKNOWN,this.finalStatus=null,this.subchannel=null,this.listener=null,this.internalError=null,this.configDeadline=1/0,this.statusWatchers=[],this.streamEndWatchers=[],this.callStatsTracker=null,this.filterStack=n.createFilter(this),this.credentials=a,this.disconnectListener=()=>{this.endCall({code:i.Status.UNAVAILABLE,details:"Connection dropped",metadata:new s.Metadata})},this.options.parentCall&&this.options.flags&i.Propagate.CANCELLATION&&this.options.parentCall.on("cancelled",(()=>{this.cancelWithStatus(i.Status.CANCELLED,"Cancelled by parent call")}))}outputStatus(){if(this.listener&&!this.statusOutput){this.statusOutput=!0;const e=this.filterStack.receiveTrailers(this.finalStatus);this.trace("ended with status: code="+e.code+' details="'+e.details+'"'),this.statusWatchers.forEach((t=>t(e))),process.nextTick((()=>{var t;null===(t=this.listener)||void 0===t||t.onReceiveStatus(e)})),this.subchannel&&(this.subchannel.callUnref(),this.subchannel.removeDisconnectListener(this.disconnectListener))}}trace(e){l.trace(d.LogVerbosity.DEBUG,"call_stream","["+this.callNumber+"] "+e)}endCall(e){null!==this.finalStatus&&this.finalStatus.code!==i.Status.OK||(this.finalStatus=e,this.maybeOutputStatus()),this.destroyHttp2Stream()}maybeOutputStatus(){null!==this.finalStatus&&(this.finalStatus.code!==i.Status.OK||this.readsClosed&&0===this.unpushedReadMessages.length&&0===this.unfilteredReadMessages.length&&!this.isReadFilterPending)&&this.outputStatus()}push(e){this.trace("pushing to reader message of length "+(e instanceof Buffer?e.length:null)),this.canPush=!1,process.nextTick((()=>{var t;this.statusOutput||(null===(t=this.listener)||void 0===t||t.onReceiveMessage(e),this.maybeOutputStatus())}))}handleFilterError(e){this.cancelWithStatus(i.Status.INTERNAL,e.message)}handleFilteredRead(e){if(null===this.finalStatus||this.finalStatus.code===i.Status.OK){if(this.isReadFilterPending=!1,this.canPush?(this.http2Stream.pause(),this.push(e)):(this.trace("unpushedReadMessages.push message of length "+e.length),this.unpushedReadMessages.push(e)),this.unfilteredReadMessages.length>0){const e=this.unfilteredReadMessages.shift();this.filterReceivedMessage(e)}}else this.maybeOutputStatus()}filterReceivedMessage(e){null===this.finalStatus||this.finalStatus.code===i.Status.OK?(this.trace("filterReceivedMessage of length "+e.length),this.isReadFilterPending=!0,this.filterStack.receiveMessage(Promise.resolve(e)).then(this.handleFilteredRead.bind(this),this.handleFilterError.bind(this))):this.maybeOutputStatus()}tryPush(e){this.isReadFilterPending?(this.trace("unfilteredReadMessages.push message of length "+(e&&e.length)),this.unfilteredReadMessages.push(e)):this.filterReceivedMessage(e)}handleTrailers(e){this.streamEndWatchers.forEach((e=>e(!0)));let t,r="";for(const t of Object.keys(e))r+="\t\t"+t+": "+e[t]+"\n";this.trace("Received server trailers:\n"+r);try{t=s.Metadata.fromHttp2Headers(e)}catch(e){t=new s.Metadata}const n=t.getMap();let a=this.mappedStatusCode;if(a===i.Status.UNKNOWN&&"string"==typeof n["grpc-status"]){const e=Number(n["grpc-status"]);e in i.Status&&(a=e,this.trace("received status code "+e+" from server")),t.remove("grpc-status")}let o="";"string"==typeof n["grpc-message"]&&(o=decodeURI(n["grpc-message"]),t.remove("grpc-message"),this.trace('received status details string "'+o+'" from server'));const l={code:a,details:o,metadata:t};this.endCall(l)}writeMessageToStream(e,t){var r;null===(r=this.callStatsTracker)||void 0===r||r.addMessageSent(),this.http2Stream.write(e,t)}attachHttp2Stream(e,t,r,o){if(this.filterStack.push(r),null!==this.finalStatus)e.close(c);else{if(this.trace("attachHttp2Stream from subchannel "+t.getAddress()),this.http2Stream=e,this.subchannel=t,this.callStatsTracker=o,t.addDisconnectListener(this.disconnectListener),t.callRef(),e.on("response",((e,t)=>{var r;let a="";for(const t of Object.keys(e))a+="\t\t"+t+": "+e[t]+"\n";switch(this.trace("Received server headers:\n"+a),e[":status"]){case 400:this.mappedStatusCode=i.Status.INTERNAL;break;case 401:this.mappedStatusCode=i.Status.UNAUTHENTICATED;break;case 403:this.mappedStatusCode=i.Status.PERMISSION_DENIED;break;case 404:this.mappedStatusCode=i.Status.UNIMPLEMENTED;break;case 429:case 502:case 503:case 504:this.mappedStatusCode=i.Status.UNAVAILABLE;break;default:this.mappedStatusCode=i.Status.UNKNOWN}if(t&n.constants.NGHTTP2_FLAG_END_STREAM)this.handleTrailers(e);else{let t;try{t=s.Metadata.fromHttp2Headers(e)}catch(e){return void this.endCall({code:i.Status.UNKNOWN,details:e.message,metadata:new s.Metadata})}try{const e=this.filterStack.receiveMetadata(t);null===(r=this.listener)||void 0===r||r.onReceiveMetadata(e)}catch(e){this.endCall({code:i.Status.UNKNOWN,details:e.message,metadata:new s.Metadata})}}})),e.on("trailers",this.handleTrailers.bind(this)),e.on("data",(e=>{this.trace("receive HTTP/2 data frame of length "+e.length);const t=this.decoder.write(e);for(const e of t)this.trace("parsed message of length "+e.length),this.callStatsTracker.addMessageReceived(),this.tryPush(e)})),e.on("end",(()=>{this.readsClosed=!0,this.maybeOutputStatus()})),e.on("close",(()=>{process.nextTick((()=>{var t;if(this.trace("HTTP/2 stream closed with code "+e.rstCode),(null===(t=this.finalStatus)||void 0===t?void 0:t.code)===i.Status.OK)return;let r,a="";switch(e.rstCode){case n.constants.NGHTTP2_NO_ERROR:if(null!==this.finalStatus)return;r=i.Status.INTERNAL,a=`Received RST_STREAM with code ${e.rstCode}`;break;case n.constants.NGHTTP2_REFUSED_STREAM:r=i.Status.UNAVAILABLE,a="Stream refused by server";break;case n.constants.NGHTTP2_CANCEL:r=i.Status.CANCELLED,a="Call cancelled";break;case n.constants.NGHTTP2_ENHANCE_YOUR_CALM:r=i.Status.RESOURCE_EXHAUSTED,a="Bandwidth exhausted or memory limit exceeded";break;case n.constants.NGHTTP2_INADEQUATE_SECURITY:r=i.Status.PERMISSION_DENIED,a="Protocol not secure enough";break;case n.constants.NGHTTP2_INTERNAL_ERROR:r=i.Status.INTERNAL,null===this.internalError?a=`Received RST_STREAM with code ${e.rstCode} (Internal server error)`:"ECONNRESET"===this.internalError.code||"ETIMEDOUT"===this.internalError.code?(r=i.Status.UNAVAILABLE,a=this.internalError.message):a=`Received RST_STREAM with code ${e.rstCode} triggered by internal client error: ${this.internalError.message}`;break;default:r=i.Status.INTERNAL,a=`Received RST_STREAM with code ${e.rstCode}`}this.endCall({code:r,details:a,metadata:new s.Metadata})}))})),e.on("error",(e=>{"ERR_HTTP2_STREAM_ERROR"!==e.code&&(this.trace("Node error event: message="+e.message+" code="+e.code+" errno="+function(e){for(const[t,r]of Object.entries(a.constants.errno))if(r===e)return t;return"Unknown system error "+e}(e.errno)+" syscall="+e.syscall),this.internalError=e),this.streamEndWatchers.forEach((e=>e(!1)))})),this.pendingRead||e.pause(),this.pendingWrite){if(!this.pendingWriteCallback)throw new Error("Invalid state in write handling code");this.trace("sending data chunk of length "+this.pendingWrite.length+" (deferred)");try{this.writeMessageToStream(this.pendingWrite,this.pendingWriteCallback)}catch(e){this.endCall({code:i.Status.UNAVAILABLE,details:`Write failed with error ${e.message}`,metadata:new s.Metadata})}}this.maybeCloseWrites()}}start(e,t){this.trace("Sending metadata"),this.listener=t,this.channel._startCallStream(this,e),this.maybeOutputStatus()}destroyHttp2Stream(){var e;if(null!==this.http2Stream&&!this.http2Stream.destroyed){let t;t=(null===(e=this.finalStatus)||void 0===e?void 0:e.code)===i.Status.OK?n.constants.NGHTTP2_NO_ERROR:n.constants.NGHTTP2_CANCEL,this.trace("close http2 stream with code "+t),this.http2Stream.close(t)}}cancelWithStatus(e,t){this.trace("cancelWithStatus code: "+e+' details: "'+t+'"'),this.endCall({code:e,details:t,metadata:new s.Metadata})}getDeadline(){const e=[this.options.deadline];return this.options.parentCall&&this.options.flags&i.Propagate.DEADLINE&&e.push(this.options.parentCall.getDeadline()),this.configDeadline&&e.push(this.configDeadline),function(e){let t=1/0;for(const r of e){const e=r instanceof Date?r.getTime():r;e<t&&(t=e)}return t}(e)}getCredentials(){return this.credentials}setCredentials(e){this.credentials=this.channelCallCredentials.compose(e)}getStatus(){return this.finalStatus}getPeer(){var e,t;return null!==(t=null===(e=this.subchannel)||void 0===e?void 0:e.getAddress())&&void 0!==t?t:this.channel.getTarget()}getMethod(){return this.methodName}getHost(){return this.options.host}setConfigDeadline(e){this.configDeadline=e}addStatusWatcher(e){this.statusWatchers.push(e)}addStreamEndWatcher(e){this.streamEndWatchers.push(e)}addFilters(e){this.filterStack.push(e)}getCallNumber(){return this.callNumber}startRead(){if(null!==this.finalStatus&&this.finalStatus.code!==i.Status.OK)return this.readsClosed=!0,void this.maybeOutputStatus();if(this.canPush=!0,null===this.http2Stream)this.pendingRead=!0;else{if(this.unpushedReadMessages.length>0){const e=this.unpushedReadMessages.shift();return void this.push(e)}this.http2Stream.resume()}}maybeCloseWrites(){this.writesClosed&&!this.isWriteFilterPending&&null!==this.http2Stream&&(this.trace("calling end() on HTTP/2 stream"),this.http2Stream.end())}sendMessageWithContext(e,t){this.trace("write() called with message of length "+t.length);const r={message:t,flags:e.flags},n=t=>{var r,n;let a=i.Status.UNAVAILABLE;"ERR_STREAM_WRITE_AFTER_END"===(null===(r=t)||void 0===r?void 0:r.code)&&(a=i.Status.INTERNAL),t&&this.cancelWithStatus(a,`Write error: ${t.message}`),null===(n=e.callback)||void 0===n||n.call(e)};this.isWriteFilterPending=!0,this.filterStack.sendMessage(Promise.resolve(r)).then((e=>{if(this.isWriteFilterPending=!1,null===this.http2Stream)this.trace("deferring writing data chunk of length "+e.message.length),this.pendingWrite=e.message,this.pendingWriteCallback=n;else{this.trace("sending data chunk of length "+e.message.length);try{this.writeMessageToStream(e.message,n)}catch(e){this.endCall({code:i.Status.UNAVAILABLE,details:`Write failed with error ${e.message}`,metadata:new s.Metadata})}this.maybeCloseWrites()}}),this.handleFilterError.bind(this))}halfClose(){this.trace("end() called"),this.writesClosed=!0,this.maybeCloseWrites()}}},13509:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ClientDuplexStreamImpl=t.ClientWritableStreamImpl=t.ClientReadableStreamImpl=t.ClientUnaryCallImpl=t.callErrorFromStatus=void 0;const n=r(82361),a=r(12781),i=r(53189);t.callErrorFromStatus=function(e){const t=`${e.code} ${i.Status[e.code]}: ${e.details}`;return Object.assign(new Error(t),e)};class s extends n.EventEmitter{constructor(){super()}cancel(){var e;null===(e=this.call)||void 0===e||e.cancelWithStatus(i.Status.CANCELLED,"Cancelled on client")}getPeer(){var e,t;return null!==(t=null===(e=this.call)||void 0===e?void 0:e.getPeer())&&void 0!==t?t:"unknown"}}t.ClientUnaryCallImpl=s;class o extends a.Readable{constructor(e){super({objectMode:!0}),this.deserialize=e}cancel(){var e;null===(e=this.call)||void 0===e||e.cancelWithStatus(i.Status.CANCELLED,"Cancelled on client")}getPeer(){var e,t;return null!==(t=null===(e=this.call)||void 0===e?void 0:e.getPeer())&&void 0!==t?t:"unknown"}_read(e){var t;null===(t=this.call)||void 0===t||t.startRead()}}t.ClientReadableStreamImpl=o;class l extends a.Writable{constructor(e){super({objectMode:!0}),this.serialize=e}cancel(){var e;null===(e=this.call)||void 0===e||e.cancelWithStatus(i.Status.CANCELLED,"Cancelled on client")}getPeer(){var e,t;return null!==(t=null===(e=this.call)||void 0===e?void 0:e.getPeer())&&void 0!==t?t:"unknown"}_write(e,t,r){var n;const a={callback:r},i=Number(t);Number.isNaN(i)||(a.flags=i),null===(n=this.call)||void 0===n||n.sendMessageWithContext(a,e)}_final(e){var t;null===(t=this.call)||void 0===t||t.halfClose(),e()}}t.ClientWritableStreamImpl=l;class d extends a.Duplex{constructor(e,t){super({objectMode:!0}),this.serialize=e,this.deserialize=t}cancel(){var e;null===(e=this.call)||void 0===e||e.cancelWithStatus(i.Status.CANCELLED,"Cancelled on client")}getPeer(){var e,t;return null!==(t=null===(e=this.call)||void 0===e?void 0:e.getPeer())&&void 0!==t?t:"unknown"}_read(e){var t;null===(t=this.call)||void 0===t||t.startRead()}_write(e,t,r){var n;const a={callback:r},i=Number(t);Number.isNaN(i)||(a.flags=i),null===(n=this.call)||void 0===n||n.sendMessageWithContext(a,e)}_final(e){var t;null===(t=this.call)||void 0===t||t.halfClose(),e()}}t.ClientDuplexStreamImpl=d},49357:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChannelCredentials=void 0;const n=r(24404),a=r(69587),i=r(98283);function s(e,t){if(e&&!(e instanceof Buffer))throw new TypeError(`${t}, if provided, must be a Buffer.`)}class o{constructor(e){this.callCredentials=e||a.CallCredentials.createEmpty()}_getCallCredentials(){return this.callCredentials}static createSsl(e,t,r,a){var o;if(s(e,"Root certificate"),s(t,"Private key"),s(r,"Certificate chain"),t&&!r)throw new Error("Private key must be given with accompanying certificate chain");if(!t&&r)throw new Error("Certificate chain must be given with accompanying private key");const l=n.createSecureContext({ca:null!==(o=null!=e?e:i.getDefaultRootsData())&&void 0!==o?o:void 0,key:null!=t?t:void 0,cert:null!=r?r:void 0,ciphers:i.CIPHER_SUITES});return new d(l,null!=a?a:{})}static createFromSecureContext(e,t){return new d(e,null!=t?t:{})}static createInsecure(){return new l}}t.ChannelCredentials=o;class l extends o{constructor(e){super(e)}compose(e){throw new Error("Cannot compose insecure credentials")}_getConnectionOptions(){return null}_isSecure(){return!1}_equals(e){return e instanceof l}}class d extends o{constructor(e,t){super(),this.secureContext=e,this.verifyOptions=t,this.connectionOptions={secureContext:e},(null==t?void 0:t.checkServerIdentity)&&(this.connectionOptions.checkServerIdentity=t.checkServerIdentity)}compose(e){const t=this.callCredentials.compose(e);return new p(this,t)}_getConnectionOptions(){return Object.assign({},this.connectionOptions)}_isSecure(){return!0}_equals(e){return this===e||e instanceof d&&this.secureContext===e.secureContext&&this.verifyOptions.checkServerIdentity===e.verifyOptions.checkServerIdentity}}class p extends o{constructor(e,t){super(t),this.channelCredentials=e}compose(e){const t=this.callCredentials.compose(e);return new p(this.channelCredentials,t)}_getConnectionOptions(){return this.channelCredentials._getConnectionOptions()}_isSecure(){return!0}_equals(e){return this===e||e instanceof p&&this.channelCredentials._equals(e.channelCredentials)&&this.callCredentials._equals(e.callCredentials)}}},38938:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.channelOptionsEqual=t.recognizedOptions=void 0,t.recognizedOptions={"grpc.ssl_target_name_override":!0,"grpc.primary_user_agent":!0,"grpc.secondary_user_agent":!0,"grpc.default_authority":!0,"grpc.keepalive_time_ms":!0,"grpc.keepalive_timeout_ms":!0,"grpc.keepalive_permit_without_calls":!0,"grpc.service_config":!0,"grpc.max_concurrent_streams":!0,"grpc.initial_reconnect_backoff_ms":!0,"grpc.max_reconnect_backoff_ms":!0,"grpc.use_local_subchannel_pool":!0,"grpc.max_send_message_length":!0,"grpc.max_receive_message_length":!0,"grpc.enable_http_proxy":!0,"grpc.enable_channelz":!0,"grpc.dns_min_time_between_resolutions_ms":!0,"grpc-node.max_session_memory":!0},t.channelOptionsEqual=function(e,t){const r=Object.keys(e).sort(),n=Object.keys(t).sort();if(r.length!==n.length)return!1;for(let a=0;a<r.length;a+=1){if(r[a]!==n[a])return!1;if(e[r[a]]!==t[n[a]])return!1}return!0}},72253:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChannelImplementation=void 0;const n=r(72526),a=r(49357),i=r(83970),s=r(90651),o=r(24219),l=r(53189),d=r(71882),p=r(42766),u=r(47169),c=r(94930),h=r(83513),m=r(48626),f=r(2829),g=r(86042),v=r(95165),y=r(40207),b=r(8950);let w=0;t.ChannelImplementation=class{constructor(e,t,r){var n,w,_,S;if(this.credentials=t,this.options=r,this.connectivityState=y.ConnectivityState.IDLE,this.currentPicker=new o.UnavailablePicker,this.configSelectionQueue=[],this.pickQueue=[],this.connectivityStateWatchers=[],this.configSelector=null,this.currentResolutionError=null,this.channelzEnabled=!0,this.callTracker=new b.ChannelzCallTracker,this.childrenTracker=new b.ChannelzChildrenTracker,"string"!=typeof e)throw new TypeError("Channel target must be a string");if(!(t instanceof a.ChannelCredentials))throw new TypeError("Channel credentials must be a ChannelCredentials object");if(r&&"object"!=typeof r)throw new TypeError("Channel options must be an object");this.originalTarget=e;const T=v.parseUri(e);if(null===T)throw new Error(`Could not parse target name "${e}"`);const C=h.mapUriDefaultScheme(T);if(null===C)throw new Error(`Could not find a default scheme for target name "${e}"`);this.callRefTimer=setInterval((()=>{}),2147483647),null===(w=(n=this.callRefTimer).unref)||void 0===w||w.call(n),0===this.options["grpc.enable_channelz"]&&(this.channelzEnabled=!1),this.channelzTrace=new b.ChannelzTrace,this.channelzRef=b.registerChannelzChannel(e,(()=>this.getChannelzInfo()),this.channelzEnabled),this.channelzEnabled&&this.channelzTrace.addTrace("CT_INFO","Channel created"),this.options["grpc.default_authority"]?this.defaultAuthority=this.options["grpc.default_authority"]:this.defaultAuthority=h.getDefaultAuthority(C);const E=g.mapProxyName(C,r);this.target=E.target,this.options=Object.assign({},this.options,E.extraOptions),this.subchannelPool=s.getSubchannelPool(0===(null!==(_=r["grpc.use_local_subchannel_pool"])&&void 0!==_?_:0));const I={createSubchannel:(e,t)=>{const r=this.subchannelPool.getOrCreateSubchannel(this.target,e,Object.assign({},this.options,t),this.credentials);return this.channelzEnabled&&this.channelzTrace.addTrace("CT_INFO","Created subchannel or used existing subchannel",r.getChannelzRef()),r},updateState:(e,t)=>{this.currentPicker=t;const r=this.pickQueue.slice();this.pickQueue=[],this.callRefTimerUnref();for(const{callStream:e,callMetadata:t,callConfig:n,dynamicFilters:a}of r)this.tryPick(e,t,n,a);this.updateState(e)},requestReresolution:()=>{throw new Error("Resolving load balancer should never call requestReresolution")},addChannelzChild:e=>{this.channelzEnabled&&this.childrenTracker.refChild(e)},removeChannelzChild:e=>{this.channelzEnabled&&this.childrenTracker.unrefChild(e)}};this.resolvingLoadBalancer=new i.ResolvingLoadBalancer(this.target,I,r,(e=>{this.channelzEnabled&&this.channelzTrace.addTrace("CT_INFO","Address resolution succeeded"),this.configSelector=e,this.currentResolutionError=null,process.nextTick((()=>{const e=this.configSelectionQueue;this.configSelectionQueue=[],this.callRefTimerUnref();for(const{callStream:t,callMetadata:r}of e)this.tryGetConfig(t,r);this.configSelectionQueue=[]}))}),(e=>{this.channelzEnabled&&this.channelzTrace.addTrace("CT_WARNING","Address resolution failed with code "+e.code+' and details "'+e.details+'"'),this.configSelectionQueue.length>0&&this.trace("Name resolution failed with calls queued for config selection"),null===this.configSelector&&(this.currentResolutionError=e);const t=this.configSelectionQueue;this.configSelectionQueue=[],this.callRefTimerUnref();for(const{callStream:r,callMetadata:n}of t)n.getOptions().waitForReady?(this.callRefTimerRef(),this.configSelectionQueue.push({callStream:r,callMetadata:n})):r.cancelWithStatus(e.code,e.details)})),this.filterStackFactory=new d.FilterStackFactory([new p.CallCredentialsFilterFactory(this),new u.DeadlineFilterFactory(this),new f.MaxMessageSizeFilterFactory(this.options),new c.CompressionFilterFactory(this,this.options)]),this.trace("Channel constructed with options "+JSON.stringify(r,void 0,2));const A=new Error;m.trace(l.LogVerbosity.DEBUG,"channel_stacktrace","("+this.channelzRef.id+") Channel constructed \n"+(null===(S=A.stack)||void 0===S?void 0:S.substring(A.stack.indexOf("\n")+1)))}getChannelzInfo(){return{target:this.originalTarget,state:this.connectivityState,trace:this.channelzTrace,callTracker:this.callTracker,children:this.childrenTracker.getChildLists()}}trace(e,t){m.trace(null!=t?t:l.LogVerbosity.DEBUG,"channel","("+this.channelzRef.id+") "+v.uriToString(this.target)+" "+e)}callRefTimerRef(){var e,t,r,n;(null===(t=(e=this.callRefTimer).hasRef)||void 0===t?void 0:t.call(e))||(this.trace("callRefTimer.ref | configSelectionQueue.length="+this.configSelectionQueue.length+" pickQueue.length="+this.pickQueue.length),null===(n=(r=this.callRefTimer).ref)||void 0===n||n.call(r))}callRefTimerUnref(){var e,t;this.callRefTimer.hasRef&&!this.callRefTimer.hasRef()||(this.trace("callRefTimer.unref | configSelectionQueue.length="+this.configSelectionQueue.length+" pickQueue.length="+this.pickQueue.length),null===(t=(e=this.callRefTimer).unref)||void 0===t||t.call(e))}pushPick(e,t,r,n){this.pickQueue.push({callStream:e,callMetadata:t,callConfig:r,dynamicFilters:n}),this.callRefTimerRef()}tryPick(e,t,r,n){var a,i;const s=this.currentPicker.pick({metadata:t,extraPickInfo:r.pickInformation}),d=s.subchannel?"("+s.subchannel.getChannelzRef().id+") "+s.subchannel.getAddress():""+s.subchannel;switch(this.trace("Pick result for call ["+e.getCallNumber()+"]: "+o.PickResultType[s.pickResultType]+" subchannel: "+d+" status: "+(null===(a=s.status)||void 0===a?void 0:a.code)+" "+(null===(i=s.status)||void 0===i?void 0:i.details)),s.pickResultType){case o.PickResultType.COMPLETE:if(null===s.subchannel)e.cancelWithStatus(l.Status.UNAVAILABLE,"Request dropped by load balancing policy");else{if(s.subchannel.getConnectivityState()!==y.ConnectivityState.READY){m.log(l.LogVerbosity.ERROR,"Error: COMPLETE pick result subchannel "+d+" has state "+y.ConnectivityState[s.subchannel.getConnectivityState()]),this.pushPick(e,t,r,n);break}e.filterStack.sendMetadata(Promise.resolve(t.clone())).then((a=>{var i,o,p;const u=s.subchannel.getConnectivityState();if(u===y.ConnectivityState.READY)try{const t=s.extraFilterFactories.map((t=>t.createFilter(e)));null===(i=s.subchannel)||void 0===i||i.getRealSubchannel().startCallStream(a,e,[...n,...t]),null===(o=r.onCommitted)||void 0===o||o.call(r),null===(p=s.onCallStarted)||void 0===p||p.call(s)}catch(a){const i=a.code;"ERR_HTTP2_GOAWAY_SESSION"===i||"ERR_HTTP2_INVALID_SESSION"===i?(this.trace("Failed to start call on picked subchannel "+d+" with error "+a.message+". Retrying pick",l.LogVerbosity.INFO),this.tryPick(e,t,r,n)):(this.trace("Failed to start call on picked subchanel "+d+" with error "+a.message+". Ending call",l.LogVerbosity.INFO),e.cancelWithStatus(l.Status.INTERNAL,`Failed to start HTTP/2 stream with error: ${a.message}`))}else this.trace("Picked subchannel "+d+" has state "+y.ConnectivityState[u]+" after metadata filters. Retrying pick",l.LogVerbosity.INFO),this.tryPick(e,t,r,n)}),(t=>{e.cancelWithStatus("number"==typeof t.code?t.code:l.Status.UNKNOWN,`Getting metadata from plugin failed with error: ${t.message}`)}))}break;case o.PickResultType.QUEUE:this.pushPick(e,t,r,n);break;case o.PickResultType.TRANSIENT_FAILURE:t.getOptions().waitForReady?this.pushPick(e,t,r,n):e.cancelWithStatus(s.status.code,s.status.details);break;case o.PickResultType.DROP:e.cancelWithStatus(s.status.code,s.status.details);break;default:throw new Error(`Invalid state: unknown pickResultType ${s.pickResultType}`)}}removeConnectivityStateWatcher(e){const t=this.connectivityStateWatchers.findIndex((t=>t===e));t>=0&&this.connectivityStateWatchers.splice(t,1)}updateState(e){m.trace(l.LogVerbosity.DEBUG,"connectivity_state","("+this.channelzRef.id+") "+v.uriToString(this.target)+" "+y.ConnectivityState[this.connectivityState]+" -> "+y.ConnectivityState[e]),this.channelzEnabled&&this.channelzTrace.addTrace("CT_INFO",y.ConnectivityState[this.connectivityState]+" -> "+y.ConnectivityState[e]),this.connectivityState=e;const t=this.connectivityStateWatchers.slice();for(const r of t)e!==r.currentState&&(r.timer&&clearTimeout(r.timer),this.removeConnectivityStateWatcher(r),r.callback());e!==y.ConnectivityState.TRANSIENT_FAILURE&&(this.currentResolutionError=null)}tryGetConfig(e,t){if(null===e.getStatus())if(null===this.configSelector)this.resolvingLoadBalancer.exitIdle(),this.currentResolutionError&&!t.getOptions().waitForReady?e.cancelWithStatus(this.currentResolutionError.code,this.currentResolutionError.details):(this.configSelectionQueue.push({callStream:e,callMetadata:t}),this.callRefTimerRef());else{const r=this.configSelector(e.getMethod(),t);if(r.status===l.Status.OK){if(r.methodConfig.timeout){const t=new Date;t.setSeconds(t.getSeconds()+r.methodConfig.timeout.seconds),t.setMilliseconds(t.getMilliseconds()+r.methodConfig.timeout.nanos/1e6),e.setConfigDeadline(t),e.filterStack.refresh()}if(r.dynamicFilterFactories.length>0){const n=new d.FilterStackFactory(r.dynamicFilterFactories).createFilter(e);n.sendMetadata(Promise.resolve(t)).then((t=>{this.tryPick(e,t,r,n.getFilters())}))}else this.tryPick(e,t,r,[])}else e.cancelWithStatus(r.status,"Failed to route call to method "+e.getMethod())}}_startCallStream(e,t){this.tryGetConfig(e,t.clone())}close(){this.resolvingLoadBalancer.destroy(),this.updateState(y.ConnectivityState.SHUTDOWN),clearInterval(this.callRefTimer),this.channelzEnabled&&b.unregisterChannelzRef(this.channelzRef),this.subchannelPool.unrefUnusedSubchannels()}getTarget(){return v.uriToString(this.target)}getConnectivityState(e){const t=this.connectivityState;return e&&this.resolvingLoadBalancer.exitIdle(),t}watchConnectivityState(e,t,r){if(this.connectivityState===y.ConnectivityState.SHUTDOWN)throw new Error("Channel has been shut down");let n=null;if(t!==1/0){const e=t instanceof Date?t:new Date(t),i=new Date;if(t===-1/0||e<=i)return void process.nextTick(r,new Error("Deadline passed without connectivity state change"));n=setTimeout((()=>{this.removeConnectivityStateWatcher(a),r(new Error("Deadline passed without connectivity state change"))}),e.getTime()-i.getTime())}const a={currentState:e,callback:r,timer:n};this.connectivityStateWatchers.push(a)}getChannelzRef(){return this.channelzRef}createCall(e,t,r,a,i){if("string"!=typeof e)throw new TypeError("Channel#createCall: method must be a string");if(!("number"==typeof t||t instanceof Date))throw new TypeError("Channel#createCall: deadline must be a number or Date");if(this.connectivityState===y.ConnectivityState.SHUTDOWN)throw new Error("Channel has been shut down");const s=function(){const e=w;return w+=1,w>=Number.MAX_SAFE_INTEGER&&(w=0),e}();this.trace("createCall ["+s+'] method="'+e+'", deadline='+t);const o={deadline:t,flags:null!=i?i:l.Propagate.DEFAULTS,host:null!=r?r:this.defaultAuthority,parentCall:a},d=new n.Http2CallStream(e,this,o,this.filterStackFactory,this.credentials._getCallCredentials(),s);return this.channelzEnabled&&(this.callTracker.addCallStarted(),d.addStatusWatcher((e=>{e.code===l.Status.OK?this.callTracker.addCallSucceeded():this.callTracker.addCallFailed()}))),d}}},8950:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setup=t.getChannelzServiceDefinition=t.getChannelzHandlers=t.unregisterChannelzRef=t.registerChannelzSocket=t.registerChannelzServer=t.registerChannelzSubchannel=t.registerChannelzChannel=t.ChannelzCallTracker=t.ChannelzChildrenTracker=t.ChannelzTrace=void 0;const n=r(41808),a=r(40207),i=r(53189),s=r(48741),o=r(71265),l=r(72011);function d(e){return{channel_id:e.id,name:e.name}}function p(e){return{subchannel_id:e.id,name:e.name}}function u(e){return{socket_id:e.id,name:e.name}}t.ChannelzTrace=class{constructor(){this.events=[],this.eventsLogged=0,this.creationTimestamp=new Date}addTrace(e,t,r){const n=new Date;this.events.push({description:t,severity:e,timestamp:n,childChannel:"channel"===(null==r?void 0:r.kind)?r:void 0,childSubchannel:"subchannel"===(null==r?void 0:r.kind)?r:void 0}),this.events.length>=64&&(this.events=this.events.slice(32)),this.eventsLogged+=1}getTraceMessage(){return{creation_timestamp:_(this.creationTimestamp),num_events_logged:this.eventsLogged,events:this.events.map((e=>({description:e.description,severity:e.severity,timestamp:_(e.timestamp),channel_ref:e.childChannel?d(e.childChannel):null,subchannel_ref:e.childSubchannel?p(e.childSubchannel):null})))}}},t.ChannelzChildrenTracker=class{constructor(){this.channelChildren=new Map,this.subchannelChildren=new Map,this.socketChildren=new Map}refChild(e){var t,r,n;switch(e.kind){case"channel":{let r=null!==(t=this.channelChildren.get(e.id))&&void 0!==t?t:{ref:e,count:0};r.count+=1,this.channelChildren.set(e.id,r);break}case"subchannel":{let t=null!==(r=this.subchannelChildren.get(e.id))&&void 0!==r?r:{ref:e,count:0};t.count+=1,this.subchannelChildren.set(e.id,t);break}case"socket":{let t=null!==(n=this.socketChildren.get(e.id))&&void 0!==n?n:{ref:e,count:0};t.count+=1,this.socketChildren.set(e.id,t);break}}}unrefChild(e){switch(e.kind){case"channel":{let t=this.channelChildren.get(e.id);void 0!==t&&(t.count-=1,0===t.count?this.channelChildren.delete(e.id):this.channelChildren.set(e.id,t));break}case"subchannel":{let t=this.subchannelChildren.get(e.id);void 0!==t&&(t.count-=1,0===t.count?this.subchannelChildren.delete(e.id):this.subchannelChildren.set(e.id,t));break}case"socket":{let t=this.socketChildren.get(e.id);void 0!==t&&(t.count-=1,0===t.count?this.socketChildren.delete(e.id):this.socketChildren.set(e.id,t));break}}}getChildLists(){const e=[];for(const{ref:t}of this.channelChildren.values())e.push(t);const t=[];for(const{ref:e}of this.subchannelChildren.values())t.push(e);const r=[];for(const{ref:e}of this.socketChildren.values())r.push(e);return{channels:e,subchannels:t,sockets:r}}},t.ChannelzCallTracker=class{constructor(){this.callsStarted=0,this.callsSucceeded=0,this.callsFailed=0,this.lastCallStartedTimestamp=null}addCallStarted(){this.callsStarted+=1,this.lastCallStartedTimestamp=new Date}addCallSucceeded(){this.callsSucceeded+=1}addCallFailed(){this.callsFailed+=1}};let c=1;function h(){return c++}const m=[],f=[],g=[],v=[];function y(e){if(""===e)return[];const t=e.split(":").map((e=>function(e){const t=Number.parseInt(e,16);return[t/256|0,t%256]}(e)));return[].concat(...t)}function b(e){if(n.isIPv4(e))return Buffer.from(Uint8Array.from(e.split(".").map((e=>Number.parseInt(e)))));if(n.isIPv6(e)){let t,r;const n=e.indexOf("::");-1===n?(t=e,r=""):(t=e.substring(0,n),r=e.substring(n+2));const a=Buffer.from(y(t)),i=Buffer.from(y(r)),s=Buffer.alloc(16-a.length-i.length,0);return Buffer.concat([a,s,i])}return null}function w(e){switch(e){case a.ConnectivityState.CONNECTING:return{state:"CONNECTING"};case a.ConnectivityState.IDLE:return{state:"IDLE"};case a.ConnectivityState.READY:return{state:"READY"};case a.ConnectivityState.SHUTDOWN:return{state:"SHUTDOWN"};case a.ConnectivityState.TRANSIENT_FAILURE:return{state:"TRANSIENT_FAILURE"};default:return{state:"UNKNOWN"}}}function _(e){if(!e)return null;const t=e.getTime();return{seconds:t/1e3|0,nanos:t%1e3*1e6}}function S(e){const t=e.getInfo();return{ref:d(e.ref),data:{target:t.target,state:w(t.state),calls_started:t.callTracker.callsStarted,calls_succeeded:t.callTracker.callsSucceeded,calls_failed:t.callTracker.callsFailed,last_call_started_timestamp:_(t.callTracker.lastCallStartedTimestamp),trace:t.trace.getTraceMessage()},channel_ref:t.children.channels.map((e=>d(e))),subchannel_ref:t.children.subchannels.map((e=>p(e)))}}function T(e,t){const r=Number.parseInt(e.request.channel_id),n=m[r];void 0!==n?t(null,{channel:S(n)}):t({code:i.Status.NOT_FOUND,details:"No channel data found for id "+r})}function C(e,t){const r=Number.parseInt(e.request.max_results),n=[];let a=Number.parseInt(e.request.start_channel_id);for(;a<m.length;a++){const e=m[a];if(void 0!==e&&(n.push(S(e)),n.length>=r))break}t(null,{channel:n,end:a>=g.length})}function E(e){const t=e.getInfo();return{ref:(r=e.ref,{server_id:r.id}),data:{calls_started:t.callTracker.callsStarted,calls_succeeded:t.callTracker.callsSucceeded,calls_failed:t.callTracker.callsFailed,last_call_started_timestamp:_(t.callTracker.lastCallStartedTimestamp),trace:t.trace.getTraceMessage()},listen_socket:t.listenerChildren.sockets.map((e=>u(e)))};var r}function I(e,t){const r=Number.parseInt(e.request.server_id),n=g[r];void 0!==n?t(null,{server:E(n)}):t({code:i.Status.NOT_FOUND,details:"No server data found for id "+r})}function A(e,t){const r=Number.parseInt(e.request.max_results),n=[];let a=Number.parseInt(e.request.start_server_id);for(;a<g.length;a++){const e=g[a];if(void 0!==e&&(n.push(E(e)),n.length>=r))break}t(null,{server:n,end:a>=g.length})}function x(e,t){const r=Number.parseInt(e.request.subchannel_id),n=f[r];if(void 0===n)return void t({code:i.Status.NOT_FOUND,details:"No subchannel data found for id "+r});const a=n.getInfo();t(null,{subchannel:{ref:p(n.ref),data:{target:a.target,state:w(a.state),calls_started:a.callTracker.callsStarted,calls_succeeded:a.callTracker.callsSucceeded,calls_failed:a.callTracker.callsFailed,last_call_started_timestamp:_(a.callTracker.lastCallStartedTimestamp),trace:a.trace.getTraceMessage()},socket_ref:a.children.sockets.map((e=>u(e)))}})}function O(e){var t;return s.isTcpSubchannelAddress(e)?{address:"tcpip_address",tcpip_address:{ip_address:null!==(t=b(e.host))&&void 0!==t?t:void 0,port:e.port}}:{address:"uds_address",uds_address:{filename:e.path}}}function R(e,t){var r,n,a,s,o;const l=Number.parseInt(e.request.socket_id),d=v[l];if(void 0===d)return void t({code:i.Status.NOT_FOUND,details:"No socket data found for id "+l});const p=d.getInfo(),c=p.security?{model:"tls",tls:{cipher_suite:p.security.cipherSuiteStandardName?"standard_name":"other_name",standard_name:null!==(r=p.security.cipherSuiteStandardName)&&void 0!==r?r:void 0,other_name:null!==(n=p.security.cipherSuiteOtherName)&&void 0!==n?n:void 0,local_certificate:null!==(a=p.security.localCertificate)&&void 0!==a?a:void 0,remote_certificate:null!==(s=p.security.remoteCertificate)&&void 0!==s?s:void 0}}:null;t(null,{socket:{ref:u(d.ref),local:p.localAddress?O(p.localAddress):null,remote:p.remoteAddress?O(p.remoteAddress):null,remote_name:null!==(o=p.remoteName)&&void 0!==o?o:void 0,security:c,data:{keep_alives_sent:p.keepAlivesSent,streams_started:p.streamsStarted,streams_succeeded:p.streamsSucceeded,streams_failed:p.streamsFailed,last_local_stream_created_timestamp:_(p.lastLocalStreamCreatedTimestamp),last_remote_stream_created_timestamp:_(p.lastRemoteStreamCreatedTimestamp),messages_received:p.messagesReceived,messages_sent:p.messagesSent,last_message_received_timestamp:_(p.lastMessageReceivedTimestamp),last_message_sent_timestamp:_(p.lastMessageSentTimestamp),local_flow_control_window:p.localFlowControlWindow?{value:p.localFlowControlWindow}:null,remote_flow_control_window:p.remoteFlowControlWindow?{value:p.remoteFlowControlWindow}:null}}})}function D(e,t){const r=Number.parseInt(e.request.server_id),n=g[r];if(void 0===n)return void t({code:i.Status.NOT_FOUND,details:"No server data found for id "+r});const a=Number.parseInt(e.request.start_socket_id),s=Number.parseInt(e.request.max_results),o=n.getInfo().sessionChildren.sockets.sort(((e,t)=>e.id-t.id)),l=[];let d=0;for(;d<o.length&&!(o[d].id>=a&&(l.push(u(o[d])),l.length>=s));d++);t(null,{socket_ref:l,end:d>=o.length})}function N(){return{GetChannel:T,GetTopChannels:C,GetServer:I,GetServers:A,GetSubchannel:x,GetSocket:R,GetServerSockets:D}}t.registerChannelzChannel=function(e,t,r){const n=h(),a={id:n,name:e,kind:"channel"};return r&&(m[n]={ref:a,getInfo:t}),a},t.registerChannelzSubchannel=function(e,t,r){const n=h(),a={id:n,name:e,kind:"subchannel"};return r&&(f[n]={ref:a,getInfo:t}),a},t.registerChannelzServer=function(e,t){const r=h(),n={id:r,kind:"server"};return t&&(g[r]={ref:n,getInfo:e}),n},t.registerChannelzSocket=function(e,t,r){const n=h(),a={id:n,name:e,kind:"socket"};return r&&(v[n]={ref:a,getInfo:t}),a},t.unregisterChannelzRef=function(e){switch(e.kind){case"channel":return void delete m[e.id];case"subchannel":return void delete f[e.id];case"server":return void delete g[e.id];case"socket":return void delete v[e.id]}},t.getChannelzHandlers=N;let k=null;function P(){if(k)return k;const e=(0,r(59421).J_)("channelz.proto",{keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0,includeDirs:[`${__dirname}/../../proto`]}),t=l.loadPackageDefinition(e);return k=t.grpc.channelz.v1.Channelz.service,k}t.getChannelzServiceDefinition=P,t.setup=function(){o.registerAdminService(P,N)}},3740:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getInterceptingCall=t.InterceptingCall=t.RequesterBuilder=t.ListenerBuilder=t.InterceptorConfigurationError=void 0;const n=r(14664),a=r(72526),i=r(53189);class s extends Error{constructor(e){super(e),this.name="InterceptorConfigurationError",Error.captureStackTrace(this,s)}}t.InterceptorConfigurationError=s,t.ListenerBuilder=class{constructor(){this.metadata=void 0,this.message=void 0,this.status=void 0}withOnReceiveMetadata(e){return this.metadata=e,this}withOnReceiveMessage(e){return this.message=e,this}withOnReceiveStatus(e){return this.status=e,this}build(){return{onReceiveMetadata:this.metadata,onReceiveMessage:this.message,onReceiveStatus:this.status}}},t.RequesterBuilder=class{constructor(){this.start=void 0,this.message=void 0,this.halfClose=void 0,this.cancel=void 0}withStart(e){return this.start=e,this}withSendMessage(e){return this.message=e,this}withHalfClose(e){return this.halfClose=e,this}withCancel(e){return this.cancel=e,this}build(){return{start:this.start,sendMessage:this.message,halfClose:this.halfClose,cancel:this.cancel}}};const o={onReceiveMetadata:(e,t)=>{t(e)},onReceiveMessage:(e,t)=>{t(e)},onReceiveStatus:(e,t)=>{t(e)}},l={start:(e,t,r)=>{r(e,t)},sendMessage:(e,t)=>{t(e)},halfClose:e=>{e()},cancel:e=>{e()}};t.InterceptingCall=class{constructor(e,t){var r,n,a,i;this.nextCall=e,this.processingMetadata=!1,this.pendingMessageContext=null,this.processingMessage=!1,this.pendingHalfClose=!1,this.requester=t?{start:null!==(r=t.start)&&void 0!==r?r:l.start,sendMessage:null!==(n=t.sendMessage)&&void 0!==n?n:l.sendMessage,halfClose:null!==(a=t.halfClose)&&void 0!==a?a:l.halfClose,cancel:null!==(i=t.cancel)&&void 0!==i?i:l.cancel}:l}cancelWithStatus(e,t){this.requester.cancel((()=>{this.nextCall.cancelWithStatus(e,t)}))}getPeer(){return this.nextCall.getPeer()}processPendingMessage(){this.pendingMessageContext&&(this.nextCall.sendMessageWithContext(this.pendingMessageContext,this.pendingMessage),this.pendingMessageContext=null,this.pendingMessage=null)}processPendingHalfClose(){this.pendingHalfClose&&this.nextCall.halfClose()}start(e,t){var r,n,i,s,l,d;const p={onReceiveMetadata:null!==(n=null===(r=null==t?void 0:t.onReceiveMetadata)||void 0===r?void 0:r.bind(t))&&void 0!==n?n:e=>{},onReceiveMessage:null!==(s=null===(i=null==t?void 0:t.onReceiveMessage)||void 0===i?void 0:i.bind(t))&&void 0!==s?s:e=>{},onReceiveStatus:null!==(d=null===(l=null==t?void 0:t.onReceiveStatus)||void 0===l?void 0:l.bind(t))&&void 0!==d?d:e=>{}};this.processingMetadata=!0,this.requester.start(e,p,((e,t)=>{var r,n,i;let s;if(this.processingMetadata=!1,a.isInterceptingListener(t))s=t;else{const e={onReceiveMetadata:null!==(r=t.onReceiveMetadata)&&void 0!==r?r:o.onReceiveMetadata,onReceiveMessage:null!==(n=t.onReceiveMessage)&&void 0!==n?n:o.onReceiveMessage,onReceiveStatus:null!==(i=t.onReceiveStatus)&&void 0!==i?i:o.onReceiveStatus};s=new a.InterceptingListenerImpl(e,p)}this.nextCall.start(e,s),this.processPendingMessage(),this.processPendingHalfClose()}))}sendMessageWithContext(e,t){this.processingMessage=!0,this.requester.sendMessage(t,(r=>{this.processingMessage=!1,this.processingMetadata?(this.pendingMessageContext=e,this.pendingMessage=t):(this.nextCall.sendMessageWithContext(e,r),this.processPendingHalfClose())}))}sendMessage(e){this.sendMessageWithContext({},e)}startRead(){this.nextCall.startRead()}halfClose(){this.requester.halfClose((()=>{this.processingMetadata||this.processingMessage?this.pendingHalfClose=!0:this.nextCall.halfClose()}))}setCredentials(e){this.nextCall.setCredentials(e)}};class d{constructor(e,t){this.call=e,this.methodDefinition=t}cancelWithStatus(e,t){this.call.cancelWithStatus(e,t)}getPeer(){return this.call.getPeer()}setCredentials(e){this.call.setCredentials(e)}sendMessageWithContext(e,t){let r;try{r=this.methodDefinition.requestSerialize(t)}catch(e){return void this.call.cancelWithStatus(i.Status.INTERNAL,`Request message serialization failure: ${e.message}`)}this.call.sendMessageWithContext(e,r)}sendMessage(e){this.sendMessageWithContext({},e)}start(e,t){let r=null;this.call.start(e,{onReceiveMetadata:e=>{var r;null===(r=null==t?void 0:t.onReceiveMetadata)||void 0===r||r.call(t,e)},onReceiveMessage:e=>{var a;let s;try{s=this.methodDefinition.responseDeserialize(e)}catch(e){return r={code:i.Status.INTERNAL,details:`Response message parsing error: ${e.message}`,metadata:new n.Metadata},void this.call.cancelWithStatus(r.code,r.details)}null===(a=null==t?void 0:t.onReceiveMessage)||void 0===a||a.call(t,s)},onReceiveStatus:e=>{var n,a;r?null===(n=null==t?void 0:t.onReceiveStatus)||void 0===n||n.call(t,r):null===(a=null==t?void 0:t.onReceiveStatus)||void 0===a||a.call(t,e)}})}startRead(){this.call.startRead()}halfClose(){this.call.halfClose()}}class p extends d{constructor(e,t){super(e,t)}start(e,t){var r,n;let a=!1;const i={onReceiveMetadata:null!==(n=null===(r=null==t?void 0:t.onReceiveMetadata)||void 0===r?void 0:r.bind(t))&&void 0!==n?n:e=>{},onReceiveMessage:e=>{var r;a=!0,null===(r=null==t?void 0:t.onReceiveMessage)||void 0===r||r.call(t,e)},onReceiveStatus:e=>{var r,n;a||null===(r=null==t?void 0:t.onReceiveMessage)||void 0===r||r.call(t,null),null===(n=null==t?void 0:t.onReceiveStatus)||void 0===n||n.call(t,e)}};super.start(e,i),this.call.startRead()}}class u extends d{}t.getInterceptingCall=function(e,t,r,n){if(e.clientInterceptors.length>0&&e.clientInterceptorProviders.length>0)throw new s("Both interceptors and interceptor_providers were passed as options to the client constructor. Only one of these is allowed.");if(e.callInterceptors.length>0&&e.callInterceptorProviders.length>0)throw new s("Both interceptors and interceptor_providers were passed as call options. Only one of these is allowed.");let a=[];a=e.callInterceptors.length>0||e.callInterceptorProviders.length>0?[].concat(e.callInterceptors,e.callInterceptorProviders.map((e=>e(t)))).filter((e=>e)):[].concat(e.clientInterceptors,e.clientInterceptorProviders.map((e=>e(t)))).filter((e=>e));const i=Object.assign({},r,{method_definition:t});return a.reduceRight(((e,t)=>r=>t(r,e)),(e=>function(e,t,r){const n=function(e,t,r){var n,a;const i=null!==(n=r.deadline)&&void 0!==n?n:1/0,s=r.host,o=null!==(a=r.parent)&&void 0!==a?a:null,l=r.propagate_flags,d=r.credentials,p=e.createCall(t,i,s,o,l);return d&&p.setCredentials(d),p}(e,r.path,t);return r.responseStream?new u(n,r):new p(n,r)}(n,e,t)))(i)}},8279:(e,t,