import { jsxs, Fragment, jsx } from "react/jsx-runtime";
import React__default from "react";
import default_1 from "../../../../node_modules/@mui/icons-material/AttachFile.js";
import default_1$9 from "../../../../node_modules/@mui/icons-material/Brush.js";
import default_1$f from "../../../../node_modules/@mui/icons-material/FormatBold.js";
import default_1$e from "../../../../node_modules/@mui/icons-material/FormatItalic.js";
import default_1$c from "../../../../node_modules/@mui/icons-material/FormatListBulleted.js";
import default_1$b from "../../../../node_modules/@mui/icons-material/FormatListNumbered.js";
import default_1$1 from "../../../../node_modules/@mui/icons-material/Image.js";
import default_1$2 from "../../../../node_modules/@mui/icons-material/InsertEmoticon.js";
import default_1$d from "../../../../node_modules/@mui/icons-material/Link.js";
import default_1$6 from "../../../../node_modules/@mui/icons-material/Looks3.js";
import default_1$5 from "../../../../node_modules/@mui/icons-material/Looks4.js";
import default_1$4 from "../../../../node_modules/@mui/icons-material/Looks5.js";
import default_1$3 from "../../../../node_modules/@mui/icons-material/Looks6.js";
import default_1$8 from "../../../../node_modules/@mui/icons-material/LooksOne.js";
import default_1$7 from "../../../../node_modules/@mui/icons-material/LooksTwo.js";
import default_1$a from "../../../../node_modules/@mui/icons-material/StrikethroughS.js";
import { ChatIconButton } from "../TableChatLeftSection/ChatIconButton/ChatIconButton.js";
/* empty css                          */
const TOOLBAR_ITEMS = {
  bold: {
    icon: default_1$f,
    ariaLabel: "Bold text",
    command: "toggleBold"
  },
  italic: {
    icon: default_1$e,
    ariaLabel: "Italic text",
    command: "toggleItalic"
  },
  link: {
    icon: default_1$d,
    ariaLabel: "Add link",
    command: "toggleLink"
  },
  bulletList: {
    icon: default_1$c,
    ariaLabel: "Bullet list",
    command: "toggleBulletList"
  },
  orderedList: {
    icon: default_1$b,
    ariaLabel: "Numbered list",
    command: "toggleOrderedList"
  },
  strike: {
    icon: default_1$a,
    ariaLabel: "Strike through",
    command: "toggleStrike"
  },
  highlight: {
    icon: default_1$9,
    ariaLabel: "Highlight text",
    command: "toggleHighlight"
  },
  h1: {
    icon: default_1$8,
    ariaLabel: "Heading 1",
    command: "toggleH1"
  },
  h2: {
    icon: default_1$7,
    ariaLabel: "Heading 2",
    command: "toggleH2"
  },
  h3: {
    icon: default_1$6,
    ariaLabel: "Heading 3",
    command: "toggleH3"
  },
  h4: {
    icon: default_1$5,
    ariaLabel: "Heading 4",
    command: "toggleH4"
  },
  h5: {
    icon: default_1$4,
    ariaLabel: "Heading 5",
    command: "toggleH5"
  },
  h6: {
    icon: default_1$3,
    ariaLabel: "Heading 6",
    command: "toggleH6"
  }
};
const EditorToolbar = React__default.forwardRef(
  ({
    editor,
    activeStates = {},
    enabledItems = Object.keys(TOOLBAR_ITEMS),
    onFileSelect,
    onImageSelect,
    onEmojiSelect,
    className = ""
  }, ref) => {
    const fileInputRef = React__default.useRef(null);
    const imageInputRef = React__default.useRef(null);
    React__default.useImperativeHandle(ref, () => ({
      fileInput: fileInputRef.current,
      imageInput: imageInputRef.current
    }));
    const handleCommand = React__default.useCallback(
      (command) => {
        console.log("EditorToolbar - editor[command]:", editor == null ? void 0 : editor[command]);
        if (editor == null ? void 0 : editor[command]) {
          editor[command]();
        } else {
          console.warn(`Command ${command} not available on editor:`, editor);
        }
      },
      [editor]
    );
    return /* @__PURE__ */ jsxs("div", { className: `editor-toolbar ${className}`, children: [
      onFileSelect && /* @__PURE__ */ jsxs(Fragment, { children: [
        /* @__PURE__ */ jsx(
          "input",
          {
            ref: fileInputRef,
            accept: ".pdf,.doc,.docx,.txt,.xls,.xlsx",
            style: { display: "none" },
            type: "file",
            onChange: onFileSelect
          }
        ),
        /* @__PURE__ */ jsx(
          ChatIconButton,
          {
            ariaLabel: "Attach file",
            className: "format-button",
            icon: /* @__PURE__ */ jsx(default_1, { fontSize: "small", style: { width: "16px", height: "16px" } }),
            onClick: () => {
              var _a;
              return (_a = fileInputRef.current) == null ? void 0 : _a.click();
            }
          }
        )
      ] }),
      onImageSelect && /* @__PURE__ */ jsxs(Fragment, { children: [
        /* @__PURE__ */ jsx(
          "input",
          {
            ref: imageInputRef,
            accept: "image/*",
            style: { display: "none" },
            type: "file",
            onChange: onImageSelect
          }
        ),
        /* @__PURE__ */ jsx(
          ChatIconButton,
          {
            ariaLabel: "Upload image",
            className: "format-button",
            icon: /* @__PURE__ */ jsx(default_1$1, { fontSize: "small", style: { width: "16px", height: "16px" } }),
            onClick: () => {
              var _a;
              return (_a = imageInputRef.current) == null ? void 0 : _a.click();
            }
          }
        )
      ] }),
      onEmojiSelect && /* @__PURE__ */ jsx(
        ChatIconButton,
        {
          ariaLabel: "Add emoji",
          className: "format-button",
          icon: /* @__PURE__ */ jsx(default_1$2, { fontSize: "small", style: { width: "16px", height: "16px" } }),
          onClick: onEmojiSelect
        }
      ),
      enabledItems.map((itemKey) => {
        const item = TOOLBAR_ITEMS[itemKey];
        if (!item) return null;
        const Icon = item.icon;
        return /* @__PURE__ */ jsx(
          ChatIconButton,
          {
            ariaLabel: item.ariaLabel,
            className: `format-button ${activeStates[itemKey] ? "is-active" : ""}`,
            icon: /* @__PURE__ */ jsx(Icon, { fontSize: "small", style: { width: "16px", height: "16px" } }),
            onClick: () => {
              handleCommand(item.command);
            }
          },
          itemKey
        );
      })
    ] });
  }
);
export {
  EditorToolbar
};
