import { ZodOptional as u } from "../../../../../../zod@3.24.4/node_modules/zod/lib/index.js";
import { parseDef as l } from "../parseDef.js";
function y(r, e) {
  const s = e.target === "openAi", n = {
    type: "object",
    properties: {}
  }, o = [], p = r.shape();
  for (const i in p) {
    let t = p[i];
    if (t === void 0 || t._def === void 0)
      continue;
    let a = h(t);
    a && s && (t instanceof u && (t = t._def.innerType), t.isNullable() || (t = t.nullable()), a = !1);
    const c = l(t._def, {
      ...e,
      currentPath: [...e.currentPath, "properties", i],
      propertyPath: [...e.currentPath, "properties", i]
    });
    c !== void 0 && (n.properties[i] = c, a || o.push(i));
  }
  o.length && (n.required = o);
  const d = f(r, e);
  return d !== void 0 && (n.additionalProperties = d), n;
}
function f(r, e) {
  if (r.catchall._def.typeName !== "ZodNever")
    return l(r.catchall._def, {
      ...e,
      currentPath: [...e.currentPath, "additionalProperties"]
    });
  switch (r.unknownKeys) {
    case "passthrough":
      return e.allowedAdditionalProperties;
    case "strict":
      return e.rejectedAdditionalProperties;
    case "strip":
      return e.removeAdditionalStrategy === "strict" ? e.allowedAdditionalProperties : e.rejectedAdditionalProperties;
  }
}
function h(r) {
  try {
    return r.isOptional();
  } catch {
    return !0;
  }
}
export {
  y as parseObjectDef
};
//# sourceMappingURL=object.js.map
