import React from 'react';
import { Route, Switch, useHistory } from 'react-router';
import { join } from 'path';
import { DevicesList } from './DevicesList';
import { ConnectionNotification } from '../../Notifications/ConnectionNotification';
import { DisconnectAccount } from '../DisconnectAccount';
import { ConnectionSuccessNotification } from '../../Notifications/ConnectionSuccessNotification';
import { WaitingForTransaction } from '../../commons/WaitingForTransaction';
import { ErrorMessage } from '../../commons/ErrorMessage';
export var Devices = function (_a) {
    var walletService = _a.walletService, onAccountDisconnected = _a.onAccountDisconnected, className = _a.className, _b = _a.basePath, basePath = _b === void 0 ? '' : _b;
    var deployedWallet = walletService.getDeployedWallet();
    var relayerConfig = walletService.sdk.getRelayerConfig();
    var history = useHistory();
    return (React.createElement(Switch, null,
        React.createElement(Route, { path: basePath + "/", exact: true },
            React.createElement(DevicesList, { deployedWallet: deployedWallet, devicesBasePath: basePath, className: className })),
        React.createElement(Route, { path: join(basePath, 'approveDevice'), exact: true },
            React.createElement(ConnectionNotification, { deployedWallet: deployedWallet, devicesBasePath: basePath, className: className })),
        React.createElement(Route, { path: join(basePath, 'connectionSuccess'), exact: true },
            React.createElement(ConnectionSuccessNotification, { basePath: basePath, className: className })),
        React.createElement(Route, { path: join(basePath, 'connectionFailed'), exact: true },
            React.createElement(ErrorMessage, { className: className })),
        React.createElement(Route, { path: join(basePath, 'disconnectAccount'), exact: true },
            React.createElement(DisconnectAccount, { walletService: walletService, onDisconnectProgress: function (transactionHash) { return history.replace(join(basePath, 'waitingForDeletingAccount'), { transactionHash: transactionHash }); }, onAccountDisconnected: onAccountDisconnected, onCancelClick: function () { return history.replace(basePath + "/"); }, className: className })),
        React.createElement(Route, { path: join(basePath, 'waitingForRemovingDevice'), exact: true, render: function (_a) {
                var location = _a.location;
                var _b;
                return React.createElement(WaitingForTransaction, { action: "Removing device", relayerConfig: relayerConfig, className: className, transactionHash: (_b = location.state) === null || _b === void 0 ? void 0 : _b.transactionHash });
            } }),
        React.createElement(Route, { path: join(basePath, 'waitingForDeletingAccount'), exact: true, render: function (_a) {
                var location = _a.location;
                var _b;
                return React.createElement(WaitingForTransaction, { action: "Deleting account", relayerConfig: relayerConfig, className: className, transactionHash: (_b = location.state) === null || _b === void 0 ? void 0 : _b.transactionHash });
            } }),
        React.createElement(Route, { path: join(basePath, 'waitingForConnection'), exact: true, render: function (_a) {
                var location = _a.location;
                var _b;
                return React.createElement(WaitingForTransaction, { action: "Connecting device", relayerConfig: relayerConfig, className: className, transactionHash: (_b = location.state) === null || _b === void 0 ? void 0 : _b.transactionHash });
            } })));
};
//# sourceMappingURL=Devices.js.map