import React, { useContext } from "react";
import { RicosContext } from "./../../ricos-context/index.js";
import { withEditorEvents } from "./../../editor-common/editor-events-context.js";
import { PollContextProvider } from "../components/poll-context/poll-context.js";
import { RCEHelpersContext } from "../components/rce-helpers-context/index.js";
import { usePollServices } from "../hooks/use-poll-services.js";
import { Poll } from "./poll-component.js";
const Polls = (props) => {
  const { theme, t, isMobile } = useContext(RicosContext);
  const setPoll = (poll) => {
    const { updateAttributes } = props;
    updateAttributes?.({ poll });
  };
  const {
    componentData,
    editorEvents,
    selected,
    isViewMode = false,
    settings,
    isOnlySelected
  } = props;
  const resolvedSettings = usePollServices(settings);
  return /* @__PURE__ */ React.createElement(
    RCEHelpersContext.Provider,
    {
      value: {
        isViewMode: isViewMode ? isViewMode : resolvedSettings.isWebView || typeof selected === "boolean" ? !selected : true,
        setInPluginEditingMode: () => {
        },
        layout: componentData.layout,
        design: componentData.design,
        preventVoting: !isViewMode,
        isPreview: !!resolvedSettings.isWebView,
        theme,
        t,
        isMobile,
        isOnlySelected,
        ...resolvedSettings
      }
    },
    /* @__PURE__ */ React.createElement(
      PollContextProvider,
      {
        editorEvents,
        settings: resolvedSettings,
        poll: componentData.poll,
        setPoll,
        t
      },
      /* @__PURE__ */ React.createElement(Poll, null)
    )
  );
};
var poll_viewer_default = withEditorEvents(Polls);
export {
  poll_viewer_default as default
};
//# sourceMappingURL=poll-viewer.js.map
