import { Box, Text } from "@wix/design-system";
import { SparklesFilledSmall } from "@wix/wix-ui-icons-common";
import React, { useContext } from "react";
import { RicosContext } from "./../../../ricos-context/index.js";
import { unreachable } from "./../../../_shared/uncreachable.js";
import { AI_MODAL_RESULTS_CONTENT_ITEM } from "../../data-hooks.js";
import { ResultContentViewer } from "../result-content/result-content.js";
import { ResultsFooter } from "../results-footer/results-footer.js";
import { TextCursor } from "../text-cursor/text-cursor.js";
import styles from "./feed-scss.js";
const defaultFeedUserEntryFormatter = (prompt, t) => {
  return typeof prompt === "string" ? prompt : t(prompt.title);
};
const Feed = ({
  entries,
  zIndex,
  getResultActions,
  isLoading,
  modalRef,
  feedUserEntryFormatter = defaultFeedUserEntryFormatter
}) => {
  const { t } = useContext(RicosContext);
  return /* @__PURE__ */ React.createElement(Box, { direction: "vertical" }, entries.map((entry, index) => {
    switch (entry.type) {
      case "request": {
        return /* @__PURE__ */ React.createElement(
          Box,
          {
            key: index,
            direction: "vertical",
            paddingLeft: "SP4",
            paddingRight: "SP4",
            paddingTop: "SP2",
            paddingBottom: "SP2",
            gap: "SP1"
          },
          /* @__PURE__ */ React.createElement(
            Text,
            {
              size: "small",
              weight: "bold",
              tagName: "h6",
              className: styles.label,
              skin: "disabled"
            },
            t("AIPlugin_FeedLabel_You")
          ),
          /* @__PURE__ */ React.createElement(Text, { size: "small", tagName: "p", className: styles.entry, skin: "disabled" }, feedUserEntryFormatter(entry.requestPrompt, t))
        );
      }
      case "result": {
        return /* @__PURE__ */ React.createElement(
          Box,
          {
            key: index,
            direction: "vertical",
            paddingTop: "SP2",
            backgroundColor: entries.length - 1 === index ? "B60" : void 0,
            dataHook: AI_MODAL_RESULTS_CONTENT_ITEM
          },
          /* @__PURE__ */ React.createElement(ResponseBodyEntry, { key: index }, /* @__PURE__ */ React.createElement(ResultContentViewer, { resultItem: entry.response })),
          /* @__PURE__ */ React.createElement(
            ResultsFooter,
            {
              actions: getResultActions(entry),
              entry,
              zIndex,
              modalRef
            }
          )
        );
      }
      default: {
        throw unreachable(entry);
      }
    }
  }), isLoading && /* @__PURE__ */ React.createElement(Box, { direction: "vertical", paddingTop: "SP2" }, /* @__PURE__ */ React.createElement(ResponseBodyEntry, null, /* @__PURE__ */ React.createElement(Box, { direction: "vertical", paddingBottom: "SP3" }, /* @__PURE__ */ React.createElement(TextCursor, null)))));
};
const ResponseBodyEntry = ({ children }) => {
  const { t } = useContext(RicosContext);
  return /* @__PURE__ */ React.createElement(Box, { direction: "vertical", paddingLeft: "SP4", paddingRight: "SP4", gap: "SP1" }, /* @__PURE__ */ React.createElement(Box, { verticalAlign: "middle" }, /* @__PURE__ */ React.createElement(Text, { size: "small", weight: "bold", tagName: "h6", className: styles.label }, t("AIPlugin_FeedLabel_Assistant")), /* @__PURE__ */ React.createElement(Box, { color: "B10" }, /* @__PURE__ */ React.createElement(SparklesFilledSmall, null))), children);
};
export {
  Feed
};
//# sourceMappingURL=feed.js.map
