/**
 * tdesign v0.41.7
 * (c) 2022 tdesign
 * @license MIT
 */

import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _regeneratorRuntime from '@babel/runtime/regenerator';
import findIndex from 'lodash/findIndex';
import isFunction from 'lodash/isFunction';
import without from 'lodash/without';
import { UploadIcon } from 'tdesign-icons-vue';
import mixins from '../utils/mixins.js';
import getConfigReceiverMixins from '../config-provider/config-receiver.js';
import { prefix } from '../config.js';
import Dragger from './dragger.js';
import ImageCard from './image.js';
import FlowList from './flow-list.js';
import xhr from '../_common/js/upload/xhr.js';
import '../_common/js/log/index.js';
import { formatFiles, isOverSizeLimit } from '../_common/js/upload/utils.js';
import { Button } from '../button/index.js';
import { Dialog } from '../dialog/index.js';
import SingleFile from './single-file.js';
import { renderContent } from '../utils/render-tnode.js';
import props from './props.js';
import { emitEvent } from '../utils/event.js';
import log from '../_common/js/log/log.js';
import 'vue';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../config-provider/type.js';
import '../loading/index.js';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/set-style.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../utils/classnames.js';
import '../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '@babel/runtime/helpers/typeof';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import './style/index.js';
import '../loading/type.js';
import '../loading/plugin.js';
import '../button/button.js';
import '../_chunks/dep-37d5b9c4.js';
import '../button/props.js';
import '../utils/ripple.js';
import '../button/type.js';
import '../dialog/dialog.js';
import 'lodash/throttle';
import '../dialog/actions.js';
import 'lodash/isObject';
import '../dialog/props.js';
import '../hooks/useDestroyOnClose.js';
import '../utils/helper.js';
import 'lodash/camelCase';
import '../dialog/type.js';
import '../dialog/plugin.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var name = "".concat(prefix, "-upload");
var _Upload = mixins(getConfigReceiverMixins("upload")).extend({
  name: "TUpload",
  components: {
    Dragger: Dragger,
    SingleFile: SingleFile,
    ImageCard: ImageCard,
    FlowList: FlowList,
    TDialog: Dialog
  },
  model: {
    prop: "files",
    event: "change"
  },
  props: _objectSpread({}, props),
  data: function data() {
    return {
      formDisabled: void 0,
      dragActive: false,
      loadingFile: null,
      toUploadFiles: [],
      errorMsg: "",
      showImageViewDialog: false,
      showImageViewUrl: "",
      xhrReq: null
    };
  },
  computed: {
    isSingleRequest: function isSingleRequest() {
      return !this.multiple || this.isBatchUpload;
    },
    tDisabled: function tDisabled() {
      return this.formDisabled || this.disabled;
    },
    showTips: function showTips() {
      if (this.theme === "file") {
        var hasNoFile = (!this.files || !this.files.length) && !this.loadingFile;
        return this.tips && hasNoFile;
      }

      return Boolean(this.tips);
    },
    showCustomDisplay: function showCustomDisplay() {
      return this.theme === "custom";
    },
    showSingleDisplay: function showSingleDisplay() {
      return !this.draggable && ["file", "file-input"].includes(this.theme);
    },
    showImgCard: function showImgCard() {
      return !this.draggable && this.theme === "image";
    },
    singleDraggable: function singleDraggable() {
      return !this.multiple && this.draggable && ["file", "file-input", "image"].includes(this.theme);
    },
    showUploadList: function showUploadList() {
      return this.multiple && ["file-flow", "image-flow"].includes(this.theme);
    },
    showImgDialog: function showImgDialog() {
      return ["image", "image-flow", "custom"].includes(this.theme);
    },
    showErrorMsg: function showErrorMsg() {
      return !!this.errorMsg;
    },
    tipsClasses: function tipsClasses() {
      return ["".concat(name, "__tips"), "".concat(prefix, "-size-s")];
    },
    errorClasses: function errorClasses() {
      return this.tipsClasses.concat("".concat(name, "__tips-error"));
    },
    uploadInOneRequest: function uploadInOneRequest() {
      return this.multiple && this.uploadAllFilesInOneRequest;
    },
    canBatchUpload: function canBatchUpload() {
      return this.uploadInOneRequest && this.isBatchUpload;
    },
    uploadListTriggerText: function uploadListTriggerText() {
      var _this$toUploadFiles, _this$files;

      var uploadText = this.global.triggerUploadText.fileInput;

      if (((_this$toUploadFiles = this.toUploadFiles) === null || _this$toUploadFiles === void 0 ? void 0 : _this$toUploadFiles.length) > 0 || ((_this$files = this.files) === null || _this$files === void 0 ? void 0 : _this$files.length) > 0) {
        var _this$files2;

        if (this.theme === "file-input" || ((_this$files2 = this.files) === null || _this$files2 === void 0 ? void 0 : _this$files2.length) > 0 && this.canBatchUpload) {
          uploadText = this.global.triggerUploadText.reupload;
        } else {
          uploadText = this.global.triggerUploadText.continueUpload;
        }
      }

      return uploadText;
    }
  },
  methods: {
    emitChangeEvent: function emitChangeEvent(files, ctx) {
      emitEvent(this, "change", files, ctx);
    },
    emitRemoveEvent: function emitRemoveEvent(ctx) {
      emitEvent(this, "remove", ctx);
    },
    handlePreviewImg: function handlePreviewImg(event, file) {
      if (!file || !file.url) return log.error("Uploader", "Preview Error file");
      this.showImageViewUrl = file.url;
      this.showImageViewDialog = true;
      var previewCtx = {
        file: file,
        e: event
      };
      emitEvent(this, "preview", previewCtx);
    },
    handleChange: function handleChange(event) {
      var files = event.target.files;
      if (this.tDisabled) return;
      this.uploadFiles(files);
      emitEvent(this, "select-change", formatFiles(Array.from(files), this.format));
      this.$refs.input.value = "";
    },
    handleDragChange: function handleDragChange(files) {
      if (this.tDisabled) return;
      this.uploadFiles(files);
      emitEvent(this, "select-change", formatFiles(Array.from(files), this.format));
    },
    handleSingleRemove: function handleSingleRemove(e) {
      var changeCtx = {
        trigger: "remove"
      };
      if (this.loadingFile) this.loadingFile = null;
      this.errorMsg = "";
      this.emitChangeEvent([], changeCtx);
      this.emitRemoveEvent({
        e: e
      });
    },
    handleFileInputRemove: function handleFileInputRemove(e) {
      e === null || e === void 0 ? void 0 : e.stopPropagation();
      this.handleSingleRemove(e);
    },
    handleMultipleRemove: function handleMultipleRemove(options) {
      var changeCtx = _objectSpread({
        trigger: "remove"
      }, options);

      var files;

      if (!this.canBatchUpload) {
        files = this.files.concat();
        files.splice(options.index, 1);
      } else {
        files = [];
        options.files = this.files.concat();
      }

      this.emitChangeEvent(files, changeCtx);
      this.emitRemoveEvent(options);
    },
    handleListRemove: function handleListRemove(context) {
      var file = context.file,
          e = context.e;
      var index = findIndex(this.toUploadFiles, function (o) {
        return o.name === (file === null || file === void 0 ? void 0 : file.name);
      });

      if (index >= 0) {
        this.toUploadFiles.splice(index, 1);
        this.emitRemoveEvent({
          e: e,
          file: file,
          index: index
        });
      } else {
        var index2 = findIndex(this.files, function (o) {
          return o.name === (file === null || file === void 0 ? void 0 : file.name);
        });
        this.handleMultipleRemove({
          e: e,
          index: index2
        });
      }
    },
    uploadFiles: function uploadFiles(files) {
      var _this$files3,
          _this = this;

      if (this.canBatchUpload && ((_this$files3 = this.files) === null || _this$files3 === void 0 ? void 0 : _this$files3.length) > 0) {
        var context = {
          trigger: "batch-clear"
        };
        this.emitChangeEvent([], context);
      }

      var tmpFiles = _toConsumableArray(files);

      if (this.max) {
        tmpFiles = tmpFiles.slice(0, this.max - this.toUploadFiles.length - this.files.length);

        if (tmpFiles.length !== files.length) {
          console.warn("TDesign Upload Warn: you can only upload ".concat(this.max, " files"));
        }
      }

      tmpFiles.forEach(function (fileRaw) {
        var file = fileRaw;

        if (typeof _this.format === "function") {
          file = _this.format(fileRaw);
        }

        var uploadFile = _objectSpread({
          raw: fileRaw,
          lastModified: fileRaw.lastModified,
          name: fileRaw.name,
          size: fileRaw.size,
          type: fileRaw.type,
          percent: 0,
          status: "waiting"
        }, file);

        var reader = new FileReader();
        reader.readAsDataURL(fileRaw);

        reader.onload = function (event) {
          uploadFile.url = event.target.result;
        };

        _this.handleBeforeUpload(file).then(function (canUpload) {
          if (!canUpload) return;

          var newFiles = _this.toUploadFiles.concat();

          if (_this.allowUploadDuplicateFile || !_this.toUploadFiles.find(function (file2) {
            return file2.name === uploadFile.name;
          })) {
            newFiles.push(uploadFile);
          }

          _this.toUploadFiles = newFiles;
          _this.loadingFile = uploadFile;

          if (_this.autoUpload) {
            _this.upload(uploadFile);
          }
        });
      });
    },
    upload: function upload(currentFiles, index) {
      var _this2 = this;

      return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
        var innerFiles, request, currentXhr;
        return _regeneratorRuntime.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                innerFiles = Array.isArray(currentFiles) ? currentFiles : [currentFiles];

                if (!(!_this2.action && !_this2.requestMethod)) {
                  _context.next = 4;
                  break;
                }

                console.error("TDesign Upload Error: one of action and requestMethod must be exist.");
                return _context.abrupt("return");

              case 4:
                _this2.errorMsg = "";
                innerFiles.forEach(function (file) {
                  file.status = "progress";
                  _this2.loadingFile = file;
                });

                if (_this2.requestMethod) {
                  _this2.handleRequestMethod(innerFiles);
                } else {
                  if (_this2.useMockProgress) {
                    _this2.handleMockProgress(innerFiles);
                  }

                  request = xhr;
                  currentXhr = request({
                    method: _this2.method,
                    action: _this2.action,
                    data: _this2.data,
                    files: innerFiles,
                    name: _this2.name,
                    headers: _this2.headers,
                    withCredentials: _this2.withCredentials,
                    onError: _this2.onError,
                    onProgress: _this2.handleProgress,
                    onSuccess: _this2.handleSuccess
                  });

                  if (_this2.isSingleRequest) {
                    _this2.xhrReq = currentXhr;
                  } else if (typeof index === "number") _this2.toUploadFiles[index].xhr = currentXhr;
                }

              case 7:
              case "end":
                return _context.stop();
            }
          }
        }, _callee);
      }))();
    },
    handleMockProgress: function handleMockProgress(files) {
      var _this3 = this;

      var timer = setInterval(function () {
        files.forEach(function (file) {
          if (file.status === "success" || file.percent >= 99) {
            clearInterval(timer);
            return;
          }

          file.percent += 1;
        });
        var percent = files[0].percent;

        _this3.handleProgress({
          files: files,
          percent: percent,
          type: "mock"
        });
      }, 10);
    },
    handleRequestMethod: function handleRequestMethod(files) {
      var _this4 = this;

      if (!isFunction(this.requestMethod)) {
        console.warn("TDesign Upload Warn: `requestMethod` must be a function.");
        return;
      }

      var requestMethodParam = this.uploadInOneRequest ? files : files[0];
      this.requestMethod(requestMethodParam).then(function (res) {
        if (!_this4.handleRequestMethodResponse(res)) return;

        if (res.status === "success") {
          _this4.handleSuccess({
            files: files,
            response: res.response
          });
        } else if (res.status === "fail") {
          var r = res.response || {};

          _this4.onError({
            file: _this4.uploadInOneRequest ? null : files[0],
            files: files,
            response: _objectSpread(_objectSpread({}, r), {}, {
              error: res.error
            })
          });
        }
      });
    },
    handleRequestMethodResponse: function handleRequestMethodResponse(res) {
      if (!res) {
        console.error("TDesign Upload Error: `requestMethodResponse` is required.");
        return false;
      }

      if (!res.status) {
        console.error("TDesign Upload Error: `requestMethodResponse.status` is missing, which value is `success` or `fail`");
        return false;
      }

      if (!["success", "fail"].includes(res.status)) {
        console.error("TDesign Upload Error: `requestMethodResponse.status` must be `success` or `fail`");
        return false;
      }

      if (res.status === "success" && (!res.response || !res.response.url)) {
        console.warn("TDesign Upload Warn: `requestMethodResponse.response.url` is required, when `status` is `success`");
      }

      return true;
    },
    multipleUpload: function multipleUpload(currentFiles) {
      var _this5 = this;

      if (this.uploadAllFilesInOneRequest) {
        this.upload(currentFiles);
      } else {
        currentFiles.forEach(function (file, index) {
          _this5.upload(file, index);
        });
      }
    },
    onError: function onError(options) {
      var _this6 = this,
          _res;

      var event = options.event,
          file = options.file,
          files = options.files,
          response = options.response,
          resFormatted = options.resFormatted;
      var innerFiles = Array.isArray(files) ? files : [file];
      innerFiles.forEach(function (file2) {
        file2.status = "fail";
        _this6.loadingFile = file2;
      });
      var res = response;

      if (!resFormatted && typeof this.formatResponse === "function") {
        res = this.formatResponse(response, {
          file: file,
          currentFiles: files
        });
      }

      this.errorMsg = (_res = res) === null || _res === void 0 ? void 0 : _res.error;
      var context = {
        e: event,
        file: this.uploadInOneRequest ? null : innerFiles[0],
        currentFiles: innerFiles
      };
      emitEvent(this, "fail", context);
    },
    handleProgress: function handleProgress(_ref) {
      var _this7 = this;

      var event = _ref.event,
          file = _ref.file,
          currentFiles = _ref.files,
          percent = _ref.percent,
          _ref$type = _ref.type,
          type = _ref$type === void 0 ? "real" : _ref$type;
      var innerFiles = Array.isArray(currentFiles) ? currentFiles : [file];
      if ((innerFiles === null || innerFiles === void 0 ? void 0 : innerFiles.length) <= 0) return log.error("Uploader", "Progress Error files");
      innerFiles.forEach(function (file2) {
        file2.percent = Math.min(percent, 100);
        _this7.loadingFile = file2.status === "success" ? null : file2;
      });
      var progressCtx = {
        percent: percent,
        e: event,
        file: file,
        type: type,
        currentFiles: innerFiles
      };
      emitEvent(this, "progress", progressCtx);
    },
    handleSuccess: function handleSuccess(_ref2) {
      var _res2, _this$files4;

      var event = _ref2.event,
          file = _ref2.file,
          currentFiles = _ref2.files,
          response = _ref2.response;
      var innerFiles = Array.isArray(currentFiles) ? currentFiles : [file];
      if ((innerFiles === null || innerFiles === void 0 ? void 0 : innerFiles.length) <= 0) return log.error("Uploader", "success no files");
      innerFiles.forEach(function (file2) {
        file2.status = "success";
      });
      var res = response;

      if (typeof this.formatResponse === "function") {
        res = this.formatResponse(response, {
          file: this.uploadInOneRequest ? null : innerFiles[0],
          currentFiles: innerFiles
        });
      }

      if ((_res2 = res) !== null && _res2 !== void 0 && _res2.error) {
        this.onError({
          event: event,
          file: this.uploadInOneRequest ? null : innerFiles[0],
          files: innerFiles,
          response: res,
          resFormatted: true
        });
        return;
      }

      if (!this.uploadInOneRequest) {
        innerFiles[0].url = res.url || innerFiles[0].url;
      }

      this.toUploadFiles = without.apply(void 0, [this.toUploadFiles].concat(_toConsumableArray(innerFiles)));
      var newFiles = innerFiles.map(function (file2) {
        return _objectSpread(_objectSpread({}, file2), {}, {
          response: res
        });
      });
      this.multiple && (_this$files4 = this.files).push.apply(_this$files4, _toConsumableArray(newFiles));
      var uploadedFiles = this.multiple ? this.files : newFiles;
      var context = {
        e: event,
        response: res,
        trigger: "upload-success"
      };
      this.emitChangeEvent(uploadedFiles, context);
      var sContext = {
        file: this.uploadInOneRequest ? null : newFiles[0],
        fileList: uploadedFiles,
        currentFiles: newFiles,
        e: event,
        response: res
      };
      emitEvent(this, "success", sContext);
      this.loadingFile = null;
    },
    handlePreview: function handlePreview(_ref3) {
      var file = _ref3.file,
          event = _ref3.event;
      return {
        file: file,
        event: event
      };
    },
    triggerUpload: function triggerUpload() {
      if (this.tDisabled) return;
      this.$refs.input.click();
    },
    handleDragenter: function handleDragenter(e) {
      if (this.tDisabled) return;
      this.dragActive = true;
      emitEvent(this, "dragenter", {
        e: e
      });
    },
    handleDragleave: function handleDragleave(e) {
      if (this.tDisabled) return;
      this.dragActive = false;
      emitEvent(this, "dragleave", {
        e: e
      });
    },
    handleBeforeUpload: function handleBeforeUpload(file) {
      var _this8 = this;

      if (typeof this.beforeUpload === "function") {
        var r = this.beforeUpload(file);
        if (r instanceof Promise) return r;
        return new Promise(function (resolve) {
          return resolve(r);
        });
      }

      return new Promise(function (resolve) {
        if (_this8.sizeLimit) {
          resolve(_this8.handleSizeLimit(file.size));
        }

        resolve(true);
      });
    },
    handleSizeLimit: function handleSizeLimit(fileSize) {
      var sizeLimit = typeof this.sizeLimit === "number" ? {
        size: this.sizeLimit,
        unit: "KB"
      } : this.sizeLimit;
      var rSize = isOverSizeLimit(fileSize, sizeLimit.size, sizeLimit.unit);

      if (!rSize) {
        this.errorMsg = sizeLimit.message ? this.t(sizeLimit.message, {
          sizeLimit: sizeLimit.size
        }) : "".concat(this.t(this.global.sizeLimitMessage, {
          sizeLimit: sizeLimit.size
        }), " ").concat(sizeLimit.unit);
      }

      return rSize;
    },
    cancelUpload: function cancelUpload() {
      var _this9 = this;

      if (this.loadingFile) {
        if (!this.requestMethod) {
          var _this$xhrReq, _this$xhrReq$abort;

          this.isSingleRequest && ((_this$xhrReq = this.xhrReq) === null || _this$xhrReq === void 0 ? void 0 : (_this$xhrReq$abort = _this$xhrReq.abort) === null || _this$xhrReq$abort === void 0 ? void 0 : _this$xhrReq$abort.call(_this$xhrReq));
          this.multiple && this.toUploadFiles.forEach(function (file) {
            if (file.status === "progress") {
              !_this9.isBatchUpload && file.xhr.abort();
              file.status = "waiting";
            }
          });
        }

        emitEvent(this, "cancel-upload");
        this.loadingFile = null;
      }

      this.$refs.input.value = "";
    },
    cancelPreviewImgDialog: function cancelPreviewImgDialog() {
      var _this10 = this;

      this.showImageViewDialog = false;
      var timer = setTimeout(function () {
        _this10.showImageViewUrl = "";
        clearTimeout(timer);
        timer = null;
      }, 500);
    },
    getDefaultTrigger: function getDefaultTrigger() {
      var _this$files5;

      var h = this.$createElement;

      if (this.theme === "file-input" || this.showUploadList) {
        return h(Button, {
          "attrs": {
            "variant": "outline"
          }
        }, [this.uploadListTriggerText]);
      }

      return h(Button, {
        "attrs": {
          "variant": "outline"
        }
      }, [h(UploadIcon, {
        "slot": "icon"
      }), (_this$files5 = this.files) !== null && _this$files5 !== void 0 && _this$files5.length ? this.global.triggerUploadText.reupload : this.global.triggerUploadText.normal]);
    },
    renderInput: function renderInput() {
      var h = this.$createElement;
      return h("input", {
        "ref": "input",
        "attrs": {
          "type": "file",
          "disabled": this.tDisabled,
          "multiple": this.multiple,
          "accept": this.accept,
          "hidden": true
        },
        "on": {
          "change": this.handleChange
        }
      });
    },
    renderSingleDisplay: function renderSingleDisplay(triggerElement) {
      var h = this.$createElement;
      return h(SingleFile, {
        "attrs": {
          "file": this.files && this.files[0],
          "loadingFile": this.loadingFile,
          "display": this.theme,
          "remove": this.handleSingleRemove,
          "showUploadProgress": this.showUploadProgress,
          "placeholder": this.placeholder,
          "fileListDisplay": this.fileListDisplay
        }
      }, [h("div", {
        "class": "".concat(name, "__trigger"),
        "on": {
          "click": this.triggerUpload
        }
      }, [triggerElement])]);
    },
    renderDraggerTrigger: function renderDraggerTrigger() {
      var h = this.$createElement;
      var params = {
        dragActive: this.dragActive,
        uploadingFile: this.multiple ? this.toUploadFiles : this.loadingFile
      };
      var triggerElement = renderContent(this, "default", "trigger", {
        params: params
      });
      return h(Dragger, {
        "attrs": {
          "showUploadProgress": this.showUploadProgress,
          "loadingFile": this.loadingFile,
          "file": this.files && this.files[0],
          "display": this.theme,
          "cancel": this.cancelUpload,
          "trigger": this.triggerUpload,
          "remove": this.handleSingleRemove,
          "upload": this.upload,
          "autoUpload": this.autoUpload
        },
        "on": {
          "change": this.handleDragChange,
          "dragenter": this.handleDragenter,
          "dragleave": this.handleDragleave
        }
      }, [triggerElement]);
    },
    renderTrigger: function renderTrigger() {
      var defaultNode = this.getDefaultTrigger();
      return renderContent(this, "default", "trigger", defaultNode);
    },
    renderCustom: function renderCustom(triggerElement) {
      var h = this.$createElement;
      return this.draggable ? this.renderDraggerTrigger() : h("div", {
        "class": "".concat(name, "__trigger"),
        "on": {
          "click": this.triggerUpload
        }
      }, [triggerElement]);
    }
  },
  render: function render() {
    var h = arguments[0];
    var triggerElement = this.renderTrigger();
    return h("div", {
      "class": name
    }, [this.renderInput(), this.showCustomDisplay && this.renderCustom(triggerElement), this.showSingleDisplay && this.renderSingleDisplay(triggerElement), this.singleDraggable && this.renderDraggerTrigger(), this.showImgCard && h(ImageCard, {
      "attrs": {
        "files": this.files,
        "multiple": this.multiple,
        "remove": this.handleMultipleRemove,
        "trigger": this.triggerUpload,
        "loadingFile": this.loadingFile,
        "toUploadFiles": this.toUploadFiles,
        "max": this.max,
        "disabled": this.tDisabled
      },
      "on": {
        "imgPreview": this.handlePreviewImg
      }
    }), this.showUploadList && h(FlowList, {
      "attrs": {
        "files": this.files,
        "disabled": this.tDisabled,
        "placeholder": this.placeholder,
        "autoUpload": this.autoUpload,
        "toUploadFiles": this.toUploadFiles,
        "remove": this.handleListRemove,
        "showUploadProgress": this.showUploadProgress,
        "allowUploadDuplicateFile": this.allowUploadDuplicateFile,
        "upload": this.multipleUpload,
        "cancel": this.cancelUpload,
        "display": this.theme,
        "batchUpload": this.canBatchUpload
      },
      "on": {
        "imgPreview": this.handlePreviewImg,
        "change": this.handleDragChange,
        "dragenter": this.handleDragenter,
        "dragleave": this.handleDragleave
      }
    }, [h("div", {
      "class": "".concat(name, "__trigger"),
      "on": {
        "click": this.triggerUpload
      }
    }, [triggerElement])]), this.showImgDialog && h(Dialog, {
      "attrs": {
        "visible": this.showImageViewDialog,
        "showOverlay": true,
        "width": "auto",
        "top": "10%",
        "footer": false,
        "header": false
      },
      "class": "".concat(name, "__dialog"),
      "on": {
        "close": this.cancelPreviewImgDialog
      }
    }, [h("div", {
      "class": "".concat(prefix, "__dialog-body-img-box")
    }, [h("img", {
      "attrs": {
        "src": this.showImageViewUrl,
        "alt": ""
      }
    })])]), !this.errorMsg && this.showTips && h("small", {
      "class": this.tipsClasses
    }, [this.tips]), this.showErrorMsg && h("small", {
      "class": this.errorClasses
    }, [this.errorMsg])]);
  }
});

export { _Upload as default };
//# sourceMappingURL=upload.js.map
