import React, { useEffect, useState } from 'react'; import { createPortal } from 'react-dom'; import { APP_DISPLAY_NAME_EN, APP_DISPLAY_NAME_RU } from '../../../shared/appBranding'; import { Button } from '../../shared/ui/controls'; import styles from '../EditorApp.module.css'; import { HELP_SECTION_IDS, helpSectionBodyKey, helpSectionTitleKey, type HelpSectionId, } from '../help/helpSections'; import { useEditorI18n } from '../i18n/EditorI18nContext'; type AppAboutModalProps = { open: boolean; onClose: () => void; appVersion: string | null; }; export function AppAboutModal({ open, onClose, appVersion }: AppAboutModalProps) { const { t, locale } = useEditorI18n(); const appName = locale === 'ru' ? APP_DISPLAY_NAME_RU : APP_DISPLAY_NAME_EN; useEffect(() => { if (!open) return; const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', onKey); return () => window.removeEventListener('keydown', onKey); }, [onClose, open]); if (!open) return null; return createPortal( <>
{appName}
{t('app.about.tagline')}

{t('app.about.description')}

{t('app.about.versionLabel')}
{appVersion ?? '—'}
{t('app.about.developerLabel')}
{t('app.about.developer')}
{t('app.about.supportLabel')}
{t('app.about.supportEmail')}
{t('app.about.websiteLabel')}
{t('app.about.websiteUrl')}
, document.body, ); } type InstructionsModalProps = { open: boolean; onClose: () => void; initialSection?: HelpSectionId; }; function InstructionsModalBody({ initialSection, onClose, }: { initialSection: HelpSectionId; onClose: () => void; }) { const { t } = useEditorI18n(); const [activeId, setActiveId] = useState(initialSection); useEffect(() => { const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', onKey); return () => window.removeEventListener('keydown', onKey); }, [onClose]); const body = t(helpSectionBodyKey(activeId)); const paragraphs = body.split('\n\n').filter((p) => p.trim() !== ''); return createPortal( <>
{t(helpSectionTitleKey(activeId))}
{paragraphs.map((p, i) => (

{p}

))}
, document.body, ); } export function InstructionsModal({ open, onClose, initialSection }: InstructionsModalProps) { if (!open) return null; const section = initialSection ?? 'overview'; return ; }