"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Subaccount = exports.SubaccountId = void 0;
const asset_position_1 = require("./asset_position");
const perpetual_position_1 = require("./perpetual_position");
const _m0 = __importStar(require("protobufjs/minimal"));
function createBaseSubaccountId() {
    return {
        owner: "",
        number: 0
    };
}
exports.SubaccountId = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.owner !== "") {
            writer.uint32(10).string(message.owner);
        }
        if (message.number !== 0) {
            writer.uint32(16).uint32(message.number);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubaccountId();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.owner = reader.string();
                    break;
                case 2:
                    message.number = reader.uint32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        var _a, _b;
        const message = createBaseSubaccountId();
        message.owner = (_a = object.owner) !== null && _a !== void 0 ? _a : "";
        message.number = (_b = object.number) !== null && _b !== void 0 ? _b : 0;
        return message;
    }
};
function createBaseSubaccount() {
    return {
        id: undefined,
        assetPositions: [],
        perpetualPositions: [],
        marginEnabled: false
    };
}
exports.Subaccount = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== undefined) {
            exports.SubaccountId.encode(message.id, writer.uint32(10).fork()).ldelim();
        }
        for (const v of message.assetPositions) {
            asset_position_1.AssetPosition.encode(v, writer.uint32(18).fork()).ldelim();
        }
        for (const v of message.perpetualPositions) {
            perpetual_position_1.PerpetualPosition.encode(v, writer.uint32(26).fork()).ldelim();
        }
        if (message.marginEnabled === true) {
            writer.uint32(32).bool(message.marginEnabled);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubaccount();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = exports.SubaccountId.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.assetPositions.push(asset_position_1.AssetPosition.decode(reader, reader.uint32()));
                    break;
                case 3:
                    message.perpetualPositions.push(perpetual_position_1.PerpetualPosition.decode(reader, reader.uint32()));
                    break;
                case 4:
                    message.marginEnabled = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = createBaseSubaccount();
        message.id = object.id !== undefined && object.id !== null ? exports.SubaccountId.fromPartial(object.id) : undefined;
        message.assetPositions = ((_a = object.assetPositions) === null || _a === void 0 ? void 0 : _a.map(e => asset_position_1.AssetPosition.fromPartial(e))) || [];
        message.perpetualPositions = ((_b = object.perpetualPositions) === null || _b === void 0 ? void 0 : _b.map(e => perpetual_position_1.PerpetualPosition.fromPartial(e))) || [];
        message.marginEnabled = (_c = object.marginEnabled) !== null && _c !== void 0 ? _c : false;
        return message;
    }
};
//# sourceMappingURL=data:application/json;base64, 