import C from "../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import s from "../../@babel/runtime/helpers/esm/defineProperty.mjs";
import $ from "../../@rc-component/portal/es/Portal.mjs";
import d from "../../classnames/index.mjs";
import _ from "../../rc-motion/es/CSSMotion.mjs";
import "../../rc-motion/es/CSSMotionList.mjs";
import * as t from "react";
import { useContext as oo } from "react";
import to from "../../rc-util/es/KeyCode.mjs";
import { PreviewGroupContext as eo } from "./context.mjs";
var Co = function(o) {
  var f = o.visible, z = o.maskTransitionName, u = o.getContainer, e = o.prefixCls, L = o.rootClassName, a = o.icons, h = o.countRender, O = o.showSwitch, F = o.showProgress, l = o.current, X = o.transform, m = o.count, v = o.scale, Y = o.minScale, Z = o.maxScale, w = o.closeIcon, P = o.onSwitchLeft, K = o.onSwitchRight, g = o.onClose, y = o.onZoomIn, R = o.onZoomOut, N = o.onRotateRight, k = o.onRotateLeft, I = o.onFlipX, b = o.onFlipY, E = o.toolbarRender, p = o.zIndex, D = oo(eo), T = a.rotateLeft, j = a.rotateRight, G = a.zoomIn, M = a.zoomOut, q = a.close, A = a.left, B = a.right, H = a.flipX, J = a.flipY, Q = "".concat(e, "-operations-operation");
  t.useEffect(function() {
    var n = function(r) {
      r.keyCode === to.ESC && g();
    };
    return f && window.addEventListener("keydown", n), function() {
      window.removeEventListener("keydown", n);
    };
  }, [f]);
  var U = [{
    icon: J,
    onClick: b,
    type: "flipY"
  }, {
    icon: H,
    onClick: I,
    type: "flipX"
  }, {
    icon: T,
    onClick: k,
    type: "rotateLeft"
  }, {
    icon: j,
    onClick: N,
    type: "rotateRight"
  }, {
    icon: M,
    onClick: R,
    type: "zoomOut",
    disabled: v <= Y
  }, {
    icon: G,
    onClick: y,
    type: "zoomIn",
    disabled: v === Z
  }], i = U.map(function(n) {
    var c, r = n.icon, V = n.onClick, x = n.type, W = n.disabled;
    return /* @__PURE__ */ t.createElement("div", {
      className: d(Q, (c = {}, s(c, "".concat(e, "-operations-operation-").concat(x), !0), s(c, "".concat(e, "-operations-operation-disabled"), !!W), c)),
      onClick: V,
      key: x
    }, r);
  }), S = /* @__PURE__ */ t.createElement("div", {
    className: "".concat(e, "-operations")
  }, i);
  return /* @__PURE__ */ t.createElement(_, {
    visible: f,
    motionName: z
  }, function(n) {
    var c = n.className, r = n.style;
    return /* @__PURE__ */ t.createElement($, {
      open: !0,
      getContainer: u ?? document.body
    }, /* @__PURE__ */ t.createElement("div", {
      className: d("".concat(e, "-operations-wrapper"), c, L),
      style: C(C({}, r), {}, {
        zIndex: p
      })
    }, w === null ? null : /* @__PURE__ */ t.createElement("button", {
      className: "".concat(e, "-close"),
      onClick: g
    }, w || q), O && /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement("div", {
      className: d("".concat(e, "-switch-left"), s({}, "".concat(e, "-switch-left-disabled"), l === 0)),
      onClick: P
    }, A), /* @__PURE__ */ t.createElement("div", {
      className: d("".concat(e, "-switch-right"), s({}, "".concat(e, "-switch-right-disabled"), l === m - 1)),
      onClick: K
    }, B)), /* @__PURE__ */ t.createElement("div", {
      className: "".concat(e, "-footer")
    }, F && /* @__PURE__ */ t.createElement("div", {
      className: "".concat(e, "-progress")
    }, h ? h(l + 1, m) : "".concat(l + 1, " / ").concat(m)), E ? E(S, C({
      icons: {
        flipYIcon: i[0],
        flipXIcon: i[1],
        rotateLeftIcon: i[2],
        rotateRightIcon: i[3],
        zoomOutIcon: i[4],
        zoomInIcon: i[5]
      },
      actions: {
        onFlipY: b,
        onFlipX: I,
        onRotateLeft: k,
        onRotateRight: N,
        onZoomOut: R,
        onZoomIn: y
      },
      transform: X
    }, D ? {
      current: l,
      total: m
    } : {})) : S)));
  });
};
export {
  Co as default
};
