import { defineComponent, createVNode, Transition } from 'vue';
import getPrefixCls from '../_util/getPrefixCls';
import { ArrowUpOutlined } from '../icon';
import { useTheme } from '../_theme/useTheme';
import { backTopProps } from './props';
import { useBackTop } from './useBackTop';

const prefixCls = getPrefixCls('back-top');
var backTop = defineComponent({
  name: 'FBackTop',
  props: backTopProps,
  emits: ['click'],
  setup(props, _ref) {
    let {
      emit,
      slots
    } = _ref;
    useTheme();
    const {
      visible,
      handleClick,
      backTopStyle
    } = useBackTop(props, emit);
    return () => createVNode(Transition, {
      "name": `${prefixCls}-fade-in`
    }, {
      default: () => [visible.value && createVNode("div", {
        "style": backTopStyle.value,
        "class": `${prefixCls}`,
        "onClick": handleClick
      }, [slots.default ? slots.default() : createVNode(ArrowUpOutlined, {
        "class": `${prefixCls}-icon`
      }, null)])]
    });
  }
});

export { backTop as default };
