import { getDefaultExportFromCjs as b, commonjsGlobal as h } from "./index.es83.js";
import w from "react";
import O from "react-dom";
import { i as S } from "./index.es91.js";
import { q as D } from "./index.es92.js";
function x(r, o) {
  for (var e = 0; e < o.length; e++) {
    const t = o[e];
    if (typeof t != "string" && !Array.isArray(t)) {
      for (const n in t)
        if (n !== "default" && !(n in r)) {
          const i = Object.getOwnPropertyDescriptor(t, n);
          i && Object.defineProperty(r, n, i.get ? i : {
            enumerable: !0,
            get: () => t[n]
          });
        }
    }
  }
  return Object.freeze(Object.defineProperty(r, Symbol.toStringTag, { value: "Module" }));
}
var A = h && h.__extends || /* @__PURE__ */ function() {
  var r = function(o, e) {
    return r = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
      t.__proto__ = n;
    } || function(t, n) {
      for (var i in n)
        n.hasOwnProperty(i) && (t[i] = n[i]);
    }, r(o, e);
  };
  return function(o, e) {
    r(o, e);
    function t() {
      this.constructor = o;
    }
    o.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
  };
}(), v = h && h.__assign || function() {
  return v = Object.assign || function(r) {
    for (var o, e = 1, t = arguments.length; e < t; e++) {
      o = arguments[e];
      for (var n in o)
        Object.prototype.hasOwnProperty.call(o, n) && (r[n] = o[n]);
    }
    return r;
  }, v.apply(this, arguments);
}, M = h && h.__spreadArrays || function() {
  for (var r = 0, o = 0, e = arguments.length; o < e; o++)
    r += arguments[o].length;
  for (var t = Array(r), n = 0, o = 0; o < e; o++)
    for (var i = arguments[o], s = 0, a = i.length; s < a; s++, n++)
      t[n] = i[s];
  return t;
}, y = h && h.__importDefault || function(r) {
  return r && r.__esModule ? r : { default: r };
}, d = y(w), P = y(O), g = y(S), m = y(D), T = (
  /** @class */
  function(r) {
    A(o, r);
    function o(e) {
      var t = r.call(this, e) || this;
      t.dirtyProps = [
        "modules",
        "formats",
        "bounds",
        "theme",
        "children"
      ], t.cleanProps = [
        "id",
        "className",
        "style",
        "placeholder",
        "tabIndex",
        "onChange",
        "onChangeSelection",
        "onFocus",
        "onBlur",
        "onKeyPress",
        "onKeyDown",
        "onKeyUp"
      ], t.state = {
        generation: 0
      }, t.selection = null, t.onEditorChange = function(i, s, a, l) {
        var u, p, c, f;
        i === "text-change" ? (p = (u = t).onEditorChangeText) === null || p === void 0 || p.call(u, t.editor.root.innerHTML, s, l, t.unprivilegedEditor) : i === "selection-change" && ((f = (c = t).onEditorChangeSelection) === null || f === void 0 || f.call(c, s, l, t.unprivilegedEditor));
      };
      var n = t.isControlled() ? e.value : e.defaultValue;
      return t.value = n ?? "", t;
    }
    return o.prototype.validateProps = function(e) {
      var t;
      if (d.default.Children.count(e.children) > 1)
        throw new Error("The Quill editing area can only be composed of a single React element.");
      if (d.default.Children.count(e.children)) {
        var n = d.default.Children.only(e.children);
        if (((t = n) === null || t === void 0 ? void 0 : t.type) === "textarea")
          throw new Error("Quill does not support editing on a <textarea>. Use a <div> instead.");
      }
      if (this.lastDeltaChangeSet && e.value === this.lastDeltaChangeSet)
        throw new Error("You are passing the `delta` object from the `onChange` event back as `value`. You most probably want `editor.getContents()` instead. See: https://github.com/zenoamaro/react-quill#using-deltas");
    }, o.prototype.shouldComponentUpdate = function(e, t) {
      var n = this, i;
      if (this.validateProps(e), !this.editor || this.state.generation !== t.generation)
        return !0;
      if ("value" in e) {
        var s = this.getEditorContents(), a = (i = e.value, i ?? "");
        this.isEqualValue(a, s) || this.setEditorContents(this.editor, a);
      }
      return e.readOnly !== this.props.readOnly && this.setEditorReadOnly(this.editor, e.readOnly), M(this.cleanProps, this.dirtyProps).some(function(l) {
        return !g.default(e[l], n.props[l]);
      });
    }, o.prototype.shouldComponentRegenerate = function(e) {
      var t = this;
      return this.dirtyProps.some(function(n) {
        return !g.default(e[n], t.props[n]);
      });
    }, o.prototype.componentDidMount = function() {
      this.instantiateEditor(), this.setEditorContents(this.editor, this.getEditorContents());
    }, o.prototype.componentWillUnmount = function() {
      this.destroyEditor();
    }, o.prototype.componentDidUpdate = function(e, t) {
      var n = this;
      if (this.editor && this.shouldComponentRegenerate(e)) {
        var i = this.editor.getContents(), s = this.editor.getSelection();
        this.regenerationSnapshot = { delta: i, selection: s }, this.setState({ generation: this.state.generation + 1 }), this.destroyEditor();
      }
      if (this.state.generation !== t.generation) {
        var a = this.regenerationSnapshot, i = a.delta, l = a.selection;
        delete this.regenerationSnapshot, this.instantiateEditor();
        var u = this.editor;
        u.setContents(i), E(function() {
          return n.setEditorSelection(u, l);
        });
      }
    }, o.prototype.instantiateEditor = function() {
      this.editor ? this.hookEditor(this.editor) : this.editor = this.createEditor(this.getEditingArea(), this.getEditorConfig());
    }, o.prototype.destroyEditor = function() {
      this.editor && this.unhookEditor(this.editor);
    }, o.prototype.isControlled = function() {
      return "value" in this.props;
    }, o.prototype.getEditorConfig = function() {
      return {
        bounds: this.props.bounds,
        formats: this.props.formats,
        modules: this.props.modules,
        placeholder: this.props.placeholder,
        readOnly: this.props.readOnly,
        scrollingContainer: this.props.scrollingContainer,
        tabIndex: this.props.tabIndex,
        theme: this.props.theme
      };
    }, o.prototype.getEditor = function() {
      if (!this.editor)
        throw new Error("Accessing non-instantiated editor");
      return this.editor;
    }, o.prototype.createEditor = function(e, t) {
      var n = new m.default(e, t);
      return t.tabIndex != null && this.setEditorTabIndex(n, t.tabIndex), this.hookEditor(n), n;
    }, o.prototype.hookEditor = function(e) {
      this.unprivilegedEditor = this.makeUnprivilegedEditor(e), e.on("editor-change", this.onEditorChange);
    }, o.prototype.unhookEditor = function(e) {
      e.off("editor-change", this.onEditorChange);
    }, o.prototype.getEditorContents = function() {
      return this.value;
    }, o.prototype.getEditorSelection = function() {
      return this.selection;
    }, o.prototype.isDelta = function(e) {
      return e && e.ops;
    }, o.prototype.isEqualValue = function(e, t) {
      return this.isDelta(e) && this.isDelta(t) ? g.default(e.ops, t.ops) : g.default(e, t);
    }, o.prototype.setEditorContents = function(e, t) {
      var n = this;
      this.value = t;
      var i = this.getEditorSelection();
      typeof t == "string" ? e.setContents(e.clipboard.convert(t)) : e.setContents(t), E(function() {
        return n.setEditorSelection(e, i);
      });
    }, o.prototype.setEditorSelection = function(e, t) {
      if (this.selection = t, t) {
        var n = e.getLength();
        t.index = Math.max(0, Math.min(t.index, n - 1)), t.length = Math.max(0, Math.min(t.length, n - 1 - t.index)), e.setSelection(t);
      }
    }, o.prototype.setEditorTabIndex = function(e, t) {
      var n, i;
      !((i = (n = e) === null || n === void 0 ? void 0 : n.scroll) === null || i === void 0) && i.domNode && (e.scroll.domNode.tabIndex = t);
    }, o.prototype.setEditorReadOnly = function(e, t) {
      t ? e.disable() : e.enable();
    }, o.prototype.makeUnprivilegedEditor = function(e) {
      var t = e;
      return {
        getHTML: function() {
          return t.root.innerHTML;
        },
        getLength: t.getLength.bind(t),
        getText: t.getText.bind(t),
        getContents: t.getContents.bind(t),
        getSelection: t.getSelection.bind(t),
        getBounds: t.getBounds.bind(t)
      };
    }, o.prototype.getEditingArea = function() {
      if (!this.editingArea)
        throw new Error("Instantiating on missing editing area");
      var e = P.default.findDOMNode(this.editingArea);
      if (!e)
        throw new Error("Cannot find element for editing area");
      if (e.nodeType === 3)
        throw new Error("Editing area cannot be a text node");
      return e;
    }, o.prototype.renderEditingArea = function() {
      var e = this, t = this.props, n = t.children, i = t.preserveWhitespace, s = this.state.generation, a = {
        key: s,
        ref: function(l) {
          e.editingArea = l;
        }
      };
      return d.default.Children.count(n) ? d.default.cloneElement(d.default.Children.only(n), a) : i ? d.default.createElement("pre", v({}, a)) : d.default.createElement("div", v({}, a));
    }, o.prototype.render = function() {
      var e;
      return d.default.createElement("div", { id: this.props.id, style: this.props.style, key: this.state.generation, className: "quill " + (e = this.props.className, e ?? ""), onKeyPress: this.props.onKeyPress, onKeyDown: this.props.onKeyDown, onKeyUp: this.props.onKeyUp }, this.renderEditingArea());
    }, o.prototype.onEditorChangeText = function(e, t, n, i) {
      var s, a;
      if (this.editor) {
        var l = this.isDelta(this.value) ? i.getContents() : i.getHTML();
        l !== this.getEditorContents() && (this.lastDeltaChangeSet = t, this.value = l, (a = (s = this.props).onChange) === null || a === void 0 || a.call(s, e, t, n, i));
      }
    }, o.prototype.onEditorChangeSelection = function(e, t, n) {
      var i, s, a, l, u, p;
      if (this.editor) {
        var c = this.getEditorSelection(), f = !c && e, C = c && !e;
        g.default(e, c) || (this.selection = e, (s = (i = this.props).onChangeSelection) === null || s === void 0 || s.call(i, e, t, n), f ? (l = (a = this.props).onFocus) === null || l === void 0 || l.call(a, e, t, n) : C && ((p = (u = this.props).onBlur) === null || p === void 0 || p.call(u, c, t, n)));
      }
    }, o.prototype.focus = function() {
      this.editor && this.editor.focus();
    }, o.prototype.blur = function() {
      this.editor && (this.selection = null, this.editor.blur());
    }, o.displayName = "React Quill", o.Quill = m.default, o.defaultProps = {
      theme: "snow",
      modules: {},
      readOnly: !1
    }, o;
  }(d.default.Component)
);
function E(r) {
  Promise.resolve().then(r);
}
var _ = T;
const k = /* @__PURE__ */ b(_), U = /* @__PURE__ */ x({
  __proto__: null,
  default: k
}, [_]);
export {
  k as default,
  U as i
};
//# sourceMappingURL=index.es71.js.map
