import { jsx } from "react/jsx-runtime";
import { forwardRef, useImperativeHandle } from "react";
import { tcx } from "@choiceform/design-system";
import './styles/style.css';/* empty css                  */
import { useCodeEditor } from "./hooks/use-code-editor.js";
const CodeEditor = forwardRef((props, ref) => {
  const {
    value,
    onChange,
    autoFocus,
    className,
    readonly,
    lineWrapping,
    onEditorUpdate,
    onFormat,
    onCursorChange,
    onSelectionChange
  } = props;
  const { containerRef, editorViewRef, getCursorPosition, getSelectedCharacterCount } = useCodeEditor({
    value,
    onChange,
    autoFocus,
    readonly,
    lineWrapping,
    onEditorUpdate,
    onFormat,
    onCursorChange,
    onSelectionChange
  });
  useImperativeHandle(ref, () => ({
    getCursorPosition,
    getEditor: () => editorViewRef.current,
    getSelectedCharacterCount
  }), [getCursorPosition, editorViewRef, getSelectedCharacterCount]);
  return /* @__PURE__ */ jsx(
    "div",
    {
      ref: containerRef,
      className: tcx("relative h-full", className)
    }
  );
});
CodeEditor.displayName = "CodeEditor";
export {
  CodeEditor
};
//# sourceMappingURL=code-editor.js.map
