import {
  InvalidRequest2
} from "../chunk-FO7L563E.js";
import "../chunk-IUKLHJNE.js";
import "../chunk-FRWSD3YQ.js";
import "../chunk-QAE2S7MG.js";
import "../chunk-X6XO7USX.js";
import "../chunk-UT2RMOJS.js";
import "../chunk-TJ744C2T.js";
import "../chunk-64IS37V6.js";
import "../chunk-XLUI7RQ4.js";
import "../chunk-JBVMOFGH.js";
import "../chunk-JSBRDJBE.js";

// src/lambda/origin-response.ts
function createOriginRequestHandler() {
  return async function handler2(event) {
    const request = event.Records[0]?.cf?.request;
    const response = event.Records[0]?.cf?.response;
    if (request == null || response == null) {
      throw new InvalidRequest2("invalid request");
    }
    const bundleUrl = request.headers["x-bundle"]?.[0]?.value;
    if (bundleUrl == null) {
      return response;
    }
    const deploymentId = response.headers["x-amz-meta-x-deployment-id"]?.[0]?.value;
    if (deploymentId != null) {
      response.headers["x-deployment-id"] = [
        {
          key: "X-Deployment-Id",
          value: deploymentId
        }
      ];
    }
    const deployedAt = response.headers["x-amz-meta-x-deployment-deployed-at"]?.[0]?.value;
    if (deployedAt != null) {
      response.headers["x-deployed-at"] = [
        {
          key: "X-Deployed-At",
          value: deployedAt
        }
      ];
    }
    return response;
  };
}
var handler = createOriginRequestHandler();
export {
  createOriginRequestHandler,
  handler
};
