import { parseDef as p } from "../parseDef.js";
import { primitiveMappings as i } from "./union.js";
function u(e, n) {
  if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(e.innerType._def.typeName) && (!e.innerType._def.checks || !e.innerType._def.checks.length))
    return n.target === "openApi3" ? {
      type: i[e.innerType._def.typeName],
      nullable: !0
    } : {
      type: [
        i[e.innerType._def.typeName],
        "null"
      ]
    };
  if (n.target === "openApi3") {
    const r = p(e.innerType._def, {
      ...n,
      currentPath: [...n.currentPath]
    });
    return r && "$ref" in r ? { allOf: [r], nullable: !0 } : r && { ...r, nullable: !0 };
  }
  const t = p(e.innerType._def, {
    ...n,
    currentPath: [...n.currentPath, "anyOf", "0"]
  });
  return t && { anyOf: [t, { type: "null" }] };
}
export {
  u as parseNullableDef
};
//# sourceMappingURL=nullable.js.map
