//@ts-nocheck
import { TokenData } from "./token";
import * as _m0 from "protobufjs/minimal";
import { isSet } from "../../../helpers";
function createBaseMintAuthorization() {
  return {
    minter: "",
    constraints: []
  };
}
export const MintAuthorization = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.minter !== "") {
      writer.uint32(10).string(message.minter);
    }
    for (const v of message.constraints) {
      MintConstraints.encode(v, writer.uint32(18).fork()).ldelim();
    }
    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 = createBaseMintAuthorization();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.minter = reader.string();
          break;
        case 2:
          message.constraints.push(MintConstraints.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      minter: isSet(object.minter) ? String(object.minter) : "",
      constraints: Array.isArray(object === null || object === void 0 ? void 0 : object.constraints) ? object.constraints.map(e => MintConstraints.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.minter !== undefined && (obj.minter = message.minter);
    if (message.constraints) {
      obj.constraints = message.constraints.map(e => e ? MintConstraints.toJSON(e) : undefined);
    } else {
      obj.constraints = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$minter, _object$constraints;
    const message = createBaseMintAuthorization();
    message.minter = (_object$minter = object.minter) !== null && _object$minter !== void 0 ? _object$minter : "";
    message.constraints = ((_object$constraints = object.constraints) === null || _object$constraints === void 0 ? void 0 : _object$constraints.map(e => MintConstraints.fromPartial(e))) || [];
    return message;
  }
};
function createBaseMintConstraints() {
  return {
    contractAddress: "",
    amount: "",
    name: "",
    index: "",
    collection: "",
    tokenData: []
  };
}
export const MintConstraints = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.contractAddress !== "") {
      writer.uint32(10).string(message.contractAddress);
    }
    if (message.amount !== "") {
      writer.uint32(18).string(message.amount);
    }
    if (message.name !== "") {
      writer.uint32(26).string(message.name);
    }
    if (message.index !== "") {
      writer.uint32(34).string(message.index);
    }
    if (message.collection !== "") {
      writer.uint32(42).string(message.collection);
    }
    for (const v of message.tokenData) {
      TokenData.encode(v, writer.uint32(50).fork()).ldelim();
    }
    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 = createBaseMintConstraints();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.contractAddress = reader.string();
          break;
        case 2:
          message.amount = reader.string();
          break;
        case 3:
          message.name = reader.string();
          break;
        case 4:
          message.index = reader.string();
          break;
        case 5:
          message.collection = reader.string();
          break;
        case 6:
          message.tokenData.push(TokenData.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      contractAddress: isSet(object.contractAddress) ? String(object.contractAddress) : "",
      amount: isSet(object.amount) ? String(object.amount) : "",
      name: isSet(object.name) ? String(object.name) : "",
      index: isSet(object.index) ? String(object.index) : "",
      collection: isSet(object.collection) ? String(object.collection) : "",
      tokenData: Array.isArray(object === null || object === void 0 ? void 0 : object.tokenData) ? object.tokenData.map(e => TokenData.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress);
    message.amount !== undefined && (obj.amount = message.amount);
    message.name !== undefined && (obj.name = message.name);
    message.index !== undefined && (obj.index = message.index);
    message.collection !== undefined && (obj.collection = message.collection);
    if (message.tokenData) {
      obj.tokenData = message.tokenData.map(e => e ? TokenData.toJSON(e) : undefined);
    } else {
      obj.tokenData = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$contractAddre, _object$amount, _object$name, _object$index, _object$collection, _object$tokenData;
    const message = createBaseMintConstraints();
    message.contractAddress = (_object$contractAddre = object.contractAddress) !== null && _object$contractAddre !== void 0 ? _object$contractAddre : "";
    message.amount = (_object$amount = object.amount) !== null && _object$amount !== void 0 ? _object$amount : "";
    message.name = (_object$name = object.name) !== null && _object$name !== void 0 ? _object$name : "";
    message.index = (_object$index = object.index) !== null && _object$index !== void 0 ? _object$index : "";
    message.collection = (_object$collection = object.collection) !== null && _object$collection !== void 0 ? _object$collection : "";
    message.tokenData = ((_object$tokenData = object.tokenData) === null || _object$tokenData === void 0 ? void 0 : _object$tokenData.map(e => TokenData.fromPartial(e))) || [];
    return message;
  }
};