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

import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { ChevronRightIcon, ChevronLeftIcon } from 'tdesign-icons-vue';
import { Button } from '../../button/index.js';
import mixins from '../../utils/mixins.js';
import { getClassPrefixMixins, getGlobalIconMixins } from '../../config-provider/config-receiver.js';
import '../../button/button.js';
import '@babel/runtime/helpers/defineProperty';
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/toConsumableArray';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../../utils/dom.js';
import 'vue';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/render-tnode.js';
import '@babel/runtime/helpers/typeof';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../utils/transfer-dom.js';
import '../../loading/props.js';
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 '../../utils/withInstall.js';
import 'lodash/capitalize';
import './style/css.js';
import '../../loading/type.js';
import '../../loading/plugin.js';
import '../../config.js';
import '../../button/props.js';
import '../../utils/ripple.js';
import '../../button/type.js';

var classPrefixMixins = getClassPrefixMixins("transfer");
var TransferOperations = mixins(classPrefixMixins, getGlobalIconMixins()).extend({
  name: "TTransferOperations",
  props: {
    leftDisabled: {
      type: Boolean,
      required: true
    },
    rightDisabled: {
      type: Boolean,
      required: true
    },
    operation: {
      type: [String, Array, Function, Boolean]
    }
  },
  methods: {
    moveToRight: function moveToRight() {
      this.$emit("moveToRight");
    },
    moveToLeft: function moveToLeft() {
      this.$emit("moveToLeft");
    },
    getIconRight: function getIconRight() {
      var h = this.$createElement;

      var _this$useGlobalIcon = this.useGlobalIcon({
        ChevronRightIcon: ChevronRightIcon
      }),
          ChevronRightIcon$1 = _this$useGlobalIcon.ChevronRightIcon;

      return h(ChevronRightIcon$1);
    },
    getIconLeft: function getIconLeft() {
      var h = this.$createElement;

      var _this$useGlobalIcon2 = this.useGlobalIcon({
        ChevronLeftIcon: ChevronLeftIcon
      }),
          ChevronLeftIcon$1 = _this$useGlobalIcon2.ChevronLeftIcon;

      return h(ChevronLeftIcon$1);
    },
    getIcon: function getIcon(direction) {
      if (typeof this.operation === "function") {
        return null;
      }

      if (direction === "right" && this.operation && typeof this.operation[0] === "function") {
        return null;
      }

      if (direction === "left" && this.operation && typeof this.operation[1] === "function") {
        return null;
      }

      if (this.$scopedSlots.operation) {
        return null;
      }

      return direction === "left" ? this.getIconLeft : this.getIconRight;
    },
    _renderButton: function _renderButton(h, direction) {
      if (typeof this.$scopedSlots.operation === "function") {
        return this.$scopedSlots.operation({
          direction: direction
        });
      }

      if (typeof this.operation === "function") {
        var renderContent2 = this.operation;
        return renderContent2(h, {
          direction: direction
        });
      }

      var renderContent;

      if (Array.isArray(this.operation)) {
        var _this$operation = _slicedToArray(this.operation, 2),
            left = _this$operation[0],
            right = _this$operation[1];

        renderContent = direction === "right" ? right : left;
      } else {
        renderContent = "";
      }

      return renderContent;
    }
  },
  render: function render(h) {
    var _this$$props = this.$props,
        leftDisabled = _this$$props.leftDisabled,
        rightDisabled = _this$$props.rightDisabled;
    return h("div", {
      "class": "".concat(this.componentName, "__operations")
    }, [h(Button, {
      "attrs": {
        "variant": "outline",
        "disabled": rightDisabled,
        "icon": this.getIcon("right")
      },
      "key": rightDisabled ? "right-outline" : "right-base",
      "on": {
        "click": this.moveToRight
      }
    }, [this._renderButton(h, "right")]), h(Button, {
      "attrs": {
        "variant": "outline",
        "disabled": leftDisabled,
        "icon": this.getIcon("left")
      },
      "key": leftDisabled ? "left-outline" : "left-base",
      "on": {
        "click": this.moveToLeft
      }
    }, [this._renderButton(h, "left")])]);
  }
});

export { TransferOperations as default };
//# sourceMappingURL=transfer-operations.js.map
