"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_draggable_props = require("./props.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 name = `${uni_modules_tdesignUniapp_components_common_config.prefix}-draggable`;
const _sfc_main = uni_modules_tdesignUniapp_components_common_src_instantiationDecorator.uniComponent({
  name,
  options: {
    styleIsolation: "shared"
  },
  props: {
    ...uni_modules_tdesignUniapp_components_draggable_props.props
  },
  emits: [
    "move",
    "start",
    "end"
  ],
  data() {
    return {
      prefix: uni_modules_tdesignUniapp_components_common_config.prefix,
      classPrefix: name,
      tools: uni_modules_tdesignUniapp_components_common_utils_wxs.tools,
      systemInfo: uni_modules_tdesignUniapp_components_common_wechat.getWindowInfo()
    };
  },
  mounted() {
    this.computedRect();
  },
  methods: {
    onTouchStart(e) {
      const { systemInfo } = this;
      if (this.direction === "none")
        return;
      this.startX = e.touches[0].clientX + systemInfo.windowWidth - this.rect.right;
      this.startY = e.touches[0].clientY + systemInfo.windowHeight - this.rect.bottom;
      this.$emit("start", { startX: this.startX, startY: this.startY, rect: this.rect, e });
    },
    onTouchMove(e) {
      const { systemInfo } = this;
      if (this.direction === "none")
        return;
      let x = this.startX - e.touches[0].clientX;
      let y = this.startY - e.touches[0].clientY;
      if (this.direction === "vertical") {
        x = systemInfo.windowWidth - this.rect.right;
      }
      if (this.direction === "horizontal") {
        y = systemInfo.windowHeight - this.rect.bottom;
      }
      this.$emit("move", { x, y, rect: this.rect, e });
    },
    async onTouchEnd(e) {
      if (this.direction === "none")
        return;
      await this.computedRect();
      this.$emit("end", { rect: this.rect, e });
    },
    async computedRect() {
      this.rect = { right: 0, bottom: 0, width: 0, height: 0 };
      try {
        this.rect = await uni_modules_tdesignUniapp_components_common_utils.getRect(this, `.${this.classPrefix}`);
      } catch (e) {
      }
    }
  }
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return {
    a: common_vendor.n(_ctx.classPrefix),
    b: common_vendor.n(_ctx.tClass),
    c: common_vendor.s(_ctx.tools._style([_ctx.customStyle])),
    d: common_vendor.o((...args) => _ctx.onTouchStart && _ctx.onTouchStart(...args)),
    e: common_vendor.o((...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args)),
    f: common_vendor.o((...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args))
  };
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-02b06622"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/draggable/draggable.js.map
