import { Box } from "@wix/design-system";
import classNames from "classnames";
import React, { useContext, useState } from "react";
import { ModalServiceContext, RicosContext } from "./../../../ricos-context/index.js";
import { useBiNext } from "./../../../_shared/bi-context-provider/bi-context-provider.js";
import { unreachable } from "./../../../_shared/uncreachable.js";
import { Panel, PanelHeader } from "./../../../ui-components/index.js";
import { POLL_SETTINGS_MODAL_ID, SETTINGS_TAB } from "../../consts.js";
import { SETTINGS_MODAL } from "../../data-hooks.js";
import { DesignSettingsSection } from "./design-settings-section.js";
import { LayoutSettingsSection } from "./layout-settings-section.js";
import { PollSettingsSection } from "./poll-settings-section.js";
import classes from "./settings-modal-scss.js";
import { TabNavigation } from "./tab-navigation.js";
const SettingsModal = ({
  nodeId,
  activeTab: initialTab,
  config,
  modalId
}) => {
  const { t, isMobile } = useContext(RicosContext);
  const modalService = useContext(ModalServiceContext);
  const [activeTab, setActiveTab] = useState(initialTab ?? "layout");
  const logBi = useBiNext({ pluginId: "poll", modalId: POLL_SETTINGS_MODAL_ID, nodeId });
  const closeModal = () => modalService.closeModal(modalId);
  return /* @__PURE__ */ React.createElement(
    "div",
    {
      className: classNames({
        [classes.modalDesktop]: !isMobile
      })
    },
    /* @__PURE__ */ React.createElement(
      Panel,
      {
        closeButtonProps: { onClick: closeModal },
        dataHook: SETTINGS_MODAL,
        maxHeight: isMobile ? void 0 : 590
      },
      /* @__PURE__ */ React.createElement(PanelHeader, { title: t("Poll_PollSettings_Common_Header") }),
      /* @__PURE__ */ React.createElement(TabNavigation, { activeTab, onTabChange: setActiveTab }),
      /* @__PURE__ */ React.createElement(
        Box,
        {
          direction: "vertical",
          padding: "SP3",
          gap: "SP2",
          overflow: "auto",
          className: classes.content
        },
        (() => {
          switch (activeTab) {
            case SETTINGS_TAB.layout:
              return /* @__PURE__ */ React.createElement(LayoutSettingsSection, { nodeId, logBi });
            case SETTINGS_TAB.design:
              return /* @__PURE__ */ React.createElement(DesignSettingsSection, { nodeId, logBi });
            case SETTINGS_TAB.settings:
              return /* @__PURE__ */ React.createElement(PollSettingsSection, { nodeId, config, logBi });
            default:
              unreachable(activeTab);
              return null;
          }
        })()
      )
    )
  );
};
export {
  SettingsModal
};
//# sourceMappingURL=settings-modal.js.map
