import { jsx } from "react/jsx-runtime";
import { ControlValue } from "../../control";
function RichTextV2Leaf({ definition, plugins, ...props }) {
  function initialRenderLeaf({ attributes, children, leaf }) {
    return /* @__PURE__ */ jsx("span", { className: leaf.className, ...attributes, children });
  }
  const renderLeaf = plugins.reduce(
    (renderFn, plugin) => (props2) => {
      const { control, renderLeaf: renderLeaf2 } = plugin;
      if (control?.definition == null || renderLeaf2 == null)
        return renderFn(props2);
      if (control.getLeafValue == null)
        return renderLeaf2(renderFn, void 0)(props2);
      return /* @__PURE__ */ jsx(ControlValue, { definition: control.definition, data: control.getLeafValue(props2.leaf), children: (value) => renderLeaf2(renderFn, value)(props2) });
    },
    initialRenderLeaf
  );
  return renderLeaf(props);
}
export {
  RichTextV2Leaf
};
//# sourceMappingURL=render-leaf.js.map