"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.openPreviewImage = void 0;
var _core = require("@vxe-ui/core");
var _preview = _interopRequireDefault(require("./preview"));
var _xeUtils = _interopRequireDefault(require("xe-utils"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
var openPreviewImage = exports.openPreviewImage = function openPreviewImage(options) {
  if (_core.VxeUI.modal) {
    var opts = Object.assign({
      escClosable: true
    }, options);
    var urlList = opts.urlList,
      activeIndex = opts.activeIndex,
      zIndex = opts.zIndex;
    var _ref = opts.events || {},
      _rotate = _ref.rotate,
      _change = _ref.change;
    var modalId = _xeUtils.default.uniqueId('image-preview');
    _core.VxeUI.modal.open({
      id: modalId,
      title: '预览',
      width: '100%',
      height: '100%',
      showHeader: false,
      showFooter: false,
      padding: false,
      escClosable: opts.escClosable,
      zIndex: zIndex,
      className: 'vxe-image-preview-popup-wrapper',
      slots: {
        default: function _default(params, h) {
          return h(_preview.default, {
            props: {
              value: activeIndex,
              urlList: urlList,
              urlField: opts.urlField,
              marginSize: opts.marginSize,
              maskClosable: opts.maskClosable,
              toolbarConfig: opts.toolbarConfig,
              showPrintButton: opts.showPrintButton,
              showDownloadButton: opts.showDownloadButton,
              beforeDownloadMethod: opts.beforeDownloadMethod,
              downloadMethod: opts.downloadMethod
            },
            on: {
              close: function close() {
                _core.VxeUI.modal.close(modalId);
              },
              change: function change(eventParams) {
                if (_change) {
                  _change.call(this, eventParams);
                }
              },
              rotate: function rotate(eventParams) {
                if (_rotate) {
                  _rotate.call(this, eventParams);
                }
              }
            }
          });
        }
      }
    });
  }
  return Promise.resolve();
};