import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { Button } from "antd";
import { useAppState } from "../overmind";
export const NewsafeAuth = ({ children, redirectPath, redirectUrl }) => {
    const state = useAppState();
    const hostname = state.config.settings.app.currentHost;
    const params = {
        requestor: state.config.settings.newcoin.daoDomain,
        referer: hostname,
        redirectUrl: redirectUrl || redirectPath || `https://${hostname}`,
    };
    const newsafeUrl = `https://auth-dev.newsafe.org/explore?requestor=${params.requestor}&referer=${params.referer}&redirectUrl=${params.redirectUrl}`;
    return (_jsx(_Fragment, { children: children || (_jsxs(_Fragment, { children: [params.requestor && _jsx("h1", { className: "text-center", children: `Welcome to ${state.config.settings.app.name}` }), _jsx("h2", { className: "text-center", children: "This service is using NEWSAFE - the distributed identity service for access management." }), _jsx("br", {}), params.requestor ? (_jsxs(_Fragment, { children: [_jsx("h2", { className: "text-center", children: "Please sign in using your account at auth.newsafe.org" }), _jsx("div", { className: "text-center", children: _jsx(Button, { style: { fontSize: 30, height: 60, marginTop: 60 }, onClick: () => (window.location = newsafeUrl), children: "Sign In" }) })] })) : (_jsxs("div", { className: "text-center", style: { maxWidth: 800 }, children: ["This application had not been configured correctly.", _jsx("br", {}), _jsx("br", {}), "If you are the developer of the app:", _jsx("br", {}), _jsx("br", {}), _jsxs("ul", { children: [_jsxs("li", { children: ["Have you created your app entry yet? If not create it at\u00A0", _jsx("a", { href: "https://console-dev.newstack.dev", children: "console-dev.newstack.dev" }), "\u00A0. It only takes a few minutes.", _jsx("br", {}), _jsx("br", {})] }), _jsxs("li", { children: ["Got an app created? You are likely missing just a tiny bit of config. Please follow the instructions at\u00A0", _jsx("a", { href: "https://console-dev.newstack.dev/instructions", children: "console-dev.newstack.dev" }), "\u00A0.", _jsx("br", {}), _jsx("br", {})] })] })] }))] })) }));
};
//# sourceMappingURL=UnsidAuth.js.map