"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 });
exports.TRACE_UPLOAD_MAX_BYTES_ENV = void 0;
exports.resolveTraceUploadLimitBytes = resolveTraceUploadLimitBytes;
const DEFAULT_UPLOAD_BYTES = 5 * 1024 * 1024 * 1024;
const MIN_UPLOAD_BYTES = 16 * 1024 * 1024;
exports.TRACE_UPLOAD_MAX_BYTES_ENV = 'SMARTPERFETTO_TRACE_UPLOAD_MAX_BYTES';
function parsePositiveInteger(value) {
    if (!value)
        return null;
    const parsed = Number.parseInt(value, 10);
    return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
}
function resolveTraceUploadLimitBytes(env = process.env) {
    const configured = parsePositiveInteger(env[exports.TRACE_UPLOAD_MAX_BYTES_ENV]);
    if (configured) {
        return Math.max(configured, MIN_UPLOAD_BYTES);
    }
    return DEFAULT_UPLOAD_BYTES;
}
//# sourceMappingURL=traceUploadLimit.js.map