import React, { useContext } from "react";
import { RicosContext } from "./../../ricos-context/index.js";
import { DropdownModal } from "./../dropdown-modal/dropdown-modal.js";
import { ListItemDivider } from "./../list-item-divider/list-item-divider.js";
import { ListItemSelect } from "./../list-item-select/list-item-select.js";
import { ListItemToggle } from "./../list-item-toggle/list-item-toggle.js";
const NodeAlignmentDropdown = ({
  options,
  onSelect,
  onToggle,
  selectedId,
  closeModal
}) => {
  const { t, isMobile } = useContext(RicosContext);
  const [isToggleSelected, setIsToggleSelected] = React.useState(
    () => options.find((option) => option.type === "toggle")?.selected ?? false
  );
  const AlignmentDropdownOptions = options.filter((option) => option.type === "button").map(({ dataHook, icon: Icon, iconMobile: IconMobile, label, id: commandKey }) => /* @__PURE__ */ React.createElement(
    ListItemSelect,
    {
      key: commandKey,
      dataHook,
      prefix: isMobile ? /* @__PURE__ */ React.createElement(IconMobile, null) : /* @__PURE__ */ React.createElement(Icon, null),
      title: label,
      selected: commandKey === selectedId,
      onSelect: () => {
        onSelect(commandKey);
        closeModal();
      }
    }
  ));
  const textWrapToggle = options.find((option) => option.type === "toggle");
  return /* @__PURE__ */ React.createElement(
    DropdownModal,
    {
      onCloseButtonClick: closeModal,
      title: t("NodeAlignmentDropdown_Title"),
      options: textWrapToggle ? [
        ...AlignmentDropdownOptions,
        ...[
          /* @__PURE__ */ React.createElement(ListItemDivider, { key: "divider" }),
          /* @__PURE__ */ React.createElement(
            ListItemToggle,
            {
              key: textWrapToggle.id,
              dataHook: textWrapToggle.dataHook,
              onChange: () => {
                onToggle?.();
                setIsToggleSelected((prev) => !prev);
              },
              title: textWrapToggle.label,
              selected: isToggleSelected,
              infoContent: textWrapToggle.infoContent,
              disabled: textWrapToggle.disabled
            }
          )
        ]
      ] : AlignmentDropdownOptions
    }
  );
};
export {
  NodeAlignmentDropdown
};
//# sourceMappingURL=node-alignment-dropdown.js.map
