"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SrpcServer = void 0;
const tslib_1 = require("tslib");
const __ΩReturnType = ['T', 'args', '', 'ReturnType', 'l>e"!R"RPde#!P"@2"h"!/#qk#\'QRb!Pde"!p)w$y'];
const __ΩNonNullable = ['T', 'NonNullable', 'b!Pe"!PMKw"y'];
const __ΩPartial = ['T', 'Partial', 'l+e#!e"!fRb!Pde"!gN#"w"y'];
function __assignType(fn, args) {
    fn.__type = args;
    return fn;
}
const framework_1 = require("@deepkit/framework");
/*@ts-ignore*/
var { __ΩScopedLogger } = require('@deepkit/logger');
const crypto_1 = require("crypto");
const ws_1 = tslib_1.__importDefault(require("ws"));
const resolver_1 = require("../app/resolver");
const helpers_1 = require("../helpers");
const services_1 = require("../services");
const telemetry_1 = require("../telemetry");
const SrpcByteStream_1 = require("./SrpcByteStream");
const WebSocketUpgradeHandler_1 = require("./WebSocketUpgradeHandler");
/*@ts-ignore*/
var { __ΩSrpcStream, __ΩRequestKeys, __ΩTSrpcMessageHandlerFnOrClass, __ΩSrpcDisconnectCause, __ΩIQueuedRequest, __ΩSrpcMeta, __ΩBaseMessage, __ΩSrpcMessageFns, __ΩISrpcServerOptions, __ΩHandlerRequestData, __ΩResponseData, __ΩRequestData } = require('./types');
const types_1 = require("./types");
const type_1 = require("@deepkit/type");
const StreamInfoSymbol = Symbol('srpc-info');
class SrpcServer {
    constructor(options) {
        this.options = options;
        this.streamConnectionHandlers = (Set.Ω = [[() => __ΩSrpcStream, 'stream', '', 'P!o!"2"$/#']], new Set());
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        this.streamMessageHandlers = (Map.Ω = [[() => __ΩRequestKeys, '!o!"'], ['resultType', () => __ΩTSrpcMessageHandlerFnOrClass, () => __ΩSrpcStream, 'handler', 'P&4!!o#"""o"$4$M']], new Map());
        this.streamDisconnectionHandlers = (Set.Ω = [[() => __ΩSrpcStream, 'stream', () => __ΩSrpcDisconnectCause, 'cause', '', 'P!o!"2"n#2$$/%']], new Set());
        this.streamsById = (Map.Ω = [['&'], [() => __ΩSrpcStream, '!o!"']], new Map());
        this.streamsByClientId = (Map.Ω = [['&'], [() => __ΩSrpcStream, '!o!"']], new Map());
        const logLevel = options.logLevel ?? 'info';
        if (logLevel === false) {
            const noop = (() => { });
            this.logger = { info: noop, warn: noop, error: noop, debug: noop };
            options.debug = false;
        }
        else if (logLevel === 'debug') {
            const base = options.logger;
            this.logger = {
                info: base.debug.bind(base),
                warn: base.warn.bind(base),
                error: base.error.bind(base),
                debug: base.debug.bind(base)
            };
        }
        else {
            this.logger = options.logger;
        }
        this.inboundType = options.clientMessage;
        this.outboundType = options.serverMessage;
        const appConfig = (0, resolver_1.getAppConfig)();
        this.standardSrpcAuthKey = appConfig.SRPC_AUTH_SECRET;
        this.authClockDriftMs = appConfig.SRPC_AUTH_CLOCK_DRIFT_MS;
        this.useRealIpHeader = appConfig.USE_REAL_IP_HEADER ?? false;
        // WebSocket server setup — use noServer mode so multiple ws servers
        // can coexist on the same HTTP server without aborting each other's
        // upgrade requests (the default `{ server, path }` mode aborts
        // non-matching upgrades, breaking other ws servers on the same port).
        const app = (0, resolver_1.r)(framework_1.ApplicationServer);
        this.httpServer = app.getHttpWorker()['server'];
        this.wsServer = new ws_1.default.Server({ noServer: true });
        this.wsServer.on('connection', this.attachConnection.bind(this));
        (0, WebSocketUpgradeHandler_1.installWebSocketUpgradeHandler)({
            httpServer: this.httpServer,
            wsPath: options.wsPath,
            wsServer: this.wsServer,
            verifyClient: this.verifyClient.bind(this)
        });
        this.logger.info('WebSocket server listening', { path: options.wsPath });
        this.inactivityCheckInterval = setInterval(() => this.terminateInactiveStreams(), 15_000);
    }
    ////////////////////////////////////////
    // WebSocket Connection Handling
    verifyClient(info, cb) {
        const url = new URL(info.req.url, 'http://localhost');
        const q = Object.fromEntries(url.searchParams.entries());
        const { id: clientStreamId, cid: clientId, appv: appVersion } = q;
        const address = (this.useRealIpHeader && info.req.headers['x-real-ip']) || info.req.socket.remoteAddress;
        this.logger.info('Incoming streaming WebSocket request', {
            address,
            clientStreamId,
            clientId,
            appVersion
        });
        if (!clientStreamId || !clientId || !appVersion) {
            this.logger.warn('Client missing required query parameters', { clientId, clientStreamId });
            cb(false, 400, 'Missing required query parameters');
            return;
        }
        this.validateClientAuth(q, info.req).then(__assignType(result => {
            if (!result) {
                this.logger.warn('Client failed authentication', { clientId, clientStreamId });
                // eslint-disable-next-line promise/no-callback-in-promise
                return cb(false, 403, 'Failed authentication');
            }
            const authMeta = result !== true ? result : undefined;
            const meta = Object.fromEntries(Object.entries(q)
                .filter(__assignType(([key]) => key.startsWith('m--'), ['param0', '', 'P"2!"/"']))
                .map(__assignType(([key, value]) => [key.slice(3), value], ['param0', '', 'P"2!"/"'])));
            // eslint-disable-next-line @typescript-eslint/no-explicit-any
            info.req[StreamInfoSymbol] = {
                clientStreamId,
                clientId,
                appVersion,
                configureTs: parseInt(q.ts ?? '0'),
                address,
                meta: {
                    ...meta,
                    ...authMeta
                }
            };
            // eslint-disable-next-line promise/no-callback-in-promise
            cb(true);
        }, ['result', '', 'P"2!"/"']), __assignType(err => {
            this.logger.error('Error validating client auth', err, { clientId, clientStreamId });
            // eslint-disable-next-line promise/no-callback-in-promise
            cb(false, 500, 'Error during authentication');
        }, ['err', '', 'P"2!"/"']));
    }
    attachConnection(ws, req) {
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        const { clientId, clientStreamId, appVersion, address, configureTs, meta } = req[StreamInfoSymbol];
        const streamId = (0, type_1.uuid)();
        this.logger.info('WebSocket request answered', {
            address,
            streamId,
            clientId,
            clientStreamId,
            meta
        });
        const now = Date.now();
        const stream = {
            $ws: ws,
            $queue: (Map.Ω = [['&'], [() => __ΩIQueuedRequest, 'n!']], new Map()),
            id: streamId,
            clientStreamId,
            address,
            clientId,
            appVersion,
            configureTs,
            connectedAt: now,
            lastPingAt: now,
            meta,
            byteStream: {
                parentStreamId: streamId,
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                write: __assignType((substreamId, chunk) => {
                    this.write(ws, { byteStreamOperation: { streamId: substreamId, write: { chunk } } });
                    return true;
                }, ['substreamId', 'chunk', '', 'P\'2!"2""/#']),
                finish: __assignType((substreamId) => {
                    this.write(ws, { byteStreamOperation: { streamId: substreamId, finish: {} } });
                }, ['substreamId', '', 'P\'2!"/"']),
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                destroy: __assignType((substreamId, err) => {
                    this.write(ws, {
                        byteStreamOperation: { streamId: substreamId, destroy: { error: err ? String(err) : undefined } }
                    });
                }, ['substreamId', 'err', '', 'P\'2!"2"8"/#']),
                attachDisconnectHandler: __assignType(function attachDisconnectHandler(handler) {
                    ws.on('close', handler);
                }, ['', 'handler', 'attachDisconnectHandler', 'PP$/!2""/#']),
                detachDisconnectHandler: __assignType(function detachDisconnectHandler(handler) {
                    ws.off('close', handler);
                }, ['', 'handler', 'detachDisconnectHandler', 'PP$/!2""/#']),
                getBufferedAmount: __assignType(function getBufferedAmount() {
                    return ws.bufferedAmount;
                }, ['getBufferedAmount', 'P"/!'])
            }
        };
        SrpcByteStream_1.SrpcByteStream.init(stream, { startId: 2, step: 2 });
        ws.on('message', __assignType(data => this.handleWsMessage(stream, data), ['data', '', 'P"2!"/"']));
        ws.on('error', __assignType(err => this.handleStreamError(stream, err), ['err', '', 'P"2!"/"']));
        ws.on('close', () => this.handleStreamDisconnected(stream));
        this.handleStreamEstablished(stream);
    }
    handleWsMessage(stream, data) {
        if (!(data instanceof Buffer)) {
            return this.closeStreamWithError(stream, 'badArg', 'Received non-binary data');
        }
        try {
            const decoded = this.inboundType.decode(data);
            this.handleStreamDataReceived(stream, decoded);
        }
        catch (error) {
            this.logger.warn('Failed to decode message', { error, streamId: stream.id, clientId: stream.clientId });
            return this.closeStreamWithError(stream, 'badArg', 'Invalid message format');
        }
    }
    write(ws, message) {
        const encoded = this.outboundType.encode(message).finish();
        ws.send(encoded);
    }
    writeToStream(stream, data) {
        this.write(stream.$ws, data);
    }
    closeStreamWithError(stream, cause, message) {
        stream.$ws.close(cause === 'disconnect' ? 1000 : 4000, message.substring(0, 123));
    }
    ////////////////////////////////////////
    // Authentication
    async validateClientAuth(meta, req) {
        if (this.clientAuthorizer) {
            return this.clientAuthorizer(meta, req);
        }
        const { authv, appv, ts, id, cid, signature } = meta;
        if (!meta.authv || !meta.appv || !meta.ts || !meta.signature) {
            throw new Error('Missing authorization metadata');
        }
        const clientKey = await this.fetchClientKey(cid);
        if (clientKey === false)
            return false;
        const tsInt = parseInt(ts, 10);
        if (isNaN(tsInt)) {
            this.logger.warn('Invalid timestamp');
            return false;
        }
        if (Math.abs(Date.now() - tsInt) > this.authClockDriftMs) {
            this.logger.warn('Timestamp expired');
            return false;
        }
        const computedSignature = (0, crypto_1.createHmac)('sha256', clientKey).update(`${authv}\n${appv}\n${ts}\n${id}\n${cid}\n`).digest('hex');
        const sigBuf = Buffer.from(signature ?? '');
        const computedBuf = Buffer.from(computedSignature);
        if (sigBuf.length !== computedBuf.length || !(0, crypto_1.timingSafeEqual)(sigBuf, computedBuf)) {
            this.logger.warn('Invalid signature');
            return false;
        }
        return true;
    }
    async fetchClientKey(clientId) {
        if (this.clientKeyFetcher)
            return this.clientKeyFetcher(clientId);
        if (!this.standardSrpcAuthKey) {
            throw new Error('SRPC_AUTH_SECRET is not configured.');
        }
        return this.standardSrpcAuthKey;
    }
    setClientAuthorizer(authorizer) {
        this.clientAuthorizer = authorizer;
    }
    setClientKeyFetcher(fetcher) {
        this.clientKeyFetcher = fetcher;
    }
    close() {
        clearInterval(this.inactivityCheckInterval);
        for (const stream of this.streamsById.values()) {
            this.cleanupStream(stream, 'disconnect');
        }
        this.wsServer.close();
    }
    ////////////////////////////////////////
    // Stream Lifecycle
    handleStreamEstablished(stream) {
        const conflictingStream = this.streamsByClientId.get(stream.clientId);
        if (conflictingStream) {
            this.logger.warn('Kicking existing stream with same client ID', {
                streamId: stream.id,
                clientId: stream.clientId,
                conflictingStreamId: conflictingStream.id
            });
            this.cleanupStream(conflictingStream, 'duplicate');
        }
        this.streamsById.set(stream.id, stream);
        this.streamsByClientId.set(stream.clientId, stream);
        this.streamConnectionHandlers.forEach(__assignType(handler => handler(stream), ['handler', '', 'P"2!"/"']));
        this.writeToStream(stream, { pingPong: {} });
    }
    handleStreamDisconnected(stream) {
        const { id: streamId, clientId } = stream;
        this.logger.info('Stream disconnected', { streamId, clientId });
        this.cleanupStream(stream);
    }
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    handleStreamError(stream, err) {
        const { id: streamId, clientId } = stream;
        this.logger.warn('Stream error', { err, streamId, clientId });
        this.cleanupStream(stream);
    }
    terminateInactiveStreams() {
        const deadlineMs = Date.now() - 75_000;
        for (const stream of this.streamsById.values()) {
            if (stream.lastPingAt < deadlineMs) {
                this.logger.warn('Terminating inactive stream', { streamId: stream.id, clientId: stream.clientId });
                this.cleanupStream(stream, 'timeout');
            }
        }
    }
    cleanupStream(stream, forceCause) {
        if (stream.lastPingAt < 0)
            return; // already cleaned up
        stream.lastPingAt = -1;
        if (forceCause)
            this.closeStreamWithError(stream, forceCause, `Stream terminated with cause: ${forceCause}`);
        this.streamDisconnectionHandlers.forEach(__assignType(handler => handler(stream, forceCause ?? 'disconnect'), ['handler', '', 'P"2!"/"']));
        stream.$queue.forEach(__assignType(item => item.reject(new Error('Stream disconnected')), ['item', '', 'P"2!"/"']));
        stream.$queue.clear();
        this.streamsById.delete(stream.id);
        if (this.streamsByClientId.get(stream.clientId) === stream) {
            this.streamsByClientId.delete(stream.clientId);
        }
    }
    ////////////////////////////////////////
    // Message Handling
    handleStreamDataReceived(stream, data) {
        if (data.pingPong) {
            stream.lastPingAt = Date.now();
            return this.writeToStream(stream, { pingPong: {} });
        }
        if (data.byteStreamOperation) {
            return this.handleByteSubstreamOperation(stream, data.byteStreamOperation);
        }
        const { id: streamId, clientId } = stream;
        const { requestId, reply } = data;
        const logObject = {
            streamId,
            clientId,
            requestId,
            reply,
            error: data.userError ? 'user' : data.error ? 'application' : undefined
        };
        this.logger[this.options.debug ? 'info' : 'debug']('Client message received', this.options.debug ? { ...logObject, data } : logObject);
        if (!requestId) {
            this.logger.warn('Invalid request ID', { srpc: { streamId, clientId, requestId } });
            return this.closeStreamWithError(stream, 'badArg', 'Invalid request ID');
        }
        if (reply) {
            const queueItem = stream.$queue.get(requestId);
            if (!queueItem) {
                this.logger.warn('Unknown request ID for reply', { srpc: { streamId, clientId, requestId } });
                return this.closeStreamWithError(stream, 'badArg', 'Unknown request ID');
            }
            stream.$queue.delete(requestId);
            if (data.error) {
                return queueItem.reject(new types_1.SrpcError(data.error, data.userError));
            }
            return queueItem.resolve(data);
        }
        this.handleClientRequest(stream, requestId, data).then(__assignType(response => {
            // eslint-disable-next-line @typescript-eslint/no-explicit-any
            this.writeToStream(stream, { requestId, reply: true, ...response });
        }, ['response', '', 'P"2!"/"']), __assignType(err => {
            this.logger.warn('Error processing client request', err, { srpc: { streamId, clientId, requestId } });
            const isUserError = err instanceof types_1.SrpcError && err.isUserError;
            this.writeToStream(stream, {
                requestId,
                reply: true,
                error: isUserError ? err.message : String(err),
                userError: isUserError
            });
        }, ['err', '', 'P"2!"/"']));
    }
    handleByteSubstreamOperation(stream, op) {
        if (op.write) {
            return SrpcByteStream_1.SrpcByteStream.writeReceiver(stream, op.streamId, op.write.chunk);
        }
        if (op.finish) {
            return SrpcByteStream_1.SrpcByteStream.finishReceiver(stream, op.streamId);
        }
        if (op.destroy) {
            return SrpcByteStream_1.SrpcByteStream.destroySubstream(stream, op.streamId, op.destroy.error);
        }
    }
    async handleClientRequest(stream, requestId, message) {
        const logMeta = { streamId: stream.id, clientId: stream.clientId, requestId };
        for (const key of this.streamMessageHandlers.keys()) {
            if (message[key]) {
                Object.assign(logMeta, { requestType: key });
                return (0, telemetry_1.withRemoteSpan)('srpc:handleClientRequest', message.trace, logMeta, () => (0, services_1.withLoggerContext)({ srpc: logMeta }, async () => {
                    try {
                        this.logger.info('Client request received');
                        const handlerMeta = this.streamMessageHandlers.get(key);
                        const result = await this.runMessageHandler(handlerMeta.handler, stream, message[key]);
                        this.logger.info('Client request processed');
                        return {
                            [handlerMeta.resultType]: result
                            // eslint-disable-next-line @typescript-eslint/no-explicit-any
                        };
                    }
                    catch (err) {
                        this.logger.warn('Client request failed', err);
                        throw err;
                    }
                }));
            }
        }
        throw new Error('Unhandled message type');
    }
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    async runMessageHandler(handler, stream, data) {
        if ((0, types_1.isSrpcMessageHandlerClass)(handler)) {
            // eslint-disable-next-line @typescript-eslint/no-explicit-any
            const handlerInstance = new handler();
            return handlerInstance.handle(stream, data);
        }
        return handler(stream, data);
    }
    ////////////////////////////////////////
    // Public API
    registerConnectionHandler(handler) {
        this.streamConnectionHandlers.add(handler);
    }
    /**
     * Register a handler for client requests.
     * @example server.registerMessageHandler('uEcho', async (stream, data) => ({ message: `Echo: ${data.message}` }))
     */
    registerMessageHandler(prefix, handler) {
        const actionType = `${prefix}Request`;
        const resultType = `${prefix}Response`;
        this.streamMessageHandlers.set(actionType, {
            resultType,
            handler
        });
    }
    registerDisconnectHandler(handler) {
        this.streamDisconnectionHandlers.add(handler);
    }
    /**
     * Invoke a client method.
     * @example server.invoke(stream, 'dNotify', { notification: 'hello' })
     */
    invoke(stream, prefix, data, timeoutMs = 30_000) {
        const requestType = `${prefix}Request`;
        const resultType = `${prefix}Response`;
        const requestId = (0, helpers_1.uuid7)();
        const traceContext = (0, telemetry_1.getTraceContext)();
        const trace = traceContext ? { traceId: traceContext.traceId, spanId: traceContext.spanId, traceFlags: traceContext.traceFlags } : undefined;
        const logMeta = { streamId: stream.id, clientId: stream.clientId, requestId, requestType };
        return (0, telemetry_1.withSpan)('srpc:invokeClient', logMeta, () => (0, services_1.withLoggerContext)({ srpc: logMeta }, async () => {
            try {
                this.logger.info('Requesting client invocation', this.options.debug ? { data } : undefined);
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                const response = await (Promise.Ω = [['"']], new Promise(__assignType((resolve, reject) => {
                    stream.$queue.set(requestId, {
                        exp: Date.now() + timeoutMs,
                        resolve,
                        reject
                    });
                    this.writeToStream(stream, { requestId, trace, [requestType]: data });
                }, ['resolve', 'reject', '', 'P"2!"2""/#'])));
                // Use null check instead of `in` for consistency with ts-proto field materialization
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                if (response[resultType] == null) {
                    throw new Error('Invalid response from client');
                }
                this.logger.info('Client invocation completed');
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                return response[resultType];
            }
            catch (err) {
                const isUserError = err instanceof types_1.SrpcError && err.isUserError;
                if (isUserError) {
                    this.logger.warn('Client invocation returned user error', { err: err.message });
                }
                else {
                    this.logger.warn('Client invocation failed', err);
                }
                throw err;
            }
        }));
    }
    static createInvoke(instanceFn) {
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        const fn = __assignType((...args) => {
            const instance = instanceFn();
            // eslint-disable-next-line prefer-spread, @typescript-eslint/no-explicit-any
            return instance.invoke.apply(instance, args);
        }, ['args', '', 'P"@2!"/"']);
        return fn;
    }
}
exports.SrpcServer = SrpcServer;
SrpcServer.__type = [() => __ΩSrpcMeta, 'TMeta', () => __ΩBaseMessage, 'TClientOutput', () => __ΩBaseMessage, 'TServerOutput', 'standardSrpcAuthKey', 'authClockDriftMs', 'useRealIpHeader', () => __ΩScopedLogger, 'logger', 'wsServer', 'httpServer', () => __ΩSrpcMessageFns, 'inboundType', () => __ΩSrpcMessageFns, 'outboundType', () => __ΩSrpcMeta, 'metadata', 'req', () => __ΩSrpcMeta, '', 'clientAuthorizer', 'clientId', false, 'clientKeyFetcher', 'streamConnectionHandlers', function () { return (Set.Ω = [[() => __ΩSrpcStream, 'stream', '', 'P!o!"2"$/#']], new Set()); }, 'streamMessageHandlers', function () { return (Map.Ω = [[() => __ΩRequestKeys, '!o!"'], ['resultType', () => __ΩTSrpcMessageHandlerFnOrClass, () => __ΩSrpcStream, 'handler', 'P&4!!o#"""o"$4$M']], new Map()); }, 'streamDisconnectionHandlers', function () { return (Set.Ω = [[() => __ΩSrpcStream, 'stream', () => __ΩSrpcDisconnectCause, 'cause', '', 'P!o!"2"n#2$$/%']], new Set()); }, () => __ΩReturnType, () => setInterval, 'inactivityCheckInterval', 'streamsById', function () { return (Map.Ω = [['&'], [() => __ΩSrpcStream, '!o!"']], new Map()); }, 'streamsByClientId', function () { return (Map.Ω = [['&'], [() => __ΩSrpcStream, '!o!"']], new Map()); }, () => __ΩISrpcServerOptions, 'options', 'constructor', 'origin', 'secure', 'info', 'res', 'code', 'message', 'cb', 'verifyClient', () => ws_1.default, 'ws', 'attachConnection', () => __ΩSrpcStream, 'stream', 'data', 'handleWsMessage', () => ws_1.default, 'write', () => __ΩSrpcStream, 'writeToStream', () => __ΩSrpcStream, () => __ΩSrpcDisconnectCause, 'cause', 'closeStreamWithError', () => __ΩSrpcMeta, 'meta', 'validateClientAuth', 'fetchClientKey', () => __ΩSrpcMeta, () => __ΩSrpcMeta, 'authorizer', 'setClientAuthorizer', false, 'fetcher', 'setClientKeyFetcher', 'close', () => __ΩSrpcStream, 'handleStreamEstablished', () => __ΩSrpcStream, 'handleStreamDisconnected', () => __ΩSrpcStream, 'err', 'handleStreamError', 'terminateInactiveStreams', () => __ΩSrpcStream, () => __ΩSrpcDisconnectCause, 'forceCause', 'cleanupStream', () => __ΩSrpcStream, 'handleStreamDataReceived', () => __ΩSrpcStream, () => __ΩNonNullable, "byteStreamOperation", 'op', 'handleByteSubstreamOperation', () => __ΩSrpcStream, 'requestId', () => __ΩPartial, 'handleClientRequest', () => __ΩTSrpcMessageHandlerFnOrClass, () => __ΩSrpcStream, 'handler', () => __ΩSrpcStream, 'runMessageHandler', () => __ΩSrpcStream, 'registerConnectionHandler', 'prefix', () => __ΩTSrpcMessageHandlerFnOrClass, () => __ΩSrpcStream, () => __ΩHandlerRequestData, () => __ΩResponseData, 'registerMessageHandler', () => __ΩSrpcStream, () => __ΩSrpcDisconnectCause, 'registerDisconnectHandler', () => __ΩSrpcStream, () => __ΩRequestData, 'timeoutMs', () => __ΩResponseData, 'invoke', () => SrpcServer, 'instanceFn', () => SrpcServer, "invoke", 'createInvoke', 'SrpcServer', 'n!c"n#c$n%c&&3\'8;\'3(;)3);n*3+;!3,;!3-;e!"o."3/;e!#o0"31;Pn223!24P)n5J`/6378;P&28P.9&J`/63:8;!3;;><!3=;>>!3?;>@iBoA"3C;!3D9>E!3F9>GPe""e"#oH#2I;"0JPP&4K)4L!44M2MP)2N\'2O8&2P8$/62Q"0R;PP7S2T!24"0U;Pe"!oV"2W!2X"0Y;PP7Z2Te"#2P"0[;Pe"!o\\"2We"#2X$0];Pe"!o^"2Wn_2`&2P"0a;Pnb2c!24"0d;P&28"0e;PPnf23!24P)ngJ`/62h"0iPP&28P.j&J`/62k"0lP"0mPe"!on"2W"0o;Pe"!op"2W$0q;Pe"!or"2W"2s$0t;P"0u;Pe"!ov"2Wnw2x8"0y;Pe"!oz"2We""2X$0{;Pe"!o|"2We"".~fo}"2$0\u0080;Pe"!o\u0081"2W&2\u0082e""2Pe"#o\u0083"`0\u0084;Pe"!o\u0086"""o\u0085$2\u0087e"!o\u0088"2W"2X"0\u0089;PPe#!o\u008A"2W$/62\u0087"0\u008BP"2\u008Ce"!o\u008E"e"""o\u008F#e"#"o\u0090#o\u008D$2\u0087"0\u0091PPe#!o\u0092"2Wn\u00932`$/62\u0087"0\u0094Pe"!o\u0095"2W"2\u008Ce"#"o\u0096#2X"2\u0097e"""o\u0098#`0\u0099PPP"""7\u009A/62\u009BP"""7\u009C.\u009Df0\u009Es5w\u009F'];
//# sourceMappingURL=SrpcServer.js.map