import CheckmarkCircleIcon from 'mdi-react/CheckCircleIcon';
import * as React from 'react';
import { AccessTokenScopes } from '../../auth/accessToken';
import { CopyableText } from '../../components/CopyableText';
/**
 * Displays a message informing the user to copy and save the newly created access token.
 */
export class AccessTokenCreatedAlert extends React.PureComponent {
    render() {
        const isSudoToken = this.props.token.scopes.includes(AccessTokenScopes.SiteAdminSudo);
        return (React.createElement("div", { className: `access-token-created-alert ${this.props.className}` },
            React.createElement("p", null,
                React.createElement(CheckmarkCircleIcon, { className: "icon-inline" }),
                " Copy the new access token now. You won't be able to see it again."),
            React.createElement(CopyableText, { text: this.props.tokenSecret, size: 48 }),
            React.createElement("h5", { className: "mt-4" },
                React.createElement("strong", null, "Example usage")),
            React.createElement("pre", { className: "my-1" },
                React.createElement("code", null, curlExampleCommand(this.props.tokenSecret, isSudoToken)))));
    }
}
function curlExampleCommand(tokenSecret, isSudoToken) {
    const credentials = isSudoToken
        ? `token-sudo user="SUDO-TO-USERNAME",token="${tokenSecret}"`
        : `token ${tokenSecret}`;
    return `curl \\
  -H 'Authorization: ${credentials}' \\
  -d '{"query":"query { currentUser { username } }"}' \\
  ${window.context.appURL}/.api/graphql`;
}
//# sourceMappingURL=AccessTokenCreatedAlert.js.map