import { jsx, jsxs } from 'react/jsx-runtime';
import { EditorContext, EditorContent } from '../../../../../node_modules/.pnpm/@tiptap_react@3.15.3_@floating-ui_dom@1.7.4_@tiptap_core@3.20.0_@tiptap_pm@3.15.3__@tip_b42b5b2d59902d8a01cd4cc3e2d5dc64/node_modules/@tiptap/react/dist/index.mjs';
import { Separator } from '../separator.mjs';
import { cn } from '../../lib/utils.mjs';
import { SectionOne } from './components/section/one.mjs';
import { SectionTwo } from './components/section/two.mjs';
import { SectionThree } from './components/section/three.mjs';
import { SectionFour } from './components/section/four.mjs';
import { SectionFive } from './components/section/five.mjs';
import { LinkBubbleMenu } from './components/bubble-menu/link-bubble-menu.mjs';
import { useMinimalTiptapEditor } from './hooks/use-minimal-tiptap.mjs';
import { MeasuredContainer } from './components/measured-container.mjs';
import { useTiptapEditor } from './hooks/use-tiptap-editor.mjs';

const Toolbar = ({ editor }) => /* @__PURE__ */ jsx("div", { className: "border-border flex h-12 shrink-0 overflow-x-auto border-b p-2", children: /* @__PURE__ */ jsxs("div", { className: "flex w-max items-center gap-px", children: [
  /* @__PURE__ */ jsx(SectionOne, { editor, activeLevels: [1, 2, 3, 4, 5, 6] }),
  /* @__PURE__ */ jsx(Separator, { orientation: "vertical", className: "mx-2" }),
  /* @__PURE__ */ jsx(
    SectionTwo,
    {
      editor,
      activeActions: [
        "bold",
        "italic",
        "underline",
        "strikethrough",
        "code",
        "clearFormatting"
      ],
      mainActionCount: 3
    }
  ),
  /* @__PURE__ */ jsx(Separator, { orientation: "vertical", className: "mx-2" }),
  /* @__PURE__ */ jsx(SectionThree, { editor }),
  /* @__PURE__ */ jsx(Separator, { orientation: "vertical", className: "mx-2" }),
  /* @__PURE__ */ jsx(
    SectionFour,
    {
      editor,
      activeActions: ["orderedList", "bulletList"],
      mainActionCount: 0
    }
  ),
  /* @__PURE__ */ jsx(Separator, { orientation: "vertical", className: "mx-2" }),
  /* @__PURE__ */ jsx(
    SectionFive,
    {
      editor,
      activeActions: ["codeBlock", "blockquote", "horizontalRule"],
      mainActionCount: 0
    }
  )
] }) });
const MinimalTiptapEditor = ({
  value,
  onChange,
  className,
  editorContentClassName,
  ...props
}) => {
  const editor = useMinimalTiptapEditor({
    value,
    onUpdate: onChange,
    ...props
  });
  if (!editor) {
    return null;
  }
  return /* @__PURE__ */ jsx(EditorContext.Provider, { value: { editor }, children: /* @__PURE__ */ jsx(
    MainMinimalTiptapEditor,
    {
      editor,
      className,
      editorContentClassName
    }
  ) });
};
MinimalTiptapEditor.displayName = "MinimalTiptapEditor";
const MainMinimalTiptapEditor = ({
  editor: providedEditor,
  className,
  editorContentClassName
}) => {
  const { editor } = useTiptapEditor(providedEditor);
  if (!editor) {
    return null;
  }
  return /* @__PURE__ */ jsxs(
    MeasuredContainer,
    {
      as: "div",
      name: "editor",
      className: cn(
        "border-input min-data-[orientation=vertical]:h-72 flex h-auto w-full flex-col rounded-md border shadow-xs",
        "focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]",
        className
      ),
      children: [
        /* @__PURE__ */ jsx(Toolbar, { editor }),
        /* @__PURE__ */ jsx(
          EditorContent,
          {
            editor,
            className: cn("minimal-tiptap-editor", editorContentClassName)
          }
        ),
        /* @__PURE__ */ jsx(LinkBubbleMenu, { editor })
      ]
    }
  );
};

export { MainMinimalTiptapEditor, MinimalTiptapEditor, MinimalTiptapEditor as default };
