"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    getCallbackManager: function() {
        return getCallbackManager;
    },
    setCallbackManager: function() {
        return setCallbackManager;
    },
    withCallbackManager: function() {
        return withCallbackManager;
    }
});
const _env = require("@llamaindex/env");
const _CallbackManager = require("../../callbacks/CallbackManager.js");
const callbackManagerAsyncLocalStorage = new _env.AsyncLocalStorage();
let globalCallbackManager = null;
function getCallbackManager() {
    if (globalCallbackManager === null) {
        globalCallbackManager = new _CallbackManager.CallbackManager();
    }
    return callbackManagerAsyncLocalStorage.getStore() ?? globalCallbackManager;
}
function setCallbackManager(callbackManager) {
    globalCallbackManager = callbackManager;
}
function withCallbackManager(callbackManager, fn) {
    return callbackManagerAsyncLocalStorage.run(callbackManager, fn);
}
