import { jsx } from "react/jsx-runtime";
import { ControlValue } from "../../control";
function RichTextV2Element({ definition, plugins, ...props }) {
  function initialRenderElement(props2) {
    return props2.children;
  }
  const renderElement = plugins.reduce(
    (renderFn, plugin) => (props2) => {
      const { control, renderElement: renderElement2 } = plugin;
      if (renderElement2 == null)
        return renderFn(props2);
      if (control == null || control.getElementValue == null)
        return renderElement2(renderFn, void 0)(props2);
      return /* @__PURE__ */ jsx(ControlValue, { definition: control.definition, data: control.getElementValue(props2.element), children: (value) => renderElement2(renderFn, value)(props2) });
    },
    initialRenderElement
  );
  return renderElement(props);
}
export {
  RichTextV2Element
};
//# sourceMappingURL=render-element.js.map