'use strict';

function kebabCase(key) {
  const result = key.replace(/([A-Z])/g, " $1").trim();
  return result.split(" ").join("-").toLowerCase();
}
const GiimeResolver = () => {
  return [
    {
      type: "component",
      resolve: async (name) => {
        if (!name.match(/^Gm[A-Z]/)) return;
        return { name, from: "giime" };
      }
    },
    {
      type: "directive",
      resolve: async () => {
        return;
      }
    }
  ];
};
const bypass = (req, res, options, giimeOptions) => {
  const targetPath = new URL(options.target?.toString() ?? "").pathname.replace(/\/$/, "");
  const rewrittenPath = options.rewrite?.(req.url) ?? "";
  const fullPath = `${targetPath}${rewrittenPath}`;
  const proxyUrl = new URL(fullPath, options.target?.toString());
  if (giimeOptions?.showLog) {
    console.log("proxyUrl", proxyUrl.toString());
  }
  res?.setHeader("x-giime-proxy-url", proxyUrl.toString());
};

exports.GiimeResolver = GiimeResolver;
exports.bypass = bypass;
exports.kebabCase = kebabCase;
//# sourceMappingURL=resolver.js.map
