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

import { _ as _defineProperty } from '../../_chunks/dep-2db7b3ec.mjs';
import { defineComponent, toRefs, createVNode, Fragment } from 'vue';
import useDrag from '../hooks/useDrag.mjs';
import { commonProps } from '../constants.mjs';
import { useContent } from '../../hooks/tnode.mjs';
import '../../_chunks/dep-255303ba.mjs';
import '../../_chunks/dep-5717e263.mjs';
import '../../_chunks/dep-eba0ea6e.mjs';
import '../../_chunks/dep-469b4ae0.mjs';
import '../../_chunks/dep-a8bcacea.mjs';
import '../../_chunks/dep-406cd044.mjs';
import '../../_chunks/dep-42cc3015.mjs';
import '../../_chunks/dep-b57180d0.mjs';
import '../../_chunks/dep-c8d7b6b4.mjs';
import '../../_chunks/dep-2bc37d52.mjs';
import '../../_chunks/dep-3da99438.mjs';
import '../../_chunks/dep-327559e8.mjs';
import '../../_chunks/dep-b2235f26.mjs';
import '../../_chunks/dep-8b989474.mjs';
import '../../_chunks/dep-1372b2d3.mjs';
import '../../_chunks/dep-9a85dac1.mjs';
import '../../utils/render-tnode.mjs';
import '../../_chunks/dep-888e80c4.mjs';
import '../../_chunks/dep-334a4f6b.mjs';
import '../../_chunks/dep-e5eb9f23.mjs';
import '../../_chunks/dep-9fe2ef12.mjs';
import '../../_chunks/dep-672e7d1a.mjs';
import '../../_chunks/dep-4d7a675b.mjs';
import '../../_chunks/dep-2e7f59b1.mjs';
import '../../_chunks/dep-1434aa15.mjs';
import '../../_chunks/dep-9262ee2f.mjs';
import '../../_chunks/dep-876fb3ec.mjs';

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 CustomFile = defineComponent({
  name: "UploadCustomFile",
  props: _objectSpread(_objectSpread({}, commonProps), {}, {
    dragEvents: Object,
    draggable: Boolean,
    dragContent: Function,
    trigger: Function,
    triggerUpload: Function,
    childrenNode: [String, Function]
  }),
  setup: function setup(props, _ref) {
    var slots = _ref.slots;
    var _toRefs = toRefs(props),
      classPrefix = _toRefs.classPrefix,
      displayFiles = _toRefs.displayFiles;
    var drag = useDrag(props.dragEvents);
    var dragActive = drag.dragActive;
    var renderContent = useContent();
    var renderDragContent = function renderDragContent() {
      var _props$childrenNode;
      var params = {
        dragActive: dragActive.value || false,
        files: displayFiles.value
      };
      return createVNode("div", {
        "class": "".concat(classPrefix.value, "-upload__dragger ").concat(classPrefix.value, "-upload__dragger-center"),
        "onDrop": drag.handleDrop,
        "onDragenter": drag.handleDragenter,
        "onDragover": drag.handleDragover,
        "onDragleave": drag.handleDragleave,
        "onClick": props.triggerUpload
      }, [createVNode("div", {
        "class": "".concat(classPrefix.value, "-upload__trigger")
      }, [renderContent("dragContent", "trigger", {
        params: params
      }) || ((_props$childrenNode = props.childrenNode) === null || _props$childrenNode === void 0 ? void 0 : _props$childrenNode.call(props, params))])]);
    };
    return function () {
      var _props$childrenNode2, _slots$default;
      return createVNode(Fragment, null, [props.draggable ? renderDragContent() : createVNode("div", {
        "class": "".concat(classPrefix.value, "-upload__trigger"),
        "onClick": props.triggerUpload
      }, [((_props$childrenNode2 = props.childrenNode) === null || _props$childrenNode2 === void 0 ? void 0 : _props$childrenNode2.call(props, {
        files: displayFiles.value
      })) || ((_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots))])]);
    };
  }
});

export { CustomFile as default };
//# sourceMappingURL=custom-file.mjs.map
