import { jsxs as i, jsx as e } from "react/jsx-runtime";
import { Box as n, Typography as b, Chip as w, alpha as v } from "@mui/material";
import { Icon as p } from "@iconify/react";
import S from "@iconify-icons/material-symbols/swap-horiz-rounded";
import C from "@iconify-icons/material-symbols/arrow-right-alt-rounded";
import { useMemoizedFn as I, useCreation as s } from "ahooks";
import d from "lodash/noop";
import z from "../../Avatar/index.js";
import { getUserAvatar as R } from "../../Util/index.js";
import k from "./session-user-switch.js";
import { getWallet as A } from "../libs/utils.js";
import { translations as U } from "../libs/translation.js";
import { translate as W } from "../../Locale/util.js";
function K({
  session: r,
  onSwitchPassport: a,
  onSwitchAccount: m,
  onBindWallet: u,
  onSwitchProfile: f = d,
  locale: l = "en",
  isBlocklet: o = !0
}) {
  const c = I((t, y = {}) => W(U, t, l, "en", y)), h = R(r.user?.avatar?.replace(/\s/g, encodeURIComponent(" ")), 64), g = s(() => r.user?.passports?.find(
    (t) => t.name === r.user.role || t.role === r.user.role
  ), [r?.user?.passports, r?.user?.role]), x = s(() => A(r?.user), [r?.user]);
  return /* @__PURE__ */ i(
    n,
    {
      sx: {
        py: 2,
        px: 0.5,
        pb: 1,
        display: "flex",
        flexDirection: "column",
        gap: 1.5
      },
      children: [
        /* @__PURE__ */ i(
          n,
          {
            sx: {
              display: "flex",
              justifyContent: "space-between",
              alignItems: "center",
              gap: 1,
              px: 2
            },
            children: [
              /* @__PURE__ */ i(
                n,
                {
                  sx: {
                    display: "flex",
                    alignItems: "center",
                    gap: 1.5
                  },
                  children: [
                    /* @__PURE__ */ e(
                      n,
                      {
                        onClick: o ? d : f,
                        "data-cy": "sessionManager-switch-profile-trigger",
                        sx: {
                          cursor: o ? "default" : "pointer",
                          position: "relative",
                          borderRadius: "100%",
                          overflow: "hidden",
                          fontSize: 0,
                          flexShrink: 0,
                          "&:hover": o ? {} : {
                            "&::after": {
                              content: `"${c("switch")}"`,
                              position: "absolute",
                              bottom: 0,
                              background: "rgba(0, 0, 0, 0.2)",
                              left: 0,
                              right: 0,
                              height: "2.2em",
                              color: "white",
                              textAlign: "center",
                              fontSize: "12px",
                              lineHeight: "2em"
                            }
                          }
                        },
                        children: /* @__PURE__ */ e(
                          z,
                          {
                            variant: "circle",
                            did: r.user.did,
                            src: h,
                            size: 48,
                            shape: "circle",
                            sx: {
                              cursor: o ? "unset" : "pointer"
                            }
                          }
                        )
                      }
                    ),
                    /* @__PURE__ */ e(b, { variant: "h6", sx: { wordBreak: "break-word" }, children: r.user.fullName })
                  ]
                }
              ),
              /* @__PURE__ */ e(
                w,
                {
                  label: g?.title || r.user?.role.toUpperCase(),
                  size: "small",
                  variant: "outlined",
                  clickable: !0,
                  sx: {
                    flexShrink: 0,
                    fontWeight: "bold",
                    fontSize: "12px",
                    color: "text.primary",
                    borderColor: "grey.100",
                    pr: 1,
                    pl: 0.5,
                    "&:active": {
                      boxShadow: "none"
                    }
                  },
                  deleteIcon: /* @__PURE__ */ e(p, { icon: S, color: "inherit" }),
                  onDelete: a,
                  onClick: a,
                  "data-cy": "sessionManager-switch-passport-trigger"
                }
              )
            ]
          }
        ),
        /* @__PURE__ */ e(k, { session: r, onSwitch: m, isBlocklet: o, locale: l }),
        x ? null : /* @__PURE__ */ i(
          n,
          {
            sx: {
              color: "secondary.main",
              bgcolor: ({ palette: t }) => v(t.secondary.main, 0.05),
              borderRadius: 1,
              display: "flex",
              justifyContent: "space-between",
              alignItems: "center",
              fontSize: 12,
              py: 0.75,
              px: 1.5,
              cursor: "pointer",
              mt: -0.75
            },
            onClick: u,
            "data-cy": "sessionManager-bind-trigger",
            children: [
              c("connectDIDWallet"),
              /* @__PURE__ */ e(p, { icon: C, color: "inherit", fontSize: 16 })
            ]
          }
        )
      ]
    }
  );
}
export {
  K as default
};
