'use client'
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var createProviderHook = require('../../shared/utils/functions/createProviderHook/createProviderHook.cjs');
var getWalletGroupType = require('../../utils/functions/getWalletGroupType/getWalletGroupType.cjs');
var useWalletItemActions = require('../../utils/hooks/useWalletItemActions/useWalletItemActions.cjs');
var ViewContext = require('../ViewContext/ViewContext.cjs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

const WalletGroupContext = React__default["default"].createContext(undefined);
const useWalletGroupContext = createProviderHook.createProviderHook(WalletGroupContext, 'WalletGroupContextProvider');
const WalletGroupContextProvider = ({ children, }) => {
    const [selectedWalletGroup, setSelectedWalletGroup] = React__default["default"].useState();
    const { pushView } = ViewContext.useViewContext();
    const { handleWalletItemClick } = useWalletItemActions.useWalletItemActions();
    const navigateToWalletGroup = React__default["default"].useCallback((walletGroup, { onSelectWallet } = {}) => {
        setSelectedWalletGroup(walletGroup);
        const walletGroupType = getWalletGroupType.getWalletGroupType(walletGroup);
        const mapGroupTypeToView = {
            'multi-chain': 'wallet-group',
            'multi-wallet': 'select-wallet-in-wallet-group',
        };
        const view = walletGroupType
            ? mapGroupTypeToView[walletGroupType]
            : mapGroupTypeToView['multi-chain'];
        pushView(view, {
            onSelectWallet: onSelectWallet !== null && onSelectWallet !== void 0 ? onSelectWallet : handleWalletItemClick,
        });
    }, [handleWalletItemClick, pushView]);
    const contextValue = {
        navigateToWalletGroup,
        selectedWalletGroup,
    };
    return (jsxRuntime.jsx(WalletGroupContext.Provider, { value: contextValue, children: children }));
};

exports.WalletGroupContext = WalletGroupContext;
exports.WalletGroupContextProvider = WalletGroupContextProvider;
exports.useWalletGroupContext = useWalletGroupContext;
