"use strict";
const uni_modules_tdesignUniapp_components_common_src_instantiationDecorator = require("../common/src/instantiationDecorator.js");
const uni_modules_tdesignUniapp_components_common_config = require("../common/config.js");
const uni_modules_tdesignUniapp_components_fab_props = require("./props.js");
const uni_modules_tdesignUniapp_components_mixins_usingCustomNavbar = require("../mixins/using-custom-navbar.js");
const uni_modules_tdesignUniapp_components_common_utils = require("../common/utils.js");
const uni_modules_tdesignUniapp_components_common_utils_wxs = require("../common/utils.wxs.js");
const common_vendor = require("../../../../common/vendor.js");
const uni_modules_tdesignUniapp_components_common_wechat = require("../common/wechat.js");
const TButton = () => "../button/button.js";
const TDraggable = () => "../draggable/draggable.js";
const name = `${uni_modules_tdesignUniapp_components_common_config.prefix}-fab`;
const baseButtonProps = {
  size: "large",
  shape: "circle",
  theme: "primary",
  tClass: `${uni_modules_tdesignUniapp_components_common_config.prefix}-fab__button`
};
const _sfc_main = uni_modules_tdesignUniapp_components_common_src_instantiationDecorator.uniComponent({
  name,
  options: {
    styleIsolation: "shared"
  },
  externalClasses: [`${uni_modules_tdesignUniapp_components_common_config.prefix}-class`, `${uni_modules_tdesignUniapp_components_common_config.prefix}-class-button`],
  mixins: [uni_modules_tdesignUniapp_components_mixins_usingCustomNavbar.useCustomNavbarBehavior],
  components: {
    TButton,
    TDraggable
  },
  props: {
    ...uni_modules_tdesignUniapp_components_fab_props.props
  },
  emits: [
    "move",
    "start",
    "end"
  ],
  data() {
    return {
      prefix: uni_modules_tdesignUniapp_components_common_config.prefix,
      classPrefix: name,
      moveStyle: null,
      tools: uni_modules_tdesignUniapp_components_common_utils_wxs.tools,
      systemInfo: uni_modules_tdesignUniapp_components_common_wechat.getWindowInfo()
    };
  },
  computed: {
    buttonData() {
      return {
        ...baseButtonProps,
        shape: this.text ? "round" : "circle",
        ...this.buttonProps,
        icon: this.icon,
        content: this.text,
        ariaLabel: this.ariaLabel
      };
    }
  },
  watch: {
    icon: "computedSize",
    ariaLabel: "computedSize",
    yBounds: "computedSize",
    buttonProps: "computedSize",
    text: {
      handler(val) {
        this.content = val;
        this.computedSize();
      },
      immediate: true
    }
  },
  methods: {
    onTplButtonTap(e) {
      this.$emit("click", { e });
    },
    onStart(t) {
      this.$emit("drag-start", t);
    },
    onMove(e) {
      const {
        yBounds = [],
        distanceTop,
        systemInfo
      } = this;
      const { x, y, rect } = e;
      const maxX = systemInfo.windowWidth - rect.width;
      const maxY = systemInfo.windowHeight - Math.max(distanceTop, uni_modules_tdesignUniapp_components_common_utils.unitConvert(yBounds[0])) - rect.height;
      const right = Math.max(0, Math.min(x, maxX));
      const bottom = Math.max(0, uni_modules_tdesignUniapp_components_common_utils.unitConvert(yBounds[1]), Math.min(y, maxY));
      this.moveStyle = `right: ${right}px; bottom: ${bottom}px;`;
    },
    onEnd(t) {
      this.$emit("drag-end", t);
    },
    computedSize() {
      if (!this.draggable)
        return;
      setTimeout(() => {
        var _a, _b, _c;
        const insChild = (_b = (_a = this.$refs.draggableTemplate) == null ? void 0 : _a.$refs) == null ? void 0 : _b.draggable;
        if ((_c = this == null ? void 0 : this.yBounds) == null ? void 0 : _c[1]) {
          this.moveStyle = `bottom: ${uni_modules_tdesignUniapp_components_common_utils.unitConvert(this.yBounds[1])}px`;
          insChild == null ? void 0 : insChild.computedRect();
        } else {
          insChild == null ? void 0 : insChild.computedRect();
        }
      });
    },
    getActionClass(a, b) {
      return `${a}-${b}`;
    }
  }
});
if (!Array) {
  const _easycom_t_button2 = common_vendor.resolveComponent("t-button");
  const _easycom_t_draggable2 = common_vendor.resolveComponent("t-draggable");
  (_easycom_t_button2 + _easycom_t_draggable2)();
}
const _easycom_t_button = () => "../button/button.js";
const _easycom_t_draggable = () => "../draggable/draggable.js";
if (!Math) {
  (_easycom_t_button + _easycom_t_draggable)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: _ctx.draggable
  }, _ctx.draggable ? common_vendor.e({
    b: !_ctx.buttonData.content && !_ctx.buttonData.icon
  }, !_ctx.buttonData.content && !_ctx.buttonData.icon ? {} : common_vendor.e({
    c: true
  }, {}, {
    d: common_vendor.n(_ctx.getActionClass(_ctx.classPrefix, _ctx.buttonData.buttonLayout) || ""),
    e: _ctx.buttonData.index,
    f: common_vendor.o(_ctx.onTplButtonTap),
    g: common_vendor.o(_ctx.onTplButtonTap),
    h: common_vendor.o(_ctx.onTplButtonTap),
    i: common_vendor.o(_ctx.onTplButtonTap),
    j: common_vendor.o(_ctx.onTplButtonTap),
    k: common_vendor.o(_ctx.onTplButtonTap),
    l: common_vendor.o(_ctx.onTplButtonTap),
    m: common_vendor.o(_ctx.onTplButtonTap),
    n: common_vendor.p({
      ["t-id"]: _ctx.buttonData.tId,
      ["custom-style"]: _ctx.buttonData.style || "",
      block: _ctx.buttonData.block,
      ["t-class"]: _ctx.buttonData.tClass,
      disabled: _ctx.buttonData.disabled,
      ["custom-dataset"]: _ctx.buttonData.customDataset,
      content: _ctx.buttonData.content,
      icon: _ctx.buttonData.icon,
      loading: _ctx.buttonData.loading,
      ["loading-props"]: _ctx.buttonData.loadingProps,
      theme: _ctx.buttonData.theme,
      ghost: _ctx.buttonData.ghost,
      shape: _ctx.buttonData.shape,
      size: _ctx.buttonData.size,
      variant: _ctx.buttonData.variant,
      ["open-type"]: _ctx.buttonData.openType,
      ["hover-class"]: _ctx.buttonData.hoverClass,
      ["hover-stop-propagation"]: _ctx.buttonData.hoverStopPropagation,
      ["hover-start-time"]: _ctx.buttonData.hoverStartTime,
      ["hover-stay-time"]: _ctx.buttonData.hoverStayTime,
      lang: _ctx.buttonData.lang,
      ["session-from"]: _ctx.buttonData.sessionFrom,
      ["send-message-title"]: _ctx.buttonData.sendMessageTitle,
      ["send-message-path"]: _ctx.buttonData.sendMessagePath,
      ["send-message-img"]: _ctx.buttonData.sendMessageImg,
      ["app-parameter"]: _ctx.buttonData.appParameter,
      ["show-message-card"]: _ctx.buttonData.showMessageCard,
      ["aria-label"]: _ctx.buttonData.ariaLabel
    })
  }), {
    o: common_vendor.sr("draggable", "f580c3f3-0"),
    p: common_vendor.o(_ctx.onStart),
    q: common_vendor.o(_ctx.onMove),
    r: common_vendor.o(_ctx.onEnd),
    s: common_vendor.p({
      ["custom-style"]: _ctx.tools._style(["right: 16px; bottom: 32px;", _ctx.customStyle, _ctx.moveStyle]),
      direction: _ctx.draggable === true ? "all" : _ctx.draggable,
      ["t-class"]: _ctx.tClass
    })
  }) : common_vendor.e({
    t: !_ctx.buttonData || !_ctx.buttonData.content && !_ctx.buttonData.icon
  }, !_ctx.buttonData || !_ctx.buttonData.content && !_ctx.buttonData.icon ? {} : {
    v: common_vendor.n(_ctx.getActionClass(_ctx.classPrefix, _ctx.buttonData.buttonLayout) || ""),
    w: _ctx.buttonData.index,
    x: common_vendor.o(_ctx.onTplButtonTap),
    y: common_vendor.o(_ctx.onTplButtonTap),
    z: common_vendor.o(_ctx.onTplButtonTap),
    A: common_vendor.o(_ctx.onTplButtonTap),
    B: common_vendor.o(_ctx.onTplButtonTap),
    C: common_vendor.o(_ctx.onTplButtonTap),
    D: common_vendor.o(_ctx.onTplButtonTap),
    E: common_vendor.o(_ctx.onTplButtonTap),
    F: common_vendor.p({
      ["t-id"]: _ctx.buttonData.tId,
      ["custom-style"]: _ctx.buttonData.style || "",
      block: _ctx.buttonData.block,
      ["t-class"]: _ctx.buttonData.tClass,
      disabled: _ctx.buttonData.disabled,
      ["custom-dataset"]: _ctx.buttonData.customDataset,
      content: _ctx.buttonData.content,
      icon: _ctx.buttonData.icon,
      loading: _ctx.buttonData.loading,
      ["loading-props"]: _ctx.buttonData.loadingProps,
      theme: _ctx.buttonData.theme,
      ghost: _ctx.buttonData.ghost,
      shape: _ctx.buttonData.shape,
      size: _ctx.buttonData.size,
      variant: _ctx.buttonData.variant,
      ["open-type"]: _ctx.buttonData.openType,
      ["hover-class"]: _ctx.buttonData.hoverClass,
      ["hover-stop-propagation"]: _ctx.buttonData.hoverStopPropagation,
      ["hover-start-time"]: _ctx.buttonData.hoverStartTime,
      ["hover-stay-time"]: _ctx.buttonData.hoverStayTime,
      lang: _ctx.buttonData.lang,
      ["session-from"]: _ctx.buttonData.sessionFrom,
      ["send-message-title"]: _ctx.buttonData.sendMessageTitle,
      ["send-message-path"]: _ctx.buttonData.sendMessagePath,
      ["send-message-img"]: _ctx.buttonData.sendMessageImg,
      ["app-parameter"]: _ctx.buttonData.appParameter,
      ["show-message-card"]: _ctx.buttonData.showMessageCard,
      ["aria-label"]: _ctx.buttonData.ariaLabel
    })
  }, {
    G: common_vendor.n(_ctx.classPrefix),
    H: common_vendor.n(_ctx.tClass),
    I: common_vendor.s(_ctx.tools._style(["right: 16px; bottom: 32px;", _ctx.customStyle]))
  }));
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-f580c3f3"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/fab/fab.js.map
