"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MerklePath = void 0;
const binary_1 = require("../../../../binary");
const helpers_1 = require("../../../../helpers");
const registry_1 = require("../../../../registry");
function createBaseMerklePath() {
    return {
        keyPath: []
    };
}
exports.MerklePath = {
    typeUrl: "/ibc.core.commitment.v2.MerklePath",
    aminoType: "cosmos-sdk/MerklePath",
    is(o) {
        return o && (o.$typeUrl === exports.MerklePath.typeUrl || Array.isArray(o.keyPath) && (!o.keyPath.length || o.keyPath[0] instanceof Uint8Array || typeof o.keyPath[0] === "string"));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.MerklePath.typeUrl || Array.isArray(o.key_path) && (!o.key_path.length || o.key_path[0] instanceof Uint8Array || typeof o.key_path[0] === "string"));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.keyPath) {
            writer.uint32(10).bytes(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMerklePath();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.keyPath.push(reader.bytes());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseMerklePath();
        message.keyPath = object.keyPath?.map(e => e) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseMerklePath();
        message.keyPath = object.key_path?.map(e => (0, helpers_1.bytesFromBase64)(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.keyPath) {
            obj.key_path = message.keyPath.map(e => (0, helpers_1.base64FromBytes)(e));
        }
        else {
            obj.key_path = message.keyPath;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.MerklePath.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/MerklePath",
            value: exports.MerklePath.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MerklePath.decode(message.value);
    },
    toProto(message) {
        return exports.MerklePath.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.core.commitment.v2.MerklePath",
            value: exports.MerklePath.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.MerklePath.typeUrl, exports.MerklePath);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.MerklePath.aminoType, exports.MerklePath.typeUrl);
