import { d as g } from "../../../../../sdk/dist/shared/chunk-QGYZ7CG5.js";
import "../../../../../sdk/dist/shared/chunk-AFVJZPLS.js";
import "@sinclair/typebox";
import "../../../../../sdk/dist/shared/chunk-A3GF4PYW.js";
import "../../../../../sdk/dist/shared/chunk-W33JMRRN.js";
const f = () => !0;
function F(n, r = f, m = []) {
  const o = n["ui:groups"] ?? {}, d = /* @__PURE__ */ new Map();
  return Object.entries(n.properties).map(([i, t]) => [i, g(t)]).filter(([, i]) => i["ui:field"] !== "hidden").filter(([i, t]) => r(t, i)).map(([i, t]) => {
    const a = [...m, i];
    if (t["ui:group"]) {
      const s = d.get(t["ui:group"]), c = t.type === "object" && !t["ui:field"];
      if (!s) {
        d.set(
          t["ui:group"],
          c ? [] : [
            {
              id: i,
              label: t.title,
              path: a.join("."),
              ...t.metadata && { metadata: t.metadata },
              ...t.description ? { description: t.description } : {},
              schema: t
            }
          ]
        );
        const u = [];
        if (c)
          for (const [l, e] of Object.entries(t.properties)) {
            const h = [...a, l].join(".");
            u.push({
              id: l,
              label: e.title,
              path: h,
              ...e.metadata && { metadata: e.metadata },
              ...e.description ? { description: e.description } : {},
              schema: e
            });
          }
        return {
          id: t["ui:group"],
          label: o[t["ui:group"]] ?? t["ui:group"],
          ...t.metadata && { metadata: t.metadata },
          ...t.description ? { description: t.description } : {},
          path: a.join("."),
          groupId: t["ui:group"],
          children: u
        };
      }
      return s.push({
        id: i,
        label: t.title,
        path: a.join("."),
        ...t.metadata && { metadata: t.metadata },
        ...t.description ? { description: t.description } : {},
        schema: t
      }), null;
    }
    return {
      id: i,
      label: t.title,
      path: a.join("."),
      ...t.metadata && { metadata: t.metadata },
      ...t.description ? { description: t.description } : {},
      schema: t
    };
  }).filter((i) => i !== null).map((i) => {
    if (i.groupId) {
      const t = d.get(i.groupId);
      t?.length && (i.children = t);
    }
    return i;
  }).flat();
}
export {
  F as getNavItemsFromManifest
};
//# sourceMappingURL=form-utils.js.map
