"use strict";module.exports=MapField;var Field=require("./field");((MapField.prototype=Object.create(Field.prototype)).constructor=MapField).className="MapField";var types=require("./types"),util=require("./util");function MapField(e,t,i,o,r,p){if(Field.call(this,e,t,o,void 0,void 0,r,p),!util.isString(i))throw TypeError("keyType must be a string");this.keyType=i,this.resolvedKeyType=null,this.map=!0}MapField.fromJSON=function(e,t){return new MapField(e,t.id,t.keyType,t.type,t.options,t.comment)},MapField.prototype.toJSON=function(e){var t=!!e&&!!e.keepComments;return util.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},MapField.prototype.resolve=function(){if(this.resolved)return this;if(void 0===types.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return Field.prototype.resolve.call(this)},MapField.d=function(e,t,i){return"function"==typeof i?i=util.decorateType(i).name:i&&"object"==typeof i&&(i=util.decorateEnum(i).name),function(o,r){util.decorateType(o.constructor).add(new MapField(r,e,t,i))}};