"use strict";

var _react = _interopRequireDefault(require("react"));

var _reactDom = _interopRequireDefault(require("react-dom"));

var _ = _interopRequireDefault(require(".."));

var _2 = require("../..");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var afterSelect = function afterSelect(file) {
  return new Promise(function (resolve, reject) {
    var reader = new FileReader();

    reader.onload = function () {
      var img = new Image();

      img.onload = function () {
        if (img.width === 1200) {
          resolve(undefined);
        } else {
          _2.Dialog.alert({
            content: "Image width must be 1200px now ".concat(img.width, "px\uFF01"),
            // @ts-ignore
            closable: false,
            title: 'Warning'
          });

          reject(new Error('error'));
        }
      };

      img.src = reader.result;
    };

    reader.readAsDataURL(file.originFileObj);
  });
};

_reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(_["default"], {
  action: "https://www.easy-mock.com/mock/5b713974309d0d7d107a74a3/alifd/upload",
  autoUpload: false,
  listType: "text" // @ts-ignore
  ,
  afterSelect: afterSelect,
  onError: function onError(err) {
    return console.log('Error', err);
  }
}, /*#__PURE__*/_react["default"].createElement(_2.Button, null, "Upload")), document.getElementById('upload-demo-16'));