import * as R from "react";
import { g as Y } from "./index.CfM2L_w0.js";
var F = function(a, r) {
  return F = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
    e.__proto__ = t;
  } || function(e, t) {
    for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
  }, F(a, r);
};
function V(a, r) {
  if (typeof r != "function" && r !== null)
    throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
  F(a, r);
  function e() {
    this.constructor = a;
  }
  a.prototype = r === null ? Object.create(r) : (e.prototype = r.prototype, new e());
}
var m = function() {
  return m = Object.assign || function(r) {
    for (var e, t = 1, n = arguments.length; t < n; t++) {
      e = arguments[t];
      for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (r[i] = e[i]);
    }
    return r;
  }, m.apply(this, arguments);
};
var A, Z;
function K() {
  if (Z) return A;
  Z = 1;
  var a = !1, r, e, t, n, i, o, s, c, u, h, p, f, w, v, C;
  function d() {
    if (!a) {
      a = !0;
      var g = navigator.userAgent, l = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(g), y = /(Mac OS X)|(Windows)|(Linux)/.exec(g);
      if (f = /\b(iPhone|iP[ao]d)/.exec(g), w = /\b(iP[ao]d)/.exec(g), h = /Android/i.exec(g), v = /FBAN\/\w+;/i.exec(g), C = /Mobile/i.exec(g), p = !!/Win64/.exec(g), l) {
        r = l[1] ? parseFloat(l[1]) : l[5] ? parseFloat(l[5]) : NaN, r && document && document.documentMode && (r = document.documentMode);
        var D = /(?:Trident\/(\d+.\d+))/.exec(g);
        o = D ? parseFloat(D[1]) + 4 : r, e = l[2] ? parseFloat(l[2]) : NaN, t = l[3] ? parseFloat(l[3]) : NaN, n = l[4] ? parseFloat(l[4]) : NaN, n ? (l = /(?:Chrome\/(\d+\.\d+))/.exec(g), i = l && l[1] ? parseFloat(l[1]) : NaN) : i = NaN;
      } else
        r = e = t = i = n = NaN;
      if (y) {
        if (y[1]) {
          var b = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(g);
          s = b ? parseFloat(b[1].replace("_", ".")) : !0;
        } else
          s = !1;
        c = !!y[2], u = !!y[3];
      } else
        s = c = u = !1;
    }
  }
  var S = {
    /**
     *  Check if the UA is Internet Explorer.
     *
     *
     *  @return float|NaN Version number (if match) or NaN.
     */
    ie: function() {
      return d() || r;
    },
    /**
     * Check if we're in Internet Explorer compatibility mode.
     *
     * @return bool true if in compatibility mode, false if
     * not compatibility mode or not ie
     */
    ieCompatibilityMode: function() {
      return d() || o > r;
    },
    /**
     * Whether the browser is 64-bit IE.  Really, this is kind of weak sauce;  we
     * only need this because Skype can't handle 64-bit IE yet.  We need to remove
     * this when we don't need it -- tracked by #601957.
     */
    ie64: function() {
      return S.ie() && p;
    },
    /**
     *  Check if the UA is Firefox.
     *
     *
     *  @return float|NaN Version number (if match) or NaN.
     */
    firefox: function() {
      return d() || e;
    },
    /**
     *  Check if the UA is Opera.
     *
     *
     *  @return float|NaN Version number (if match) or NaN.
     */
    opera: function() {
      return d() || t;
    },
    /**
     *  Check if the UA is WebKit.
     *
     *
     *  @return float|NaN Version number (if match) or NaN.
     */
    webkit: function() {
      return d() || n;
    },
    /**
     *  For Push
     *  WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit
     */
    safari: function() {
      return S.webkit();
    },
    /**
     *  Check if the UA is a Chrome browser.
     *
     *
     *  @return float|NaN Version number (if match) or NaN.
     */
    chrome: function() {
      return d() || i;
    },
    /**
     *  Check if the user is running Windows.
     *
     *  @return bool `true' if the user's OS is Windows.
     */
    windows: function() {
      return d() || c;
    },
    /**
     *  Check if the user is running Mac OS X.
     *
     *  @return float|bool   Returns a float if a version number is detected,
     *                       otherwise true/false.
     */
    osx: function() {
      return d() || s;
    },
    /**
     * Check if the user is running Linux.
     *
     * @return bool `true' if the user's OS is some flavor of Linux.
     */
    linux: function() {
      return d() || u;
    },
    /**
     * Check if the user is running on an iPhone or iPod platform.
     *
     * @return bool `true' if the user is running some flavor of the
     *    iPhone OS.
     */
    iphone: function() {
      return d() || f;
    },
    mobile: function() {
      return d() || f || w || h || C;
    },
    nativeApp: function() {
      return d() || v;
    },
    android: function() {
      return d() || h;
    },
    ipad: function() {
      return d() || w;
    }
  };
  return A = S, A;
}
var W, I;
function J() {
  if (I) return W;
  I = 1;
  var a = !!(typeof window < "u" && window.document && window.document.createElement), r = {
    canUseDOM: a,
    canUseWorkers: typeof Worker < "u",
    canUseEventListeners: a && !!(window.addEventListener || window.attachEvent),
    canUseViewport: a && !!window.screen,
    isInWorker: !a
    // For now, this is true - might change in the future.
  };
  return W = r, W;
}
var T, j;
function $() {
  if (j) return T;
  j = 1;
  var a = J(), r;
  a.canUseDOM && (r = document.implementation && document.implementation.hasFeature && // always returns true in newer browsers as per the standard.
  // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
  document.implementation.hasFeature("", "") !== !0);
  /**
   * Checks if an event is supported in the current execution environment.
   *
   * NOTE: This will not work correctly for non-generic events such as `change`,
   * `reset`, `load`, `error`, and `select`.
   *
   * Borrows from Modernizr.
   *
   * @param {string} eventNameSuffix Event name, e.g. "click".
   * @param {?boolean} capture Check if the capture phase is supported.
   * @return {boolean} True if the event is supported.
   * @internal
   * @license Modernizr 3.0.0pre (Custom Build) | MIT
   */
  function e(t, n) {
    if (!a.canUseDOM || n && !("addEventListener" in document))
      return !1;
    var i = "on" + t, o = i in document;
    if (!o) {
      var s = document.createElement("div");
      s.setAttribute(i, "return;"), o = typeof s[i] == "function";
    }
    return !o && r && t === "wheel" && (o = document.implementation.hasFeature("Events.wheel", "3.0")), o;
  }
  return T = e, T;
}
var O, H;
function Q() {
  if (H) return O;
  H = 1;
  var a = K(), r = $(), e = 10, t = 40, n = 800;
  function i(o) {
    var s = 0, c = 0, u = 0, h = 0;
    return "detail" in o && (c = o.detail), "wheelDelta" in o && (c = -o.wheelDelta / 120), "wheelDeltaY" in o && (c = -o.wheelDeltaY / 120), "wheelDeltaX" in o && (s = -o.wheelDeltaX / 120), "axis" in o && o.axis === o.HORIZONTAL_AXIS && (s = c, c = 0), u = s * e, h = c * e, "deltaY" in o && (h = o.deltaY), "deltaX" in o && (u = o.deltaX), (u || h) && o.deltaMode && (o.deltaMode == 1 ? (u *= t, h *= t) : (u *= n, h *= n)), u && !s && (s = u < 1 ? -1 : 1), h && !c && (c = h < 1 ? -1 : 1), {
      spinX: s,
      spinY: c,
      pixelX: u,
      pixelY: h
    };
  }
  return i.getEventType = function() {
    return a.firefox() ? "DOMMouseScroll" : r("wheel") ? "wheel" : "mousewheel";
  }, O = i, O;
}
var N, U;
function ee() {
  return U || (U = 1, N = Q()), N;
}
var te = ee();
const ne = /* @__PURE__ */ Y(te);
function re(a, r, e, t, n, i) {
  i === void 0 && (i = 0);
  var o = E(a, r, i), s = o.width, c = o.height, u = Math.min(s, e), h = Math.min(c, t);
  return u > h * n ? {
    width: h * n,
    height: h
  } : {
    width: u,
    height: u / n
  };
}
function oe(a) {
  return a.width > a.height ? a.width / a.naturalWidth : a.height / a.naturalHeight;
}
function _(a, r, e, t, n) {
  n === void 0 && (n = 0);
  var i = E(r.width, r.height, n), o = i.width, s = i.height;
  return {
    x: k(a.x, o, e.width, t),
    y: k(a.y, s, e.height, t)
  };
}
function k(a, r, e, t) {
  var n = r * t / 2 - e / 2;
  return z(a, -n, n);
}
function G(a, r) {
  return Math.sqrt(Math.pow(a.y - r.y, 2) + Math.pow(a.x - r.x, 2));
}
function q(a, r) {
  return Math.atan2(r.y - a.y, r.x - a.x) * 180 / Math.PI;
}
function ie(a, r, e, t, n, i, o) {
  i === void 0 && (i = 0), o === void 0 && (o = !0);
  var s = o ? ae : se, c = E(r.width, r.height, i), u = E(r.naturalWidth, r.naturalHeight, i), h = {
    x: s(100, ((c.width - e.width / n) / 2 - a.x / n) / c.width * 100),
    y: s(100, ((c.height - e.height / n) / 2 - a.y / n) / c.height * 100),
    width: s(100, e.width / c.width * 100 / n),
    height: s(100, e.height / c.height * 100 / n)
  }, p = Math.round(s(u.width, h.width * u.width / 100)), f = Math.round(s(u.height, h.height * u.height / 100)), w = u.width >= u.height * t, v = w ? {
    width: Math.round(f * t),
    height: f
  } : {
    width: p,
    height: Math.round(p / t)
  }, C = m(m({}, v), {
    x: Math.round(s(u.width - v.width, h.x * u.width / 100)),
    y: Math.round(s(u.height - v.height, h.y * u.height / 100))
  });
  return {
    croppedAreaPercentages: h,
    croppedAreaPixels: C
  };
}
function ae(a, r) {
  return Math.min(a, Math.max(0, r));
}
function se(a, r) {
  return r;
}
function ce(a, r, e, t, n, i) {
  var o = E(r.width, r.height, e), s = z(t.width / o.width * (100 / a.width), n, i), c = {
    x: s * o.width / 2 - t.width / 2 - o.width * s * (a.x / 100),
    y: s * o.height / 2 - t.height / 2 - o.height * s * (a.y / 100)
  };
  return {
    crop: c,
    zoom: s
  };
}
function ue(a, r, e) {
  var t = oe(r);
  return e.height > e.width ? e.height / (a.height * t) : e.width / (a.width * t);
}
function he(a, r, e, t, n, i) {
  e === void 0 && (e = 0);
  var o = E(r.naturalWidth, r.naturalHeight, e), s = z(ue(a, r, t), n, i), c = t.height > t.width ? t.height / a.height : t.width / a.width, u = {
    x: ((o.width - a.width) / 2 - a.x) * c,
    y: ((o.height - a.height) / 2 - a.y) * c
  };
  return {
    crop: u,
    zoom: s
  };
}
function X(a, r) {
  return {
    x: (r.x + a.x) / 2,
    y: (r.y + a.y) / 2
  };
}
function pe(a) {
  return a * Math.PI / 180;
}
function E(a, r, e) {
  var t = pe(e);
  return {
    width: Math.abs(Math.cos(t) * a) + Math.abs(Math.sin(t) * r),
    height: Math.abs(Math.sin(t) * a) + Math.abs(Math.cos(t) * r)
  };
}
function z(a, r, e) {
  return Math.min(Math.max(a, r), e);
}
function P() {
  for (var a = [], r = 0; r < arguments.length; r++)
    a[r] = arguments[r];
  return a.filter(function(e) {
    return typeof e == "string" && e.length > 0;
  }).join(" ").trim();
}
var de = `.reactEasyCrop_Container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  cursor: move;
  display: flex;
  justify-content: center;
  align-items: center;
}

.reactEasyCrop_Image,
.reactEasyCrop_Video {
  will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */
}

.reactEasyCrop_Contain {
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}
.reactEasyCrop_Cover_Horizontal {
  width: 100%;
  height: auto;
}
.reactEasyCrop_Cover_Vertical {
  width: auto;
  height: 100%;
}

.reactEasyCrop_CropArea {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-sizing: border-box;
  box-shadow: 0 0 0 9999em;
  color: rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.reactEasyCrop_CropAreaRound {
  border-radius: 50%;
}

.reactEasyCrop_CropAreaGrid::before {
  content: ' ';
  box-sizing: border-box;
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.5);
  top: 0;
  bottom: 0;
  left: 33.33%;
  right: 33.33%;
  border-top: 0;
  border-bottom: 0;
}

.reactEasyCrop_CropAreaGrid::after {
  content: ' ';
  box-sizing: border-box;
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.5);
  top: 33.33%;
  bottom: 33.33%;
  left: 0;
  right: 0;
  border-left: 0;
  border-right: 0;
}
`, fe = 1, le = 3, me = 1, ge = (
  /** @class */
  function(a) {
    V(r, a);
    function r() {
      var e = a !== null && a.apply(this, arguments) || this;
      return e.imageRef = R.createRef(), e.videoRef = R.createRef(), e.containerPosition = {
        x: 0,
        y: 0
      }, e.containerRef = null, e.styleRef = null, e.containerRect = null, e.mediaSize = {
        width: 0,
        height: 0,
        naturalWidth: 0,
        naturalHeight: 0
      }, e.dragStartPosition = {
        x: 0,
        y: 0
      }, e.dragStartCrop = {
        x: 0,
        y: 0
      }, e.gestureZoomStart = 0, e.gestureRotationStart = 0, e.isTouching = !1, e.lastPinchDistance = 0, e.lastPinchRotation = 0, e.rafDragTimeout = null, e.rafPinchTimeout = null, e.wheelTimer = null, e.currentDoc = typeof document < "u" ? document : null, e.currentWindow = typeof window < "u" ? window : null, e.resizeObserver = null, e.state = {
        cropSize: null,
        hasWheelJustStarted: !1,
        mediaObjectFit: void 0
      }, e.initResizeObserver = function() {
        if (!(typeof window.ResizeObserver > "u" || !e.containerRef)) {
          var t = !0;
          e.resizeObserver = new window.ResizeObserver(function(n) {
            if (t) {
              t = !1;
              return;
            }
            e.computeSizes();
          }), e.resizeObserver.observe(e.containerRef);
        }
      }, e.preventZoomSafari = function(t) {
        return t.preventDefault();
      }, e.cleanEvents = function() {
        e.currentDoc && (e.currentDoc.removeEventListener("mousemove", e.onMouseMove), e.currentDoc.removeEventListener("mouseup", e.onDragStopped), e.currentDoc.removeEventListener("touchmove", e.onTouchMove), e.currentDoc.removeEventListener("touchend", e.onDragStopped), e.currentDoc.removeEventListener("gesturemove", e.onGestureMove), e.currentDoc.removeEventListener("gestureend", e.onGestureEnd), e.currentDoc.removeEventListener("scroll", e.onScroll));
      }, e.clearScrollEvent = function() {
        e.containerRef && e.containerRef.removeEventListener("wheel", e.onWheel), e.wheelTimer && clearTimeout(e.wheelTimer);
      }, e.onMediaLoad = function() {
        var t = e.computeSizes();
        t && (e.emitCropData(), e.setInitialCrop(t)), e.props.onMediaLoaded && e.props.onMediaLoaded(e.mediaSize);
      }, e.setInitialCrop = function(t) {
        if (e.props.initialCroppedAreaPercentages) {
          var n = ce(e.props.initialCroppedAreaPercentages, e.mediaSize, e.props.rotation, t, e.props.minZoom, e.props.maxZoom), i = n.crop, o = n.zoom;
          e.props.onCropChange(i), e.props.onZoomChange && e.props.onZoomChange(o);
        } else if (e.props.initialCroppedAreaPixels) {
          var s = he(e.props.initialCroppedAreaPixels, e.mediaSize, e.props.rotation, t, e.props.minZoom, e.props.maxZoom), i = s.crop, o = s.zoom;
          e.props.onCropChange(i), e.props.onZoomChange && e.props.onZoomChange(o);
        }
      }, e.computeSizes = function() {
        var t, n, i, o, s, c, u = e.imageRef.current || e.videoRef.current;
        if (u && e.containerRef) {
          e.containerRect = e.containerRef.getBoundingClientRect(), e.saveContainerPosition();
          var h = e.containerRect.width / e.containerRect.height, p = ((t = e.imageRef.current) === null || t === void 0 ? void 0 : t.naturalWidth) || ((n = e.videoRef.current) === null || n === void 0 ? void 0 : n.videoWidth) || 0, f = ((i = e.imageRef.current) === null || i === void 0 ? void 0 : i.naturalHeight) || ((o = e.videoRef.current) === null || o === void 0 ? void 0 : o.videoHeight) || 0, w = u.offsetWidth < p || u.offsetHeight < f, v = p / f, C = void 0;
          if (w)
            switch (e.state.mediaObjectFit) {
              default:
              case "contain":
                C = h > v ? {
                  width: e.containerRect.height * v,
                  height: e.containerRect.height
                } : {
                  width: e.containerRect.width,
                  height: e.containerRect.width / v
                };
                break;
              case "horizontal-cover":
                C = {
                  width: e.containerRect.width,
                  height: e.containerRect.width / v
                };
                break;
              case "vertical-cover":
                C = {
                  width: e.containerRect.height * v,
                  height: e.containerRect.height
                };
                break;
            }
          else
            C = {
              width: u.offsetWidth,
              height: u.offsetHeight
            };
          e.mediaSize = m(m({}, C), {
            naturalWidth: p,
            naturalHeight: f
          }), e.props.setMediaSize && e.props.setMediaSize(e.mediaSize);
          var d = e.props.cropSize ? e.props.cropSize : re(e.mediaSize.width, e.mediaSize.height, e.containerRect.width, e.containerRect.height, e.props.aspect, e.props.rotation);
          return (((s = e.state.cropSize) === null || s === void 0 ? void 0 : s.height) !== d.height || ((c = e.state.cropSize) === null || c === void 0 ? void 0 : c.width) !== d.width) && e.props.onCropSizeChange && e.props.onCropSizeChange(d), e.setState({
            cropSize: d
          }, e.recomputeCropPosition), e.props.setCropSize && e.props.setCropSize(d), d;
        }
      }, e.saveContainerPosition = function() {
        if (e.containerRef) {
          var t = e.containerRef.getBoundingClientRect();
          e.containerPosition = {
            x: t.left,
            y: t.top
          };
        }
      }, e.onMouseDown = function(t) {
        e.currentDoc && (t.preventDefault(), e.currentDoc.addEventListener("mousemove", e.onMouseMove), e.currentDoc.addEventListener("mouseup", e.onDragStopped), e.saveContainerPosition(), e.onDragStart(r.getMousePoint(t)));
      }, e.onMouseMove = function(t) {
        return e.onDrag(r.getMousePoint(t));
      }, e.onScroll = function(t) {
        e.currentDoc && (t.preventDefault(), e.saveContainerPosition());
      }, e.onTouchStart = function(t) {
        e.currentDoc && (e.isTouching = !0, !(e.props.onTouchRequest && !e.props.onTouchRequest(t)) && (e.currentDoc.addEventListener("touchmove", e.onTouchMove, {
          passive: !1
        }), e.currentDoc.addEventListener("touchend", e.onDragStopped), e.saveContainerPosition(), t.touches.length === 2 ? e.onPinchStart(t) : t.touches.length === 1 && e.onDragStart(r.getTouchPoint(t.touches[0]))));
      }, e.onTouchMove = function(t) {
        t.preventDefault(), t.touches.length === 2 ? e.onPinchMove(t) : t.touches.length === 1 && e.onDrag(r.getTouchPoint(t.touches[0]));
      }, e.onGestureStart = function(t) {
        e.currentDoc && (t.preventDefault(), e.currentDoc.addEventListener("gesturechange", e.onGestureMove), e.currentDoc.addEventListener("gestureend", e.onGestureEnd), e.gestureZoomStart = e.props.zoom, e.gestureRotationStart = e.props.rotation);
      }, e.onGestureMove = function(t) {
        if (t.preventDefault(), !e.isTouching) {
          var n = r.getMousePoint(t), i = e.gestureZoomStart - 1 + t.scale;
          if (e.setNewZoom(i, n, {
            shouldUpdatePosition: !0
          }), e.props.onRotationChange) {
            var o = e.gestureRotationStart + t.rotation;
            e.props.onRotationChange(o);
          }
        }
      }, e.onGestureEnd = function(t) {
        e.cleanEvents();
      }, e.onDragStart = function(t) {
        var n, i, o = t.x, s = t.y;
        e.dragStartPosition = {
          x: o,
          y: s
        }, e.dragStartCrop = m({}, e.props.crop), (i = (n = e.props).onInteractionStart) === null || i === void 0 || i.call(n);
      }, e.onDrag = function(t) {
        var n = t.x, i = t.y;
        e.currentWindow && (e.rafDragTimeout && e.currentWindow.cancelAnimationFrame(e.rafDragTimeout), e.rafDragTimeout = e.currentWindow.requestAnimationFrame(function() {
          if (e.state.cropSize && !(n === void 0 || i === void 0)) {
            var o = n - e.dragStartPosition.x, s = i - e.dragStartPosition.y, c = {
              x: e.dragStartCrop.x + o,
              y: e.dragStartCrop.y + s
            }, u = e.props.restrictPosition ? _(c, e.mediaSize, e.state.cropSize, e.props.zoom, e.props.rotation) : c;
            e.props.onCropChange(u);
          }
        }));
      }, e.onDragStopped = function() {
        var t, n;
        e.isTouching = !1, e.cleanEvents(), e.emitCropData(), (n = (t = e.props).onInteractionEnd) === null || n === void 0 || n.call(t);
      }, e.onWheel = function(t) {
        if (e.currentWindow && !(e.props.onWheelRequest && !e.props.onWheelRequest(t))) {
          t.preventDefault();
          var n = r.getMousePoint(t), i = ne(t).pixelY, o = e.props.zoom - i * e.props.zoomSpeed / 200;
          e.setNewZoom(o, n, {
            shouldUpdatePosition: !0
          }), e.state.hasWheelJustStarted || e.setState({
            hasWheelJustStarted: !0
          }, function() {
            var s, c;
            return (c = (s = e.props).onInteractionStart) === null || c === void 0 ? void 0 : c.call(s);
          }), e.wheelTimer && clearTimeout(e.wheelTimer), e.wheelTimer = e.currentWindow.setTimeout(function() {
            return e.setState({
              hasWheelJustStarted: !1
            }, function() {
              var s, c;
              return (c = (s = e.props).onInteractionEnd) === null || c === void 0 ? void 0 : c.call(s);
            });
          }, 250);
        }
      }, e.getPointOnContainer = function(t, n) {
        var i = t.x, o = t.y;
        if (!e.containerRect)
          throw new Error("The Cropper is not mounted");
        return {
          x: e.containerRect.width / 2 - (i - n.x),
          y: e.containerRect.height / 2 - (o - n.y)
        };
      }, e.getPointOnMedia = function(t) {
        var n = t.x, i = t.y, o = e.props, s = o.crop, c = o.zoom;
        return {
          x: (n + s.x) / c,
          y: (i + s.y) / c
        };
      }, e.setNewZoom = function(t, n, i) {
        var o = i === void 0 ? {} : i, s = o.shouldUpdatePosition, c = s === void 0 ? !0 : s;
        if (!(!e.state.cropSize || !e.props.onZoomChange)) {
          var u = z(t, e.props.minZoom, e.props.maxZoom);
          if (c) {
            var h = e.getPointOnContainer(n, e.containerPosition), p = e.getPointOnMedia(h), f = {
              x: p.x * u - h.x,
              y: p.y * u - h.y
            }, w = e.props.restrictPosition ? _(f, e.mediaSize, e.state.cropSize, u, e.props.rotation) : f;
            e.props.onCropChange(w);
          }
          e.props.onZoomChange(u);
        }
      }, e.getCropData = function() {
        if (!e.state.cropSize)
          return null;
        var t = e.props.restrictPosition ? _(e.props.crop, e.mediaSize, e.state.cropSize, e.props.zoom, e.props.rotation) : e.props.crop;
        return ie(t, e.mediaSize, e.state.cropSize, e.getAspect(), e.props.zoom, e.props.rotation, e.props.restrictPosition);
      }, e.emitCropData = function() {
        var t = e.getCropData();
        if (t) {
          var n = t.croppedAreaPercentages, i = t.croppedAreaPixels;
          e.props.onCropComplete && e.props.onCropComplete(n, i), e.props.onCropAreaChange && e.props.onCropAreaChange(n, i);
        }
      }, e.emitCropAreaChange = function() {
        var t = e.getCropData();
        if (t) {
          var n = t.croppedAreaPercentages, i = t.croppedAreaPixels;
          e.props.onCropAreaChange && e.props.onCropAreaChange(n, i);
        }
      }, e.recomputeCropPosition = function() {
        if (e.state.cropSize) {
          var t = e.props.restrictPosition ? _(e.props.crop, e.mediaSize, e.state.cropSize, e.props.zoom, e.props.rotation) : e.props.crop;
          e.props.onCropChange(t), e.emitCropData();
        }
      }, e.onKeyDown = function(t) {
        var n = e.props, i = n.crop, o = n.onCropChange, s = n.keyboardStep, c = n.zoom, u = n.rotation, h = s;
        if (e.state.cropSize) {
          t.shiftKey && (h *= 0.2);
          var p = m({}, i);
          switch (t.key) {
            case "ArrowUp":
              p.y -= h, t.preventDefault();
              break;
            case "ArrowDown":
              p.y += h, t.preventDefault();
              break;
            case "ArrowLeft":
              p.x -= h, t.preventDefault();
              break;
            case "ArrowRight":
              p.x += h, t.preventDefault();
              break;
            default:
              return;
          }
          e.props.restrictPosition && (p = _(p, e.mediaSize, e.state.cropSize, c, u)), o(p);
        }
      }, e;
    }
    return r.prototype.componentDidMount = function() {
      !this.currentDoc || !this.currentWindow || (this.containerRef && (this.containerRef.ownerDocument && (this.currentDoc = this.containerRef.ownerDocument), this.currentDoc.defaultView && (this.currentWindow = this.currentDoc.defaultView), this.initResizeObserver(), typeof window.ResizeObserver > "u" && this.currentWindow.addEventListener("resize", this.computeSizes), this.props.zoomWithScroll && this.containerRef.addEventListener("wheel", this.onWheel, {
        passive: !1
      }), this.containerRef.addEventListener("gesturestart", this.onGestureStart)), this.currentDoc.addEventListener("scroll", this.onScroll), this.props.disableAutomaticStylesInjection || (this.styleRef = this.currentDoc.createElement("style"), this.styleRef.setAttribute("type", "text/css"), this.props.nonce && this.styleRef.setAttribute("nonce", this.props.nonce), this.styleRef.innerHTML = de, this.currentDoc.head.appendChild(this.styleRef)), this.imageRef.current && this.imageRef.current.complete && this.onMediaLoad(), this.props.setImageRef && this.props.setImageRef(this.imageRef), this.props.setVideoRef && this.props.setVideoRef(this.videoRef));
    }, r.prototype.componentWillUnmount = function() {
      var e, t;
      !this.currentDoc || !this.currentWindow || (typeof window.ResizeObserver > "u" && this.currentWindow.removeEventListener("resize", this.computeSizes), (e = this.resizeObserver) === null || e === void 0 || e.disconnect(), this.containerRef && this.containerRef.removeEventListener("gesturestart", this.preventZoomSafari), this.styleRef && ((t = this.styleRef.parentNode) === null || t === void 0 || t.removeChild(this.styleRef)), this.cleanEvents(), this.props.zoomWithScroll && this.clearScrollEvent());
    }, r.prototype.componentDidUpdate = function(e) {
      var t, n, i, o, s, c, u, h, p;
      e.rotation !== this.props.rotation ? (this.computeSizes(), this.recomputeCropPosition()) : e.aspect !== this.props.aspect ? this.computeSizes() : e.objectFit !== this.props.objectFit ? this.computeSizes() : e.zoom !== this.props.zoom ? this.recomputeCropPosition() : ((t = e.cropSize) === null || t === void 0 ? void 0 : t.height) !== ((n = this.props.cropSize) === null || n === void 0 ? void 0 : n.height) || ((i = e.cropSize) === null || i === void 0 ? void 0 : i.width) !== ((o = this.props.cropSize) === null || o === void 0 ? void 0 : o.width) ? this.computeSizes() : (((s = e.crop) === null || s === void 0 ? void 0 : s.x) !== ((c = this.props.crop) === null || c === void 0 ? void 0 : c.x) || ((u = e.crop) === null || u === void 0 ? void 0 : u.y) !== ((h = this.props.crop) === null || h === void 0 ? void 0 : h.y)) && this.emitCropAreaChange(), e.zoomWithScroll !== this.props.zoomWithScroll && this.containerRef && (this.props.zoomWithScroll ? this.containerRef.addEventListener("wheel", this.onWheel, {
        passive: !1
      }) : this.clearScrollEvent()), e.video !== this.props.video && ((p = this.videoRef.current) === null || p === void 0 || p.load());
      var f = this.getObjectFit();
      f !== this.state.mediaObjectFit && this.setState({
        mediaObjectFit: f
      }, this.computeSizes);
    }, r.prototype.getAspect = function() {
      var e = this.props, t = e.cropSize, n = e.aspect;
      return t ? t.width / t.height : n;
    }, r.prototype.getObjectFit = function() {
      var e, t, n, i;
      if (this.props.objectFit === "cover") {
        var o = this.imageRef.current || this.videoRef.current;
        if (o && this.containerRef) {
          this.containerRect = this.containerRef.getBoundingClientRect();
          var s = this.containerRect.width / this.containerRect.height, c = ((e = this.imageRef.current) === null || e === void 0 ? void 0 : e.naturalWidth) || ((t = this.videoRef.current) === null || t === void 0 ? void 0 : t.videoWidth) || 0, u = ((n = this.imageRef.current) === null || n === void 0 ? void 0 : n.naturalHeight) || ((i = this.videoRef.current) === null || i === void 0 ? void 0 : i.videoHeight) || 0, h = c / u;
          return h < s ? "horizontal-cover" : "vertical-cover";
        }
        return "horizontal-cover";
      }
      return this.props.objectFit;
    }, r.prototype.onPinchStart = function(e) {
      var t = r.getTouchPoint(e.touches[0]), n = r.getTouchPoint(e.touches[1]);
      this.lastPinchDistance = G(t, n), this.lastPinchRotation = q(t, n), this.onDragStart(X(t, n));
    }, r.prototype.onPinchMove = function(e) {
      var t = this;
      if (!(!this.currentDoc || !this.currentWindow)) {
        var n = r.getTouchPoint(e.touches[0]), i = r.getTouchPoint(e.touches[1]), o = X(n, i);
        this.onDrag(o), this.rafPinchTimeout && this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout), this.rafPinchTimeout = this.currentWindow.requestAnimationFrame(function() {
          var s = G(n, i), c = t.props.zoom * (s / t.lastPinchDistance);
          t.setNewZoom(c, o, {
            shouldUpdatePosition: !1
          }), t.lastPinchDistance = s;
          var u = q(n, i), h = t.props.rotation + (u - t.lastPinchRotation);
          t.props.onRotationChange && t.props.onRotationChange(h), t.lastPinchRotation = u;
        });
      }
    }, r.prototype.render = function() {
      var e = this, t, n = this.props, i = n.image, o = n.video, s = n.mediaProps, c = n.transform, u = n.crop, h = u.x, p = u.y, f = n.rotation, w = n.zoom, v = n.cropShape, C = n.showGrid, d = n.style, S = d.containerStyle, g = d.cropAreaStyle, l = d.mediaStyle, y = n.classes, D = y.containerClassName, b = y.cropAreaClassName, L = y.mediaClassName, x = (t = this.state.mediaObjectFit) !== null && t !== void 0 ? t : this.getObjectFit();
      return R.createElement("div", {
        onMouseDown: this.onMouseDown,
        onTouchStart: this.onTouchStart,
        ref: function(B) {
          return e.containerRef = B;
        },
        "data-testid": "container",
        style: S,
        className: P("reactEasyCrop_Container", D)
      }, i ? R.createElement("img", m({
        alt: "",
        className: P("reactEasyCrop_Image", x === "contain" && "reactEasyCrop_Contain", x === "horizontal-cover" && "reactEasyCrop_Cover_Horizontal", x === "vertical-cover" && "reactEasyCrop_Cover_Vertical", L)
      }, s, {
        src: i,
        ref: this.imageRef,
        style: m(m({}, l), {
          transform: c || "translate(".concat(h, "px, ").concat(p, "px) rotate(").concat(f, "deg) scale(").concat(w, ")")
        }),
        onLoad: this.onMediaLoad
      })) : o && R.createElement("video", m({
        autoPlay: !0,
        playsInline: !0,
        loop: !0,
        muted: !0,
        className: P("reactEasyCrop_Video", x === "contain" && "reactEasyCrop_Contain", x === "horizontal-cover" && "reactEasyCrop_Cover_Horizontal", x === "vertical-cover" && "reactEasyCrop_Cover_Vertical", L)
      }, s, {
        ref: this.videoRef,
        onLoadedMetadata: this.onMediaLoad,
        style: m(m({}, l), {
          transform: c || "translate(".concat(h, "px, ").concat(p, "px) rotate(").concat(f, "deg) scale(").concat(w, ")")
        }),
        controls: !1
      }), (Array.isArray(o) ? o : [{
        src: o
      }]).map(function(M) {
        return R.createElement("source", m({
          key: M.src
        }, M));
      })), this.state.cropSize && R.createElement("div", {
        style: m(m({}, g), {
          width: this.state.cropSize.width,
          height: this.state.cropSize.height
        }),
        tabIndex: 0,
        onKeyDown: this.onKeyDown,
        "data-testid": "cropper",
        className: P("reactEasyCrop_CropArea", v === "round" && "reactEasyCrop_CropAreaRound", C && "reactEasyCrop_CropAreaGrid", b)
      }));
    }, r.defaultProps = {
      zoom: 1,
      rotation: 0,
      aspect: 4 / 3,
      maxZoom: le,
      minZoom: fe,
      cropShape: "rect",
      objectFit: "contain",
      showGrid: !0,
      style: {},
      classes: {},
      mediaProps: {},
      zoomSpeed: 1,
      restrictPosition: !0,
      zoomWithScroll: !0,
      keyboardStep: me
    }, r.getMousePoint = function(e) {
      return {
        x: Number(e.clientX),
        y: Number(e.clientY)
      };
    }, r.getTouchPoint = function(e) {
      return {
        x: Number(e.clientX),
        y: Number(e.clientY)
      };
    }, r;
  }(R.Component)
);
export {
  ge as C
};
