import { useMemo } from 'react';
import { ParaProviderCore, } from '@getpara/react-core/internal';
import { asyncStorageAdapter } from './asyncStorageAdapter.js';
import { ParaMobile } from '../react-native/ParaMobile.js';
/**
 * React Native Para provider. Wraps ParaProviderCore with AsyncStorage-backed
 * persistence by default. Accepts either a ParaMobile instance or a simple
 * `{ apiKey, env?, opts? }` config — the provider creates the client internally.
 */
export function ParaProvider({ children, paraClientConfig: paraClientInput, config, callbacks, storageAdapter = asyncStorageAdapter, waitForReady, fallback, }) {
    const coreInput = useMemo(() => {
        if (paraClientInput instanceof ParaMobile)
            return paraClientInput;
        return Object.assign(Object.assign({}, paraClientInput), { createClient: (apiKey, env, opts) => new ParaMobile(apiKey, env, opts) });
    }, [paraClientInput]);
    return (<ParaProviderCore paraClientConfig={coreInput} config={config} callbacks={callbacks} storageAdapter={storageAdapter} waitForReady={waitForReady} fallback={fallback}>
      {children}
    </ParaProviderCore>);
}
