function o(t) {
  if (!t)
    return null;
  if ("title" in t && t.title)
    return t.title;
  if ("name" in t && t.name)
    return t.name;
  if ("$ref" in t) {
    const i = t.$ref.match(/\/([^\/]+)$/);
    if (i)
      return i[1];
  }
  return null;
}
function e(t, n) {
  return t === "array" ? `${t} ${n}[]` : `${t} ${n}`;
}
function p(t, n, i = !1, y) {
  if (!(t != null && t.type) || i)
    return null;
  const r = o(t);
  if (r && (t.title || t.name))
    return t.type === "array" ? `array ${r}[]` : r;
  if (t.type === "array" && t.items) {
    if (y) {
      const m = y(t.items, n);
      if (m)
        return e(t.type, m);
    }
    if (t.items.title || t.items.name)
      return e(t.type, t.items.title || t.items.name);
    const f = o(t.items);
    return f && f !== t.items.type ? e(t.type, f) : t.items.type ? e(t.type, t.items.type) : e(t.type, "object");
  }
  return r && r !== t.type ? r.startsWith("Array of ") ? `array ${r.replace("Array of ", "")}[]` : r : null;
}
export {
  e as formatTypeWithModel,
  p as getModelName,
  o as getModelNameFromSchema
};
