/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

import { defineComponent, ref, computed, watch, createVNode } from 'vue';
import { ImageErrorIcon } from '@ldesign/icons-vue-next';
import { usePrefixClass } from '../../hooks/useConfig.mjs';
import { useDrag } from '../hooks.mjs';
import '../../config-provider/useConfig.mjs';
import '../../_chunks/dep-095107f7.mjs';
import '../../_chunks/dep-eba0ea6e.mjs';
import '../../_chunks/dep-c989dff3.mjs';
import '../../_chunks/dep-9cf86cf1.mjs';
import '../../_chunks/dep-bc1d737a.mjs';
import '../../_chunks/dep-4d7a675b.mjs';
import '../../_chunks/dep-5717e263.mjs';
import '../../_chunks/dep-469b4ae0.mjs';
import '../../_chunks/dep-255303ba.mjs';
import '../../_chunks/dep-a8bcacea.mjs';
import '../../_chunks/dep-2e7f59b1.mjs';
import '../../_chunks/dep-855db8bc.mjs';
import '../../_chunks/dep-a87f3e4c.mjs';
import '../../_chunks/dep-1e566bb5.mjs';
import '../../_chunks/dep-1434aa15.mjs';
import '../../_chunks/dep-3da99438.mjs';
import '../../_chunks/dep-b57180d0.mjs';
import '../../_chunks/dep-c8d7b6b4.mjs';
import '../../_chunks/dep-e5eb9f23.mjs';
import '../../_chunks/dep-9fe2ef12.mjs';
import '../../_chunks/dep-672e7d1a.mjs';
import '../../_chunks/dep-42a19209.mjs';
import '../../_chunks/dep-9262ee2f.mjs';
import '../../_chunks/dep-334a4f6b.mjs';
import '../../_chunks/dep-8d3e9aa3.mjs';
import '../../_chunks/dep-876fb3ec.mjs';
import '../../_chunks/dep-40d69a9c.mjs';
import '../../_chunks/dep-dcc83161.mjs';
import '../../_chunks/dep-0fc02184.mjs';
import '../../_chunks/dep-f1994936.mjs';
import '../../_chunks/dep-345e1be3.mjs';
import '../../_common/js/global-config/default-config.mjs';
import '../../_common/js/global-config/locale/zh_CN.mjs';
import '../../_chunks/dep-9888611c.mjs';
import '../../_chunks/dep-697a1365.mjs';
import '../../config-provider/type.mjs';
import '../../_chunks/dep-2db7b3ec.mjs';

var TImageItem = defineComponent({
  name: "TImageItem",
  props: {
    rotate: Number,
    scale: Number,
    mirror: Number,
    src: String,
    placementSrc: String
  },
  setup: function setup(props) {
    var classPrefix = usePrefixClass();
    var error = ref(false);
    var loaded = ref(false);
    var _useDrag = useDrag({
        translateX: 0,
        translateY: 0
      }),
      transform = _useDrag.transform,
      mouseDownHandler = _useDrag.mouseDownHandler;
    var imgStyle = computed(function () {
      return {
        transform: "rotate(".concat(props.rotate, "deg) scale(").concat(props.scale, ")"),
        display: !props.placementSrc || loaded.value ? "block" : "none"
      };
    });
    var placementImgStyle = computed(function () {
      return {
        transform: "rotate(".concat(props.rotate, "deg) scale(").concat(props.scale, ")"),
        display: !loaded.value ? "block" : "none"
      };
    });
    var boxStyle = computed(function () {
      var _transform$value = transform.value,
        translateX = _transform$value.translateX,
        translateY = _transform$value.translateY;
      return {
        transform: "translate(".concat(translateX, "px, ").concat(translateY, "px) scale(").concat(props.mirror, ", 1)")
      };
    });
    var resetStatus = function resetStatus() {
      error.value = false;
      loaded.value = false;
    };
    watch(function () {
      return props.src;
    }, function () {
      resetStatus();
    });
    return function () {
      return createVNode("div", {
        "class": "".concat(classPrefix.value, "-image-viewer__modal-pic")
      }, [createVNode("div", {
        "class": "".concat(classPrefix.value, "-image-viewer__modal-box"),
        "style": boxStyle.value
      }, [error.value && createVNode("div", {
        "class": "".concat(classPrefix.value, "-image-viewer__img-error")
      }, [createVNode("div", {
        "class": "".concat(classPrefix.value, "-image-viewer__img-error-content")
      }, [createVNode(ImageErrorIcon, {
        "size": "4em"
      }, null), createVNode("div", {
        "class": "".concat(classPrefix.value, "-image-viewer__img-error-text")
      }, ["\u56FE\u7247\u52A0\u8F7D\u5931\u8D25\uFF0C\u53EF\u5C1D\u8BD5\u91CD\u65B0\u52A0\u8F7D"])])]), !error.value && !!props.placementSrc && createVNode("img", {
        "class": "".concat(classPrefix.value, "-image-viewer__modal-image"),
        "onMousedown": function onMousedown(event) {
          event.stopPropagation();
          mouseDownHandler(event);
        },
        "src": props.placementSrc,
        "style": placementImgStyle.value,
        "alt": "image",
        "draggable": "false"
      }, null), !error.value && createVNode("img", {
        "class": "".concat(classPrefix.value, "-image-viewer__modal-image"),
        "onMousedown": function onMousedown(event) {
          event.stopPropagation();
          mouseDownHandler(event);
        },
        "src": props.src,
        "onLoad": function onLoad() {
          return loaded.value = true;
        },
        "onError": function onError() {
          return error.value = true;
        },
        "style": imgStyle.value,
        "alt": "image",
        "draggable": "false"
      }, null)])]);
    };
  }
});

export { TImageItem as default };
//# sourceMappingURL=ImageItem.mjs.map
