"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var app_router_site_version_exports = {};
__export(app_router_site_version_exports, {
  getSiteVersion: () => getSiteVersion
});
module.exports = __toCommonJS(app_router_site_version_exports);
var import_headers = require("next/headers");
var import_site_version = require("../api/site-version");
var import_preview = require("./api-handler/preview");
async function getSiteVersion() {
  const { isEnabled: isDraftModeEnabled } = await (0, import_headers.draftMode)();
  if (!isDraftModeEnabled)
    return null;
  const allCookies = await (0, import_headers.cookies)();
  const cookie = allCookies.get(import_preview.MAKESWIFT_SITE_VERSION_COOKIE);
  if (cookie == null) {
    if (allCookies.get(import_preview.PRERENDER_BYPASS_COOKIE) == null) {
      console.error(
        "WARNING: Draft mode is enabled, but both the site version and the prerender bypass cookies are missing.\nThis is abnormal and could cause Makeswift editing and preview to not work as expected.\nDouble-check that you're not forcing static rendering (export const dynamic = 'force-static') on your Makeswift pages.\nMore info: https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamic"
      );
    }
    return null;
  }
  return (0, import_site_version.deserializeSiteVersion)(cookie.value);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  getSiteVersion
});
//# sourceMappingURL=app-router-site-version.js.map