import { DEFAULT_COLORS as x, getNftBGColorFromDid as C, getNftBGColor as E, getSvg as m } from "@arcblock/nft-display";
const v = (e, a) => {
  let t;
  return e === "default" ? t = x["app-passport"] : e === "auto" ? t = C(a) : t = E(e), t;
}, y = (e) => {
  const a = parseInt(e.slice(1, 3), 16), t = parseInt(e.slice(3, 5), 16), n = parseInt(e.slice(5, 7), 16);
  return (0.299 * a + 0.587 * t + 0.114 * n) / 255 > 0.5 ? "#111" : "#EEE";
}, L = ({
  issuer: e = "",
  title: a = "",
  issuerDid: t = "",
  issuerAvatarUrl: n = "",
  ownerDid: o = "",
  ownerAvatarUrl: c = "",
  preferredColor: l = "default",
  revoked: r = !1,
  isDataUrl: f = !1,
  width: s = "100%",
  height: p = "100%"
}) => {
  const u = v(l, t), i = m({
    width: s,
    height: p,
    tag: r ? "revoked" : "",
    tagVariant: r ? "error" : "info",
    color: u,
    did: o,
    variant: "app-passport",
    verifiable: !0,
    issuer: {
      name: e,
      icon: n
    },
    header: {
      name: a,
      icon: c
    },
    // FIXME: @wangshijun this should be dynamic
    extra: {
      key: "Exp",
      value: "2123-01-01"
    }
  });
  return f ? `data:image/svg+xml;utf8,${encodeURIComponent(i)}` : i;
}, S = ({
  issuer: e = "",
  title: a = "",
  issuerDid: t = "",
  issuerAvatarUrl: n = "",
  ownerDid: o = "",
  ownerName: c = "",
  ownerAvatarUrl: l = "",
  preferredColor: r = "default",
  type: f = "email",
  revoked: s = !1,
  isDataUrl: p = !1,
  width: u = "100%",
  height: i = "100%"
}) => {
  const d = v(r, t), g = m({
    width: u,
    height: i,
    tag: s ? "revoked" : "",
    tagVariant: s ? "error" : "info",
    color: d,
    did: o,
    variant: "app-kyc",
    verifiable: !0,
    issuer: {
      name: e,
      icon: n
    },
    header: {
      name: c,
      icon: l
    },
    extra: {
      key: f,
      value: a
    }
  });
  return p ? `data:image/svg+xml;utf8,${encodeURIComponent(g)}` : g;
};
export {
  S as createKycSvg,
  L as createPassportSvg,
  v as getPassportColor,
  y as getTextColor
};
