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 graphiql_exports = {};
__export(graphiql_exports, {
  generateAuthHeaders: () => generateAuthHeaders
});
module.exports = __toCommonJS(graphiql_exports);
var import_dbAuthEncoder = require("../../lib/authProviderEncoders/dbAuthEncoder");
var import_netlifyAuthEncoder = require("../../lib/authProviderEncoders/netlifyAuthEncoder");
var import_supabaseAuthEncoder = require("../../lib/authProviderEncoders/supabaseAuthEncoder");
var import_project = require("../../util/project");
function getGraphiqlConfig() {
  return (0, import_project.getUserProjectConfig)().studio?.graphiql;
}
const generateAuthHeaders = async ({
  userId
}) => {
  const provider = getGraphiqlConfig()?.authImpersonation?.authProvider;
  const impersonateUserId = getGraphiqlConfig()?.authImpersonation?.userId;
  const email = getGraphiqlConfig()?.authImpersonation?.email;
  const secret = getGraphiqlConfig()?.authImpersonation?.jwtSecret;
  if (provider === "dbAuth") {
    return (0, import_dbAuthEncoder.getDBAuthHeader)(userId || impersonateUserId);
  }
  if (provider === "netlify") {
    return (0, import_netlifyAuthEncoder.getNetlifyAuthHeader)(userId || impersonateUserId, email, secret);
  }
  if (provider === "supabase") {
    return (0, import_supabaseAuthEncoder.getSupabaseAuthHeader)(userId || impersonateUserId, email);
  }
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  generateAuthHeaders
});
//# sourceMappingURL=graphiql.js.map
