import type { BinaryLibraryWithParams } from './index.d' ; export function libReactNativeJsi ( ) { const tonClientJsiModule = ( global as any ) . tonClientJsiModule ; return Promise . resolve ( { setResponseParamsHandler ( handler ) { tonClientJsiModule . setResponseParamsHandler ( handler ) ; } , createContext ( configJson ) { return new Promise ( ( resolve ) => { tonClientJsiModule . createContext ( configJson , resolve ) ; } ) ; } , destroyContext ( context ) { tonClientJsiModule . destroyContext ( context ) ; } , sendRequestParams ( context , requestId , functionName , functionParams ) { tonClientJsiModule . sendRequestParams ( context , requestId , functionName , replaceBigInts ( functionParams ) ) ; } , } ) ; } function replaceBigInts ( value ) { if ( typeof value === 'bigint' ) { if ( value < Number . MAX_SAFE_INTEGER && value > Number . MIN_SAFE_INTEGER ) { return Number ( value ) ; } else { return value . toString ( ) ; } } if ( typeof value === 'object' && value !== null && value . toJSON != null ) { return value . toJSON ( ) ; } if ( typeof value === 'object' && value !== null ) { const result = Array . isArray ( value ) ? [ ] : { } ; for ( const key in value ) { ( result as any ) [ key ] = replaceBigInts ( value [ key ] ) ; } return result ; } return value ; } function __createBlob ( blobId , offset , size ) { const BlobManager = require ( 'react-native/Libraries/Blob/BlobManager' ) ; return BlobManager . createFromOptions ( { blobId , offset , size } ) ; } ( global as any ) . __createBlob = __createBlob ;