text: export class ImageResize {
      constructor(t, e = {}) {
          (this.quill = t),
              (this.options = e),
              (this.handleClick = this.handleClick.bind(this)),
              (this.handleMousedown = this.handleMousedown.bind(this)),
              (this.handleMouseup = this.handleMouseup.bind(this)),
              (this.handleDrag = this.handleDrag.bind(this)),
              (this.checkImage = this.checkImage.bind(this)),
              (this.boxes = []),
              document.execCommand("enableObjectResizing", !1, "false"),
              this.quill.root.addEventListener("click", this.handleClick, !1);
      }
      handleClick(t) {
          if (t.target && t.target.tagName && "IMG" === t.target.tagName.toUpperCase()) {
              if (this.img === t.target) return;
              this.img && this.hide(), this.show(t.target);
          } else this.img && this.hide();
      }
      show(t) {
          (this.img = t), this.showResizers(), this.showSizeDisplay();
          const e = this.img.getBoundingClientRect();
          this.positionBoxes(e), this.positionSizeDisplay(e);
      }
      hide() {
          this.hideResizers(), this.hideSizeDisplay(), (this.img = void 0);
      }
      showResizers() {
          this.setUserSelect("none"),
              this.addBox("nwse-resize"),
              this.addBox("nesw-resize"),
              this.addBox("nwse-resize"),
              this.addBox("nesw-resize"),
              document.addEventListener("keyup", this.checkImage, !0),
              this.quill.root.addEventListener("input", this.checkImage, !0);
      }
      hideResizers() {
          document.removeEventListener("keyup", this.checkImage),
              this.quill.root.removeEventListener("input", this.checkImage),
              this.setUserSelect(""),
              this.setCursor(""),
              this.boxes.forEach(t => document.body.removeChild(t)),
              (this.dragBox = void 0),
              (this.dragStartX = void 0),
              (this.preDragWidth = void 0),
              (this.boxes = []);
      }
      addBox(t) {
          const e = document.createElement("div"),
              i = {
                  position: "absolute",
                  height: "12px",
                  width: "12px",
                  backgroundColor: "white",
                  border: "1px solid #777",
                  boxSizing: "border-box",
                  opacity: "0.80",
                  cursor: t
              };
          this.extend(e.style, i, this.options.handleStyles || {}),
              e.addEventListener("mousedown", this.handleMousedown, !1),
              document.body.appendChild(e),
              this.boxes.push(e);
      }
      extend(t, ...e) {
          return (
              e.forEach(e => {
                  for (let i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
              }),
              t
          );
      }
      positionBoxes(t) {
          [
              { left: t.left - 6, top: t.top - 6 },
              { left: t.left + t.width - 6, top: t.top - 6 },
              { left: t.left + t.width - 6, top: t.top + t.height - 6 },
              { left: t.left - 6, top: t.top + t.height - 6 }
          ].forEach((t, e) => {
              this.extend(this.boxes[e].style, {
                  top: Math.round(t.top + window.pageYOffset) + "px",
                  left: Math.round(t.left + window.pageXOffset) + "px"
              });
          });
      }
      handleMousedown(t) {
          (this.dragBox = t.target),
              (this.dragStartX = t.clientX),
              (this.preDragWidth = this.img.width || this.img.naturalWidth),
              this.setCursor(this.dragBox.style.cursor),
              document.addEventListener("mousemove", this.handleDrag, !1),
              document.addEventListener("mouseup", this.handleMouseup, !1);
      }
      handleMouseup() {
          this.setCursor(""),
              document.removeEventListener("mousemove", this.handleDrag),
              document.removeEventListener("mouseup", this.handleMouseup);
      }
      handleDrag(t) {
          if (!this.img) return;
          this.dragBox === this.boxes[0] || this.dragBox === this.boxes[3]
              ? (this.img.width = Math.round(this.preDragWidth - t.clientX - this.dragStartX))
              : (this.img.width = Math.round(this.preDragWidth + t.clientX - this.dragStartX));
          const e = this.img.getBoundingClientRect();
          this.positionBoxes(e), this.positionSizeDisplay(e);
      }
      setUserSelect(t) {
          ["userSelect", "mozUserSelect", "webkitUserSelect", "msUserSelect"].forEach(e => {
              (this.quill.root.style[e] = t), (document.documentElement.style[e] = t);
          });
      }
      setCursor(t) {
          [document.body, this.img, this.quill.root].forEach(function(e) {
              e.style.cursor = t;
          });
      }
      checkImage() {
          this.img && this.hide();
      }
      showSizeDisplay() {
          if (!this.options.displaySize) return;
          this.display = document.createElement("div");
          this.extend(
              this.display.style,
              {
                  position: "absolute",
                  font: "12px/1.0 Arial, Helvetica, sans-serif",
                  padding: "4px 8px",
                  textAlign: "center",
                  backgroundColor: "white",
                  color: "#333",
                  border: "1px solid #777",
                  boxSizing: "border-box",
                  opacity: "0.80",
                  cursor: "default"
              },
              this.options.displayStyles || {}
          ),
              document.body.appendChild(this.display);
      }
      hideSizeDisplay() {
          void 0 !== this.display && (document.body.removeChild(this.display), (this.display = void 0));
      }
      positionSizeDisplay(t) {
          if (!this.display || !this.img) return;
          const e = this.getCurrentSize();
          if (((this.display.innerHTML = e.join(" &times ")), e[0] > 120 && e[1] > 30)) {
              const e = this.display.getBoundingClientRect();
              this.extend(this.display.style, {
                  left: Math.round(t.left + t.width + window.pageXOffset - e.width - 8) + "px",
                  top: Math.round(t.top + t.height + window.pageYOffset - e.height - 8) + "px"
              });
          } else
              this.extend(this.display.style, {
                  left: Math.round(t.left + t.width + window.pageXOffset + 8) + "px",
                  top: Math.round(t.top + t.height + window.pageYOffset + 8) + "px"
              });
      }
      getCurrentSize() {
          return [this.img.width, Math.round((this.img.width / this.img.naturalWidth) * this.img.naturalHeight)];
      }
  }
  