"use strict";
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2024-2026 Gracker (Chris)
// This file is part of SmartPerfetto. See LICENSE for details.
Object.defineProperty(exports, "__esModule", { value: true });
const worker_threads_1 = require("worker_threads");
const traceProcessorHttpRpcClient_1 = require("./traceProcessorHttpRpcClient");
if (!worker_threads_1.parentPort) {
    throw new Error('traceProcessorSqlWorkerThread must run inside a worker_thread');
}
worker_threads_1.parentPort.on('message', (message) => {
    void (async () => {
        try {
            const body = await (0, traceProcessorHttpRpcClient_1.executeTraceProcessorHttpRpcRaw)({
                hostname: message.hostname,
                port: message.port,
                body: Buffer.from(message.body),
                timeoutMs: message.timeoutMs,
            });
            worker_threads_1.parentPort.postMessage({
                id: message.id,
                ok: true,
                body,
            });
        }
        catch (error) {
            worker_threads_1.parentPort.postMessage({
                id: message.id,
                ok: false,
                error: error?.message || String(error),
            });
        }
    })();
});
//# sourceMappingURL=traceProcessorSqlWorkerThread.js.map