import classnames from "classnames";
import React, { useContext } from "react";
import { getTextDirection } from "./../../../../../ricos-content/index.js";
import {
  RicosNodeContext,
  RicosNodeContextProvider,
  RicosViewerContext
} from "./../../../../../ricos-context/index.js";
import indentStyle from "../../../../statics/indentation-scss.js";
import { Anchorable } from "../../utils/anchorable.js";
import { getPaywallSeoClass, isPaywallSeo } from "../../utils/paywall-seo.js";
import { alignmentToFlex, indentLevelToClassName } from "../consts.js";
import styles from "./blockquote-scss.js";
const Blockquote = ({ node, nodeIndex, RicosNodesRenderer }) => {
  const { seoMode } = useContext(RicosViewerContext);
  const { parentNode } = useContext(RicosNodeContext);
  const { indentation = 0 } = node.blockquoteData || {};
  const firstChild = node.nodes?.[0];
  const dataProperty = `${firstChild?.type?.toLowerCase()}Data`;
  const { textAlignment } = firstChild?.[dataProperty]?.textStyle || {};
  const indentClassName = indentLevelToClassName[indentation];
  const BlockquoteClassName = classnames(
    styles.quote,
    indentation > 0 && indentStyle[indentClassName],
    !parentNode && isPaywallSeo(seoMode) && getPaywallSeoClass(seoMode?.paywall || {}, nodeIndex)
  );
  const childClassName = styles.child;
  return /* @__PURE__ */ React.createElement(Anchorable, { nodeId: node.id }, /* @__PURE__ */ React.createElement(
    "div",
    {
      className: styles.quoteContainer,
      style: {
        justifyContent: alignmentToFlex[textAlignment]
      },
      dir: getTextDirection(node.nodes?.[0]?.nodes?.[0]?.textData?.text) || "ltr"
    },
    /* @__PURE__ */ React.createElement("blockquote", { className: BlockquoteClassName, style: node.style }, /* @__PURE__ */ React.createElement("span", { className: childClassName }, /* @__PURE__ */ React.createElement(RicosNodeContextProvider, { parentNode: node, parentIndex: nodeIndex }, /* @__PURE__ */ React.createElement(RicosNodesRenderer, { nodes: node.nodes ?? [] }))))
  ));
};
const BlockquoteRenderer = ({ node, ...props }) => {
  return /* @__PURE__ */ React.createElement(Blockquote, { key: node.id, node, ...props });
};
var blockquote_default = BlockquoteRenderer;
export {
  blockquote_default as default
};
//# sourceMappingURL=blockquote.js.map
