"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);

// src/preview-next/index.ts
var preview_next_exports = {};
__export(preview_next_exports, {
  PREVIEW_AUTH_ENTRY_PATH: () => PREVIEW_AUTH_ENTRY_PATH,
  PREVIEW_CODE_PARAM: () => PREVIEW_CODE_PARAM,
  PREVIEW_COOKIE_MAX_AGE: () => PREVIEW_COOKIE_MAX_AGE,
  PREVIEW_COOKIE_NAME: () => PREVIEW_COOKIE_NAME,
  PREVIEW_REFRESH_COOKIE_NAME: () => PREVIEW_REFRESH_COOKIE_NAME,
  PREVIEW_SURFACE_PARAM: () => PREVIEW_SURFACE_PARAM,
  PREVIEW_THEME_COOKIE_NAME: () => PREVIEW_THEME_COOKIE_NAME,
  clearPreviewCookies: () => clearPreviewCookies,
  setPreviewAuthCookies: () => setPreviewAuthCookies,
  setPreviewCookie: () => setPreviewCookie,
  setPreviewRefreshCookie: () => setPreviewRefreshCookie
});
module.exports = __toCommonJS(preview_next_exports);

// ../preview-next/src/constants.ts
var PREVIEW_COOKIE_NAME = "preview_token";
var PREVIEW_REFRESH_COOKIE_NAME = "preview_refresh_token";
var PREVIEW_COOKIE_MAX_AGE = 60 * 60 * 12;
var PREVIEW_CODE_PARAM = "preview_code";
var PREVIEW_AUTH_ENTRY_PATH = "/preview/auth";
var PREVIEW_SURFACE_PARAM = "preview_surface";
var PREVIEW_THEME_COOKIE_NAME = "preview_theme_id";

// ../preview-next/src/cookies.ts
function getPreviewCookieOptions(options = {}) {
  const { maxAge = PREVIEW_COOKIE_MAX_AGE, secure } = options;
  const resolvedSecure = secure ?? process.env.NODE_ENV === "production";
  return {
    httpOnly: true,
    secure: resolvedSecure,
    sameSite: "lax",
    path: "/",
    maxAge
  };
}
function setPreviewCookie(res, token, options) {
  res.cookies.set(PREVIEW_COOKIE_NAME, token, getPreviewCookieOptions(options));
  return res;
}
function setPreviewRefreshCookie(res, token, options) {
  res.cookies.set(PREVIEW_REFRESH_COOKIE_NAME, token, getPreviewCookieOptions(options));
  return res;
}
function setPreviewAuthCookies(res, {
  accessToken,
  refreshToken
}, options) {
  if (accessToken) {
    setPreviewCookie(res, accessToken, options);
  }
  if (refreshToken) {
    setPreviewRefreshCookie(res, refreshToken, options);
  }
  return res;
}
function clearPreviewCookies(res) {
  res.cookies.delete(PREVIEW_COOKIE_NAME);
  res.cookies.delete(PREVIEW_REFRESH_COOKIE_NAME);
  return res;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  PREVIEW_AUTH_ENTRY_PATH,
  PREVIEW_CODE_PARAM,
  PREVIEW_COOKIE_MAX_AGE,
  PREVIEW_COOKIE_NAME,
  PREVIEW_REFRESH_COOKIE_NAME,
  PREVIEW_SURFACE_PARAM,
  PREVIEW_THEME_COOKIE_NAME,
  clearPreviewCookies,
  setPreviewAuthCookies,
  setPreviewCookie,
  setPreviewRefreshCookie
});
//# sourceMappingURL=index.js.map