import { j as jsxRuntimeExports } from "../../../../../_virtual/jsx-runtime.js";
import FormNavigator from "./json-form/FormNavigator.js";
import { f as p } from "../../../../sdk/dist/shared/chunk-GOMXZC4B.js";
import "@sinclair/typebox";
import "../../../../sdk/dist/shared/chunk-PSCN3VVA.js";
import "../../../../sdk/dist/shared/chunk-R6ATC4TC.js";
import "../../../../sdk/dist/shared/chunk-CFF6Q7O7.js";
import "../../../../sdk/dist/shared/chunk-IKC3FK7L.js";
import "../../../../sdk/dist/shared/chunk-E6XEI7IK.js";
import "../../../../sdk/dist/shared/chunk-SQ5T4AT5.js";
import "../../../../sdk/dist/shared/chunk-G5CJU6RD.js";
import "../../../../sdk/dist/shared/chunk-PSTFJ5IJ.js";
import "../../../../sdk/dist/shared/chunk-NJGXC7D6.js";
import "../../../../sdk/dist/shared/chunk-SXHDQ64Z.js";
import "../../../../sdk/dist/shared/chunk-QX6OGRRT.js";
import "../../../../sdk/dist/shared/chunk-FLOMNC6J.js";
import "../../../../sdk/dist/shared/chunk-PLSV746R.js";
import "../../../../sdk/dist/shared/chunk-WBZW5LVH.js";
import "../../../../sdk/dist/shared/chunk-WYVJE6J5.js";
import "../../../../sdk/dist/shared/chunk-I3VL6SRH.js";
import "../../../../sdk/dist/shared/chunk-B3EATRFX.js";
import "../../../../sdk/dist/shared/chunk-IKHZD2JH.js";
import "../../../../sdk/dist/shared/chunk-PXI7AHWS.js";
import { merge, set } from "lodash-es";
import "../../../../sdk/dist/shared/chunk-SY6DZLTC.js";
import "../../../../sdk/dist/shared/chunk-7A2JNQX3.js";
import "../../../../sdk/dist/shared/chunk-3YVJ2ELD.js";
import { b as S } from "../../../../sdk/dist/shared/chunk-QGYZ7CG5.js";
import "../../../../sdk/dist/shared/chunk-AFVJZPLS.js";
import "../../../../sdk/dist/shared/chunk-A3GF4PYW.js";
import "../../../../sdk/dist/shared/chunk-W33JMRRN.js";
import { useCallback, useMemo } from "react";
import { usePreviewMode } from "../../../../../use-editor.js";
import { getNavItemsFromManifest } from "./json-form/form-utils.js";
import { useLocalStorage } from "../../../../../node_modules/.pnpm/usehooks-ts@3.1.1_react@19.1.1/node_modules/usehooks-ts/dist/index.js";
import { useDraftHelpers } from "../../../../../use-page-data.js";
function SectionSettingsView({ section, group }) {
  const { updateSectionProps } = useDraftHelpers();
  const previewMode = usePreviewMode();
  const [showAdvanced, setShowAdvanced] = useLocalStorage("upstart:editor:show-advanced", false);
  const filter = useCallback(
    (prop) => {
      return (typeof prop.metadata?.["ui:responsive"] === "undefined" || prop.metadata?.["ui:responsive"] === true || prop.metadata?.["ui:responsive"] === previewMode) && (typeof prop["ui:responsive"] === "undefined" || prop["ui:responsive"] === true || prop["ui:responsive"] === previewMode) && (!prop.metadata?.category || prop.metadata?.category === "settings") && (!prop["ui:advanced"] || showAdvanced);
    },
    [previewMode, showAdvanced]
  );
  const navItems = useMemo(() => getNavItemsFromManifest(p.properties.props, filter), [filter]);
  const formData = useMemo(() => {
    const defProps = S(p.properties.props, previewMode);
    return previewMode === "mobile" ? merge({}, defProps, section.props, section.mobileProps) : merge({}, defProps, section.props ?? {});
  }, [previewMode, section.props, section.mobileProps]);
  const onChange = useCallback(
    (data, propertyChangedPath) => {
      if (!propertyChangedPath) {
        console.warn("propertyChangedPath is missing in style tab");
        return;
      }
      const props = structuredClone(section?.props ?? {});
      set(props, propertyChangedPath, data[propertyChangedPath]);
      console.log("SectionSettingsView onChange", {
        props
      });
      updateSectionProps(section.id, props, previewMode === "mobile");
    },
    [section.id, previewMode, updateSectionProps, section.props]
  );
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
    FormNavigator,
    {
      title: `Section settings`,
      initialGroup: group,
      navItems,
      formSchema: p.properties.props,
      className: "flex-grow",
      formData,
      onChange,
      brickId: section.id
    },
    `section-settings-${section.id}-${previewMode}`
  );
}
export {
  SectionSettingsView as default
};
//# sourceMappingURL=SectionSettingsView.js.map
