'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { useModal } from '@faceless-ui/modal';
import React, { useCallback } from 'react';
import { toast } from 'sonner';
import { useDocumentInfo } from '../../providers/DocumentInfo/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import { Button } from '../Button/index.js';
import { ConfirmationModal } from '../ConfirmationModal/index.js';
import { Translation } from '../Translation/index.js';
export function GenerateConfirmation(props) {
    const { highlightField, setKey } = props;
    const { id } = useDocumentInfo();
    const { toggleModal } = useModal();
    const { t } = useTranslation();
    const modalSlug = `generate-confirmation-${id}`;
    const handleGenerate = useCallback(()=>{
        setKey();
        toast.success(t('authentication:newAPIKeyGenerated'));
        highlightField(true);
    }, [
        highlightField,
        setKey,
        t
    ]);
    return /*#__PURE__*/ _jsxDEV(React.Fragment, {
        children: [
            /*#__PURE__*/ _jsxDEV(Button, {
                buttonStyle: "secondary",
                onClick: ()=>{
                    toggleModal(modalSlug);
                },
                size: "small",
                children: t('authentication:generateNewAPIKey')
            }, void 0, false, {
                fileName: "src/elements/GenerateConfirmation/index.tsx",
                lineNumber: 34,
                columnNumber: 7
            }, this),
            /*#__PURE__*/ _jsxDEV(ConfirmationModal, {
                body: /*#__PURE__*/ _jsxDEV(Translation, {
                    elements: {
                        1: ({ children })=>/*#__PURE__*/ _jsxDEV("strong", {
                                children: children
                            }, void 0, false, {
                                fileName: "src/elements/GenerateConfirmation/index.tsx",
                                lineNumber: 47,
                                columnNumber: 36
                            }, void 0)
                    },
                    i18nKey: "authentication:generatingNewAPIKeyWillInvalidate",
                    t: t
                }, void 0, false, {
                    fileName: "src/elements/GenerateConfirmation/index.tsx",
                    lineNumber: 45,
                    columnNumber: 11
                }, void 0),
                confirmLabel: t('authentication:generate'),
                heading: t('authentication:confirmGeneration'),
                modalSlug: modalSlug,
                onConfirm: handleGenerate
            }, void 0, false, {
                fileName: "src/elements/GenerateConfirmation/index.tsx",
                lineNumber: 43,
                columnNumber: 7
            }, this)
        ]
    }, void 0, true, {
        fileName: "src/elements/GenerateConfirmation/index.tsx",
        lineNumber: 33,
        columnNumber: 5
    }, this);
}

//# sourceMappingURL=index.js.map