"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var layout_settings_exports = {};
__export(layout_settings_exports, {
  LayoutSettings: () => LayoutSettings
});
module.exports = __toCommonJS(layout_settings_exports);
var import_react = __toESM(require("react"));
var import_ricos_context = require("./../../../../ricos-context/index.js");
var import_next_schema = require("./../../../../ricos-schema/next-schema/index.js");
var import_use_node_attrs = require("./../../../../_shared/use-node-attrs.js");
var import_ui_components = require("./../../../../ui-components/index.js");
var import_data_hooks = require("../../../data-hooks.js");
var import_icons = require("../../../icons/index.js");
var import_layout_data_provider = require("../../../layout-data-provider.js");
var import_layout_controls_section = require("./layout-controls-section/layout-controls-section.js");
const LayoutSettings = ({ nodeId, logBi }) => {
  const { t } = (0, import_react.useContext)(import_ricos_context.RicosContext);
  const containerEl = (0, import_ui_components.usePanelContainerElement)();
  const { pmNodeAttrs, patchPmNodeAttrs } = (0, import_use_node_attrs.useNodeAttrs)(nodeId, "GALLERY");
  const layoutType = pmNodeAttrs?.options?.layout?.type;
  return pmNodeAttrs && pmNodeAttrs.options && layoutType ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    import_ui_components.ThumbnailPicker,
    {
      selectedValue: layoutType,
      onChange: (galleryLayout) => {
        const defaultData = {
          ...pmNodeAttrs.options,
          ...import_layout_data_provider.layoutRicosData[galleryLayout]
        };
        patchPmNodeAttrs({
          ...pmNodeAttrs,
          options: {
            ...defaultData,
            layout: { ...defaultData?.layout, type: galleryLayout }
          }
        });
      },
      dataSource: galleryLayouts.map(({ label, value, icon: Icon }) => ({
        value,
        dataHook: `${import_data_hooks.LAYOUT_SETTINGS_LAYOUT_THUMBNAIL}${value}`,
        renderBackgroundImage: (props) => /* @__PURE__ */ import_react.default.createElement(Icon, { ...props }),
        label: t(label)
      })),
      tooltipAppendTo: containerEl,
      dataHook: import_data_hooks.LAYOUT_SETTINGS_LAYOUT_THUMBNAIL_PICKER,
      logBi
    }
  ), /* @__PURE__ */ import_react.default.createElement(
    import_layout_controls_section.LayoutControlsSection,
    {
      layout: layoutType,
      data: pmNodeAttrs,
      updateData: patchPmNodeAttrs,
      logBi
    }
  )) : null;
};
const galleryLayouts = [
  {
    value: import_next_schema.GalleryOptions_Layout_Type.GRID,
    label: "GalleryPlugin_Layout_Grid",
    icon: import_icons.LayoutGridIcon
  },
  {
    value: import_next_schema.GalleryOptions_Layout_Type.MASONRY,
    label: "GalleryPlugin_Layout_Masonry",
    icon: import_icons.LayoutMasonryIcon
  },
  {
    value: import_next_schema.GalleryOptions_Layout_Type.COLLAGE,
    label: "GalleryPlugin_Layout_Collage",
    icon: import_icons.LayoutCollageIcon
  },
  {
    value: import_next_schema.GalleryOptions_Layout_Type.THUMBNAIL,
    label: "GalleryPlugin_Layout_Thumbnails",
    icon: import_icons.LayoutThumbnailsIcon
  },
  {
    value: import_next_schema.GalleryOptions_Layout_Type.FULLSIZE,
    label: "GalleryPlugin_Layout_Slideshow",
    icon: import_icons.LayoutSlideshowIcon
  },
  {
    value: import_next_schema.GalleryOptions_Layout_Type.PANORAMA,
    label: "GalleryPlugin_Layout_Panorama",
    icon: import_icons.LayoutPanoramaIcon
  },
  {
    value: import_next_schema.GalleryOptions_Layout_Type.COLUMN,
    label: "GalleryPlugin_Layout_Columns",
    icon: import_icons.LayoutColumnsIcon
  },
  {
    value: import_next_schema.GalleryOptions_Layout_Type.SLIDER,
    label: "GalleryPlugin_Layout_Slides",
    icon: import_icons.LayoutSlidesIcon
  }
];
//# sourceMappingURL=layout-settings.js.map
