import { j as P } from "../../../../../_virtual/jsx-runtime.js";
import { b as B } from "../../../../sdk/dist/shared/chunk-AQPN5SE2.js";
import "../../../../sdk/dist/shared/chunk-DQXDGV67.js";
import "@sinclair/typebox";
import "../../../../sdk/dist/shared/chunk-7DMUDZ4H.js";
import "../../../../sdk/dist/shared/chunk-LSPN22SI.js";
import "../../../../sdk/dist/shared/chunk-ETYYRWLK.js";
import "../../../../sdk/dist/shared/chunk-4TH3C76A.js";
import "../../../../sdk/dist/shared/chunk-FKNNTHWX.js";
import "../../../../sdk/dist/shared/chunk-JS4K5JRM.js";
import "../../../../sdk/dist/shared/chunk-WU6Q4WYD.js";
import "../../../../sdk/dist/shared/chunk-QISTDGPP.js";
import "../../../../sdk/dist/shared/chunk-LFQZRGHS.js";
import "../../../../sdk/dist/shared/chunk-SLRU4CT6.js";
import "../../../../sdk/dist/shared/chunk-TTTXV7TJ.js";
import "../../../../sdk/dist/shared/chunk-UHF6IEKV.js";
import "../../../../sdk/dist/shared/chunk-LGP6GWIY.js";
import "../../../../sdk/dist/shared/chunk-X43MB5WD.js";
import "../../../../sdk/dist/shared/chunk-NNI225RG.js";
import "../../../../sdk/dist/shared/chunk-ZQGNYK5I.js";
import "../../../../sdk/dist/shared/chunk-KHFNN4P3.js";
import "../../../../sdk/dist/shared/chunk-BZGNY7LB.js";
import "../../../../sdk/dist/shared/chunk-IIFTGWFZ.js";
import "../../../../sdk/dist/shared/chunk-UU2MSQXY.js";
import "../../../../sdk/dist/shared/chunk-T3LIA4YB.js";
import "../../../../sdk/dist/shared/chunk-YBGPPF7T.js";
import "../../../../sdk/dist/shared/chunk-UMHXXXVP.js";
import "../../../../sdk/dist/shared/chunk-5N6MBJJ4.js";
import { a as u } from "../../../../sdk/dist/shared/chunk-MPBYGS6W.js";
import { tx as I } from "../../../../style-system/dist/twind.js";
import { get as $, set as j } from "lodash-es";
import { useCallback as d, useMemo as l } from "react";
import { usePreviewMode as F } from "../../../../../use-editor.js";
import { useDraftHelpers as N, useBrick as y } from "../../../../../use-page-data.js";
import { useBrickManifest as C } from "../../shared/hooks/use-brick-manifest.js";
import { getNavItemsFromManifest as D } from "./json-form/form-utils.js";
import S from "./json-form/FormNavigator.js";
const b = (o) => o === "settings" || !o;
function go({
  brick: o,
  label: c,
  group: v,
  categoryFilter: p = b
}) {
  const { updateBrickProps: n } = N(), e = C(o.type), r = F(), s = y(o.id), a = d(
    (t) => (typeof t.metadata?.["ui:responsive"] > "u" || t.metadata?.["ui:responsive"] === !0 || t.metadata?.["ui:responsive"] === r) && (typeof t["ui:responsive"] > "u" || t["ui:responsive"] === !0 || t["ui:responsive"] === r) && p(t.metadata?.category),
    [r, p]
  ), g = l(() => D(e.props, a), [a, e.props]), x = l(() => {
    const t = B[o.type].props;
    return r === "mobile" ? u({}, t, o.props, o.mobileProps ?? {}) : u({}, t, o.props ?? {});
  }, [o, r]), M = d(
    (t, i) => {
      if (!i) {
        console.warn("propertyChangedPath is missing in onChange");
        return;
      }
      const w = $(e.props.properties, i), f = r === "mobile" && w?.metadata?.category !== "content", m = structuredClone(
        f ? s?.mobileProps ?? {} : s?.props ?? {}
      );
      j(m, i, t[i]), console.debug("Props update for brick %s: %o", o.id, m), n(o.id, m, f);
    },
    [o.id, e, r, n, s]
  );
  return /* @__PURE__ */ P.jsx(
    S,
    {
      title: `${e.name} ${c ?? "settings"}`,
      initialGroup: v,
      navItems: g,
      formSchema: e.props,
      className: I("flex-grow"),
      formData: x,
      onChange: M,
      brickId: o.id
    },
    `brick-nav-${o.id}-${r}`
  );
}
export {
  go as default
};
//# sourceMappingURL=BrickSettingsView.js.map
