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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var vue = require('vue');
var iconsVueNext = require('@ldesign/icons-vue-next');
var isFunction = require('lodash/isFunction');
var isString = require('lodash/isString');
var isArray = require('lodash/isArray');
var button_index = require('../../button/index.js');
var hooks_useConfig = require('../../hooks/useConfig.js');
var hooks_useGlobalIcon = require('../../hooks/useGlobalIcon.js');
var transfer_props = require('../props.js');
require('../../utils/withInstall.js');
require('../../button/button.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/defineProperty');
require('../../loading/index.js');
require('../../loading/directive.js');
require('../../loading/plugin.js');
require('../../utils/dom.js');
require('../../_chunks/dep-7f0559c3.js');
require('../../utils/easing.js');
require('../../loading/loading.js');
require('../../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/isObject');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../../hooks/useTeleport.js');
require('../../loading/props.js');
require('../../loading/icon/gradient.js');
require('../../_common/js/loading/circle-adapter.js');
require('../../_common/js/utils/set-style.js');
require('../../_common/js/utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');
require('../../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('../../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('../../_common/js/global-config/default-config.js');
require('../../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('dayjs');
require('../../hooks/useRipple.js');
require('../../utils/set-style.js');
require('../../hooks/useKeepAnimation.js');
require('../../form/hooks.js');
require('../../hooks/tnode.js');
require('../../button/props.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction);
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);

function _isSlot(s) {
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
}
var TransferOperations = vue.defineComponent({
  name: "TTransferOperations",
  props: {
    leftDisabled: {
      type: Boolean,
      required: true
    },
    rightDisabled: {
      type: Boolean,
      required: true
    },
    operation: transfer_props["default"].operation
  },
  emits: ["moveToRight", "moveToLeft"],
  setup: function setup(props2, _ref) {
    var slots = _ref.slots,
      emit = _ref.emit;
    var classPrefix = hooks_useConfig.usePrefixClass();
    var _useGlobalIcon = hooks_useGlobalIcon.useGlobalIcon({
        ChevronRightIcon: iconsVueNext.ChevronRightIcon,
        ChevronLeftIcon: iconsVueNext.ChevronLeftIcon
      }),
      ChevronRightIcon = _useGlobalIcon.ChevronRightIcon,
      ChevronLeftIcon = _useGlobalIcon.ChevronLeftIcon;
    var moveToRight = function moveToRight() {
      emit("moveToRight");
    };
    var moveToLeft = function moveToLeft() {
      emit("moveToLeft");
    };
    var getIconRight = function getIconRight() {
      return vue.createVNode(ChevronRightIcon, null, null);
    };
    var getIconLeft = function getIconLeft() {
      return vue.createVNode(ChevronLeftIcon, null, null);
    };
    var getIcon = function getIcon(direction) {
      if (isFunction__default["default"](props2.operation)) return null;
      if (direction === "right" && props2.operation && isFunction__default["default"](props2.operation[0])) return null;
      if (direction === "left" && props2.operation && isFunction__default["default"](props2.operation[1])) return null;
      if (slots.operation) return null;
      return direction === "left" ? getIconLeft : getIconRight;
    };
    var renderButton = function renderButton(h2, direction) {
      if (isFunction__default["default"](slots.operation)) {
        return slots.operation({
          direction: direction
        });
      }
      if (isFunction__default["default"](props2.operation)) {
        var renderContent2 = props2.operation;
        return renderContent2(h2, {
          direction: direction
        });
      }
      var renderContent;
      if (isArray__default["default"](props2.operation)) {
        var _props2$operation = _slicedToArray__default["default"](props2.operation, 2),
          left = _props2$operation[0],
          right = _props2$operation[1];
        renderContent = direction === "right" ? right : left;
      } else {
        renderContent = "";
      }
      return renderContent;
    };
    return function () {
      var _slot, _slot2;
      var _props2$operation2, _props2$operation3;
      return vue.createVNode("div", {
        "class": "".concat(classPrefix.value, "-transfer__operations")
      }, [vue.createVNode(button_index.Button, {
        "variant": "outline",
        "size": "small",
        "shape": isString__default["default"]((_props2$operation2 = props2.operation) === null || _props2$operation2 === void 0 ? void 0 : _props2$operation2[1]) ? "rectangle" : "square",
        "key": props2.rightDisabled ? "right-outline" : "right-base",
        "disabled": props2.rightDisabled,
        "onClick": moveToRight,
        "icon": getIcon("right")
      }, _isSlot(_slot = renderButton(vue.h, "right")) ? _slot : {
        "default": function _default() {
          return [_slot];
        }
      }), vue.createVNode(button_index.Button, {
        "variant": "outline",
        "size": "small",
        "shape": isString__default["default"]((_props2$operation3 = props2.operation) === null || _props2$operation3 === void 0 ? void 0 : _props2$operation3[0]) ? "rectangle" : "square",
        "key": props2.rightDisabled ? "left-outline" : "left-base",
        "disabled": props2.leftDisabled,
        "onClick": moveToLeft,
        "icon": getIcon("left")
      }, _isSlot(_slot2 = renderButton(vue.h, "left")) ? _slot2 : {
        "default": function _default() {
          return [_slot2];
        }
      })]);
    };
  }
});

exports["default"] = TransferOperations;
//# sourceMappingURL=transfer-operations.js.map
