"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.accessCallTrace = exports.traceCallLast = exports.traceCall = exports.tracingSymbol = void 0;
// ets_tracing: off
const Global_1 = require("./Global");
exports.tracingSymbol = "$trace";
let currentTraceCall;
function traceCall(f, trace) {
    if (!(0, Global_1.isTracingEnabled)() || !trace) {
        return f;
    }
    // @ts-expect-error
    return (...args) => {
        currentTraceCall = trace;
        const res = f(...args);
        currentTraceCall = undefined;
        return res;
    };
}
exports.traceCall = traceCall;
function traceCallLast(f, __trace) {
    return (a, t) => (t ? f(a, t) : f(a, __trace));
}
exports.traceCallLast = traceCallLast;
function accessCallTrace() {
    if (!(0, Global_1.isTracingEnabled)() || !currentTraceCall) {
        return undefined;
    }
    const callTrace = currentTraceCall;
    currentTraceCall = undefined;
    return callTrace;
}
exports.accessCallTrace = accessCallTrace;
__exportStar(require("./Global"), exports);
//# sourceMappingURL=index.js.map