import { jsxs as a, jsx as o } from "react/jsx-runtime";
import { DIDSpaceStatus as i, DIDSpaceConnect as p } from "@blocklet/did-space-react";
import { Stack as m, IconButton as d, Link as s } from "@mui/material";
import u from "@arcblock/ux/lib/Toast";
import { OpenInNew as f } from "@mui/icons-material";
import { getSpaceHomeUrl as l } from "../../../libs/spaces.js";
import { formatAxiosError as S } from "../../libs/utils.js";
function g({
  session: r,
  spaceGateway: t,
  spaceStatus: n,
  refresh: c
}) {
  return /* @__PURE__ */ a(m, { direction: "row", spacing: 1, children: [
    n === i.DISCONNECTED && /* @__PURE__ */ o(
      p,
      {
        reconnect: !0,
        variant: "outlined",
        session: r,
        spaceDid: r.user?.didSpace?.did,
        spaceGatewayUrl: r.user?.didSpace?.url,
        connectScope: "user",
        onSuccess: async () => {
          await c();
        },
        onError: (e) => {
          console.error(e), u.error(S(e));
        }
      }
    ),
    /* @__PURE__ */ o(d, { size: "small", LinkComponent: s, href: l(t.endpoint), target: "_blank", children: /* @__PURE__ */ o(f, {}) })
  ] });
}
export {
  g as default
};
