"use strict";
const common_vendor = require("../common/vendor.js");
function useToast() {
  const tipTitle = common_vendor.ref("");
  const tipIcon = common_vendor.ref("none");
  const tipEndtime = common_vendor.ref(2e3);
  function Toast(opt, to_url) {
    common_vendor.index.__f__("log", "at hooks/useToast.js:31", "Toast", opt, to_url);
    if (typeof opt == "string") {
      to_url = opt;
      opt = {};
    }
    tipTitle.value = opt.title || "";
    tipIcon.value = opt.icon || "none";
    tipEndtime.value = opt.endtime || 1e3;
    let success = opt.success;
    if (tipTitle.value)
      common_vendor.index.showToast({
        title: tipTitle.value,
        icon: tipIcon.value,
        duration: tipEndtime.value,
        success
      });
    if (to_url != void 0) {
      if (typeof to_url == "object") {
        let tab = to_url.tab || 1, url = to_url.url || "";
        common_vendor.index.__f__("log", "at hooks/useToast.js:59", "tab", tab);
        switch (tab) {
          case 1:
            setTimeout(() => common_vendor.index.switchTab({ url }), tipEndtime.value);
            break;
          case 2:
            setTimeout(() => common_vendor.index.navigateTo({ url }), tipEndtime.value);
            break;
          case 3:
            setTimeout(() => {
              common_vendor.index.navigateBack({ delta: 1 });
            }, tipEndtime.value);
            break;
          case 4:
            setTimeout(() => common_vendor.index.reLaunch({ url }), tipEndtime.value);
            break;
          case 5:
            setTimeout(() => common_vendor.index.redirectTo({ url }), tipEndtime.value);
            break;
        }
      } else if (typeof to_url == "function") {
        setTimeout(() => to_url && to_url(), tipEndtime.value);
      } else {
        setTimeout(
          () => common_vendor.index.navigateTo({ url: to_url }),
          tipTitle.value ? tipEndtime.value : 0
        );
      }
    }
  }
  return {
    tipTitle,
    tipIcon,
    tipEndtime,
    Toast
  };
}
exports.useToast = useToast;
//# sourceMappingURL=../../.sourcemap/mp-weixin/hooks/useToast.js.map
