"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_exports = {};
__export(app_router_exports, {
  argsPattern: () => argsPattern,
  config: () => config
});
module.exports = __toCommonJS(app_router_exports);
var import_ts_pattern = require("ts-pattern");
var import_cache = require("next/cache");
var import_server = require("next/server");
var import_cache2 = require("../../cache");
var import_app_router_redirect_preview = require("../handlers/app-router-redirect-preview");
var import_preview = require("../preview");
var import_base = require("./base");
const argsPattern = [
  import_ts_pattern.P.union(import_ts_pattern.P.instanceOf(Request), import_ts_pattern.P.instanceOf(import_server.NextRequest)),
  import_ts_pattern.P.any
];
async function config({
  req,
  context,
  client
}) {
  return {
    req,
    route: (0, import_base.validateApiRoute)(await context.params),
    previewCookieNames: [import_preview.PRERENDER_BYPASS_COOKIE, import_preview.MAKESWIFT_SITE_VERSION_COOKIE],
    sendResponse: async (res) => res,
    revalidationHandler: async (path) => {
      if (path != null) {
        (0, import_cache.revalidatePath)(path);
      } else {
        (0, import_cache.revalidateTag)(import_cache2.MAKESWIFT_CACHE_TAG);
      }
    },
    customRoutes: async (route) => {
      if (route === "/redirect-preview") {
        const request = req instanceof import_server.NextRequest ? req : new import_server.NextRequest(req, req);
        return { res: await (0, import_app_router_redirect_preview.appRouterRedirectPreviewHandler)(request, context, client) };
      }
      return null;
    }
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  argsPattern,
  config
});
//# sourceMappingURL=app-router.js.map