'use strict';

var chunkYGD6CZV4_cjs = require('./chunk-YGD6CZV4.cjs');
var async_hooks = require('async_hooks');

var spanContextStorage = new async_hooks.AsyncLocalStorage();
function getCurrentSpan() {
  return spanContextStorage.getStore();
}
var initialized = false;
function initContextStorage() {
  if (initialized) return;
  initialized = true;
  chunkYGD6CZV4_cjs.setCurrentSpanResolver(getCurrentSpan);
  chunkYGD6CZV4_cjs.setExecuteWithContext(executeWithContext);
  chunkYGD6CZV4_cjs.setExecuteWithContextSync(executeWithContextSync);
}
async function executeWithContext(params) {
  const { span, fn } = params;
  const wrappedFn = span ? () => spanContextStorage.run(span, fn) : fn;
  if (span?.executeInContext) {
    return span.executeInContext(wrappedFn);
  }
  return wrappedFn();
}
function executeWithContextSync(params) {
  const { span, fn } = params;
  const wrappedFn = span ? () => spanContextStorage.run(span, fn) : fn;
  if (span?.executeInContextSync) {
    return span.executeInContextSync(wrappedFn);
  }
  return wrappedFn();
}

exports.executeWithContext = executeWithContext;
exports.executeWithContextSync = executeWithContextSync;
exports.getCurrentSpan = getCurrentSpan;
exports.initContextStorage = initContextStorage;
//# sourceMappingURL=chunk-6ZDWJUUO.cjs.map
//# sourceMappingURL=chunk-6ZDWJUUO.cjs.map