"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
0 && (module.exports = {
    getExpectedRequestStore: null,
    requestAsyncStorage: null
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    getExpectedRequestStore: function() {
        return getExpectedRequestStore;
    },
    requestAsyncStorage: function() {
        return _requestasyncstorageinstance.requestAsyncStorage;
    }
});
const _requestasyncstorageinstance = require("./request-async-storage-instance");
const _cacheasyncstorageexternal = require("../../server/app-render/cache-async-storage.external");
const _prerenderasyncstorageexternal = require("../../server/app-render/prerender-async-storage.external");
function getExpectedRequestStore(callingExpression) {
    const prerenderStore = _prerenderasyncstorageexternal.prerenderAsyncStorage.getStore();
    if (prerenderStore) {
        // This should not happen because we should have checked it already.
        throw new Error("`" + callingExpression + "` cannot be called inside a prerender. This is a bug in Next.js.");
    }
    const store = _requestasyncstorageinstance.requestAsyncStorage.getStore();
    if (store) return store;
    const cacheStore = _cacheasyncstorageexternal.cacheAsyncStorage.getStore();
    if (cacheStore) {
        if (cacheStore.type === 'cache') {
            throw new Error("`" + callingExpression + '` cannot be called inside "use cache". Call it outside and pass an argument instead. Read more: https://nextjs.org/docs/messages/next-request-in-use-cache');
        } else if (cacheStore.type === 'unstable-cache') {
            throw new Error("`" + callingExpression + "` cannot be called inside unstable_cache. Call it outside and pass an argument instead. Read more: https://nextjs.org/docs/app/api-reference/functions/unstable_cache");
        }
    }
    throw new Error("`" + callingExpression + "` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context");
}

if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
  Object.defineProperty(exports.default, '__esModule', { value: true });
  Object.assign(exports.default, exports);
  module.exports = exports.default;
}

//# sourceMappingURL=request-async-storage.external.js.map