// SPDX-License-Identifier: MIT
// Copyright (c) 2022 The Pybricks Authors
import { Callout, Intent } from '@blueprintjs/core';
import React, { useMemo } from 'react';
import {
pybricksUsbDfuWindowsDriverInstallUrl,
pybricksUsbLinuxUdevRulesUrl,
} from '../../app/constants';
import { Hub, hubHasBluetoothButton, hubHasUSB } from '../../components/hubPicker';
import ExternalLinkIcon from '../../utils/ExternalLinkIcon';
import { isLinux, isWindows } from '../../utils/os';
import { useI18n } from './i18n';
type BootloaderInstructionsProps = {
hubType: Hub;
};
/**
* Provides customized instructions on how to enter bootloader mode based
* on the hub type.
*/
const BootloaderInstructions: React.VoidFunctionComponent<
BootloaderInstructionsProps
> = ({ hubType }) => {
const i18n = useI18n();
const { button, light, lightPattern } = useMemo(() => {
return {
button: i18n.translate(
hubHasBluetoothButton(hubType) ? 'button.bluetooth' : 'button.power',
),
light: i18n.translate(
hubHasBluetoothButton(hubType) ? 'light.bluetooth' : 'light.status',
),
lightPattern: i18n.translate(
hubHasBluetoothButton(hubType)
? 'lightPattern.bluetooth'
: 'lightPattern.status',
),
};
}, [i18n, hubType]);
return (
<>
{hubHasUSB(hubType) && isLinux() && (
{i18n.translate('instruction')}