import * as keepkey from "@shapeshiftoss/hdwallet-keepkey" ; import { CLIENT_TAG , Client } from "./client" ; function getClient ( ) { return ( ( window as any ) ?. [ CLIENT_TAG ] as Client ) ?? Client ; } export const AdapterDelegateProxy = { getDevices ( ) { return getClient ( ) . getDevices ( ) ; } , getDevice ( serialNumber ? ) { return getClient ( ) . getDevice ( serialNumber ) ; } , async getTransportDelegate ( handle ) { await getClient ( ) . getTransportDelegate ( handle ) ; return new TransportDelegateProxy ( handle ) ; } , } ; export class TransportDelegateProxy implements keepkey . TransportDelegate { handle : string ; constructor ( handle ) { this . handle = handle ; } isOpened ( ) { return getClient ( ) . isOpened ( this . handle ) ; } getDeviceID ( ) { return getClient ( ) . getDeviceID ( this . handle ) ; } connect ( ) { return getClient ( ) . connect ( this . handle ) ; } tryConnectDebugLink ( ) { return getClient ( ) . tryConnectDebugLink ( this . handle ) ; } disconnect ( ) { return getClient ( ) . disconnect ( this . handle ) ; } writeChunk ( buf , debugLink ? ) { return getClient ( ) . writeChunk ( this . handle , buf , debugLink ) ; } readChunk ( debugLink ? ) { return getClient ( ) . readChunk ( this . handle , debugLink ) ; } }