"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var InlinePlugin_exports = {};
__export(InlinePlugin_exports, {
  InlinePlugin: () => InlinePlugin,
  withInline: () => withInline
});
module.exports = __toCommonJS(InlinePlugin_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_controls = require("@makeswift/controls");
var import_plugin = require("../../controls/rich-text-v2/plugin");
var import_types = require("./types");
var import_onChange = require("./onChange");
var import_getValue = require("./getValue");
const withInline = (editor) => {
  const { isInline } = editor;
  editor.isInline = (entry) => {
    return import_controls.Slate.isInline(entry) && isInline(entry);
  };
  return editor;
};
function InlinePlugin() {
  return (0, import_plugin.Plugin)({
    control: {
      definition: (0, import_controls.unstable_IconRadioGroup)({
        label: "Inline",
        options: import_types.supportedInlineOptions
      }),
      onChange: import_onChange.onChange,
      getValue: import_getValue.getValue,
      getElementValue: (element) => (0, import_types.isSupportedInlineNode)(element) ? element.type : void 0
    },
    withPlugin: withInline,
    renderElement: (renderElement) => (props) => {
      return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InlinePluginComponent, { ...props, renderElement });
    }
  });
}
function InlinePluginComponent({
  renderElement,
  ...props
}) {
  switch (props.element.type) {
    case import_controls.Slate.InlineType.Code:
      return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { ...props.attributes, children: renderElement(props) });
    case import_controls.Slate.InlineType.SuperScript:
      return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("sup", { ...props.attributes, children: renderElement(props) });
    case import_controls.Slate.InlineType.SubScript:
      return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("sub", { ...props.attributes, children: renderElement(props) });
    default:
      return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: renderElement(props) });
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  InlinePlugin,
  withInline
});
//# sourceMappingURL=index.js.map