const EXTENSION_HEADER_PREFIX = "x-om-ext-";
function buildExtensionHeader(moduleId, key) {
  return `${EXTENSION_HEADER_PREFIX}${moduleId}-${key}`;
}
function parseExtensionHeaders(headers) {
  const result = {};
  for (const [headerName, value] of Object.entries(headers)) {
    const lower = headerName.toLowerCase();
    if (!lower.startsWith(EXTENSION_HEADER_PREFIX)) continue;
    const suffix = lower.slice(EXTENSION_HEADER_PREFIX.length);
    const dashIdx = suffix.indexOf("-");
    if (dashIdx === -1) continue;
    const moduleId = suffix.slice(0, dashIdx);
    const key = suffix.slice(dashIdx + 1);
    const headerValue = Array.isArray(value) ? value[0] : value;
    if (!headerValue) continue;
    if (!result[moduleId]) {
      result[moduleId] = {};
    }
    result[moduleId][key] = headerValue;
  }
  return result;
}
function getExtensionHeaderValue(headers, moduleId, key) {
  const headerName = buildExtensionHeader(moduleId, key);
  for (const [name, value] of Object.entries(headers)) {
    if (name.toLowerCase() === headerName) {
      return Array.isArray(value) ? value[0] : value;
    }
  }
  return void 0;
}
export {
  buildExtensionHeader,
  getExtensionHeaderValue,
  parseExtensionHeaders
};
//# sourceMappingURL=extension-headers.js.map
