"use strict";
const common_vendor = require("../../../../common/vendor.js");
const uni_modules_uviewPro_libs_index = require("../../libs/index.js");
require("../../libs/util/logger.js");
require("../../libs/config/theme-tokens.js");
const uni_modules_uviewPro_components_uButton_types = require("./types.js");
const __default__ = {
  name: "u-button",
  options: {
    addGlobalClass: true,
    virtualHost: true,
    styleIsolation: "shared"
  }
};
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  ...__default__,
  props: uni_modules_uviewPro_components_uButton_types.ButtonProps,
  emits: [
    "click",
    "getuserinfo",
    "contact",
    "getphonenumber",
    "error",
    "launchapp",
    "opensetting",
    "chooseavatar",
    "agreeprivacyauthorization"
  ],
  setup(__props, { emit: __emit }) {
    const emit = __emit;
    const props = __props;
    const rippleTop = common_vendor.ref(0);
    const rippleLeft = common_vendor.ref(0);
    const fields = common_vendor.ref({});
    const waveActive = common_vendor.ref(false);
    const getHoverClass = common_vendor.computed(() => {
      if (props.loading || props.disabled || props.ripple)
        return "";
      if (props.hoverClass)
        return props.hoverClass;
      let hoverClass = "";
      hoverClass = props.plain ? "u-" + props.type + "-plain-hover" : "u-" + props.type + "-hover";
      return hoverClass;
    });
    const showHairLineBorder = common_vendor.computed(() => {
      if (["primary", "success", "error", "warning"].indexOf(props.type) >= 0 && !props.plain) {
        return "";
      } else {
        return "u-hairline-border";
      }
    });
    function click(e) {
      if (Number(props.throttleTime)) {
        uni_modules_uviewPro_libs_index.$u.throttle(() => {
          clickAction(e);
        }, Number(props.throttleTime));
      } else {
        clickAction(e);
      }
    }
    function clickAction(e) {
      if (props.loading === true || props.disabled === true)
        return;
      if (props.ripple) {
        waveActive.value = false;
        common_vendor.nextTick$1(() => {
          getWaveQuery(e);
        });
      }
      emit("click", e);
    }
    function getWaveQuery(e) {
      getElQuery().then((res) => {
        let data = res[0];
        if (!data.width || !data.width)
          return;
        data.targetWidth = data.height > data.width ? data.height : data.width;
        if (!data.targetWidth)
          return;
        fields.value = data;
        let touchesX = "", touchesY = "";
        touchesX = e.touches[0].clientX;
        touchesY = e.touches[0].clientY;
        rippleTop.value = Number(touchesY) - data.top - data.targetWidth / 2;
        rippleLeft.value = Number(touchesX) - data.left - data.targetWidth / 2;
        common_vendor.nextTick$1(() => {
          waveActive.value = true;
        });
      });
    }
    function getElQuery() {
      return new Promise((resolve) => {
        let queryInfo = "";
        queryInfo = common_vendor.index.createSelectorQuery().in(null);
        queryInfo.select(".u-btn").boundingClientRect();
        queryInfo.exec((data) => {
          resolve(data);
        });
      });
    }
    function getphonenumber(event) {
      emit("getphonenumber", event);
    }
    function getuserinfo(event) {
      emit("getuserinfo", event);
    }
    function error(event) {
      emit("error", event);
    }
    function opensetting(event) {
      emit("opensetting", event);
    }
    function launchapp(event) {
      emit("launchapp", event);
    }
    function getAuthorize(event) {
      if (props.scope === "phoneNumber") {
        getphonenumber(event);
      } else if (props.scope === "userInfo") {
        getuserinfo(event);
      }
    }
    function contact(event) {
      emit("contact", event);
    }
    function chooseavatar(event) {
      emit("chooseavatar", event);
    }
    function agreeprivacyauthorization(event) {
      emit("agreeprivacyauthorization", event);
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.t(props.text),
        b: _ctx.ripple
      }, _ctx.ripple ? {
        c: common_vendor.n(waveActive.value ? "u-wave-active" : ""),
        d: rippleTop.value + "px",
        e: rippleLeft.value + "px",
        f: fields.value.targetWidth + "px",
        g: fields.value.targetWidth + "px",
        h: _ctx.rippleBgColor || "rgba(0, 0, 0, 0.15)"
      } : {}, {
        i: common_vendor.n("u-size-" + _ctx.size),
        j: common_vendor.n(_ctx.plain ? "u-btn--" + _ctx.type + "--plain" : ""),
        k: common_vendor.n(_ctx.loading ? "u-loading" : ""),
        l: common_vendor.n(_ctx.shape === "circle" ? "u-round-circle" : ""),
        m: common_vendor.n(_ctx.hairLine ? showHairLineBorder.value : "u-btn--bold-border"),
        n: common_vendor.n("u-btn--" + _ctx.type),
        o: common_vendor.n(_ctx.disabled ? `u-btn--${_ctx.type}--disabled` : ""),
        p: common_vendor.n(_ctx.customClass),
        q: Number(_ctx.hoverStartTime),
        r: Number(_ctx.hoverStayTime),
        s: _ctx.disabled,
        t: _ctx.formType,
        v: _ctx.disabled || _ctx.loading ? void 0 : _ctx.openType,
        w: _ctx.appParameter,
        x: _ctx.hoverStopPropagation,
        y: _ctx.sendMessageTitle,
        z: _ctx.sendMessagePath,
        A: _ctx.lang,
        B: _ctx.dataName,
        C: _ctx.sessionFrom,
        D: _ctx.sendMessageImg,
        E: _ctx.showMessageCard,
        F: common_vendor.o(getAuthorize, "73"),
        G: common_vendor.o(getuserinfo, "10"),
        H: common_vendor.o(contact, "34"),
        I: common_vendor.o(getphonenumber, "a9"),
        J: common_vendor.o(error, "8a"),
        K: common_vendor.o(launchapp, "dc"),
        L: common_vendor.o(opensetting, "4e"),
        M: common_vendor.o(chooseavatar, "c5"),
        N: common_vendor.o(agreeprivacyauthorization, "fa"),
        O: common_vendor.s(common_vendor.unref(uni_modules_uviewPro_libs_index.$u).toStyle({
          overflow: _ctx.ripple ? "hidden" : "visible"
        }, _ctx.customStyle)),
        P: common_vendor.o(($event) => click($event), "1c"),
        Q: getHoverClass.value,
        R: _ctx.loading
      });
    };
  }
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-a44cf897"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/components/u-button/u-button.js.map
