import { ZodFirstPartyTypeKind as y } from "../../../../../../zod@3.24.4/node_modules/zod/lib/index.js";
import { parseDef as o } from "../parseDef.js";
import { parseStringDef as n } from "./string.js";
import { parseBrandedDef as i } from "./branded.js";
function c(e, t) {
  if (t.target === "openAi" && console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."), t.target === "openApi3" && e.keyType?._def.typeName === y.ZodEnum)
    return {
      type: "object",
      required: e.keyType._def.values,
      properties: e.keyType._def.values.reduce((a, r) => ({
        ...a,
        [r]: o(e.valueType._def, {
          ...t,
          currentPath: [...t.currentPath, "properties", r]
        }) ?? {}
      }), {}),
      additionalProperties: t.rejectedAdditionalProperties
    };
  const p = {
    type: "object",
    additionalProperties: o(e.valueType._def, {
      ...t,
      currentPath: [...t.currentPath, "additionalProperties"]
    }) ?? t.allowedAdditionalProperties
  };
  if (t.target === "openApi3")
    return p;
  if (e.keyType?._def.typeName === y.ZodString && e.keyType._def.checks?.length) {
    const { type: a, ...r } = n(e.keyType._def, t);
    return {
      ...p,
      propertyNames: r
    };
  } else {
    if (e.keyType?._def.typeName === y.ZodEnum)
      return {
        ...p,
        propertyNames: {
          enum: e.keyType._def.values
        }
      };
    if (e.keyType?._def.typeName === y.ZodBranded && e.keyType._def.type._def.typeName === y.ZodString && e.keyType._def.type._def.checks?.length) {
      const { type: a, ...r } = i(e.keyType._def, t);
      return {
        ...p,
        propertyNames: r
      };
    }
  }
  return p;
}
export {
  c as parseRecordDef
};
//# sourceMappingURL=record.js.map
