import React, { useState } from 'react'; import { Checkbox, RadioGroup, Paragraph } from 'evergreen-ui'; import Swal from 'sweetalert2'; import i18n from 'i18next'; import { Trans } from 'react-i18next'; import withReactContent from 'sweetalert2-react-content'; import SyntaxHighlighter from 'react-syntax-highlighter'; import { tomorrow as style } from 'react-syntax-highlighter/dist/esm/styles/hljs'; import JSON5 from 'json5'; import { parseDuration } from './util/duration'; import { parseYouTube } from './edlFormats'; import CopyClipboardButton from './components/CopyClipboardButton'; import { errorToast } from './util'; import SortableFiles from './SortableFiles'; const electron = window.require('electron'); // eslint-disable-line const { dialog, app } = electron.remote; const ReactSwal = withReactContent(Swal); export async function promptTimeOffset(inputValue) { const { value } = await Swal.fire({ title: i18n.t('Set custom start time offset'), text: i18n.t('Instead of video apparently starting at 0, you can offset by a specified value. This only applies to the preview inside LosslessCut and does not modify the file in any way. (Useful for viewing/cutting videos according to timecodes)'), input: 'text', inputValue: inputValue || '', showCancelButton: true, inputPlaceholder: '00:00:00.000', }); if (value === undefined) { return undefined; } const duration = parseDuration(value); // Invalid, try again if (duration === undefined) return promptTimeOffset(value); return duration; } export async function askForHtml5ifySpeed({ allowedOptions, showRemember, initialOption }) { const availOptions = { fastest: i18n.t('Fastest: Low playback speed (no audio)'), 'fastest-audio': i18n.t('Fastest: Low playback speed'), 'fastest-audio-remux': i18n.t('Fastest: Low playback speed (audio remux), likely to fail'), fast: i18n.t('Fast: Full quality remux (no audio), likely to fail'), 'fast-audio': i18n.t('Fast: Full quality remux, likely to fail'), slow: i18n.t('Slow: Low quality encode (no audio)'), 'slow-audio': i18n.t('Slow: Low quality encode'), slowest: i18n.t('Slowest: High quality encode'), }; const inputOptions = {}; allowedOptions.forEach((allowedOption) => { inputOptions[allowedOption] = availOptions[allowedOption]; }); let selectedOption = inputOptions[initialOption] ? initialOption : Object.keys(inputOptions)[0]; let rememberChoice = !!initialOption; const Html = () => { const [option, setOption] = useState(selectedOption); const [remember, setRemember] = useState(rememberChoice); function onOptionChange(e) { selectedOption = e.target.value; setOption(selectedOption); } function onRememberChange(e) { rememberChoice = e.target.checked; setRemember(rememberChoice); } return (