import { useCreation as p } from "ahooks";
import { useStateContext as l } from "../contexts/state.js";
import m from "./security.js";
import "../../utils.js";
import { getVisitorId as d } from "@arcblock/ux/lib/Util";
function A({ disableSwitchApp: c, tokenState: t }) {
  const { appInfoList: o, connectState: s } = l(), { encryptKey: i } = m();
  return p(() => {
    if (!t.url)
      return "";
    const u = !c && o.length > 1, e = new URL(t.url || "https://www.didwallet.io"), a = e.searchParams.get("url");
    if (a && u) {
      const r = new URL(decodeURIComponent(a));
      r.searchParams.set("_ek_", i);
      const n = d();
      n && r.searchParams.set("vid", n), s?.sourceAppPid && r.searchParams.set("spid", s?.sourceAppPid), e.searchParams.set("url", r.toString());
    }
    return e.toString();
  }, [t.url, o.length, s?.sourceAppPid, i]);
}
export {
  A as default
};
