//@ts-nocheck
import { Height } from '../../../core/client/v1/client.js';
import { BinaryReader, BinaryWriter } from '../../../../binary.js';
import { isSet } from '../../../../helpers.js';
import { decodeBase64 as bytesFromBase64 } from '@endo/base64';
import { encodeBase64 as base64FromBytes } from '@endo/base64';
import {} from '../../../../json-safe.js';
function createBaseClientState() {
    return {
        data: new Uint8Array(),
        checksum: new Uint8Array(),
        latestHeight: Height.fromPartial({}),
    };
}
export const ClientState = {
    typeUrl: '/ibc.lightclients.wasm.v1.ClientState',
    encode(message, writer = BinaryWriter.create()) {
        if (message.data.length !== 0) {
            writer.uint32(10).bytes(message.data);
        }
        if (message.checksum.length !== 0) {
            writer.uint32(18).bytes(message.checksum);
        }
        if (message.latestHeight !== undefined) {
            Height.encode(message.latestHeight, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseClientState();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.data = reader.bytes();
                    break;
                case 2:
                    message.checksum = reader.bytes();
                    break;
                case 3:
                    message.latestHeight = Height.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            data: isSet(object.data)
                ? bytesFromBase64(object.data)
                : new Uint8Array(),
            checksum: isSet(object.checksum)
                ? bytesFromBase64(object.checksum)
                : new Uint8Array(),
            latestHeight: isSet(object.latestHeight)
                ? Height.fromJSON(object.latestHeight)
                : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        message.data !== undefined &&
            (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array()));
        message.checksum !== undefined &&
            (obj.checksum = base64FromBytes(message.checksum !== undefined ? message.checksum : new Uint8Array()));
        message.latestHeight !== undefined &&
            (obj.latestHeight = message.latestHeight
                ? Height.toJSON(message.latestHeight)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = createBaseClientState();
        message.data = object.data ?? new Uint8Array();
        message.checksum = object.checksum ?? new Uint8Array();
        message.latestHeight =
            object.latestHeight !== undefined && object.latestHeight !== null
                ? Height.fromPartial(object.latestHeight)
                : undefined;
        return message;
    },
    fromProtoMsg(message) {
        return ClientState.decode(message.value);
    },
    toProto(message) {
        return ClientState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.wasm.v1.ClientState',
            value: ClientState.encode(message).finish(),
        };
    },
};
function createBaseConsensusState() {
    return {
        data: new Uint8Array(),
    };
}
export const ConsensusState = {
    typeUrl: '/ibc.lightclients.wasm.v1.ConsensusState',
    encode(message, writer = BinaryWriter.create()) {
        if (message.data.length !== 0) {
            writer.uint32(10).bytes(message.data);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseConsensusState();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.data = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            data: isSet(object.data)
                ? bytesFromBase64(object.data)
                : new Uint8Array(),
        };
    },
    toJSON(message) {
        const obj = {};
        message.data !== undefined &&
            (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array()));
        return obj;
    },
    fromPartial(object) {
        const message = createBaseConsensusState();
        message.data = object.data ?? new Uint8Array();
        return message;
    },
    fromProtoMsg(message) {
        return ConsensusState.decode(message.value);
    },
    toProto(message) {
        return ConsensusState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.wasm.v1.ConsensusState',
            value: ConsensusState.encode(message).finish(),
        };
    },
};
function createBaseClientMessage() {
    return {
        data: new Uint8Array(),
    };
}
export const ClientMessage = {
    typeUrl: '/ibc.lightclients.wasm.v1.ClientMessage',
    encode(message, writer = BinaryWriter.create()) {
        if (message.data.length !== 0) {
            writer.uint32(10).bytes(message.data);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseClientMessage();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.data = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            data: isSet(object.data)
                ? bytesFromBase64(object.data)
                : new Uint8Array(),
        };
    },
    toJSON(message) {
        const obj = {};
        message.data !== undefined &&
            (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array()));
        return obj;
    },
    fromPartial(object) {
        const message = createBaseClientMessage();
        message.data = object.data ?? new Uint8Array();
        return message;
    },
    fromProtoMsg(message) {
        return ClientMessage.decode(message.value);
    },
    toProto(message) {
        return ClientMessage.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.wasm.v1.ClientMessage',
            value: ClientMessage.encode(message).finish(),
        };
    },
};
function createBaseChecksums() {
    return {
        checksums: [],
    };
}
export const Checksums = {
    typeUrl: '/ibc.lightclients.wasm.v1.Checksums',
    encode(message, writer = BinaryWriter.create()) {
        for (const v of message.checksums) {
            writer.uint32(10).bytes(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseChecksums();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.checksums.push(reader.bytes());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            checksums: Array.isArray(object?.checksums)
                ? object.checksums.map((e) => bytesFromBase64(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.checksums) {
            obj.checksums = message.checksums.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array()));
        }
        else {
            obj.checksums = [];
        }
        return obj;
    },
    fromPartial(object) {
        const message = createBaseChecksums();
        message.checksums = object.checksums?.map(e => e) || [];
        return message;
    },
    fromProtoMsg(message) {
        return Checksums.decode(message.value);
    },
    toProto(message) {
        return Checksums.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.wasm.v1.Checksums',
            value: Checksums.encode(message).finish(),
        };
    },
};
//# sourceMappingURL=wasm.js.map