dota2-fork
Version:
A node-steam plugin for Dota 2. Fork with fresh updates
102 lines • 53.8 kB
JavaScript
/*
protobuf.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
Released under the Apache License, Version 2.0
see: https://github.com/dcodeIO/protobuf.js for details
*/
(function(B,P){"function"===typeof define&&define.amd?define(["bytebuffer"],P):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=P(require("bytebuffer"),!0):(B.dcodeIO=B.dcodeIO||{}).ProtoBuf=P(B.dcodeIO.ByteBuffer)})(this,function(B,P){var p={};p.ByteBuffer=B;p.Long=B.Long||null;p.VERSION="5.0.3";p.WIRE_TYPES={};p.WIRE_TYPES.VARINT=0;p.WIRE_TYPES.BITS64=1;p.WIRE_TYPES.LDELIM=2;p.WIRE_TYPES.STARTGROUP=3;p.WIRE_TYPES.ENDGROUP=4;p.WIRE_TYPES.BITS32=5;p.PACKABLE_WIRE_TYPES=
[p.WIRE_TYPES.VARINT,p.WIRE_TYPES.BITS64,p.WIRE_TYPES.BITS32];p.TYPES={int32:{name:"int32",wireType:p.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:p.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:p.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:p.WIRE_TYPES.VARINT,defaultValue:p.Long?p.Long.ZERO:void 0},uint64:{name:"uint64",wireType:p.WIRE_TYPES.VARINT,defaultValue:p.Long?p.Long.UZERO:void 0},sint64:{name:"sint64",wireType:p.WIRE_TYPES.VARINT,
defaultValue:p.Long?p.Long.ZERO:void 0},bool:{name:"bool",wireType:p.WIRE_TYPES.VARINT,defaultValue:!1},"double":{name:"double",wireType:p.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:p.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:p.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:p.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:p.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:p.WIRE_TYPES.BITS64,
defaultValue:p.Long?p.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:p.WIRE_TYPES.BITS64,defaultValue:p.Long?p.Long.ZERO:void 0},"float":{name:"float",wireType:p.WIRE_TYPES.BITS32,defaultValue:0},"enum":{name:"enum",wireType:p.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:p.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:p.WIRE_TYPES.STARTGROUP,defaultValue:null}};p.MAP_KEY_TYPES=[p.TYPES.int32,p.TYPES.sint32,p.TYPES.sfixed32,p.TYPES.uint32,p.TYPES.fixed32,
p.TYPES.int64,p.TYPES.sint64,p.TYPES.sfixed64,p.TYPES.uint64,p.TYPES.fixed64,p.TYPES.bool,p.TYPES.string,p.TYPES.bytes];p.ID_MIN=1;p.ID_MAX=536870911;p.convertFieldsToCamelCase=!1;p.populateAccessors=!0;p.populateDefaults=!0;p.Util=function(){var c={};c.IS_NODE=!("object"!==typeof process||"[object process]"!==process+""||process.browser);c.XHR=function(){for(var n=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},
function(){return new ActiveXObject("Microsoft.XMLHTTP")}],x=null,A=0;A<n.length;A++){try{x=n[A]()}catch(r){continue}break}if(!x)throw Error("XMLHttpRequest is not supported");return x};c.fetch=function(n,x){x&&"function"!=typeof x&&(x=null);if(c.IS_NODE){var A=require("fs");if(x)A.readFile(n,function(w,h){w?x(null):x(""+h)});else try{return A.readFileSync(n)}catch(w){return null}}else{var r=c.XHR();r.open("GET",n,x?!0:!1);r.setRequestHeader("Accept","text/plain");"function"===typeof r.overrideMimeType&&
r.overrideMimeType("text/plain");if(x)r.onreadystatechange=function(){4==r.readyState&&(200==r.status||0==r.status&&"string"===typeof r.responseText?x(r.responseText):x(null))},4!=r.readyState&&r.send(null);else return r.send(null),200==r.status||0==r.status&&"string"===typeof r.responseText?r.responseText:null}};c.toCamelCase=function(n){return n.replace(/_([a-zA-Z])/g,function(x,A){return A.toUpperCase()})};return c}();p.Lang={DELIM:/[\s\{\}=;:\[\],'"\(\)<>]/g,RULE:/^(?:required|optional|repeated|map)$/,
TYPE:/^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,NAME:/^[a-zA-Z_][a-zA-Z_0-9]*$/,TYPEDEF:/^[a-zA-Z][a-zA-Z_0-9]*$/,TYPEREF:/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,FQTYPEREF:/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/,NUMBER:/^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0[xX][0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/,
BOOL:/^(?:true|false)$/i,ID:/^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,STRING_DQ:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,STRING_SQ:/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g};p.DotProto=function(c,n){function x(f,d){var q=1;"-"==f.charAt(0)&&(q=-1,f=f.substring(1));if(n.NUMBER_DEC.test(f))var m=parseInt(f);else if(n.NUMBER_HEX.test(f))m=parseInt(f.substring(2),16);
else if(n.NUMBER_OCT.test(f))m=parseInt(f.substring(1),8);else throw Error("illegal id value: "+(0>q?"-":"")+f);m=q*m|0;if(!d&&0>m)throw Error("illegal id value: "+(0>q?"-":"")+f);return m}function A(f){var d=1;"-"==f.charAt(0)&&(d=-1,f=f.substring(1));if(n.NUMBER_DEC.test(f))return d*parseInt(f,10);if(n.NUMBER_HEX.test(f))return d*parseInt(f.substring(2),16);if(n.NUMBER_OCT.test(f))return d*parseInt(f.substring(1),8);if("inf"===f)return Infinity*d;if("nan"===f)return NaN;if(n.NUMBER_FLT.test(f))return d*
parseFloat(f);throw Error("illegal number value: "+(0>d?"-":"")+f);}function r(f,d,q){"undefined"===typeof f[d]?f[d]=q:(Array.isArray(f[d])||(f[d]=[f[d]]),f[d].push(q))}var w={},h=function(f){this.source=f+"";this.index=0;this.line=1;this.stack=[];this._stringOpen=null},t=h.prototype;t._readString=function(){var f='"'===this._stringOpen?n.STRING_DQ:n.STRING_SQ;f.lastIndex=this.index-1;var d=f.exec(this.source);if(!d)throw Error("unterminated string");this.index=f.lastIndex;this.stack.push(this._stringOpen);
this._stringOpen=null;return d[1]};t.next=function(){if(0<this.stack.length)return this.stack.shift();if(this.index>=this.source.length)return null;if(null!==this._stringOpen)return this._readString();var f,d;do{for(f=!1;n.WHITESPACE.test(d=this.source.charAt(this.index));)if("\n"===d&&++this.line,++this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if(++this.index,"/"===this.source.charAt(this.index)){for(;"\n"!==this.source.charAt(++this.index);)if(this.index==this.source.length)return null;
++this.index;++this.line;f=!0}else if("*"===(d=this.source.charAt(this.index))){do{"\n"===d&&++this.line;if(++this.index===this.source.length)return null;f=d;d=this.source.charAt(this.index)}while("*"!==f||"/"!==d);++this.index;f=!0}else return"/"}while(f);if(this.index===this.source.length)return null;d=this.index;n.DELIM.lastIndex=0;if(!n.DELIM.test(this.source.charAt(d++)))for(;d<this.source.length&&!n.DELIM.test(this.source.charAt(d));)++d;d=this.source.substring(this.index,this.index=d);if('"'===
d||"'"===d)this._stringOpen=d;return d};t.peek=function(){if(0===this.stack.length){var f=this.next();if(null===f)return null;this.stack.push(f)}return this.stack[0]};t.skip=function(f){var d=this.next();if(d!==f)throw Error("illegal '"+d+"', '"+f+"' expected");};t.omit=function(f){return this.peek()===f?(this.next(),!0):!1};t.toString=function(){return"Tokenizer ("+this.index+"/"+this.source.length+" at line "+this.line+")"};w.Tokenizer=h;var u=function(f){this.tn=new h(f);this.proto3=!1};t=u.prototype;
t.parse=function(){var f={name:"[ROOT]","package":null,messages:[],enums:[],imports:[],options:{},services:[]},d,q=!0,m;try{for(;d=this.tn.next();)switch(d){case "package":if(!q||null!==f["package"])throw Error("unexpected 'package'");d=this.tn.next();if(!n.TYPEREF.test(d))throw Error("illegal package name: "+d);this.tn.skip(";");f["package"]=d;break;case "import":if(!q)throw Error("unexpected 'import'");d=this.tn.peek();("public"===d||(m="weak"===d))&&this.tn.next();d=this._readString();this.tn.skip(";");
m||f.imports.push(d);break;case "syntax":if(!q)throw Error("unexpected 'syntax'");this.tn.skip("=");"proto3"===(f.syntax=this._readString())&&(this.proto3=!0);this.tn.skip(";");break;case "message":this._parseMessage(f,null);q=!1;break;case "enum":this._parseEnum(f);q=!1;break;case "option":this._parseOption(f);break;case "service":this._parseService(f);break;case "extend":this._parseExtend(f);break;default:throw Error("unexpected '"+d+"'");}}catch(E){throw E.message="Parse error at line "+this.tn.line+
": "+E.message,E;}delete f.name;return f};u.parse=function(f){return(new u(f)).parse()};t._readString=function(){var f="";do{var d=this.tn.next();if("'"!==d&&'"'!==d)throw Error("illegal string delimiter: "+d);f+=this.tn.next();this.tn.skip(d);d=this.tn.peek()}while('"'===d||'"'===d);return f};t._readValue=function(f){var d=this.tn.peek();if('"'===d||"'"===d)return this._readString();this.tn.next();if(n.NUMBER.test(d))return A(d);if(n.BOOL.test(d))return"true"===d.toLowerCase();if(f&&n.TYPEREF.test(d))return d;
throw Error("illegal value: "+d);};t._parseOption=function(f,d){var q=this.tn.next(),m=!1;"("===q&&(m=!0,q=this.tn.next());if(!n.TYPEREF.test(q))throw Error("illegal option name: "+q);var E=q;m&&(this.tn.skip(")"),E="("+E+")",q=this.tn.peek(),n.FQTYPEREF.test(q)&&(E+=q,this.tn.next()));this.tn.skip("=");this._parseOptionValue(f,E);d||this.tn.skip(";")};t._parseOptionValue=function(f,d){var q=this.tn.peek();if("{"!==q)r(f.options,d,this._readValue(!0));else for(this.tn.skip("{");"}"!==(q=this.tn.next());){if(!n.NAME.test(q))throw Error("illegal option name: "+
d+"."+q);this.tn.omit(":")?r(f.options,d+"."+q,this._readValue(!0)):this._parseOptionValue(f,d+"."+q)}};t._parseService=function(f){var d=this.tn.next();if(!n.NAME.test(d))throw Error("illegal service name at line "+this.tn.line+": "+d);var q={name:d,rpc:{},options:{}};for(this.tn.skip("{");"}"!==(d=this.tn.next());)if("option"===d)this._parseOption(q);else if("rpc"===d)this._parseServiceRPC(q);else throw Error("illegal service token: "+d);this.tn.omit(";");f.services.push(q)};t._parseServiceRPC=
function(f){var d=this.tn.next();if(!n.NAME.test(d))throw Error("illegal rpc service method name: "+d);var q=d,m={request:null,response:null,request_stream:!1,response_stream:!1,options:{}};this.tn.skip("(");d=this.tn.next();"stream"===d.toLowerCase()&&(m.request_stream=!0,d=this.tn.next());if(!n.TYPEREF.test(d))throw Error("illegal rpc service request type: "+d);m.request=d;this.tn.skip(")");d=this.tn.next();if("returns"!==d.toLowerCase())throw Error("illegal rpc service request type delimiter: "+
d);this.tn.skip("(");d=this.tn.next();"stream"===d.toLowerCase()&&(m.response_stream=!0,d=this.tn.next());m.response=d;this.tn.skip(")");d=this.tn.peek();if("{"===d){for(this.tn.next();"}"!==(d=this.tn.next());)if("option"===d)this._parseOption(m);else throw Error("illegal rpc service token: "+d);this.tn.omit(";")}else this.tn.skip(";");"undefined"===typeof f.rpc&&(f.rpc={});f.rpc[q]=m};t._parseMessage=function(f,d){var q=!!d,m=this.tn.next(),E={name:"",fields:[],enums:[],messages:[],options:{},services:[],
oneofs:{}};if(!n.NAME.test(m))throw Error("illegal "+(q?"group":"message")+" name: "+m);E.name=m;q&&(this.tn.skip("="),d.id=x(this.tn.next()),E.isGroup=!0);m=this.tn.peek();"["===m&&d&&this._parseFieldOptions(d);for(this.tn.skip("{");"}"!==(m=this.tn.next());)if(n.RULE.test(m))this._parseMessageField(E,m);else if("oneof"===m)this._parseMessageOneOf(E);else if("enum"===m)this._parseEnum(E);else if("message"===m)this._parseMessage(E);else if("option"===m)this._parseOption(E);else if("service"===m)this._parseService(E);
else if("extensions"===m)E.hasOwnProperty("extensions")?E.extensions=E.extensions.concat(this._parseExtensionRanges()):E.extensions=this._parseExtensionRanges();else if("reserved"===m)this._parseIgnored();else if("extend"===m)this._parseExtend(E);else if(n.TYPEREF.test(m)){if(!this.proto3)throw Error("illegal field rule: "+m);this._parseMessageField(E,"optional",m)}else throw Error("illegal message token: "+m);this.tn.omit(";");f.messages.push(E);return E};t._parseIgnored=function(){for(;";"!==this.tn.peek();)this.tn.next();
this.tn.skip(";")};t._parseMessageField=function(f,d,q){if(!n.RULE.test(d))throw Error("illegal message field rule: "+d);var m={rule:d,type:"",name:"",options:{},id:0};if("map"===d){if(q)throw Error("illegal type: "+q);this.tn.skip("<");d=this.tn.next();if(!n.TYPE.test(d)&&!n.TYPEREF.test(d))throw Error("illegal message field type: "+d);m.keytype=d;this.tn.skip(",");d=this.tn.next();if(!n.TYPE.test(d)&&!n.TYPEREF.test(d))throw Error("illegal message field: "+d);m.type=d;this.tn.skip(">");d=this.tn.next();
if(!n.NAME.test(d))throw Error("illegal message field name: "+d);m.name=d;this.tn.skip("=");m.id=x(this.tn.next());d=this.tn.peek();"["===d&&this._parseFieldOptions(m);this.tn.skip(";")}else if(q="undefined"!==typeof q?q:this.tn.next(),"group"===q){d=this._parseMessage(f,m);if(!/^[A-Z]/.test(d.name))throw Error("illegal group name: "+d.name);m.type=d.name;m.name=d.name.toLowerCase();this.tn.omit(";")}else{if(!n.TYPE.test(q)&&!n.TYPEREF.test(q))throw Error("illegal message field type: "+q);m.type=
q;d=this.tn.next();if(!n.NAME.test(d))throw Error("illegal message field name: "+d);m.name=d;this.tn.skip("=");m.id=x(this.tn.next());d=this.tn.peek();"["===d&&this._parseFieldOptions(m);this.tn.skip(";")}f.fields.push(m);return m};t._parseMessageOneOf=function(f){var d=this.tn.next();if(!n.NAME.test(d))throw Error("illegal oneof name: "+d);var q=d,m=[];for(this.tn.skip("{");"}"!==(d=this.tn.next());)d=this._parseMessageField(f,"optional",d),d.oneof=q,m.push(d.id);this.tn.omit(";");f.oneofs[q]=m};
t._parseFieldOptions=function(f){this.tn.skip("[");for(var d=!0;"]"!==this.tn.peek();)d||this.tn.skip(","),this._parseOption(f,!0),d=!1;this.tn.next()};t._parseEnum=function(f){var d={name:"",values:[],options:{}},q=this.tn.next();if(!n.NAME.test(q))throw Error("illegal name: "+q);d.name=q;for(this.tn.skip("{");"}"!==(q=this.tn.next());)if("option"===q)this._parseOption(d);else{if(!n.NAME.test(q))throw Error("illegal name: "+q);this.tn.skip("=");var m={name:q,id:x(this.tn.next(),!0)};q=this.tn.peek();
"["===q&&this._parseFieldOptions({options:{}});this.tn.skip(";");d.values.push(m)}this.tn.omit(";");f.enums.push(d)};t._parseExtensionRanges=function(){var f=[],d;do{for(d=[];;){var q=this.tn.next();switch(q){case "min":q=c.ID_MIN;break;case "max":q=c.ID_MAX;break;default:q=A(q)}d.push(q);if(2===d.length)break;if("to"!==this.tn.peek()){d.push(q);break}this.tn.next()}f.push(d)}while(this.tn.omit(","));this.tn.skip(";");return f};t._parseExtend=function(f){var d=this.tn.next();if(!n.TYPEREF.test(d))throw Error("illegal extend reference: "+
d);var q={ref:d,fields:[]};for(this.tn.skip("{");"}"!==(d=this.tn.next());)if(n.RULE.test(d))this._parseMessageField(q,d);else if(n.TYPEREF.test(d)){if(!this.proto3)throw Error("illegal field rule: "+d);this._parseMessageField(q,"optional",d)}else throw Error("illegal extend token: "+d);this.tn.omit(";");f.messages.push(q);return q};t.toString=function(){return"Parser at line "+this.tn.line};w.Parser=u;return w}(p,p.Lang);p.Reflect=function(c){function n(a,b){if(a&&"number"===typeof a.low&&"number"===
typeof a.high&&"boolean"===typeof a.unsigned&&a.low===a.low&&a.high===a.high)return new c.Long(a.low,a.high,"undefined"===typeof b?a.unsigned:b);if("string"===typeof a)return c.Long.fromString(a,b||!1,10);if("number"===typeof a)return c.Long.fromNumber(a,b||!1);throw Error("not convertible to Long");}function x(a,b){var e=b.readVarint32(),k=e&7;e>>>=3;switch(k){case c.WIRE_TYPES.VARINT:do e=b.readUint8();while(128===(e&128));break;case c.WIRE_TYPES.BITS64:b.offset+=8;break;case c.WIRE_TYPES.LDELIM:e=
b.readVarint32();b.offset+=e;break;case c.WIRE_TYPES.STARTGROUP:x(e,b);break;case c.WIRE_TYPES.ENDGROUP:if(e===a)return!1;throw Error("Illegal GROUPEND after unknown group: "+e+" ("+a+" expected)");case c.WIRE_TYPES.BITS32:b.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+k);}return!0}var A={},r=function(a,b,e){this.builder=a;this.parent=b;this.name=e},w=r.prototype;w.fqn=function(){var a=this.name,b=this;do{b=b.parent;if(null==b)break;a=b.name+"."+a}while(1);return a};
w.toString=function(a){return(a?this.className+" ":"")+this.fqn()};w.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};A.T=r;var h=function(a,b,e,k,l){r.call(this,a,b,e);this.className="Namespace";this.children=[];this.options=k||{};this.syntax=l||"proto2"};w=h.prototype=Object.create(r.prototype);w.getChildren=function(a){a=a||null;if(null==a)return this.children.slice();for(var b=[],e=0,k=this.children.length;e<k;++e)this.children[e]instanceof a&&b.push(this.children[e]);
return b};w.addChild=function(a){var b;if(b=this.getChild(a.name))if(b instanceof f.Field&&b.name!==b.originalName&&null===this.getChild(b.originalName))b.name=b.originalName;else if(a instanceof f.Field&&a.name!==a.originalName&&null===this.getChild(a.originalName))a.name=a.originalName;else throw Error("Duplicate name in namespace "+this.toString(!0)+": "+a.name);this.children.push(a)};w.getChild=function(a){for(var b="number"===typeof a?"id":"name",e=0,k=this.children.length;e<k;++e)if(this.children[e][b]===
a)return this.children[e];return null};w.resolve=function(a,b){var e="string"===typeof a?a.split("."):a,k=this,l=0;if(""===e[l]){for(;null!==k.parent;)k=k.parent;l++}do{do{if(!(k instanceof A.Namespace)){k=null;break}k=k.getChild(e[l]);if(!(k&&k instanceof A.T)||b&&!(k instanceof A.Namespace)){k=null;break}l++}while(l<e.length);if(null!=k)break;if(null!==this.parent)return this.parent.resolve(a,b)}while(null!=k);return k};w.qn=function(a){var b=[],e=a;do b.unshift(e.name),e=e.parent;while(null!==
e);for(e=1;e<=b.length;e++){var k=b.slice(b.length-e);if(a===this.resolve(k,a instanceof A.Namespace))return k.join(".")}return a.fqn()};w.build=function(){for(var a={},b=this.children,e=0,k=b.length,l;e<k;++e)l=b[e],l instanceof h&&(a[l.name]=l.build());Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt()});return a};w.buildOpt=function(){for(var a={},b=Object.keys(this.options),e=0,k=b.length;e<k;++e)a[b[e]]=this.options[b[e]];return a};w.getOption=function(a){return"undefined"===
typeof a?this.options:"undefined"!==typeof this.options[a]?this.options[a]:null};A.Namespace=h;var t=function(a,b,e,k,l){this.type=a;this.resolvedType=b;this.isMapKey=e;this.syntax=k;this.name=l;if(e&&0>c.MAP_KEY_TYPES.indexOf(a))throw Error("Invalid map key type: "+a.name);},u=t.prototype;t.defaultFieldValue=function(a){"string"===typeof a&&(a=c.TYPES[a]);if("undefined"===typeof a.defaultValue)throw Error("default value for type "+a.name+" is not supported");return a==c.TYPES.bytes?new B(0):a.defaultValue};
u.toString=function(){return(this.name||"")+(this.isMapKey?"map":"value")+" element"};u.verifyValue=function(a){function b(v,G){throw Error("Illegal value for "+e.toString(!0)+" of type "+e.type.name+": "+v+" ("+G+")");}var e=this;switch(this.type){case c.TYPES.int32:case c.TYPES.sint32:case c.TYPES.sfixed32:return("number"!==typeof a||a===a&&0!==a%1)&&b(typeof a,"not an integer"),4294967295<a?a|0:a;case c.TYPES.uint32:case c.TYPES.fixed32:return("number"!==typeof a||a===a&&0!==a%1)&&b(typeof a,"not an integer"),
0>a?a>>>0:a;case c.TYPES.int64:case c.TYPES.sint64:case c.TYPES.sfixed64:if(c.Long)try{return n(a,!1)}catch(v){b(typeof a,v.message)}else b(typeof a,"requires Long.js");case c.TYPES.uint64:case c.TYPES.fixed64:if(c.Long)try{return n(a,!0)}catch(v){b(typeof a,v.message)}else b(typeof a,"requires Long.js");case c.TYPES.bool:return"boolean"!==typeof a&&b(typeof a,"not a boolean"),a;case c.TYPES["float"]:case c.TYPES["double"]:return"number"!==typeof a&&b(typeof a,"not a number"),a;case c.TYPES.string:return"string"===
typeof a||a&&a instanceof String||b(typeof a,"not a string"),""+a;case c.TYPES.bytes:return B.isByteBuffer(a)?a:B.wrap(a,"base64");case c.TYPES["enum"]:var k=this.resolvedType.getChildren(c.Reflect.Enum.Value);for(l=0;l<k.length;l++)if(k[l].name==a||k[l].id==a)return k[l].id;if("proto3"===this.syntax)return("number"!==typeof a||a===a&&0!==a%1)&&b(typeof a,"not an integer"),(4294967295<a||0>a)&&b(typeof a,"not in range for uint32"),a;b(a,"not a valid enum value");case c.TYPES.group:case c.TYPES.message:a&&
"object"===typeof a||b(typeof a,"object expected");if(a instanceof this.resolvedType.clazz)return a;if(a instanceof c.Builder.Message){k={};for(var l in a)a.hasOwnProperty(l)&&(k[l]=a[l]);a=k}return new this.resolvedType.clazz(a)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+a+" (undefined type "+this.type+")");};u.calculateLength=function(a,b){if(null===b)return 0;switch(this.type){case c.TYPES.int32:return 0>b?B.calculateVarint64(b):B.calculateVarint32(b);case c.TYPES.uint32:return B.calculateVarint32(b);
case c.TYPES.sint32:return B.calculateVarint32(B.zigZagEncode32(b));case c.TYPES.fixed32:case c.TYPES.sfixed32:case c.TYPES["float"]:return 4;case c.TYPES.int64:case c.TYPES.uint64:return B.calculateVarint64(b);case c.TYPES.sint64:return B.calculateVarint64(B.zigZagEncode64(b));case c.TYPES.fixed64:case c.TYPES.sfixed64:return 8;case c.TYPES.bool:return 1;case c.TYPES["enum"]:return B.calculateVarint32(b);case c.TYPES["double"]:return 8;case c.TYPES.string:return b=B.calculateUTF8Bytes(b),B.calculateVarint32(b)+
b;case c.TYPES.bytes:if(0>b.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+b.remaining()+" bytes remaining");return B.calculateVarint32(b.remaining())+b.remaining();case c.TYPES.message:return b=this.resolvedType.calculate(b),B.calculateVarint32(b)+b;case c.TYPES.group:return b=this.resolvedType.calculate(b),b+B.calculateVarint32(a<<3|c.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+b+" (unknown type)");};u.encodeValue=function(a,
b,e){if(null===b)return e;switch(this.type){case c.TYPES.int32:0>b?e.writeVarint64(b):e.writeVarint32(b);break;case c.TYPES.uint32:e.writeVarint32(b);break;case c.TYPES.sint32:e.writeVarint32ZigZag(b);break;case c.TYPES.fixed32:e.writeUint32(b);break;case c.TYPES.sfixed32:e.writeInt32(b);break;case c.TYPES.int64:case c.TYPES.uint64:e.writeVarint64(b);break;case c.TYPES.sint64:e.writeVarint64ZigZag(b);break;case c.TYPES.fixed64:e.writeUint64(b);break;case c.TYPES.sfixed64:e.writeInt64(b);break;case c.TYPES.bool:"string"===
typeof b?e.writeVarint32("false"===b.toLowerCase()?0:!!b):e.writeVarint32(b?1:0);break;case c.TYPES["enum"]:e.writeVarint32(b);break;case c.TYPES["float"]:e.writeFloat32(b);break;case c.TYPES["double"]:e.writeFloat64(b);break;case c.TYPES.string:e.writeVString(b);break;case c.TYPES.bytes:if(0>b.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+b.remaining()+" bytes remaining");a=b.offset;e.writeVarint32(b.remaining());e.append(b);b.offset=a;break;case c.TYPES.message:a=(new B).LE();
this.resolvedType.encode(b,a);e.writeVarint32(a.offset);e.append(a.flip());break;case c.TYPES.group:this.resolvedType.encode(b,e);e.writeVarint32(a<<3|c.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+b+" (unknown type)");}return e};u.decode=function(a,b,e){if(b!=this.type.wireType)throw Error("Unexpected wire type for element");switch(this.type){case c.TYPES.int32:return a.readVarint32()|0;case c.TYPES.uint32:return a.readVarint32()>>>
0;case c.TYPES.sint32:return a.readVarint32ZigZag()|0;case c.TYPES.fixed32:return a.readUint32()>>>0;case c.TYPES.sfixed32:return a.readInt32()|0;case c.TYPES.int64:return a.readVarint64();case c.TYPES.uint64:return a.readVarint64().toUnsigned();case c.TYPES.sint64:return a.readVarint64ZigZag();case c.TYPES.fixed64:return a.readUint64();case c.TYPES.sfixed64:return a.readInt64();case c.TYPES.bool:return!!a.readVarint32();case c.TYPES["enum"]:return a.readVarint32();case c.TYPES["float"]:return a.readFloat();
case c.TYPES["double"]:return a.readDouble();case c.TYPES.string:return a.readVString();case c.TYPES.bytes:e=a.readVarint32();if(a.remaining()<e)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+e+" required but got only "+a.remaining());b=a.clone();b.limit=b.offset+e;a.offset+=e;return b;case c.TYPES.message:return e=a.readVarint32(),this.resolvedType.decode(a,e);case c.TYPES.group:return this.resolvedType.decode(a,-1,e)}throw Error("[INTERNAL] Illegal decode type");};u.valueFromString=
function(a){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case c.TYPES.int32:case c.TYPES.sint32:case c.TYPES.sfixed32:case c.TYPES.uint32:case c.TYPES.fixed32:return this.verifyValue(parseInt(a));case c.TYPES.int64:case c.TYPES.sint64:case c.TYPES.sfixed64:case c.TYPES.uint64:case c.TYPES.fixed64:return this.verifyValue(a);case c.TYPES.bool:return"true"===a;case c.TYPES.string:return this.verifyValue(a);case c.TYPES.bytes:return B.fromBinary(a)}};
u.valueToString=function(a){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===c.TYPES.bytes?a.toString("binary"):a.toString()};A.Element=t;var f=function(a,b,e,k,l,v){h.call(this,a,b,e,k,v);this.className="Message";this.extensions=void 0;this.clazz=null;this.isGroup=!!l;this._fieldsByName=this._fieldsById=this._fields=null};u=f.prototype=Object.create(h.prototype);u.build=function(a){if(this.clazz&&!a)return this.clazz;a=function(l,v){function G(g,z,
y,C){if(null===g||"object"!==typeof g){if(C&&C instanceof l.Reflect.Enum){var I=l.Reflect.Enum.getName(C.object,g);if(null!==I)return I}return g}if(B.isByteBuffer(g))return z?g.toBase64():g.toBuffer();if(l.Long.isLong(g))return y?g.toString():l.Long.fromValue(g);if(Array.isArray(g)){var K=[];g.forEach(function(R,S){K[S]=G(R,z,y,C)});return K}K={};if(g instanceof l.Map){I=g.entries();for(var N=I.next();!N.done;N=I.next())K[g.keyElem.valueToString(N.value[0])]=G(N.value[1],z,y,g.valueElem.resolvedType);
return K}I=g.$type;N=void 0;for(var O in g)g.hasOwnProperty(O)&&(I&&(N=I.getChild(O))?K[O]=G(g[O],z,y,N.resolvedType):K[O]=G(g[O],z,y));return K}var F=v.getChildren(l.Reflect.Message.Field),J=v.getChildren(l.Reflect.Message.OneOf),H=function(g,z){l.Builder.Message.call(this);for(var y=0,C=J.length;y<C;++y)this[J[y].name]=null;y=0;for(C=F.length;y<C;++y){var I=F[y];this[I.name]=I.repeated?[]:I.map?new l.Map(I):null;!I.required&&"proto3"!==v.syntax||null===I.defaultValue||(this[I.name]=I.defaultValue)}if(0<
arguments.length){var K;if(1!==arguments.length||null===g||"object"!==typeof g||!("function"!==typeof g.encode||g instanceof H)||Array.isArray(g)||g instanceof l.Map||B.isByteBuffer(g)||g instanceof ArrayBuffer||l.Long&&g instanceof l.Long)for(y=0,C=arguments.length;y<C;++y)"undefined"!==typeof(K=arguments[y])&&this.$set(F[y].name,K);else this.$set(g)}},D=H.prototype=Object.create(l.Builder.Message.prototype);D.add=function(g,z,y){var C=v._fieldsByName[g];if(!y){if(!C)throw Error(this+"#"+g+" is undefined");
if(!(C instanceof l.Reflect.Message.Field))throw Error(this+"#"+g+" is not a field: "+C.toString(!0));if(!C.repeated)throw Error(this+"#"+g+" is not a repeated field");z=C.verifyValue(z,!0)}null===this[g]&&(this[g]=[]);this[g].push(z);return this};D.$add=D.add;D.set=function(g,z,y){if(g&&"object"===typeof g){y=z;for(var C in g)g.hasOwnProperty(C)&&"undefined"!==typeof(z=g[C])&&void 0===v._oneofsByName[C]&&this.$set(C,z,y);return this}C=v._fieldsByName[g];if(y)this[g]=z;else{if(!C)throw Error(this+
"#"+g+" is not a field: undefined");if(!(C instanceof l.Reflect.Message.Field))throw Error(this+"#"+g+" is not a field: "+C.toString(!0));this[C.name]=z=C.verifyValue(z)}C&&C.oneof&&(y=this[C.oneof.name],null!==z?(null!==y&&y!==C.name&&(this[y]=null),this[C.oneof.name]=C.name):y===g&&(this[C.oneof.name]=null));return this};D.$set=D.set;D.get=function(g,z){if(z)return this[g];z=v._fieldsByName[g];if(!(z&&z instanceof l.Reflect.Message.Field))throw Error(this+"#"+g+" is not a field: undefined");if(!(z instanceof
l.Reflect.Message.Field))throw Error(this+"#"+g+" is not a field: "+z.toString(!0));return this[z.name]};D.$get=D.get;for(var M=0;M<F.length;M++){var Q=F[M];Q instanceof l.Reflect.Message.ExtensionField||v.builder.options.populateAccessors&&function(g){var z=g.originalName.replace(/(_[a-zA-Z])/g,function(K){return K.toUpperCase().replace("_","")});z=z.substring(0,1).toUpperCase()+z.substring(1);var y=g.originalName.replace(/([A-Z])/g,function(K){return"_"+K}),C=function(K,N){this[g.name]=N?K:g.verifyValue(K);
return this},I=function(){return this[g.name]};null===v.getChild("set"+z)&&(D["set"+z]=C);null===v.getChild("set_"+y)&&(D["set_"+y]=C);null===v.getChild("get"+z)&&(D["get"+z]=I);null===v.getChild("get_"+y)&&(D["get_"+y]=I)}(Q)}D.encode=function(g,z){"boolean"===typeof g&&(z=g,g=void 0);var y=!1;g||(g=new B,y=!0);var C=g.littleEndian;try{return v.encode(this,g.LE(),z),(y?g.flip():g).LE(C)}catch(I){throw g.LE(C),I;}};H.encode=function(g,z,y){return(new H(g)).encode(z,y)};D.calculate=function(){return v.calculate(this)};
D.encodeDelimited=function(g,z){var y=!1;g||(g=new B,y=!0);var C=(new B).LE();v.encode(this,C,z).flip();g.writeVarint32(C.remaining());g.append(C);return y?g.flip():g};D.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(g){throw g.encoded&&(g.encoded=g.encoded.toArrayBuffer()),g;}};D.toArrayBuffer=D.encodeAB;D.encodeNB=function(){try{return this.encode().toBuffer()}catch(g){throw g.encoded&&(g.encoded=g.encoded.toBuffer()),g;}};D.toBuffer=D.encodeNB;D.encode64=function(){try{return this.encode().toBase64()}catch(g){throw g.encoded&&
(g.encoded=g.encoded.toBase64()),g;}};D.toBase64=D.encode64;D.encodeHex=function(){try{return this.encode().toHex()}catch(g){throw g.encoded&&(g.encoded=g.encoded.toHex()),g;}};D.toHex=D.encodeHex;D.toRaw=function(g,z){return G(this,!!g,!!z,this.$type)};D.encodeJSON=function(){return JSON.stringify(G(this,!0,!0,this.$type))};H.decode=function(g,z,y){"string"===typeof z&&(y=z,z=-1);"string"===typeof g?g=B.wrap(g,y?y:"base64"):B.isByteBuffer(g)||(g=B.wrap(g));y=g.littleEndian;try{var C=v.decode(g.LE(),
z);g.LE(y);return C}catch(I){throw g.LE(y),I;}};H.decodeDelimited=function(g,z){"string"===typeof g?g=B.wrap(g,z?z:"base64"):B.isByteBuffer(g)||(g=B.wrap(g));if(1>g.remaining())return null;z=g.offset;var y=g.readVarint32();if(g.remaining()<y)return g.offset=z,null;try{var C=v.decode(g.slice(g.offset,g.offset+y).LE());g.offset+=y;return C}catch(I){throw g.offset+=y,I;}};H.decode64=function(g){return H.decode(g,"base64")};H.decodeHex=function(g){return H.decode(g,"hex")};H.decodeJSON=function(g){return new H(JSON.parse(g))};
D.toString=function(){return v.toString()};Object.defineProperty&&(Object.defineProperty(H,"$options",{value:v.buildOpt()}),Object.defineProperty(D,"$options",{value:H.$options}),Object.defineProperty(H,"$type",{value:v}),Object.defineProperty(D,"$type",{value:v}));return H}(c,this);this._fields=[];this._fieldsById={};this._fieldsByName={};this._oneofsByName={};for(var b=0,e=this.children.length,k;b<e;b++)if(k=this.children[b],k instanceof q||k instanceof f||k instanceof E){if(a.hasOwnProperty(k.name))throw Error("Illegal reflect child of "+
this.toString(!0)+": "+k.toString(!0)+" cannot override static property '"+k.name+"'");a[k.name]=k.build()}else if(k instanceof f.Field)k.build(),this._fields.push(k),this._fieldsById[k.id]=k,this._fieldsByName[k.name]=k;else if(k instanceof f.OneOf)this._oneofsByName[k.name]=k;else if(!(k instanceof f.OneOf||k instanceof m))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[b].toString(!0));return this.clazz=a};u.encode=function(a,b,e){for(var k=null,l,v=0,G=this._fields.length,
F;v<G;++v)l=this._fields[v],F=a[l.name],l.required&&null===F?null===k&&(k=l):l.encode(e?F:l.verifyValue(F),b,a);if(null!==k)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+k),a.encoded=b,a;return b};u.calculate=function(a){for(var b=0,e=0,k=this._fields.length,l,v;e<k;++e){l=this._fields[e];v=a[l.name];if(l.required&&null===v)throw Error("Missing at least one required field for "+this.toString(!0)+": "+l);b+=l.calculate(v,a)}return b};u.decode=function(a,b,e){"number"!==
typeof b&&(b=-1);var k=a.offset;e=new this.clazz;for(var l,v,G;a.offset<k+b||-1===b&&0<a.remaining();){l=a.readVarint32();v=l&7;G=l>>>3;if(v===c.WIRE_TYPES.ENDGROUP)break;if(l=this._fieldsById[G])if(l.repeated&&!l.options.packed)try{e[l.name].push(l.decode(v,a))}catch(H){e[l.name].push("Undecoded")}else if(l.map)try{var F=l.decode(v,a);e[l.name].set(F[0],F[1])}catch(H){e[l.name]="Undecoded"}else try{if(e[l.name]=l.decode(v,a),l.oneof){var J=e[l.oneof.name];null!==J&&J!==l.name&&(e[J]=null);e[l.oneof.name]=
l.name}}catch(H){e[l.name]="Undecoded"}else switch(v){case c.WIRE_TYPES.VARINT:a.readVarint32();break;case c.WIRE_TYPES.BITS32:a.offset+=4;break;case c.WIRE_TYPES.BITS64:a.offset+=8;break;case c.WIRE_TYPES.LDELIM:l=a.readVarint32();a.offset+=l;break;case c.WIRE_TYPES.STARTGROUP:for(;x(G,a););break;default:throw Error("Illegal wire type for unknown field "+G+" in "+this.toString(!0)+"#decode: "+v);}}a=0;for(b=this._fields.length;a<b;++a)if(l=this._fields[a],null===e[l.name])if("proto3"===this.syntax)e[l.name]=
l.defaultValue;else{if(l.required)throw a=Error("Missing at least one required field for "+this.toString(!0)+": "+l.name),a.decoded=e,a;c.populateDefaults&&null!==l.defaultValue&&(e[l.name]=l.defaultValue)}return e};A.Message=f;var d=function(a,b,e,k,l,v,G,F,J,H){r.call(this,a,b,v);this.className="Message.Field";this.required="required"===e;this.repeated="repeated"===e;this.map="map"===e;this.keyType=k||null;this.type=l;this.resolvedType=null;this.id=G;this.options=F||{};this.defaultValue=null;this.oneof=
J||null;this.syntax=H||"proto2";this.originalName=this.name;this.keyElement=this.element=null;!this.builder.options.convertFieldsToCamelCase||this instanceof f.ExtensionField||(this.name=c.Util.toCamelCase(this.name))};u=d.prototype=Object.create(r.prototype);u.build=function(){this.element=new t(this.type,this.resolvedType,!1,this.syntax,this.name);this.map&&(this.keyElement=new t(this.keyType,void 0,!0,this.syntax,this.name));"proto3"!==this.syntax||this.repeated||this.map?"undefined"!==typeof this.options["default"]&&
(this.defaultValue=this.verifyValue(this.options["default"])):this.defaultValue=t.defaultFieldValue(this.type)};u.verifyValue=function(a,b){function e(v,G){throw Error("Illegal value for "+k.toString(!0)+" of type "+k.type.name+": "+v+" ("+G+")");}b=b||!1;var k=this;if(null===a)return this.required&&e(typeof a,"required"),"proto3"===this.syntax&&this.type!==c.TYPES.message&&e(typeof a,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!b){Array.isArray(a)||(a=[a]);var l=
[];for(b=0;b<a.length;b++)l.push(this.element.verifyValue(a[b]));return l}if(this.map&&!b){if(a instanceof c.Map)return a;a instanceof Object||e(typeof a,"expected ProtoBuf.Map or raw object for map field");return new c.Map(this,a)}!this.repeated&&Array.isArray(a)&&e(typeof a,"no array expected");return this.element.verifyValue(a)};u.hasWirePresence=function(a,b){if("proto3"!==this.syntax)return null!==a;if(this.oneof&&b[this.oneof.name]===this.name)return!0;switch(this.type){case c.TYPES.int32:case c.TYPES.sint32:case c.TYPES.sfixed32:case c.TYPES.uint32:case c.TYPES.fixed32:return 0!==
a;case c.TYPES.int64:case c.TYPES.sint64:case c.TYPES.sfixed64:case c.TYPES.uint64:case c.TYPES.fixed64:return 0!==a.low||0!==a.high;case c.TYPES.bool:return a;case c.TYPES["float"]:case c.TYPES["double"]:return 0!==a;case c.TYPES.string:return 0<a.length;case c.TYPES.bytes:return 0<a.remaining();case c.TYPES["enum"]:return 0!==a;case c.TYPES.message:return null!==a;default:return!0}};u.encode=function(a,b,e){if(null===this.type||"object"!==typeof this.type)throw Error("[INTERNAL] Unresolved type in "+
this.toString(!0)+": "+this.type);if(null===a||this.repeated&&0==a.length)return b;try{if(this.repeated){var k;if(this.options.packed&&0<=c.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b.writeVarint32(this.id<<3|c.WIRE_TYPES.LDELIM);b.ensureCapacity(b.offset+=1);var l=b.offset;for(k=0;k<a.length;k++)this.element.encodeValue(this.id,a[k],b);var v=b.offset-l,G=B.calculateVarint32(v);if(1<G){var F=b.slice(l,b.offset);l+=G-1;b.offset=l;b.append(F)}b.writeVarint32(v,l-G)}else for(k=0;k<a.length;k++)b.writeVarint32(this.id<<
3|this.type.wireType),this.element.encodeValue(this.id,a[k],b)}else this.map?a.forEach(function(J,H,D){D=B.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,H)+B.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,J);b.writeVarint32(this.id<<3|c.WIRE_TYPES.LDELIM);b.writeVarint32(D);b.writeVarint32(8|this.keyType.wireType);this.keyElement.encodeValue(1,H,b);b.writeVarint32(16|this.type.wireType);this.element.encodeValue(2,J,b)},this):this.hasWirePresence(a,
e)&&(b.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,a,b))}catch(J){throw Error("Illegal value for "+this.toString(!0)+": "+a+" ("+J+")");}return b};u.calculate=function(a,b){a=this.verifyValue(a);if(null===this.type||"object"!==typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===a||this.repeated&&0==a.length)return 0;var e=0;try{if(this.repeated){var k,l;if(this.options.packed&&0<=c.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){e+=
B.calculateVarint32(this.id<<3|c.WIRE_TYPES.LDELIM);for(k=l=0;k<a.length;k++)l+=this.element.calculateLength(this.id,a[k]);e+=B.calculateVarint32(l);e+=l}else for(k=0;k<a.length;k++)e+=B.calculateVarint32(this.id<<3|this.type.wireType),e+=this.element.calculateLength(this.id,a[k])}else this.map?a.forEach(function(v,G,F){v=B.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,G)+B.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,v);e+=B.calculateVarint32(this.id<<
3|c.WIRE_TYPES.LDELIM);e+=B.calculateVarint32(v);e+=v},this):this.hasWirePresence(a,b)&&(e+=B.calculateVarint32(this.id<<3|this.type.wireType),e+=this.element.calculateLength(this.id,a))}catch(v){throw Error("Illegal value for "+this.toString(!0)+": "+a+" ("+v+")");}return e};u.decode=function(a,b,e){if(!(!this.map&&a==this.type.wireType||!e&&this.repeated&&this.options.packed&&a==c.WIRE_TYPES.LDELIM||this.map&&a==c.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+
a+" ("+this.type.wireType+" expected)");if(a==c.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&0<=c.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)&&!e){a=b.readVarint32();a=b.offset+a;for(e=[];b.offset<a;)e.push(this.decode(this.type.wireType,b,!0));return e}if(this.map){var k=t.defaultFieldValue(this.keyType);e=t.defaultFieldValue(this.type);a=b.readVarint32();if(b.remaining()<a)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+a+" required but got only "+b.remaining());
var l=b.clone();l.limit=l.offset+a;for(b.offset+=a;0<l.remaining();)if(b=l.readVarint32(),a=b&7,b>>>=3,1===b)k=this.keyElement.decode(l,a,b);else if(2===b)e=this.element.decode(l,a,b);else throw Error("Unexpected tag in map field key/value submessage");return[k,e]}return this.element.decode(b,a,this.id)};A.Message.Field=d;u=function(a,b,e,k,l,v,G){d.call(this,a,b,e,null,k,l,v,G)};u.prototype=Object.create(d.prototype);A.Message.ExtensionField=u;A.Message.OneOf=function(a,b,e){r.call(this,a,b,e);this.fields=
[]};var q=function(a,b,e,k,l){h.call(this,a,b,e,k,l);this.className="Enum";this.object=null};q.getName=function(a,b){for(var e=Object.keys(a),k=0,l;k<e.length;++k)if(a[l=e[k]]===b)return l;return null};(q.prototype=Object.create(h.prototype)).build=function(a){if(this.object&&!a)return this.object;a=new c.Builder.Enum;for(var b=this.getChildren(q.Value),e=0,k=b.length;e<k;++e)a[b[e].name]=b[e].id;Object.defineProperty&&Object.defineProperty(a,"$options",{value:this.buildOpt(),enumerable:!1});return this.object=
a};A.Enum=q;u=function(a,b,e,k){r.call(this,a,b,e);this.className="Enum.Value";this.id=k};u.prototype=Object.create(r.prototype);A.Enum.Value=u;var m=function(a,b,e,k){r.call(this,a,b,e);this.field=k};m.prototype=Object.create(r.prototype);A.Extension=m;var E=function(a,b,e,k){h.call(this,a,b,e,k);this.className="Service";this.clazz=null};(E.prototype=Object.create(h.prototype)).build=function(a){return this.clazz&&!a?this.clazz:this.clazz=function(b,e){for(var k=function(F){b.Builder.Service.call(this);
this.rpcImpl=F||function(J,H,D){setTimeout(D.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},l=k.prototype=Object.create(b.Builder.Service.prototype),v=e.getChildren(b.Reflect.Service.RPCMethod),G=0;G<v.length;G++)(function(F){l[F.name]=function(J,H){try{try{J=F.resolvedRequestType.clazz.decode(B.wrap(J))}catch(D){if(!(D instanceof TypeError))throw D;}if(null===J||"object"!==typeof J)throw Error("Illegal arguments");J instanceof F.resolvedRequestType.clazz||
(J=new F.resolvedRequestType.clazz(J));this.rpcImpl(F.fqn(),J,function(D,M){if(D)H(D);else{null===M&&(M="");try{M=F.resolvedResponseType.clazz.decode(M)}catch(Q){}M&&M instanceof F.resolvedResponseType.clazz?H(null,M):H(Error("Illegal response type received in service method "+e.name+"#"+F.name))}})}catch(D){setTimeout(H.bind(this,D),0)}};k[F.name]=function(J,H,D){(new k(J))[F.name](H,D)};Object.defineProperty&&(Object.defineProperty(k[F.name],"$options",{value:F.buildOpt()}),Object.defineProperty(l[F.name],
"$options",{value:k[F.name].$options}))})(v[G]);Object.defineProperty&&(Object.defineProperty(k,"$options",{value:e.buildOpt()}),Object.defineProperty(l,"$options",{value:k.$options}),Object.defineProperty(k,"$type",{value:e}),Object.defineProperty(l,"$type",{value:e}));return k}(c,this)};A.Service=E;var L=function(a,b,e,k){r.call(this,a,b,e);this.className="Service.Method";this.options=k||{}};(L.prototype=Object.create(r.prototype)).buildOpt=w.buildOpt;A.Service.Method=L;w=function(a,b,e,k,l,v,G,
F){L.call(this,a,b,e,F);this.className="Service.RPCMethod";this.requestName=k;this.responseName=l;this.requestStream=v;this.responseStream=G;this.resolvedResponseType=this.resolvedRequestType=null};w.prototype=Object.create(L.prototype);A.Service.RPCMethod=w;return A}(p);p.Builder=function(c,n,x){function A(h){h.messages&&h.messages.forEach(function(t){t.syntax=h.syntax;A(t)});h.enums&&h.enums.forEach(function(t){t.syntax=h.syntax})}var r=function(h){this.ptr=this.ns=new x.Namespace(this,null,"");
this.resolved=!1;this.result=null;this.files={};this.importRoot=null;this.options=h||{}},w=r.prototype;r.isMessage=function(h){return"string"!==typeof h.name||"undefined"!==typeof h.values||"undefined"!==typeof h.rpc?!1:!0};r.isMessageField=function(h){return"string"!==typeof h.rule||"string"!==typeof h.name||"string"!==typeof h.type||"undefined"===typeof h.id?!1:!0};r.isEnum=function(h){return"string"===typeof h.name&&"undefined"!==typeof h.values&&Array.isArray(h.values)&&0!==h.values.length?!0:
!1};r.isService=function(h){return"string"===typeof h.name&&"object"===typeof h.rpc&&h.rpc?!0:!1};r.isExtend=function(h){return"string"!==typeof h.ref?!1:!0};w.reset=function(){this.ptr=this.ns;return this};w.define=function(h){if("string"!==typeof h||!n.TYPEREF.test(h))throw Error("illegal namespace: "+h);h.split(".").forEach(function(t){var u=this.ptr.getChild(t);null===u&&this.ptr.addChild(u=new x.Namespace(this,this.ptr,t));this.ptr=u},this);return this};w.create=function(h){if(!h)return this;
if(Array.isArray(h)){if(0===h.length)return this;h=h.slice()}else h=[h];for(var t=[h];0<t.length;){h=t.pop();if(!Array.isArray(h))throw Error("not a valid namespace: "+JSON.stringify(h));for(;0<h.length;){var u=h.shift();if(r.isMessage(u)){var f=new x.Message(this,this.ptr,u.name,u.options,u.isGroup,u.syntax),d={};u.oneofs&&Object.keys(u.oneofs).forEach(function(m){f.addChild(d[m]=new x.Message.OneOf(this,f,m))},this);u.fields&&u.fields.forEach(function(m){if(null!==f.getChild(m.id|0))throw Error("duplicate or invalid field id in "+
f.name+": "+m.id);if(m.options&&"object"!==typeof m.options)throw Error("illegal field options in "+f.name+"#"+m.name);var E=null;if("string"===typeof m.oneof&&!(E=d[m.oneof]))throw Error("illegal oneof in "+f.name+"#"+m.name+": "+m.oneof);m=new x.Message.Field(this,f,m.rule,m.keytype,m.type,m.name,m.id,m.options,E,u.syntax);E&&E.fields.push(m);f.addChild(m)},this);var q=[];u.enums&&u.enums.forEach(function(m){q.push(m)});u.messages&&u.messages.forEach(function(m){q.push(m)});u.services&&u.services.forEach(function(m){q.push(m)});
u.extensions&&(f.extensions="number"===typeof u.extensions[0]?[u.extensions]:u.extensions);this.ptr.addChild(f);if(0<q.length){t.push(h);h=q;q=null;this.ptr=f;f=null;continue}q=null}else if(r.isEnum(u))f=new x.Enum(this,this.ptr,u.name,u.options,u.syntax),u.values.forEach(function(m){f.addChild(new x.Enum.Value(this,f,m.name,m.id))},this),this.ptr.addChild(f);else if(r.isService(u))f=new x.Service(this,this.ptr,u.name,u.options),Object.keys(u.rpc).forEach(function(m){var E=u.rpc[m];f.addChild(new x.Service.RPCMethod(this,
f,m,E.request,E.response,!!E.request_stream,!!E.response_stream,E.options))},this),this.ptr.addChild(f);else if(r.isExtend(u))if(f=this.ptr.resolve(u.ref,!0))u.fields.forEach(function(m){if(null!==f.getChild(m.id|0))throw Error("duplicate extended field id in "+f.name+": "+m.id);if(f.extensions){var E=!1;f.extensions.forEach(function(b){m.id>=b[0]&&m.id<=b[1]&&(E=!0)});if(!E)throw Error("illegal extended field id in "+f.name+": "+m.id+" (not within valid ranges)");}var L=m.name;this.options.convertFieldsToCamelCase&&
(L=c.Util.toCamelCase(L));L=new x.Message.ExtensionField(this,f,m.rule,m.type,this.ptr.fqn()+"."+L,m.id,m.options);var a=new x.Extension(this,this.ptr,m.name,L);L.extension=a;this.ptr.addChild(a);f.addChild(L)},this);else{if(!/\.?google\.protobuf\./.test(u.ref))throw Error("extended message "+u.ref+" is not defined");}else throw Error("not a valid definition: "+JSON.stringify(u));f=u=null}h=null;this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};w["import"]=function(h,t){var u=
"/";if("string"===typeof t){c.Util.IS_NODE&&(t=require("path").resolve(t));if(!0===this.files[t])return this.reset();this.files[t]=!0}else if("object"===typeof t){var f=t.root;c.Util.IS_NODE&&(f=require("path").resolve(f));if(0<=f.indexOf("\\")||0<=t.file.indexOf("\\"))u="\\";f=c.Util.IS_NODE?require("path").join(f,t.file):f+u+t.file;if(!0===this.files[f])return this.reset();this.files[f]=!0}if(h.imports&&0<h.imports.length){var d=!1;if("object"===typeof t){if(this.importRoot=t.root,d=!0,f=this.importRoot,
t=t.file,0<=f.indexOf("\\")||0<=t.indexOf("\\"))u="\\"}else"string"===typeof t?this.importRoot?f=this.importRoot:0<=t.indexOf("/")?(f=t.replace(/\/[^\/]*$/,""),""===f&&(f="/")):0<=t.indexOf("\\")?(f=t.replace(/\\[^\\]*$/,""),u="\\"):f=".":f=null;for(var q=0;q<h.imports.length;q++)if("string"===typeof h.imports[q]){if(!f)throw Error("cannot determine import root");var m=h.imports[q];if("google/protobuf/descriptor.proto"!==m&&(m=c.Util.IS_NODE?require("path").join(f,m):f+u+m,!0!==this.files[m])){/\.proto$/i.test(m)&&
!c.DotProto&&(m=m.replace(/\.proto$/,".json"));var E=c.Util.fetch(m);if(null===E)throw Error("failed to import '"+m+"' in '"+t+"': file not found");if(/\.json$/i.test(m))this["import"](JSON.parse(E+""),m);else this["import"](c.DotProto.Parser.parse(E),m)}}else if(t)if(/\.(\w+)$/.test(t))this["import"](h.imports[q],t.replace(/^(.+)\.(\w+)$/,function(a,b,e){return b+"_import"+q+"."+e}));else this["import"](h.imports[q],t+"_import"+q);else this["import"](h.imports[q]);d&&(this.importRoot=null)}h["package"]&&
this.define(h["package"]);h.syntax&&A(h);var L=this.ptr;h.options&&Object.keys(h.options).forEach(function(a){L.options[a]=h.options[a]});h.messages&&(this.create(h.messages),this.ptr=L);h.enums&&(this.create(h.enums),this.ptr=L);h.services&&(this.create(h.services),this.ptr=L);h["extends"]&&this.create(h["extends"]);return this.reset()};w.resolveAll=function(){if(null==this.ptr||"object"===typeof this.ptr.type)return this;if(this.ptr instanceof x.Namespace)this.ptr.children.forEach(function(t){this.ptr=
t;this.resolveAll()},this);else if(this.ptr instanceof x.Message.Field){if(n.TYPE.test(this.ptr.type))this.ptr.type=c.TYPES[this.ptr.type];else{if(!n.TYPEREF.test(this.ptr.type))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);var h=(this.ptr instanceof x.Message.ExtensionField?this.ptr.extension.parent:this.ptr.parent).resolve(this.ptr.type,!0);if(!h)throw Error("unresolvable type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.resolvedType=h;if(h instanceof
x.Enum){if(this.ptr.type=c.TYPES["enum"],"proto3"===this.ptr.syntax&&"proto3"!==h.syntax)throw Error("proto3 message cannot reference proto2 enum");}else if(h instanceof x.Message)this.ptr.type=h.isGroup?c.TYPES.group:c.TYPES.message;else throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);}if(this.ptr.map){if(!n.TYPE.test(this.ptr.keyType))throw Error("illegal key type for map field in "+this.ptr.toString(!0)+": "+this.ptr.keyType);this.ptr.keyType=c.TYPES[this.ptr.keyType]}"proto3"===
this.ptr.syntax&&this.ptr.repeated&&void 0===this.ptr.options.packed&&-1!==c.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType)&&(this.ptr.options.packed=!0)}else if(this.ptr instanceof c.Reflect.Service.Method)if(this.ptr instanceof c.Reflect.Service.RPCMethod){h=this.ptr.parent.resolve(this.ptr.requestName,!0);if(!(h&&h instanceof c.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);this.ptr.resolvedRequestType=h;h=this.ptr.parent.resolve(this.ptr.responseName,
!0);if(!(h&&h instanceof c.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=h}else throw Error("illegal service type in "+this.ptr.toString(!0));else if(!(this.ptr instanceof c.Reflect.Message.OneOf||this.ptr i