'use strict';

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

var vue = require('vue');
var classNames = require('../_util/classNames.js');
var index$1 = require('../tooltip/index.js');
require('../hooks/index.js');
var warning = require('../_util/warning.js');
require('../_util/props-util/index.js');
var index = require('./style/index.js');
var _interface = require('./interface.js');
var FloatButtonContent = require('./FloatButtonContent.js');
var context = require('./context.js');
var initDefaultProps = require('../_util/props-util/initDefaultProps.js');
var useConfigInject = require('../config-provider/hooks/useConfigInject.js');

const floatButtonPrefixCls = "float-btn";
const FloatButton = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "AFloatButton",
  inheritAttrs: false,
  props: initDefaultProps.default(_interface.floatButtonProps(), {
    type: "default",
    shape: "circle"
  }),
  setup(props, {
    attrs,
    slots
  }) {
    const {
      prefixCls,
      direction
    } = useConfigInject.default(floatButtonPrefixCls, props);
    const [wrapSSR, hashId] = index.default(prefixCls);
    const {
      shape: groupShape
    } = context.useInjectFloatButtonGroupContext();
    const floatButtonRef = vue.ref(null);
    const mergeShape = vue.computed(() => {
      return (groupShape == null ? void 0 : groupShape.value) || props.shape;
    });
    return () => {
      var _a;
      const {
        prefixCls: customPrefixCls,
        type = "default",
        shape = "circle",
        description = (_a = slots.description) == null ? void 0 : _a.call(slots),
        tooltip,
        ...restProps
      } = props;
      const classString = classNames.default(prefixCls.value, `${prefixCls.value}-${type}`, `${prefixCls.value}-${mergeShape.value}`, {
        [`${prefixCls.value}-rtl`]: direction.value === "rtl"
      }, attrs.class, hashId.value);
      const buttonNode = vue.createVNode(index$1.default, {
        "placement": "left"
      }, {
        title: slots.tooltip || tooltip ? () => slots.tooltip && slots.tooltip() || tooltip : void 0,
        default: () => vue.createVNode("div", {
          "class": `${prefixCls.value}-body`
        }, [vue.createVNode(FloatButtonContent.default, {
          "prefixCls": prefixCls.value
        }, {
          icon: slots.icon,
          description: () => description
        })])
      });
      if (process.env.NODE_ENV !== "production") {
        warning.default(!(shape === "circle" && description), "FloatButton", "supported only when `shape` is `square`. Due to narrow space for text, short sentence is recommended.");
      }
      return wrapSSR(props.href ? vue.createVNode("a", vue.mergeProps({
        "ref": floatButtonRef
      }, attrs, restProps, {
        "class": classString
      }), [buttonNode]) : vue.createVNode("button", vue.mergeProps({
        "ref": floatButtonRef
      }, attrs, restProps, {
        "class": classString,
        "type": "button"
      }), [buttonNode]));
    };
  }
});

exports.default = FloatButton;
exports.floatButtonPrefixCls = floatButtonPrefixCls;
//# sourceMappingURL=FloatButton.js.map
