text: !function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.ld=f()}}(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var asn1=exports;asn1.bignum=require("bn.js"),asn1.define=require("./asn1/api").define,asn1.base=require("./asn1/base"),asn1.constants=require("./asn1/constants"),asn1.decoders=require("./asn1/decoders"),asn1.encoders=require("./asn1/encoders")},{"./asn1/api":2,"./asn1/base":4,"./asn1/constants":8,"./asn1/decoders":10,"./asn1/encoders":13,"bn.js":16}],2:[function(require,module,exports){function Entity(name,body){this.name=name,this.body=body,this.decoders={},this.encoders={}}var asn1=require("../asn1"),inherits=require("inherits"),api=exports;api.define=function(name,body){return new Entity(name,body)},Entity.prototype._createNamed=function(base){var named;try{named=require("vm").runInThisContext("(function "+this.name+"(entity) {\n  this._initNamed(entity);\n})")}catch(e){named=function(entity){this._initNamed(entity)}}return inherits(named,base),named.prototype._initNamed=function(entity){base.call(this,entity)},new named(this)},Entity.prototype._getDecoder=function(enc){return enc=enc||"der",this.decoders.hasOwnProperty(enc)||(this.decoders[enc]=this._createNamed(asn1.decoders[enc])),this.decoders[enc]},Entity.prototype.decode=function(data,enc,options){return this._getDecoder(enc).decode(data,options)},Entity.prototype._getEncoder=function(enc){return enc=enc||"der",this.encoders.hasOwnProperty(enc)||(this.encoders[enc]=this._createNamed(asn1.encoders[enc])),this.encoders[enc]},Entity.prototype.encode=function(data,enc,reporter){return this._getEncoder(enc).encode(data,reporter)}},{"../asn1":1,inherits:93,vm:150}],3:[function(require,module,exports){function DecoderBuffer(base,options){return Reporter.call(this,options),Buffer.isBuffer(base)?(this.base=base,this.offset=0,void(this.length=base.length)):void this.error("Input not Buffer")}function EncoderBuffer(value,reporter){if(Array.isArray(value))this.length=0,this.value=value.map(function(item){return item instanceof EncoderBuffer||(item=new EncoderBuffer(item,reporter)),this.length+=item.length,item},this);else if("number"==typeof value){if(!(value>=0&&255>=value))return reporter.error("non-byte EncoderBuffer value");this.value=value,this.length=1}else if("string"==typeof value)this.value=value,this.length=Buffer.byteLength(value);else{if(!Buffer.isBuffer(value))return reporter.error("Unsupported type: "+typeof value);this.value=value,this.length=value.length}}var inherits=require("inherits"),Reporter=require("../base").Reporter,Buffer=require("buffer").Buffer;inherits(DecoderBuffer,Reporter),exports.DecoderBuffer=DecoderBuffer,DecoderBuffer.prototype.save=function(){return{offset:this.offset,reporter:Reporter.prototype.save.call(this)}},DecoderBuffer.prototype.restore=function(save){var res=new DecoderBuffer(this.base);return res.offset=save.offset,res.length=this.offset,this.offset=save.offset,Reporter.prototype.restore.call(this,save.reporter),res},DecoderBuffer.prototype.isEmpty=function(){return this.offset===this.length},DecoderBuffer.prototype.readUInt8=function(fail){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(fail||"DecoderBuffer overrun")},DecoderBuffer.prototype.skip=function(bytes,fail){if(!(this.offset+bytes<=this.length))return this.error(fail||"DecoderBuffer overrun");var res=new DecoderBuffer(this.base);return res._reporterState=this._reporterState,res.offset=this.offset,res.length=this.offset+bytes,this.offset+=bytes,res},DecoderBuffer.prototype.raw=function(save){return this.base.slice(save?save.offset:this.offset,this.length)},exports.EncoderBuffer=EncoderBuffer,EncoderBuffer.prototype.join=function(out,offset){return out||(out=new Buffer(this.length)),offset||(offset=0),0===this.length?out:(Array.isArray(this.value)?this.value.forEach(function(item){item.join(out,offset),offset+=item.length}):("number"==typeof this.value?out[offset]=this.value:"string"==typeof this.value?out.write(this.value,offset):Buffer.isBuffer(this.value)&&this.value.copy(out,offset),offset+=this.length),out)}},{"../base":4,buffer:45,inherits:93}],4:[function(require,module,exports){var base=exports;base.Reporter=require("./reporter").Reporter,base.DecoderBuffer=require("./buffer").DecoderBuffer,base.EncoderBuffer=require("./buffer").EncoderBuffer,base.Node=require("./node")},{"./buffer":3,"./node":5,"./reporter":6}],5:[function(require,module){function Node(enc,parent){var state={};this._baseState=state,state.enc=enc,state.parent=parent||null,state.children=null,state.tag=null,state.args=null,state.reverseArgs=null,state.choice=null,state.optional=!1,state.any=!1,state.obj=!1,state.use=null,state.useDecoder=null,state.key=null,state["default"]=null,state.explicit=null,state.implicit=null,state.contains=null,state.parent||(state.children=[],this._wrap())}var Reporter=require("../base").Reporter,EncoderBuffer=require("../base").EncoderBuffer,DecoderBuffer=require("../base").DecoderBuffer,assert=require("minimalistic-assert"),tags=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],methods=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(tags),overrided=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];module.exports=Node;var stateProps=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];Node.prototype.clone=function(){var state=this._baseState,cstate={};stateProps.forEach(function(prop){cstate[prop]=state[prop]});var res=new this.constructor(cstate.parent);return res._baseState=cstate,res},Node.prototype._wrap=function(){var state=this._baseState;methods.forEach(function(method){this[method]=function(){var clone=new this.constructor(this);return state.children.push(clone),clone[method].apply(clone,arguments)}},this)},Node.prototype._init=function(body){var state=this._baseState;assert(null===state.parent),body.call(this),state.children=state.children.filter(function(child){return child._baseState.parent===this},this),assert.equal(state.children.length,1,"Root node can have only one child")},Node.prototype._useArgs=function(args){var state=this._baseState,children=args.filter(function(arg){return arg instanceof this.constructor},this);args=args.filter(function(arg){return!(arg instanceof this.constructor)},this),0!==children.length&&(assert(null===state.children),state.children=children,children.forEach(function(child){child._baseState.parent=this},this)),0!==args.length&&(assert(null===state.args),state.args=args,state.reverseArgs=args.map(function(arg){if("object"!=typeof arg||arg.constructor!==Object)return arg;var res={};return Object.keys(arg).forEach(function(key){key==(0|key)&&(key|=0);var value=arg[key];res[value]=key}),res}))},overrided.forEach(function(method){Node.prototype[method]=function(){var state=this._baseState;throw new Error(method+" not implemented for encoding: "+state.enc)}}),tags.forEach(function(tag){Node.prototype[tag]=function(){var state=this._baseState,args=Array.prototype.slice.call(arguments);return assert(null===state.tag),state.tag=tag,this._useArgs(args),this}}),Node.prototype.use=function(item){assert(item);var state=this._baseState;return assert(null===state.use),state.use=item,this},Node.prototype.optional=function(){var state=this._baseState;return state.optional=!0,this},Node.prototype.def=function(val){var state=this._baseState;return assert(null===state["default"]),state["default"]=val,state.optional=!0,this},Node.prototype.explicit=function(num){var state=this._baseState;return assert(null===state.explicit&&null===state.implicit),state.explicit=num,this},Node.prototype.implicit=function(num){var state=this._baseState;return assert(null===state.explicit&&null===state.implicit),state.implicit=num,this},Node.prototype.obj=function(){var state=this._baseState,args=Array.prototype.slice.call(arguments);return state.obj=!0,0!==args.length&&this._useArgs(args),this},Node.prototype.key=function(newKey){var state=this._baseState;return assert(null===state.key),state.key=newKey,this},Node.prototype.any=function(){var state=this._baseState;return state.any=!0,this},Node.prototype.choice=function(obj){var state=this._baseState;return assert(null===state.choice),state.choice=obj,this._useArgs(Object.keys(obj).map(function(key){return obj[key]})),this},Node.prototype.contains=function(item){var state=this._baseState;return assert(null===state.use),state.contains=item,this},Node.prototype._decode=function(input,options){var state=this._baseState;if(null===state.parent)return input.wrapResult(state.children[0]._decode(input,options));var result=state["default"],present=!0,prevKey=null;if(null!==state.key&&(prevKey=input.enterKey(state.key)),state.optional){var tag=null;if(null!==state.explicit?tag=state.explicit:null!==state.implicit?tag=state.implicit:null!==state.tag&&(tag=state.tag),null!==tag||state.any){if(present=this._peekTag(input,tag,state.any),input.isError(present))return present}else{var save=input.save();try{null===state.choice?this._decodeGeneric(state.tag,input,options):this._decodeChoice(input,options),present=!0}catch(e){present=!1}input.restore(save)}}var prevObj;if(state.obj&&present&&(prevObj=input.enterObject()),present){if(null!==state.explicit){var explicit=this._decodeTag(input,state.explicit);if(input.isError(explicit))return explicit;input=explicit}var start=input.offset;if(null===state.use&&null===state.choice){if(state.any)var save=input.save();var body=this._decodeTag(input,null!==state.implicit?state.implicit:state.tag,state.any);if(input.isError(body))return body;state.any?result=input.raw(save):input=body}if(options&&options.track&&null!==state.tag&&options.track(input.path(),start,input.length,"tagged"),options&&options.track&&null!==state.tag&&options.track(input.path(),input.offset,input.length,"content"),result=state.any?result:null===state.choice?this._decodeGeneric(state.tag,input,options):this._decodeChoice(input,options),input.isError(result))return result;if(state.any||null!==state.choice||null===state.children||state.children.forEach(function(child){child._decode(input,options)}),state.contains&&("octstr"===state.tag||"bitstr"===state.tag)){var data=new DecoderBuffer(result);result=this._getUse(state.contains,input._reporterState.obj)._decode(data,options)}}return state.obj&&present&&(result=input.leaveObject(prevObj)),null===state.key||null===result&&present!==!0?null!==prevKey&&input.exitKey(prevKey):input.leaveKey(prevKey,state.key,result),result},Node.prototype._decodeGeneric=function(tag,input,options){var state=this._baseState;return"seq"===tag||"set"===tag?null:"seqof"===tag||"setof"===tag?this._decodeList(input,tag,state.args[0],options):/str$/.test(tag)?this._decodeStr(input,tag,options):"objid"===tag&&state.args?this._decodeObjid(input,state.args[0],state.args[1],options):"objid"===tag?this._decodeObjid(input,null,null,options):"gentime"===tag||"utctime"===tag?this._decodeTime(input,tag,options):"null_"===tag?this._decodeNull(input,options):"bool"===tag?this._decodeBool(input,options):"objDesc"===tag?this._decodeStr(input,tag,options):"int"===tag||"enum"===tag?this._decodeInt(input,state.args&&state.args[0],options):null!==state.use?this._getUse(state.use,input._reporterState.obj)._decode(input,options):input.error("unknown tag: "+tag)},Node.prototype._getUse=function(entity,obj){var state=this._baseState;return state.useDecoder=this._use(entity,obj),assert(null===state.useDecoder._baseState.parent),state.useDecoder=state.useDecoder._baseState.children[0],state.implicit!==state.useDecoder._baseState.implicit&&(state.useDecoder=state.useDecoder.clone(),state.useDecoder._baseState.implicit=state.implicit),state.useDecoder},Node.prototype._decodeChoice=function(input,options){var state=this._baseState,result=null,match=!1;return Object.keys(state.choice).some(function(key){var save=input.save(),node=state.choice[key];try{var value=node._decode(input,options);if(input.isError(value))return!1;result={type:key,value:value},match=!0}catch(e){return input.restore(save),!1}return!0},this),match?result:input.error("Choice not matched")},Node.prototype._createEncoderBuffer=function(data){return new EncoderBuffer(data,this.reporter)},Node.prototype._encode=function(data,reporter,parent){var state=this._baseState;if(null===state["default"]||state["default"]!==data){var result=this._encodeValue(data,reporter,parent);if(void 0!==result&&!this._skipDefault(result,reporter,parent))return result}},Node.prototype._encodeValue=function(data,reporter,parent){var state=this._baseState;if(null===state.parent)return state.children[0]._encode(data,reporter||new Reporter);var result=null;if(this.reporter=reporter,state.optional&&void 0===data){if(null===state["default"])return;data=state["default"]}var content=null,primitive=!1;if(state.any)result=this._createEncoderBuffer(data);else if(state.choice)result=this._encodeChoice(data,reporter);else if(state.contains)content=this._getUse(state.contains,parent)._encode(data,reporter),primitive=!0;else if(state.children)content=state.children.map(function(child){if("null_"===child._baseState.tag)return child._encode(null,reporter,data);if(null===child._baseState.key)return reporter.error("Child should have a key");var prevKey=reporter.enterKey(child._baseState.key);if("object"!=typeof data)return reporter.error("Child expected, but input is not object");var res=child._encode(data[child._baseState.key],reporter,data);return reporter.leaveKey(prevKey),res},this).filter(function(child){return child}),content=this._createEncoderBuffer(content);else if("seqof"===state.tag||"setof"===state.tag){if(!state.args||1!==state.args.length)return reporter.error("Too many args for : "+state.tag);if(!Array.isArray(data))return reporter.error("seqof/setof, but data is not Array");var child=this.clone();child._baseState.implicit=null,content=this._createEncoderBuffer(data.map(function(item){var state=this._baseState;return this._getUse(state.args[0],data)._encode(item,reporter)},child))}else null!==state.use?result=this._getUse(state.use,parent)._encode(data,reporter):(content=this._encodePrimitive(state.tag,data),primitive=!0);var result;if(!state.any&&null===state.choice){var tag=null!==state.implicit?state.implicit:state.tag,cls=null===state.implicit?"universal":"context";null===tag?null===state.use&&reporter.error("Tag could be ommited only for .use()"):null===state.use&&(result=this._encodeComposite(tag,primitive,cls,content))}return null!==state.explicit&&(result=this._encodeComposite(state.explicit,!1,"context",result)),result},Node.prototype._encodeChoice=function(data,reporter){var state=this._baseState,node=state.choice[data.type];return node||assert(!1,data.type+" not found in "+JSON.stringify(Object.keys(state.choice))),node._encode(data.value,reporter)},Node.prototype._encodePrimitive=function(tag,data){var state=this._baseState;if(/str$/.test(tag))return this._encodeStr(data,tag);if("objid"===tag&&state.args)return this._encodeObjid(data,state.reverseArgs[0],state.args[1]);if("objid"===tag)return this._encodeObjid(data,null,null);if("gentime"===tag||"utctime"===tag)return this._encodeTime(data,tag);if("null_"===tag)return this._encodeNull();if("int"===tag||"enum"===tag)return this._encodeInt(data,state.args&&state.reverseArgs[0]);if("bool"===tag)return this._encodeBool(data);if("objDesc"===tag)return this._encodeStr(data,tag);throw new Error("Unsupported tag: "+tag)},Node.prototype._isNumstr=function(str){return/^[0-9 ]*$/.test(str)},Node.prototype._isPrintstr=function(str){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str)}},{"../base":4,"minimalistic-assert":97}],6:[function(require,module,exports){function Reporter(options){this._reporterState={obj:null,path:[],options:options||{},errors:[]}}function ReporterError(path,msg){this.path=path,this.rethrow(msg)}var inherits=require("inherits");exports.Reporter=Reporter,Reporter.prototype.isError=function(obj){return obj instanceof ReporterError},Reporter.prototype.save=function(){var state=this._reporterState;return{obj:state.obj,pathLen:state.path.length}},Reporter.prototype.restore=function(data){var state=this._reporterState;state.obj=data.obj,state.path=state.path.slice(0,data.pathLen)},Reporter.prototype.enterKey=function(key){return this._reporterState.path.push(key)},Reporter.prototype.exitKey=function(index){var state=this._reporterState;state.path=state.path.slice(0,index-1)},Reporter.prototype.leaveKey=function(index,key,value){var state=this._reporterState;this.exitKey(index),null!==state.obj&&(state.obj[key]=value)},Reporter.prototype.path=function(){return this._reporterState.path.join("/")},Reporter.prototype.enterObject=function(){var state=this._reporterState,prev=state.obj;return state.obj={},prev},Reporter.prototype.leaveObject=function(prev){var state=this._reporterState,now=state.obj;return state.obj=prev,now},Reporter.prototype.error=function(msg){var err,state=this._reporterState,inherited=msg instanceof ReporterError;if(err=inherited?msg:new ReporterError(state.path.map(function(elem){return"["+JSON.stringify(elem)+"]"}).join(""),msg.message||msg,msg.stack),!state.options.partial)throw err;return inherited||state.errors.push(err),err},Reporter.prototype.wrapResult=function(result){var state=this._reporterState;return state.options.partial?{result:this.isError(result)?null:result,errors:state.errors}:result},inherits(ReporterError,Error),ReporterError.prototype.rethrow=function(msg){if(this.message=msg+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,ReporterError),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:93}],7:[function(require,module,exports){var constants=require("../constants");exports.tagClass={0:"universal",1:"application",2:"context",3:"private"},exports.tagClassByName=constants._reverse(exports.tagClass),exports.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},exports.tagByName=constants._reverse(exports.tag)},{"../constants":8}],8:[function(require,module,exports){var constants=exports;constants._reverse=function(map){var res={};return Object.keys(map).forEach(function(key){(0|key)==key&&(key=0|key);var value=map[key];res[value]=key}),res},constants.der=require("./der")},{"./der":7}],9:[function(require,module){function DERDecoder(entity){this.enc="der",this.name=entity.name,this.entity=entity,this.tree=new DERNode,this.tree._init(entity.body)}function DERNode(parent){base.Node.call(this,"der",parent)}function derDecodeTag(buf,fail){var tag=buf.readUInt8(fail);if(buf.isError(tag))return tag;var cls=der.tagClass[tag>>6],primitive=0===(32&tag);if(31===(31&tag)){var oct=tag;for(tag=0;128===(128&oct);){if(oct=buf.readUInt8(fail),buf.isError(oct))return oct;tag<<=7,tag|=127&oct}}else tag&=31;var tagStr=der.tag[tag];return{cls:cls,primitive:primitive,tag:tag,tagStr:tagStr}}function derDecodeLen(buf,primitive,fail){var len=buf.readUInt8(fail);if(buf.isError(len))return len;if(!primitive&&128===len)return null;if(0===(128&len))return len;var num=127&len;if(num>=4)return buf.error("length octect is too long");len=0;for(var i=0;num>i;i++){len<<=8;var j=buf.readUInt8(fail);if(buf.isError(j))return j;len|=j}return len}var inherits=require("inherits"),asn1=require("../../asn1"),base=asn1.base,bignum=asn1.bignum,der=asn1.constants.der;module.exports=DERDecoder,DERDecoder.prototype.decode=function(data,options){return data instanceof base.DecoderBuffer||(data=new base.DecoderBuffer(data,options)),this.tree._decode(data,options)},inherits(DERNode,base.Node),DERNode.prototype._peekTag=function(buffer,tag,any){if(buffer.isEmpty())return!1;var state=buffer.save(),decodedTag=derDecodeTag(buffer,'Failed to peek tag: "'+tag+'"');return buffer.isError(decodedTag)?decodedTag:(buffer.restore(state),decodedTag.tag===tag||decodedTag.tagStr===tag||decodedTag.tagStr+"of"===tag||any)},DERNode.prototype._decodeTag=function(buffer,tag,any){var decodedTag=derDecodeTag(buffer,'Failed to decode tag of "'+tag+'"');if(buffer.isError(decodedTag))return decodedTag;var len=derDecodeLen(buffer,decodedTag.primitive,'Failed to get length of "'+tag+'"');if(buffer.isError(len))return len;if(!any&&decodedTag.tag!==tag&&decodedTag.tagStr!==tag&&decodedTag.tagStr+"of"!==tag)return buffer.error('Failed to match tag: "'+tag+'"');if(decodedTag.primitive||null!==len)return buffer.skip(len,'Failed to match body of: "'+tag+'"');var state=buffer.save(),res=this._skipUntilEnd(buffer,'Failed to skip indefinite length body: "'+this.tag+'"');return buffer.isError(res)?res:(len=buffer.offset-state.offset,buffer.restore(state),buffer.skip(len,'Failed to match body of: "'+tag+'"'))},DERNode.prototype._skipUntilEnd=function(buffer,fail){for(;;){var tag=derDecodeTag(buffer,fail);if(buffer.isError(tag))return tag;var len=derDecodeLen(buffer,tag.primitive,fail);if(buffer.isError(len))return len;var res;if(res=tag.primitive||null!==len?buffer.skip(len):this._skipUntilEnd(buffer,fail),buffer.isError(res))return res;if("end"===tag.tagStr)break}},DERNode.prototype._decodeList=function(buffer,tag,decoder,options){for(var result=[];!buffer.isEmpty();){var possibleEnd=this._peekTag(buffer,"end");if(buffer.isError(possibleEnd))return possibleEnd;var res=decoder.decode(buffer,"der",options);if(buffer.isError(res)&&possibleEnd)break;result.push(res)}return result},DERNode.prototype._decodeStr=function(buffer,tag){if("bitstr"===tag){var unused=buffer.readUInt8();return buffer.isError(unused)?unused:{unused:unused,data:buffer.raw()}}if("bmpstr"===tag){var raw=buffer.raw();if(raw.length%2===1)return buffer.error("Decoding of string type: bmpstr length mismatch");for(var str="",i=0;i<raw.length/2;i++)str+=String.fromCharCode(raw.readUInt16BE(2*i));return str}if("numstr"===tag){var numstr=buffer.raw().toString("ascii");return this._isNumstr(numstr)?numstr:buffer.error("Decoding of string type: numstr unsupported characters")}if("octstr"===tag)return buffer.raw();if("objDesc"===tag)return buffer.raw();if("printstr"===tag){var printstr=buffer.raw().toString("ascii");return this._isPrintstr(printstr)?printstr:buffer.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(tag)?buffer.raw().toString():buffer.error("Decoding of string type: "+tag+" unsupported")},DERNode.prototype._decodeObjid=function(buffer,values,relative){for(var result,identifiers=[],ident=0;!buffer.isEmpty();){var subident=buffer.readUInt8();ident<<=7,ident|=127&subident,0===(128&subident)&&(identifiers.push(ident),ident=0)}128&subident&&identifiers.push(ident);var first=identifiers[0]/40|0,second=identifiers[0]%40;if(result=relative?identifiers:[first,second].concat(identifiers.slice(1)),values){var tmp=values[result.join(" ")];void 0===tmp&&(tmp=values[result.join(".")]),void 0!==tmp&&(result=tmp)}return result},DERNode.prototype._decodeTime=function(buffer,tag){var str=buffer.raw().toString();if("gentime"===tag)var year=0|str.slice(0,4),mon=0|str.slice(4,6),day=0|str.slice(6,8),hour=0|str.slice(8,10),min=0|str.slice(10,12),sec=0|str.slice(12,14);else{if("utctime"!==tag)return buffer.error("Decoding "+tag+" time is not supported yet");var year=0|str.slice(0,2),mon=0|str.slice(2,4),day=0|str.slice(4,6),hour=0|str.slice(6,8),min=0|str.slice(8,10),sec=0|str.slice(10,12);year=70>year?2e3+year:1900+year}return Date.UTC(year,mon-1,day,hour,min,sec,0)},DERNode.prototype._decodeNull=function(){return null},DERNode.prototype._decodeBool=function(buffer){var res=buffer.readUInt8();return buffer.isError(res)?res:0!==res},DERNode.prototype._decodeInt=function(buffer,values){var raw=buffer.raw(),res=new bignum(raw);return values&&(res=values[res.toString(10)]||res),res},DERNode.prototype._use=function(entity,obj){return"function"==typeof entity&&(entity=entity(obj)),entity._getDecoder("der").tree}},{"../../asn1":1,inherits:93}],10:[function(require,module,exports){var decoders=exports;decoders.der=require("./der"),decoders.pem=require("./pem")},{"./der":9,"./pem":11}],11:[function(require,module){function PEMDecoder(entity){DERDecoder.call(this,entity),this.enc="pem"}var inherits=require("inherits"),Buffer=require("buffer").Buffer,DERDecoder=require("./der");inherits(PEMDecoder,DERDecoder),module.exports=PEMDecoder,PEMDecoder.prototype.decode=function(data,options){for(var lines=data.toString().split(/[\r\n]+/g),label=options.label.toUpperCase(),re=/^-----(BEGIN|END) ([^-]+)-----$/,start=-1,end=-1,i=0;i<lines.length;i++){var match=lines[i].match(re);if(null!==match&&match[2]===label){if(-1!==start){if("END"!==match[1])break;end=i;break}if("BEGIN"!==match[1])break;start=i}}if(-1===start||-1===end)throw new Error("PEM section not found for: "+label);var base64=lines.slice(start+1,end).join("");base64.replace(/[^a-z0-9\+\/=]+/gi,"");var input=new Buffer(base64,"base64");return DERDecoder.prototype.decode.call(this,input,options)}},{"./der":9,buffer:45,inherits:93}],12:[function(require,module){function DEREncoder(entity){this.enc="der",this.name=entity.name,this.entity=entity,this.tree=new DERNode,this.tree._init(entity.body)}function DERNode(parent){base.Node.call(this,"der",parent)}function two(num){return 10>num?"0"+num:num}function encodeTag(tag,primitive,cls,reporter){var res;if("seqof"===tag?tag="seq":"setof"===tag&&(tag="set"),der.tagByName.hasOwnProperty(tag))res=der.tagByName[tag];else{if("number"!=typeof tag||(0|tag)!==tag)return reporter.error("Unknown tag: "+tag);res=tag}return res>=31?reporter.error("Multi-octet tag encoding unsupported"):(primitive||(res|=32),res|=der.tagClassByName[cls||"universal"]<<6)}var inherits=require("inherits"),Buffer=require("buffer").Buffer,asn1=require("../../asn1"),base=asn1.base,der=asn1.constants.der;module.exports=DEREncoder,DEREncoder.prototype.encode=function(data,reporter){return this.tree._encode(data,reporter).join()},inherits(DERNode,base.Node),DERNode.prototype._encodeComposite=function(tag,primitive,cls,content){var encodedTag=encodeTag(tag,primitive,cls,this.reporter);if(content.length<128){var header=new Buffer(2);return header[0]=encodedTag,header[1]=content.length,this._createEncoderBuffer([header,content])}for(var lenOctets=1,i=content.length;i>=256;i>>=8)lenOctets++;var header=new Buffer(2+lenOctets);header[0]=encodedTag,header[1]=128|lenOctets;for(var i=1+lenOctets,j=content.length;j>0;i--,j>>=8)header[i]=255&j;return this._createEncoderBuffer([header,content])},DERNode.prototype._encodeStr=function(str,tag){if("bitstr"===tag)return this._createEncoderBuffer([0|str.unused,str.data]);if("bmpstr"===tag){for(var buf=new Buffer(2*str.length),i=0;i<str.length;i++)buf.writeUInt16BE(str.charCodeAt(i),2*i);return this._createEncoderBuffer(buf)}return"numstr"===tag?this._isNumstr(str)?this._createEncoderBuffer(str):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===tag?this._isPrintstr(str)?this._createEncoderBuffer(str):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(tag)?this._createEncoderBuffer(str):"objDesc"===tag?this._createEncoderBuffer(str):this.reporter.error("Encoding of string type: "+tag+" unsupported")},DERNode.prototype._encodeObjid=function(id,values,relative){if("string"==typeof id){if(!values)return this.reporter.error("string objid given, but no values map found");if(!values.hasOwnProperty(id))return this.reporter.error("objid not found in values map");id=values[id].split(/[\s\.]+/g);for(var i=0;i<id.length;i++)id[i]|=0}else if(Array.isArray(id)){id=id.slice();for(var i=0;i<id.length;i++)id[i]|=0}if(!Array.isArray(id))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(id));if(!relative){if(id[1]>=40)return this.reporter.error("Second objid identifier OOB");id.splice(0,2,40*id[0]+id[1])}for(var size=0,i=0;i<id.length;i++){var ident=id[i];for(size++;ident>=128;ident>>=7)size++}for(var objid=new Buffer(size),offset=objid.length-1,i=id.length-1;i>=0;i--){var ident=id[i];for(objid[offset--]=127&ident;(ident>>=7)>0;)objid[offset--]=128|127&ident}return this._createEncoderBuffer(objid)},DERNode.prototype._encodeTime=function(time,tag){var str,date=new Date(time);return"gentime"===tag?str=[two(date.getFullYear()),two(date.getUTCMonth()+1),two(date.getUTCDate()),two(date.getUTCHours()),two(date.getUTCMinutes()),two(date.getUTCSeconds()),"Z"].join(""):"utctime"===tag?str=[two(date.getFullYear()%100),two(date.getUTCMonth()+1),two(date.getUTCDate()),two(date.getUTCHours()),two(date.getUTCMinutes()),two(date.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+tag+" time is not supported yet"),this._encodeStr(str,"octstr")},DERNode.prototype._encodeNull=function(){return this._createEncoderBuffer("")},DERNode.prototype._encodeInt=function(num,values){if("string"==typeof num){if(!values)return this.reporter.error("String int or enum given, but no values map");if(!values.hasOwnProperty(num))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(num));num=values[num]}if("number"!=typeof num&&!Buffer.isBuffer(num)){var numArray=num.toArray();!num.sign&&128&numArray[0]&&numArray.unshift(0),num=new Buffer(numArray)}if(Buffer.isBuffer(num)){var size=num.length;0===num.length&&size++;var out=new Buffer(size);return num.copy(out),0===num.length&&(out[0]=0),this._createEncoderBuffer(out)}if(128>num)return this._createEncoderBuffer(num);if(256>num)return this._createEncoderBuffer([0,num]);for(var size=1,i=num;i>=256;i>>=8)size++;for(var out=new Array(size),i=out.length-1;i>=0;i--)out[i]=255&num,num>>=8;return 128&out[0]&&out.unshift(0),this._createEncoderBuffer(new Buffer(out))},DERNode.prototype._encodeBool=function(value){return this._createEncoderBuffer(value?255:0)},DERNode.prototype._use=function(entity,obj){return"function"==typeof entity&&(entity=entity(obj)),entity._getEncoder("der").tree},DERNode.prototype._skipDefault=function(dataBuffer,reporter,parent){var i,state=this._baseState;if(null===state["default"])return!1;var data=dataBuffer.join();if(void 0===state.defaultBuffer&&(state.defaultBuffer=this._encodeValue(state["default"],reporter,parent).join()),data.length!==state.defaultBuffer.length)return!1;for(i=0;i<data.length;i++)if(data[i]!==state.defaultBuffer[i])return!1;return!0}},{"../../asn1":1,buffer:45,inherits:93}],13:[function(require,module,exports){var encoders=exports;encoders.der=require("./der"),encoders.pem=require("./pem")},{"./der":12,"./pem":14}],14:[function(require,module){function PEMEncoder(entity){
  DEREncoder.call(this,entity),this.enc="pem"}var inherits=require("inherits"),DEREncoder=require("./der");inherits(PEMEncoder,DEREncoder),module.exports=PEMEncoder,PEMEncoder.prototype.encode=function(data,options){for(var buf=DEREncoder.prototype.encode.call(this,data),p=buf.toString("base64"),out=["-----BEGIN "+options.label+"-----"],i=0;i<p.length;i+=64)out.push(p.slice(i,i+64));return out.push("-----END "+options.label+"-----"),out.join("\n")}},{"./der":12,inherits:93}],15:[function(require,module,exports){"use strict";function placeHoldersCount(b64){var len=b64.length;if(len%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===b64[len-2]?2:"="===b64[len-1]?1:0}function byteLength(b64){return 3*b64.length/4-placeHoldersCount(b64)}function toByteArray(b64){var i,j,l,tmp,placeHolders,arr,len=b64.length;placeHolders=placeHoldersCount(b64),arr=new Arr(3*len/4-placeHolders),l=placeHolders>0?len-4:len;var L=0;for(i=0,j=0;l>i;i+=4,j+=3)tmp=revLookup[b64.charCodeAt(i)]<<18|revLookup[b64.charCodeAt(i+1)]<<12|revLookup[b64.charCodeAt(i+2)]<<6|revLookup[b64.charCodeAt(i+3)],arr[L++]=tmp>>16&255,arr[L++]=tmp>>8&255,arr[L++]=255&tmp;return 2===placeHolders?(tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4,arr[L++]=255&tmp):1===placeHolders&&(tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2,arr[L++]=tmp>>8&255,arr[L++]=255&tmp),arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[63&num]}function encodeChunk(uint8,start,end){for(var tmp,output=[],i=start;end>i;i+=3)tmp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2],output.push(tripletToBase64(tmp));return output.join("")}function fromByteArray(uint8){for(var tmp,len=uint8.length,extraBytes=len%3,output="",parts=[],maxChunkLength=16383,i=0,len2=len-extraBytes;len2>i;i+=maxChunkLength)parts.push(encodeChunk(uint8,i,i+maxChunkLength>len2?len2:i+maxChunkLength));return 1===extraBytes?(tmp=uint8[len-1],output+=lookup[tmp>>2],output+=lookup[tmp<<4&63],output+="=="):2===extraBytes&&(tmp=(uint8[len-2]<<8)+uint8[len-1],output+=lookup[tmp>>10],output+=lookup[tmp>>4&63],output+=lookup[tmp<<2&63],output+="="),parts.push(output),parts.join("")}exports.byteLength=byteLength,exports.toByteArray=toByteArray,exports.fromByteArray=fromByteArray;for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;len>i;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63},{}],16:[function(require,module){!function(module,exports){"use strict";function assert(val,msg){if(!val)throw new Error(msg||"Assertion failed")}function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}function BN(number,base,endian){return BN.isBN(number)?number:(this.negative=0,this.words=null,this.length=0,this.red=null,void(null!==number&&(("le"===base||"be"===base)&&(endian=base,base=10),this._init(number||0,base||10,endian||"be"))))}function parseHex(str,start,end){for(var r=0,len=Math.min(str.length,end),i=start;len>i;i++){var c=str.charCodeAt(i)-48;r<<=4,r|=c>=49&&54>=c?c-49+10:c>=17&&22>=c?c-17+10:15&c}return r}function parseBase(str,start,end,mul){for(var r=0,len=Math.min(str.length,end),i=start;len>i;i++){var c=str.charCodeAt(i)-48;r*=mul,r+=c>=49?c-49+10:c>=17?c-17+10:c}return r}function toBitArray(num){for(var w=new Array(num.bitLength()),bit=0;bit<w.length;bit++){var off=bit/26|0,wbit=bit%26;w[bit]=(num.words[off]&1<<wbit)>>>wbit}return w}function smallMulTo(self,num,out){out.negative=num.negative^self.negative;var len=self.length+num.length|0;out.length=len,len=len-1|0;var a=0|self.words[0],b=0|num.words[0],r=a*b,lo=67108863&r,carry=r/67108864|0;out.words[0]=lo;for(var k=1;len>k;k++){for(var ncarry=carry>>>26,rword=67108863&carry,maxJ=Math.min(k,num.length-1),j=Math.max(0,k-self.length+1);maxJ>=j;j++){var i=k-j|0;a=0|self.words[i],b=0|num.words[j],r=a*b+rword,ncarry+=r/67108864|0,rword=67108863&r}out.words[k]=0|rword,carry=0|ncarry}return 0!==carry?out.words[k]=0|carry:out.length--,out.strip()}function bigMulTo(self,num,out){out.negative=num.negative^self.negative,out.length=self.length+num.length;for(var carry=0,hncarry=0,k=0;k<out.length-1;k++){var ncarry=hncarry;hncarry=0;for(var rword=67108863&carry,maxJ=Math.min(k,num.length-1),j=Math.max(0,k-self.length+1);maxJ>=j;j++){var i=k-j,a=0|self.words[i],b=0|num.words[j],r=a*b,lo=67108863&r;ncarry=ncarry+(r/67108864|0)|0,lo=lo+rword|0,rword=67108863&lo,ncarry=ncarry+(lo>>>26)|0,hncarry+=ncarry>>>26,ncarry&=67108863}out.words[k]=rword,carry=ncarry,ncarry=hncarry}return 0!==carry?out.words[k]=carry:out.length--,out.strip()}function jumboMulTo(self,num,out){var fftm=new FFTM;return fftm.mulp(self,num,out)}function FFTM(x,y){this.x=x,this.y=y}function MPrime(name,p){this.name=name,this.p=new BN(p,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P224(){MPrime.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P192(){MPrime.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function P25519(){MPrime.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function Red(m){if("string"==typeof m){var prime=BN._prime(m);this.m=prime.p,this.prime=prime}else assert(m.gtn(1),"modulus must be greater than 1"),this.m=m,this.prime=null}function Mont(m){Red.call(this,m),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new BN(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}"object"==typeof module?module.exports=BN:exports.BN=BN,BN.BN=BN,BN.wordSize=26;var Buffer;try{Buffer=require("buffer").Buffer}catch(e){}BN.isBN=function(num){return num instanceof BN?!0:null!==num&&"object"==typeof num&&num.constructor.wordSize===BN.wordSize&&Array.isArray(num.words)},BN.max=function(left,right){return left.cmp(right)>0?left:right},BN.min=function(left,right){return left.cmp(right)<0?left:right},BN.prototype._init=function(number,base,endian){if("number"==typeof number)return this._initNumber(number,base,endian);if("object"==typeof number)return this._initArray(number,base,endian);"hex"===base&&(base=16),assert(base===(0|base)&&base>=2&&36>=base),number=number.toString().replace(/\s+/g,"");var start=0;"-"===number[0]&&start++,16===base?this._parseHex(number,start):this._parseBase(number,base,start),"-"===number[0]&&(this.negative=1),this.strip(),"le"===endian&&this._initArray(this.toArray(),base,endian)},BN.prototype._initNumber=function(number,base,endian){0>number&&(this.negative=1,number=-number),67108864>number?(this.words=[67108863&number],this.length=1):4503599627370496>number?(this.words=[67108863&number,number/67108864&67108863],this.length=2):(assert(9007199254740992>number),this.words=[67108863&number,number/67108864&67108863,1],this.length=3),"le"===endian&&this._initArray(this.toArray(),base,endian)},BN.prototype._initArray=function(number,base,endian){if(assert("number"==typeof number.length),number.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(number.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var j,w,off=0;if("be"===endian)for(i=number.length-1,j=0;i>=0;i-=3)w=number[i]|number[i-1]<<8|number[i-2]<<16,this.words[j]|=w<<off&67108863,this.words[j+1]=w>>>26-off&67108863,off+=24,off>=26&&(off-=26,j++);else if("le"===endian)for(i=0,j=0;i<number.length;i+=3)w=number[i]|number[i+1]<<8|number[i+2]<<16,this.words[j]|=w<<off&67108863,this.words[j+1]=w>>>26-off&67108863,off+=24,off>=26&&(off-=26,j++);return this.strip()},BN.prototype._parseHex=function(number,start){this.length=Math.ceil((number.length-start)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var j,w,off=0;for(i=number.length-6,j=0;i>=start;i-=6)w=parseHex(number,i,i+6),this.words[j]|=w<<off&67108863,this.words[j+1]|=w>>>26-off&4194303,off+=24,off>=26&&(off-=26,j++);i+6!==start&&(w=parseHex(number,start,i+6),this.words[j]|=w<<off&67108863,this.words[j+1]|=w>>>26-off&4194303),this.strip()},BN.prototype._parseBase=function(number,base,start){this.words=[0],this.length=1;for(var limbLen=0,limbPow=1;67108863>=limbPow;limbPow*=base)limbLen++;limbLen--,limbPow=limbPow/base|0;for(var total=number.length-start,mod=total%limbLen,end=Math.min(total,total-mod)+start,word=0,i=start;end>i;i+=limbLen)word=parseBase(number,i,i+limbLen,base),this.imuln(limbPow),this.words[0]+word<67108864?this.words[0]+=word:this._iaddn(word);if(0!==mod){var pow=1;for(word=parseBase(number,i,number.length,base),i=0;mod>i;i++)pow*=base;this.imuln(pow),this.words[0]+word<67108864?this.words[0]+=word:this._iaddn(word)}},BN.prototype.copy=function(dest){dest.words=new Array(this.length);for(var i=0;i<this.length;i++)dest.words[i]=this.words[i];dest.length=this.length,dest.negative=this.negative,dest.red=this.red},BN.prototype.clone=function(){var r=new BN(null);return this.copy(r),r},BN.prototype._expand=function(size){for(;this.length<size;)this.words[this.length++]=0;return this},BN.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},BN.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var zeros=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],groupSizes=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],groupBases=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];BN.prototype.toString=function(base,padding){base=base||10,padding=0|padding||1;var out;if(16===base||"hex"===base){out="";for(var off=0,carry=0,i=0;i<this.length;i++){var w=this.words[i],word=(16777215&(w<<off|carry)).toString(16);carry=w>>>24-off&16777215,out=0!==carry||i!==this.length-1?zeros[6-word.length]+word+out:word+out,off+=2,off>=26&&(off-=26,i--)}for(0!==carry&&(out=carry.toString(16)+out);out.length%padding!==0;)out="0"+out;return 0!==this.negative&&(out="-"+out),out}if(base===(0|base)&&base>=2&&36>=base){var groupSize=groupSizes[base],groupBase=groupBases[base];out="";var c=this.clone();for(c.negative=0;!c.isZero();){var r=c.modn(groupBase).toString(base);c=c.idivn(groupBase),out=c.isZero()?r+out:zeros[groupSize-r.length]+r+out}for(this.isZero()&&(out="0"+out);out.length%padding!==0;)out="0"+out;return 0!==this.negative&&(out="-"+out),out}assert(!1,"Base should be between 2 and 36")},BN.prototype.toNumber=function(){var ret=this.words[0];return 2===this.length?ret+=67108864*this.words[1]:3===this.length&&1===this.words[2]?ret+=4503599627370496+67108864*this.words[1]:this.length>2&&assert(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-ret:ret},BN.prototype.toJSON=function(){return this.toString(16)},BN.prototype.toBuffer=function(endian,length){return assert("undefined"!=typeof Buffer),this.toArrayLike(Buffer,endian,length)},BN.prototype.toArray=function(endian,length){return this.toArrayLike(Array,endian,length)},BN.prototype.toArrayLike=function(ArrayType,endian,length){var byteLength=this.byteLength(),reqLength=length||Math.max(1,byteLength);assert(reqLength>=byteLength,"byte array longer than desired length"),assert(reqLength>0,"Requested array length <= 0"),this.strip();var b,i,littleEndian="le"===endian,res=new ArrayType(reqLength),q=this.clone();if(littleEndian){for(i=0;!q.isZero();i++)b=q.andln(255),q.iushrn(8),res[i]=b;for(;reqLength>i;i++)res[i]=0}else{for(i=0;reqLength-byteLength>i;i++)res[i]=0;for(i=0;!q.isZero();i++)b=q.andln(255),q.iushrn(8),res[reqLength-i-1]=b}return res},BN.prototype._countBits=Math.clz32?function(w){return 32-Math.clz32(w)}:function(w){var t=w,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},BN.prototype._zeroBits=function(w){if(0===w)return 26;var t=w,r=0;return 0===(8191&t)&&(r+=13,t>>>=13),0===(127&t)&&(r+=7,t>>>=7),0===(15&t)&&(r+=4,t>>>=4),0===(3&t)&&(r+=2,t>>>=2),0===(1&t)&&r++,r},BN.prototype.bitLength=function(){var w=this.words[this.length-1],hi=this._countBits(w);return 26*(this.length-1)+hi},BN.prototype.zeroBits=function(){if(this.isZero())return 0;for(var r=0,i=0;i<this.length;i++){var b=this._zeroBits(this.words[i]);if(r+=b,26!==b)break}return r},BN.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},BN.prototype.toTwos=function(width){return 0!==this.negative?this.abs().inotn(width).iaddn(1):this.clone()},BN.prototype.fromTwos=function(width){return this.testn(width-1)?this.notn(width).iaddn(1).ineg():this.clone()},BN.prototype.isNeg=function(){return 0!==this.negative},BN.prototype.neg=function(){return this.clone().ineg()},BN.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},BN.prototype.iuor=function(num){for(;this.length<num.length;)this.words[this.length++]=0;for(var i=0;i<num.length;i++)this.words[i]=this.words[i]|num.words[i];return this.strip()},BN.prototype.ior=function(num){return assert(0===(this.negative|num.negative)),this.iuor(num)},BN.prototype.or=function(num){return this.length>num.length?this.clone().ior(num):num.clone().ior(this)},BN.prototype.uor=function(num){return this.length>num.length?this.clone().iuor(num):num.clone().iuor(this)},BN.prototype.iuand=function(num){var b;b=this.length>num.length?num:this;for(var i=0;i<b.length;i++)this.words[i]=this.words[i]&num.words[i];return this.length=b.length,this.strip()},BN.prototype.iand=function(num){return assert(0===(this.negative|num.negative)),this.iuand(num)},BN.prototype.and=function(num){return this.length>num.length?this.clone().iand(num):num.clone().iand(this)},BN.prototype.uand=function(num){return this.length>num.length?this.clone().iuand(num):num.clone().iuand(this)},BN.prototype.iuxor=function(num){var a,b;this.length>num.length?(a=this,b=num):(a=num,b=this);for(var i=0;i<b.length;i++)this.words[i]=a.words[i]^b.words[i];if(this!==a)for(;i<a.length;i++)this.words[i]=a.words[i];return this.length=a.length,this.strip()},BN.prototype.ixor=function(num){return assert(0===(this.negative|num.negative)),this.iuxor(num)},BN.prototype.xor=function(num){return this.length>num.length?this.clone().ixor(num):num.clone().ixor(this)},BN.prototype.uxor=function(num){return this.length>num.length?this.clone().iuxor(num):num.clone().iuxor(this)},BN.prototype.inotn=function(width){assert("number"==typeof width&&width>=0);var bytesNeeded=0|Math.ceil(width/26),bitsLeft=width%26;this._expand(bytesNeeded),bitsLeft>0&&bytesNeeded--;for(var i=0;bytesNeeded>i;i++)this.words[i]=67108863&~this.words[i];return bitsLeft>0&&(this.words[i]=~this.words[i]&67108863>>26-bitsLeft),this.strip()},BN.prototype.notn=function(width){return this.clone().inotn(width)},BN.prototype.setn=function(bit,val){assert("number"==typeof bit&&bit>=0);var off=bit/26|0,wbit=bit%26;return this._expand(off+1),this.words[off]=val?this.words[off]|1<<wbit:this.words[off]&~(1<<wbit),this.strip()},BN.prototype.iadd=function(num){var r;if(0!==this.negative&&0===num.negative)return this.negative=0,r=this.isub(num),this.negative^=1,this._normSign();if(0===this.negative&&0!==num.negative)return num.negative=0,r=this.isub(num),num.negative=1,r._normSign();var a,b;this.length>num.length?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i<b.length;i++)r=(0|a.words[i])+(0|b.words[i])+carry,this.words[i]=67108863&r,carry=r>>>26;for(;0!==carry&&i<a.length;i++)r=(0|a.words[i])+carry,this.words[i]=67108863&r,carry=r>>>26;if(this.length=a.length,0!==carry)this.words[this.length]=carry,this.length++;else if(a!==this)for(;i<a.length;i++)this.words[i]=a.words[i];return this},BN.prototype.add=function(num){var res;return 0!==num.negative&&0===this.negative?(num.negative=0,res=this.sub(num),num.negative^=1,res):0===num.negative&&0!==this.negative?(this.negative=0,res=num.sub(this),this.negative=1,res):this.length>num.length?this.clone().iadd(num):num.clone().iadd(this)},BN.prototype.isub=function(num){if(0!==num.negative){num.negative=0;var r=this.iadd(num);return num.negative=1,r._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(num),this.negative=1,this._normSign();var cmp=this.cmp(num);if(0===cmp)return this.negative=0,this.length=1,this.words[0]=0,this;var a,b;cmp>0?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i<b.length;i++)r=(0|a.words[i])-(0|b.words[i])+carry,carry=r>>26,this.words[i]=67108863&r;for(;0!==carry&&i<a.length;i++)r=(0|a.words[i])+carry,carry=r>>26,this.words[i]=67108863&r;if(0===carry&&i<a.length&&a!==this)for(;i<a.length;i++)this.words[i]=a.words[i];return this.length=Math.max(this.length,i),a!==this&&(this.negative=1),this.strip()},BN.prototype.sub=function(num){return this.clone().isub(num)};var comb10MulTo=function(self,num,out){var lo,mid,hi,a=self.words,b=num.words,o=out.words,c=0,a0=0|a[0],al0=8191&a0,ah0=a0>>>13,a1=0|a[1],al1=8191&a1,ah1=a1>>>13,a2=0|a[2],al2=8191&a2,ah2=a2>>>13,a3=0|a[3],al3=8191&a3,ah3=a3>>>13,a4=0|a[4],al4=8191&a4,ah4=a4>>>13,a5=0|a[5],al5=8191&a5,ah5=a5>>>13,a6=0|a[6],al6=8191&a6,ah6=a6>>>13,a7=0|a[7],al7=8191&a7,ah7=a7>>>13,a8=0|a[8],al8=8191&a8,ah8=a8>>>13,a9=0|a[9],al9=8191&a9,ah9=a9>>>13,b0=0|b[0],bl0=8191&b0,bh0=b0>>>13,b1=0|b[1],bl1=8191&b1,bh1=b1>>>13,b2=0|b[2],bl2=8191&b2,bh2=b2>>>13,b3=0|b[3],bl3=8191&b3,bh3=b3>>>13,b4=0|b[4],bl4=8191&b4,bh4=b4>>>13,b5=0|b[5],bl5=8191&b5,bh5=b5>>>13,b6=0|b[6],bl6=8191&b6,bh6=b6>>>13,b7=0|b[7],bl7=8191&b7,bh7=b7>>>13,b8=0|b[8],bl8=8191&b8,bh8=b8>>>13,b9=0|b[9],bl9=8191&b9,bh9=b9>>>13;out.negative=self.negative^num.negative,out.length=19,lo=Math.imul(al0,bl0),mid=Math.imul(al0,bh0),mid=mid+Math.imul(ah0,bl0)|0,hi=Math.imul(ah0,bh0);var w0=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w0>>>26)|0,w0&=67108863,lo=Math.imul(al1,bl0),mid=Math.imul(al1,bh0),mid=mid+Math.imul(ah1,bl0)|0,hi=Math.imul(ah1,bh0),lo=lo+Math.imul(al0,bl1)|0,mid=mid+Math.imul(al0,bh1)|0,mid=mid+Math.imul(ah0,bl1)|0,hi=hi+Math.imul(ah0,bh1)|0;var w1=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w1>>>26)|0,w1&=67108863,lo=Math.imul(al2,bl0),mid=Math.imul(al2,bh0),mid=mid+Math.imul(ah2,bl0)|0,hi=Math.imul(ah2,bh0),lo=lo+Math.imul(al1,bl1)|0,mid=mid+Math.imul(al1,bh1)|0,mid=mid+Math.imul(ah1,bl1)|0,hi=hi+Math.imul(ah1,bh1)|0,lo=lo+Math.imul(al0,bl2)|0,mid=mid+Math.imul(al0,bh2)|0,mid=mid+Math.imul(ah0,bl2)|0,hi=hi+Math.imul(ah0,bh2)|0;var w2=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w2>>>26)|0,w2&=67108863,lo=Math.imul(al3,bl0),mid=Math.imul(al3,bh0),mid=mid+Math.imul(ah3,bl0)|0,hi=Math.imul(ah3,bh0),lo=lo+Math.imul(al2,bl1)|0,mid=mid+Math.imul(al2,bh1)|0,mid=mid+Math.imul(ah2,bl1)|0,hi=hi+Math.imul(ah2,bh1)|0,lo=lo+Math.imul(al1,bl2)|0,mid=mid+Math.imul(al1,bh2)|0,mid=mid+Math.imul(ah1,bl2)|0,hi=hi+Math.imul(ah1,bh2)|0,lo=lo+Math.imul(al0,bl3)|0,mid=mid+Math.imul(al0,bh3)|0,mid=mid+Math.imul(ah0,bl3)|0,hi=hi+Math.imul(ah0,bh3)|0;var w3=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w3>>>26)|0,w3&=67108863,lo=Math.imul(al4,bl0),mid=Math.imul(al4,bh0),mid=mid+Math.imul(ah4,bl0)|0,hi=Math.imul(ah4,bh0),lo=lo+Math.imul(al3,bl1)|0,mid=mid+Math.imul(al3,bh1)|0,mid=mid+Math.imul(ah3,bl1)|0,hi=hi+Math.imul(ah3,bh1)|0,lo=lo+Math.imul(al2,bl2)|0,mid=mid+Math.imul(al2,bh2)|0,mid=mid+Math.imul(ah2,bl2)|0,hi=hi+Math.imul(ah2,bh2)|0,lo=lo+Math.imul(al1,bl3)|0,mid=mid+Math.imul(al1,bh3)|0,mid=mid+Math.imul(ah1,bl3)|0,hi=hi+Math.imul(ah1,bh3)|0,lo=lo+Math.imul(al0,bl4)|0,mid=mid+Math.imul(al0,bh4)|0,mid=mid+Math.imul(ah0,bl4)|0,hi=hi+Math.imul(ah0,bh4)|0;var w4=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w4>>>26)|0,w4&=67108863,lo=Math.imul(al5,bl0),mid=Math.imul(al5,bh0),mid=mid+Math.imul(ah5,bl0)|0,hi=Math.imul(ah5,bh0),lo=lo+Math.imul(al4,bl1)|0,mid=mid+Math.imul(al4,bh1)|0,mid=mid+Math.imul(ah4,bl1)|0,hi=hi+Math.imul(ah4,bh1)|0,lo=lo+Math.imul(al3,bl2)|0,mid=mid+Math.imul(al3,bh2)|0,mid=mid+Math.imul(ah3,bl2)|0,hi=hi+Math.imul(ah3,bh2)|0,lo=lo+Math.imul(al2,bl3)|0,mid=mid+Math.imul(al2,bh3)|0,mid=mid+Math.imul(ah2,bl3)|0,hi=hi+Math.imul(ah2,bh3)|0,lo=lo+Math.imul(al1,bl4)|0,mid=mid+Math.imul(al1,bh4)|0,mid=mid+Math.imul(ah1,bl4)|0,hi=hi+Math.imul(ah1,bh4)|0,lo=lo+Math.imul(al0,bl5)|0,mid=mid+Math.imul(al0,bh5)|0,mid=mid+Math.imul(ah0,bl5)|0,hi=hi+Math.imul(ah0,bh5)|0;var w5=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w5>>>26)|0,w5&=67108863,lo=Math.imul(al6,bl0),mid=Math.imul(al6,bh0),mid=mid+Math.imul(ah6,bl0)|0,hi=Math.imul(ah6,bh0),lo=lo+Math.imul(al5,bl1)|0,mid=mid+Math.imul(al5,bh1)|0,mid=mid+Math.imul(ah5,bl1)|0,hi=hi+Math.imul(ah5,bh1)|0,lo=lo+Math.imul(al4,bl2)|0,mid=mid+Math.imul(al4,bh2)|0,mid=mid+Math.imul(ah4,bl2)|0,hi=hi+Math.imul(ah4,bh2)|0,lo=lo+Math.imul(al3,bl3)|0,mid=mid+Math.imul(al3,bh3)|0,mid=mid+Math.imul(ah3,bl3)|0,hi=hi+Math.imul(ah3,bh3)|0,lo=lo+Math.imul(al2,bl4)|0,mid=mid+Math.imul(al2,bh4)|0,mid=mid+Math.imul(ah2,bl4)|0,hi=hi+Math.imul(ah2,bh4)|0,lo=lo+Math.imul(al1,bl5)|0,mid=mid+Math.imul(al1,bh5)|0,mid=mid+Math.imul(ah1,bl5)|0,hi=hi+Math.imul(ah1,bh5)|0,lo=lo+Math.imul(al0,bl6)|0,mid=mid+Math.imul(al0,bh6)|0,mid=mid+Math.imul(ah0,bl6)|0,hi=hi+Math.imul(ah0,bh6)|0;var w6=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w6>>>26)|0,w6&=67108863,lo=Math.imul(al7,bl0),mid=Math.imul(al7,bh0),mid=mid+Math.imul(ah7,bl0)|0,hi=Math.imul(ah7,bh0),lo=lo+Math.imul(al6,bl1)|0,mid=mid+Math.imul(al6,bh1)|0,mid=mid+Math.imul(ah6,bl1)|0,hi=hi+Math.imul(ah6,bh1)|0,lo=lo+Math.imul(al5,bl2)|0,mid=mid+Math.imul(al5,bh2)|0,mid=mid+Math.imul(ah5,bl2)|0,hi=hi+Math.imul(ah5,bh2)|0,lo=lo+Math.imul(al4,bl3)|0,mid=mid+Math.imul(al4,bh3)|0,mid=mid+Math.imul(ah4,bl3)|0,hi=hi+Math.imul(ah4,bh3)|0,lo=lo+Math.imul(al3,bl4)|0,mid=mid+Math.imul(al3,bh4)|0,mid=mid+Math.imul(ah3,bl4)|0,hi=hi+Math.imul(ah3,bh4)|0,lo=lo+Math.imul(al2,bl5)|0,mid=mid+Math.imul(al2,bh5)|0,mid=mid+Math.imul(ah2,bl5)|0,hi=hi+Math.imul(ah2,bh5)|0,lo=lo+Math.imul(al1,bl6)|0,mid=mid+Math.imul(al1,bh6)|0,mid=mid+Math.imul(ah1,bl6)|0,hi=hi+Math.imul(ah1,bh6)|0,lo=lo+Math.imul(al0,bl7)|0,mid=mid+Math.imul(al0,bh7)|0,mid=mid+Math.imul(ah0,bl7)|0,hi=hi+Math.imul(ah0,bh7)|0;var w7=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w7>>>26)|0,w7&=67108863,lo=Math.imul(al8,bl0),mid=Math.imul(al8,bh0),mid=mid+Math.imul(ah8,bl0)|0,hi=Math.imul(ah8,bh0),lo=lo+Math.imul(al7,bl1)|0,mid=mid+Math.imul(al7,bh1)|0,mid=mid+Math.imul(ah7,bl1)|0,hi=hi+Math.imul(ah7,bh1)|0,lo=lo+Math.imul(al6,bl2)|0,mid=mid+Math.imul(al6,bh2)|0,mid=mid+Math.imul(ah6,bl2)|0,hi=hi+Math.imul(ah6,bh2)|0,lo=lo+Math.imul(al5,bl3)|0,mid=mid+Math.imul(al5,bh3)|0,mid=mid+Math.imul(ah5,bl3)|0,hi=hi+Math.imul(ah5,bh3)|0,lo=lo+Math.imul(al4,bl4)|0,mid=mid+Math.imul(al4,bh4)|0,mid=mid+Math.imul(ah4,bl4)|0,hi=hi+Math.imul(ah4,bh4)|0,lo=lo+Math.imul(al3,bl5)|0,mid=mid+Math.imul(al3,bh5)|0,mid=mid+Math.imul(ah3,bl5)|0,hi=hi+Math.imul(ah3,bh5)|0,lo=lo+Math.imul(al2,bl6)|0,mid=mid+Math.imul(al2,bh6)|0,mid=mid+Math.imul(ah2,bl6)|0,hi=hi+Math.imul(ah2,bh6)|0,lo=lo+Math.imul(al1,bl7)|0,mid=mid+Math.imul(al1,bh7)|0,mid=mid+Math.imul(ah1,bl7)|0,hi=hi+Math.imul(ah1,bh7)|0,lo=lo+Math.imul(al0,bl8)|0,mid=mid+Math.imul(al0,bh8)|0,mid=mid+Math.imul(ah0,bl8)|0,hi=hi+Math.imul(ah0,bh8)|0;var w8=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w8>>>26)|0,w8&=67108863,lo=Math.imul(al9,bl0),mid=Math.imul(al9,bh0),mid=mid+Math.imul(ah9,bl0)|0,hi=Math.imul(ah9,bh0),lo=lo+Math.imul(al8,bl1)|0,mid=mid+Math.imul(al8,bh1)|0,mid=mid+Math.imul(ah8,bl1)|0,hi=hi+Math.imul(ah8,bh1)|0,lo=lo+Math.imul(al7,bl2)|0,mid=mid+Math.imul(al7,bh2)|0,mid=mid+Math.imul(ah7,bl2)|0,hi=hi+Math.imul(ah7,bh2)|0,lo=lo+Math.imul(al6,bl3)|0,mid=mid+Math.imul(al6,bh3)|0,mid=mid+Math.imul(ah6,bl3)|0,hi=hi+Math.imul(ah6,bh3)|0,lo=lo+Math.imul(al5,bl4)|0,mid=mid+Math.imul(al5,bh4)|0,mid=mid+Math.imul(ah5,bl4)|0,hi=hi+Math.imul(ah5,bh4)|0,lo=lo+Math.imul(al4,bl5)|0,mid=mid+Math.imul(al4,bh5)|0,mid=mid+Math.imul(ah4,bl5)|0,hi=hi+Math.imul(ah4,bh5)|0,lo=lo+Math.imul(al3,bl6)|0,mid=mid+Math.imul(al3,bh6)|0,mid=mid+Math.imul(ah3,bl6)|0,hi=hi+Math.imul(ah3,bh6)|0,lo=lo+Math.imul(al2,bl7)|0,mid=mid+Math.imul(al2,bh7)|0,mid=mid+Math.imul(ah2,bl7)|0,hi=hi+Math.imul(ah2,bh7)|0,lo=lo+Math.imul(al1,bl8)|0,mid=mid+Math.imul(al1,bh8)|0,mid=mid+Math.imul(ah1,bl8)|0,hi=hi+Math.imul(ah1,bh8)|0,lo=lo+Math.imul(al0,bl9)|0,mid=mid+Math.imul(al0,bh9)|0,mid=mid+Math.imul(ah0,bl9)|0,hi=hi+Math.imul(ah0,bh9)|0;var w9=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w9>>>26)|0,w9&=67108863,lo=Math.imul(al9,bl1),mid=Math.imul(al9,bh1),mid=mid+Math.imul(ah9,bl1)|0,hi=Math.imul(ah9,bh1),lo=lo+Math.imul(al8,bl2)|0,mid=mid+Math.imul(al8,bh2)|0,mid=mid+Math.imul(ah8,bl2)|0,hi=hi+Math.imul(ah8,bh2)|0,lo=lo+Math.imul(al7,bl3)|0,mid=mid+Math.imul(al7,bh3)|0,mid=mid+Math.imul(ah7,bl3)|0,hi=hi+Math.imul(ah7,bh3)|0,lo=lo+Math.imul(al6,bl4)|0,mid=mid+Math.imul(al6,bh4)|0,mid=mid+Math.imul(ah6,bl4)|0,hi=hi+Math.imul(ah6,bh4)|0,lo=lo+Math.imul(al5,bl5)|0,mid=mid+Math.imul(al5,bh5)|0,mid=mid+Math.imul(ah5,bl5)|0,hi=hi+Math.imul(ah5,bh5)|0,lo=lo+Math.imul(al4,bl6)|0,mid=mid+Math.imul(al4,bh6)|0,mid=mid+Math.imul(ah4,bl6)|0,hi=hi+Math.imul(ah4,bh6)|0,lo=lo+Math.imul(al3,bl7)|0,mid=mid+Math.imul(al3,bh7)|0,mid=mid+Math.imul(ah3,bl7)|0,hi=hi+Math.imul(ah3,bh7)|0,lo=lo+Math.imul(al2,bl8)|0,mid=mid+Math.imul(al2,bh8)|0,mid=mid+Math.imul(ah2,bl8)|0,hi=hi+Math.imul(ah2,bh8)|0,lo=lo+Math.imul(al1,bl9)|0,mid=mid+Math.imul(al1,bh9)|0,mid=mid+Math.imul(ah1,bl9)|0,hi=hi+Math.imul(ah1,bh9)|0;var w10=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w10>>>26)|0,w10&=67108863,lo=Math.imul(al9,bl2),mid=Math.imul(al9,bh2),mid=mid+Math.imul(ah9,bl2)|0,hi=Math.imul(ah9,bh2),lo=lo+Math.imul(al8,bl3)|0,mid=mid+Math.imul(al8,bh3)|0,mid=mid+Math.imul(ah8,bl3)|0,hi=hi+Math.imul(ah8,bh3)|0,lo=lo+Math.imul(al7,bl4)|0,mid=mid+Math.imul(al7,bh4)|0,mid=mid+Math.imul(ah7,bl4)|0,hi=hi+Math.imul(ah7,bh4)|0,lo=lo+Math.imul(al6,bl5)|0,mid=mid+Math.imul(al6,bh5)|0,mid=mid+Math.imul(ah6,bl5)|0,hi=hi+Math.imul(ah6,bh5)|0,lo=lo+Math.imul(al5,bl6)|0,mid=mid+Math.imul(al5,bh6)|0,mid=mid+Math.imul(ah5,bl6)|0,hi=hi+Math.imul(ah5,bh6)|0,lo=lo+Math.imul(al4,bl7)|0,mid=mid+Math.imul(al4,bh7)|0,mid=mid+Math.imul(ah4,bl7)|0,hi=hi+Math.imul(ah4,bh7)|0,lo=lo+Math.imul(al3,bl8)|0,mid=mid+Math.imul(al3,bh8)|0,mid=mid+Math.imul(ah3,bl8)|0,hi=hi+Math.imul(ah3,bh8)|0,lo=lo+Math.imul(al2,bl9)|0,mid=mid+Math.imul(al2,bh9)|0,mid=mid+Math.imul(ah2,bl9)|0,hi=hi+Math.imul(ah2,bh9)|0;var w11=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w11>>>26)|0,w11&=67108863,lo=Math.imul(al9,bl3),mid=Math.imul(al9,bh3),mid=mid+Math.imul(ah9,bl3)|0,hi=Math.imul(ah9,bh3),lo=lo+Math.imul(al8,bl4)|0,mid=mid+Math.imul(al8,bh4)|0,mid=mid+Math.imul(ah8,bl4)|0,hi=hi+Math.imul(ah8,bh4)|0,lo=lo+Math.imul(al7,bl5)|0,mid=mid+Math.imul(al7,bh5)|0,mid=mid+Math.imul(ah7,bl5)|0,hi=hi+Math.imul(ah7,bh5)|0,lo=lo+Math.imul(al6,bl6)|0,mid=mid+Math.imul(al6,bh6)|0,mid=mid+Math.imul(ah6,bl6)|0,hi=hi+Math.imul(ah6,bh6)|0,lo=lo+Math.imul(al5,bl7)|0,mid=mid+Math.imul(al5,bh7)|0,mid=mid+Math.imul(ah5,bl7)|0,hi=hi+Math.imul(ah5,bh7)|0,lo=lo+Math.imul(al4,bl8)|0,mid=mid+Math.imul(al4,bh8)|0,mid=mid+Math.imul(ah4,bl8)|0,hi=hi+Math.imul(ah4,bh8)|0,lo=lo+Math.imul(al3,bl9)|0,mid=mid+Math.imul(al3,bh9)|0,mid=mid+Math.imul(ah3,bl9)|0,hi=hi+Math.imul(ah3,bh9)|0;var w12=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w12>>>26)|0,w12&=67108863,lo=Math.imul(al9,bl4),mid=Math.imul(al9,bh4),mid=mid+Math.imul(ah9,bl4)|0,hi=Math.imul(ah9,bh4),lo=lo+Math.imul(al8,bl5)|0,mid=mid+Math.imul(al8,bh5)|0,mid=mid+Math.imul(ah8,bl5)|0,hi=hi+Math.imul(ah8,bh5)|0,lo=lo+Math.imul(al7,bl6)|0,mid=mid+Math.imul(al7,bh6)|0,mid=mid+Math.imul(ah7,bl6)|0,hi=hi+Math.imul(ah7,bh6)|0,lo=lo+Math.imul(al6,bl7)|0,mid=mid+Math.imul(al6,bh7)|0,mid=mid+Math.imul(ah6,bl7)|0,hi=hi+Math.imul(ah6,bh7)|0,lo=lo+Math.imul(al5,bl8)|0,mid=mid+Math.imul(al5,bh8)|0,mid=mid+Math.imul(ah5,bl8)|0,hi=hi+Math.imul(ah5,bh8)|0,lo=lo+Math.imul(al4,bl9)|0,mid=mid+Math.imul(al4,bh9)|0,mid=mid+Math.imul(ah4,bl9)|0,hi=hi+Math.imul(ah4,bh9)|0;var w13=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w13>>>26)|0,w13&=67108863,lo=Math.imul(al9,bl5),mid=Math.imul(al9,bh5),mid=mid+Math.imul(ah9,bl5)|0,hi=Math.imul(ah9,bh5),lo=lo+Math.imul(al8,bl6)|0,mid=mid+Math.imul(al8,bh6)|0,mid=mid+Math.imul(ah8,bl6)|0,hi=hi+Math.imul(ah8,bh6)|0,lo=lo+Math.imul(al7,bl7)|0,mid=mid+Math.imul(al7,bh7)|0,mid=mid+Math.imul(ah7,bl7)|0,hi=hi+Math.imul(ah7,bh7)|0,lo=lo+Math.imul(al6,bl8)|0,mid=mid+Math.imul(al6,bh8)|0,mid=mid+Math.imul(ah6,bl8)|0,hi=hi+Math.imul(ah6,bh8)|0,lo=lo+Math.imul(al5,bl9)|0,mid=mid+Math.imul(al5,bh9)|0,mid=mid+Math.imul(ah5,bl9)|0,hi=hi+Math.imul(ah5,bh9)|0;var w14=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w14>>>26)|0,w14&=67108863,lo=Math.imul(al9,bl6),mid=Math.imul(al9,bh6),mid=mid+Math.imul(ah9,bl6)|0,hi=Math.imul(ah9,bh6),lo=lo+Math.imul(al8,bl7)|0,mid=mid+Math.imul(al8,bh7)|0,mid=mid+Math.imul(ah8,bl7)|0,hi=hi+Math.imul(ah8,bh7)|0,lo=lo+Math.imul(al7,bl8)|0,mid=mid+Math.imul(al7,bh8)|0,mid=mid+Math.imul(ah7,bl8)|0,hi=hi+Math.imul(ah7,bh8)|0,lo=lo+Math.imul(al6,bl9)|0,mid=mid+Math.imul(al6,bh9)|0,mid=mid+Math.imul(ah6,bl9)|0,hi=hi+Math.imul(ah6,bh9)|0;var w15=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w15>>>26)|0,w15&=67108863,lo=Math.imul(al9,bl7),mid=Math.imul(al9,bh7),mid=mid+Math.imul(ah9,bl7)|0,hi=Math.imul(ah9,bh7),lo=lo+Math.imul(al8,bl8)|0,mid=mid+Math.imul(al8,bh8)|0,mid=mid+Math.imul(ah8,bl8)|0,hi=hi+Math.imul(ah8,bh8)|0,lo=lo+Math.imul(al7,bl9)|0,mid=mid+Math.imul(al7,bh9)|0,mid=mid+Math.imul(ah7,bl9)|0,hi=hi+Math.imul(ah7,bh9)|0;var w16=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w16>>>26)|0,w16&=67108863,lo=Math.imul(al9,bl8),mid=Math.imul(al9,bh8),mid=mid+Math.imul(ah9,bl8)|0,hi=Math.imul(ah9,bh8),lo=lo+Math.imul(al8,bl9)|0,mid=mid+Math.imul(al8,bh9)|0,mid=mid+Math.imul(ah8,bl9)|0,hi=hi+Math.imul(ah8,bh9)|0;var w17=(c+lo|0)+((8191&mid)<<13)|0;c=(hi+(mid>>>13)|0)+(w17>>>26)|0,w17&=67108863,lo=Math.imul(al9,bl9),mid=Math.imul(al9,bh9),mid=mid+Math.imul(ah9,bl9)|0,hi=Math.imul(ah9,bh9);var w18=(c+lo|0)+((8191&mid)<<13)|0;return c=(hi+(mid>>>13)|0)+(w18>>>26)|0,w18&=67108863,o[0]=w0,o[1]=w1,o[2]=w2,o[3]=w3,o[4]=w4,o[5]=w5,o[6]=w6,o[7]=w7,o[8]=w8,o[9]=w9,o[10]=w10,o[11]=w11,o[12]=w12,o[13]=w13,o[14]=w14,o[15]=w15,o[16]=w16,o[17]=w17,o[18]=w18,0!==c&&(o[19]=c,out.length++),out};Math.imul||(comb10MulTo=smallMulTo),BN.prototype.mulTo=function(num,out){var res,len=this.length+num.length;return res=10===this.length&&10===num.length?comb10MulTo(this,num,out):63>len?smallMulTo(this,num,out):1024>len?bigMulTo(this,num,out):jumboMulTo(this,num,out)},FFTM.prototype.makeRBT=function(N){for(var t=new Array(N),l=BN.prototype._countBits(N)-1,i=0;N>i;i++)t[i]=this.revBin(i,l,N);return t},FFTM.prototype.revBin=function(x,l,N){if(0===x||x===N-1)return x;for(var rb=0,i=0;l>i;i++)rb|=(1&x)<<l-i-1,x>>=1;return rb},FFTM.prototype.permute=function(rbt,rws,iws,rtws,itws,N){for(var i=0;N>i;i++)rtws[i]=rws[rbt[i]],itws[i]=iws[rbt[i]];
  
  },FFTM.prototype.transform=function(rws,iws,rtws,itws,N,rbt){this.permute(rbt,rws,iws,rtws,itws,N);for(var s=1;N>s;s<<=1)for(var l=s<<1,rtwdf=Math.cos(2*Math.PI/l),itwdf=Math.sin(2*Math.PI/l),p=0;N>p;p+=l)for(var rtwdf_=rtwdf,itwdf_=itwdf,j=0;s>j;j++){var re=rtws[p+j],ie=itws[p+j],ro=rtws[p+j+s],io=itws[p+j+s],rx=rtwdf_*ro-itwdf_*io;io=rtwdf_*io+itwdf_*ro,ro=rx,rtws[p+j]=re+ro,itws[p+j]=ie+io,rtws[p+j+s]=re-ro,itws[p+j+s]=ie-io,j!==l&&(rx=rtwdf*rtwdf_-itwdf*itwdf_,itwdf_=rtwdf*itwdf_+itwdf*rtwdf_,rtwdf_=rx)}},FFTM.prototype.guessLen13b=function(n,m){var N=1|Math.max(m,n),odd=1&N,i=0;for(N=N/2|0;N;N>>>=1)i++;return 1<<i+1+odd},FFTM.prototype.conjugate=function(rws,iws,N){if(!(1>=N))for(var i=0;N/2>i;i++){var t=rws[i];rws[i]=rws[N-i-1],rws[N-i-1]=t,t=iws[i],iws[i]=-iws[N-i-1],iws[N-i-1]=-t}},FFTM.prototype.normalize13b=function(ws,N){for(var carry=0,i=0;N/2>i;i++){var w=8192*Math.round(ws[2*i+1]/N)+Math.round(ws[2*i]/N)+carry;ws[i]=67108863&w,carry=67108864>w?0:w/67108864|0}return ws},FFTM.prototype.convert13b=function(ws,len,rws,N){for(var carry=0,i=0;len>i;i++)carry+=0|ws[i],rws[2*i]=8191&carry,carry>>>=13,rws[2*i+1]=8191&carry,carry>>>=13;for(i=2*len;N>i;++i)rws[i]=0;assert(0===carry),assert(0===(-8192&carry))},FFTM.prototype.stub=function(N){for(var ph=new Array(N),i=0;N>i;i++)ph[i]=0;return ph},FFTM.prototype.mulp=function(x,y,out){var N=2*this.guessLen13b(x.length,y.length),rbt=this.makeRBT(N),_=this.stub(N),rws=new Array(N),rwst=new Array(N),iwst=new Array(N),nrws=new Array(N),nrwst=new Array(N),niwst=new Array(N),rmws=out.words;rmws.length=N,this.convert13b(x.words,x.length,rws,N),this.convert13b(y.words,y.length,nrws,N),this.transform(rws,_,rwst,iwst,N,rbt),this.transform(nrws,_,nrwst,niwst,N,rbt);for(var i=0;N>i;i++){var rx=rwst[i]*nrwst[i]-iwst[i]*niwst[i];iwst[i]=rwst[i]*niwst[i]+iwst[i]*nrwst[i],rwst[i]=rx}return this.conjugate(rwst,iwst,N),this.transform(rwst,iwst,rmws,_,N,rbt),this.conjugate(rmws,_,N),this.normalize13b(rmws,N),out.negative=x.negative^y.negative,out.length=x.length+y.length,out.strip()},BN.prototype.mul=function(num){var out=new BN(null);return out.words=new Array(this.length+num.length),this.mulTo(num,out)},BN.prototype.mulf=function(num){var out=new BN(null);return out.words=new Array(this.length+num.length),jumboMulTo(this,num,out)},BN.prototype.imul=function(num){return this.clone().mulTo(num,this)},BN.prototype.imuln=function(num){assert("number"==typeof num),assert(67108864>num);for(var carry=0,i=0;i<this.length;i++){var w=(0|this.words[i])*num,lo=(67108863&w)+(67108863&carry);carry>>=26,carry+=w/67108864|0,carry+=lo>>>26,this.words[i]=67108863&lo}return 0!==carry&&(this.words[i]=carry,this.length++),this},BN.prototype.muln=function(num){return this.clone().imuln(num)},BN.prototype.sqr=function(){return this.mul(this)},BN.prototype.isqr=function(){return this.imul(this.clone())},BN.prototype.pow=function(num){var w=toBitArray(num);if(0===w.length)return new BN(1);for(var res=this,i=0;i<w.length&&0===w[i];i++,res=res.sqr());if(++i<w.length)for(var q=res.sqr();i<w.length;i++,q=q.sqr())0!==w[i]&&(res=res.mul(q));return res},BN.prototype.iushln=function(bits){assert("number"==typeof bits&&bits>=0);var i,r=bits%26,s=(bits-r)/26,carryMask=67108863>>>26-r<<26-r;if(0!==r){var carry=0;for(i=0;i<this.length;i++){var newCarry=this.words[i]&carryMask,c=(0|this.words[i])-newCarry<<r;this.words[i]=c|carry,carry=newCarry>>>26-r}carry&&(this.words[i]=carry,this.length++)}if(0!==s){for(i=this.length-1;i>=0;i--)this.words[i+s]=this.words[i];for(i=0;s>i;i++)this.words[i]=0;this.length+=s}return this.strip()},BN.prototype.ishln=function(bits){return assert(0===this.negative),this.iushln(bits)},BN.prototype.iushrn=function(bits,hint,extended){assert("number"==typeof bits&&bits>=0);var h;h=hint?(hint-hint%26)/26:0;var r=bits%26,s=Math.min((bits-r)/26,this.length),mask=67108863^67108863>>>r<<r,maskedWords=extended;if(h-=s,h=Math.max(0,h),maskedWords){for(var i=0;s>i;i++)maskedWords.words[i]=this.words[i];maskedWords.length=s}if(0===s);else if(this.length>s)for(this.length-=s,i=0;i<this.length;i++)this.words[i]=this.words[i+s];else this.words[0]=0,this.length=1;var carry=0;for(i=this.length-1;i>=0&&(0!==carry||i>=h);i--){var word=0|this.words[i];this.words[i]=carry<<26-r|word>>>r,carry=word&mask}return maskedWords&&0!==carry&&(maskedWords.words[maskedWords.length++]=carry),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function(bits,hint,extended){return assert(0===this.negative),this.iushrn(bits,hint,extended)},BN.prototype.shln=function(bits){return this.clone().ishln(bits)},BN.prototype.ushln=function(bits){return this.clone().iushln(bits)},BN.prototype.shrn=function(bits){return this.clone().ishrn(bits)},BN.prototype.ushrn=function(bits){return this.clone().iushrn(bits)},BN.prototype.testn=function(bit){assert("number"==typeof bit&&bit>=0);var r=bit%26,s=(bit-r)/26,q=1<<r;if(this.length<=s)return!1;var w=this.words[s];return!!(w&q)},BN.prototype.imaskn=function(bits){assert("number"==typeof bits&&bits>=0);var r=bits%26,s=(bits-r)/26;if(assert(0===this.negative,"imaskn works only with positive numbers"),this.length<=s)return this;if(0!==r&&s++,this.length=Math.min(s,this.length),0!==r){var mask=67108863^67108863>>>r<<r;this.words[this.length-1]&=mask}return this.strip()},BN.prototype.maskn=function(bits){return this.clone().imaskn(bits)},BN.prototype.iaddn=function(num){return assert("number"==typeof num),assert(67108864>num),0>num?this.isubn(-num):0!==this.negative?1===this.length&&(0|this.words[0])<num?(this.words[0]=num-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(num),this.negative=1,this):this._iaddn(num)},BN.prototype._iaddn=function(num){this.words[0]+=num;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},BN.prototype.isubn=function(num){if(assert("number"==typeof num),assert(67108864>num),0>num)return this.iaddn(-num);if(0!==this.negative)return this.negative=0,this.iaddn(num),this.negative=1,this;if(this.words[0]-=num,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this.strip()},BN.prototype.addn=function(num){return this.clone().iaddn(num)},BN.prototype.subn=function(num){return this.clone().isubn(num)},BN.prototype.iabs=function(){return this.negative=0,this},BN.prototype.abs=function(){return this.clone().iabs()},BN.prototype._ishlnsubmul=function(num,mul,shift){var i,len=num.length+shift;this._expand(len);var w,carry=0;for(i=0;i<num.length;i++){w=(0|this.words[i+shift])+carry;var right=(0|num.words[i])*mul;w-=67108863&right,carry=(w>>26)-(right/67108864|0),this.words[i+shift]=67108863&w}for(;i<this.length-shift;i++)w=(0|this.words[i+shift])+carry,carry=w>>26,this.words[i+shift]=67108863&w;if(0===carry)return this.strip();for(assert(-1===carry),carry=0,i=0;i<this.length;i++)w=-(0|this.words[i])+carry,carry=w>>26,this.words[i]=67108863&w;return this.negative=1,this.strip()},BN.prototype._wordDiv=function(num,mode){var shift=this.length-num.length,a=this.clone(),b=num,bhi=0|b.words[b.length-1],bhiBits=this._countBits(bhi);shift=26-bhiBits,0!==shift&&(b=b.ushln(shift),a.iushln(shift),bhi=0|b.words[b.length-1]);var q,m=a.length-b.length;if("mod"!==mode){q=new BN(null),q.length=m+1,q.words=new Array(q.length);for(var i=0;i<q.length;i++)q.words[i]=0}var diff=a.clone()._ishlnsubmul(b,1,m);0===diff.negative&&(a=diff,q&&(q.words[m]=1));for(var j=m-1;j>=0;j--){var qj=67108864*(0|a.words[b.length+j])+(0|a.words[b.length+j-1]);for(qj=Math.min(qj/bhi|0,67108863),a._ishlnsubmul(b,qj,j);0!==a.negative;)qj--,a.negative=0,a._ishlnsubmul(b,1,j),a.isZero()||(a.negative^=1);q&&(q.words[j]=qj)}return q&&q.strip(),a.strip(),"div"!==mode&&0!==shift&&a.iushrn(shift),{div:q||null,mod:a}},BN.prototype.divmod=function(num,mode,positive){if(assert(!num.isZero()),this.isZero())return{div:new BN(0),mod:new BN(0)};var div,mod,res;return 0!==this.negative&&0===num.negative?(res=this.neg().divmod(num,mode),"mod"!==mode&&(div=res.div.neg()),"div"!==mode&&(mod=res.mod.neg(),positive&&0!==mod.negative&&mod.iadd(num)),{div:div,mod:mod}):0===this.negative&&0!==num.negative?(res=this.divmod(num.neg(),mode),"mod"!==mode&&(div=res.div.neg()),{div:div,mod:res.mod}):0!==(this.negative&num.negative)?(res=this.neg().divmod(num.neg(),mode),"div"!==mode&&(mod=res.mod.neg(),positive&&0!==mod.negative&&mod.isub(num)),{div:res.div,mod:mod}):num.length>this.length||this.cmp(num)<0?{div:new BN(0),mod:this}:1===num.length?"div"===mode?{div:this.divn(num.words[0]),mod:null}:"mod"===mode?{div:null,mod:new BN(this.modn(num.words[0]))}:{div:this.divn(num.words[0]),mod:new BN(this.modn(num.words[0]))}:this._wordDiv(num,mode)},BN.prototype.div=function(num){return this.divmod(num,"div",!1).div},BN.prototype.mod=function(num){return this.divmod(num,"mod",!1).mod},BN.prototype.umod=function(num){return this.divmod(num,"mod",!0).mod},BN.prototype.divRound=function(num){var dm=this.divmod(num);if(dm.mod.isZero())return dm.div;var mod=0!==dm.div.negative?dm.mod.isub(num):dm.mod,half=num.ushrn(1),r2=num.andln(1),cmp=mod.cmp(half);return 0>cmp||1===r2&&0===cmp?dm.div:0!==dm.div.negative?dm.div.isubn(1):dm.div.iaddn(1)},BN.prototype.modn=function(num){assert(67108863>=num);for(var p=(1<<26)%num,acc=0,i=this.length-1;i>=0;i--)acc=(p*acc+(0|this.words[i]))%num;return acc},BN.prototype.idivn=function(num){assert(67108863>=num);for(var carry=0,i=this.length-1;i>=0;i--){var w=(0|this.words[i])+67108864*carry;this.words[i]=w/num|0,carry=w%num}return this.strip()},BN.prototype.divn=function(num){return this.clone().idivn(num)},BN.prototype.egcd=function(p){assert(0===p.negative),assert(!p.isZero());var x=this,y=p.clone();x=0!==x.negative?x.umod(p):x.clone();for(var A=new BN(1),B=new BN(0),C=new BN(0),D=new BN(1),g=0;x.isEven()&&y.isEven();)x.iushrn(1),y.iushrn(1),++g;for(var yp=y.clone(),xp=x.clone();!x.isZero();){for(var i=0,im=1;0===(x.words[0]&im)&&26>i;++i,im<<=1);if(i>0)for(x.iushrn(i);i-->0;)(A.isOdd()||B.isOdd())&&(A.iadd(yp),B.isub(xp)),A.iushrn(1),B.iushrn(1);for(var j=0,jm=1;0===(y.words[0]&jm)&&26>j;++j,jm<<=1);if(j>0)for(y.iushrn(j);j-->0;)(C.isOdd()||D.isOdd())&&(C.iadd(yp),D.isub(xp)),C.iushrn(1),D.iushrn(1);x.cmp(y)>=0?(x.isub(y),A.isub(C),B.isub(D)):(y.isub(x),C.isub(A),D.isub(B))}return{a:C,b:D,gcd:y.iushln(g)}},BN.prototype._invmp=function(p){assert(0===p.negative),assert(!p.isZero());var a=this,b=p.clone();a=0!==a.negative?a.umod(p):a.clone();for(var x1=new BN(1),x2=new BN(0),delta=b.clone();a.cmpn(1)>0&&b.cmpn(1)>0;){for(var i=0,im=1;0===(a.words[0]&im)&&26>i;++i,im<<=1);if(i>0)for(a.iushrn(i);i-->0;)x1.isOdd()&&x1.iadd(delta),x1.iushrn(1);for(var j=0,jm=1;0===(b.words[0]&jm)&&26>j;++j,jm<<=1);if(j>0)for(b.iushrn(j);j-->0;)x2.isOdd()&&x2.iadd(delta),x2.iushrn(1);a.cmp(b)>=0?(a.isub(b),x1.isub(x2)):(b.isub(a),x2.isub(x1))}var res;return res=0===a.cmpn(1)?x1:x2,res.cmpn(0)<0&&res.iadd(p),res},BN.prototype.gcd=function(num){if(this.isZero())return num.abs();if(num.isZero())return this.abs();var a=this.clone(),b=num.clone();a.negative=0,b.negative=0;for(var shift=0;a.isEven()&&b.isEven();shift++)a.iushrn(1),b.iushrn(1);for(;;){for(;a.isEven();)a.iushrn(1);for(;b.isEven();)b.iushrn(1);var r=a.cmp(b);if(0>r){var t=a;a=b,b=t}else if(0===r||0===b.cmpn(1))break;a.isub(b)}return b.iushln(shift)},BN.prototype.invm=function(num){return this.egcd(num).a.umod(num)},BN.prototype.isEven=function(){return 0===(1&this.words[0])},BN.prototype.isOdd=function(){return 1===(1&this.words[0])},BN.prototype.andln=function(num){return this.words[0]&num},BN.prototype.bincn=function(bit){assert("number"==typeof bit);var r=bit%26,s=(bit-r)/26,q=1<<r;if(this.length<=s)return this._expand(s+1),this.words[s]|=q,this;for(var carry=q,i=s;0!==carry&&i<this.length;i++){var w=0|this.words[i];w+=carry,carry=w>>>26,w&=67108863,this.words[i]=w}return 0!==carry&&(this.words[i]=carry,this.length++),this},BN.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},BN.prototype.cmpn=function(num){var negative=0>num;if(0!==this.negative&&!negative)return-1;if(0===this.negative&&negative)return 1;this.strip();var res;if(this.length>1)res=1;else{negative&&(num=-num),assert(67108863>=num,"Number is too big");var w=0|this.words[0];res=w===num?0:num>w?-1:1}return 0!==this.negative?0|-res:res},BN.prototype.cmp=function(num){if(0!==this.negative&&0===num.negative)return-1;if(0===this.negative&&0!==num.negative)return 1;var res=this.ucmp(num);return 0!==this.negative?0|-res:res},BN.prototype.ucmp=function(num){if(this.length>num.length)return 1;if(this.length<num.length)return-1;for(var res=0,i=this.length-1;i>=0;i--){var a=0|this.words[i],b=0|num.words[i];if(a!==b){b>a?res=-1:a>b&&(res=1);break}}return res},BN.prototype.gtn=function(num){return 1===this.cmpn(num)},BN.prototype.gt=function(num){return 1===this.cmp(num)},BN.prototype.gten=function(num){return this.cmpn(num)>=0},BN.prototype.gte=function(num){return this.cmp(num)>=0},BN.prototype.ltn=function(num){return-1===this.cmpn(num)},BN.prototype.lt=function(num){return-1===this.cmp(num)},BN.prototype.lten=function(num){return this.cmpn(num)<=0},BN.prototype.lte=function(num){return this.cmp(num)<=0},BN.prototype.eqn=function(num){return 0===this.cmpn(num)},BN.prototype.eq=function(num){return 0===this.cmp(num)},BN.red=function(num){return new Red(num)},BN.prototype.toRed=function(ctx){return assert(!this.red,"Already a number in reduction context"),assert(0===this.negative,"red works only with positives"),ctx.convertTo(this)._forceRed(ctx)},BN.prototype.fromRed=function(){return assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},BN.prototype._forceRed=function(ctx){return this.red=ctx,this},BN.prototype.forceRed=function(ctx){return assert(!this.red,"Already a number in reduction context"),this._forceRed(ctx)},BN.prototype.redAdd=function(num){return assert(this.red,"redAdd works only with red numbers"),this.red.add(this,num)},BN.prototype.redIAdd=function(num){return assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,num)},BN.prototype.redSub=function(num){return assert(this.red,"redSub works only with red numbers"),this.red.sub(this,num)},BN.prototype.redISub=function(num){return assert(this.red,"redISub works only with red numbers"),this.red.isub(this,num)},BN.prototype.redShl=function(num){return assert(this.red,"redShl works only with red numbers"),this.red.shl(this,num)},BN.prototype.redMul=function(num){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,num),this.red.mul(this,num)},BN.prototype.redIMul=function(num){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,num),this.red.imul(this,num)},BN.prototype.redSqr=function(){return assert(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function(){return assert(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function(){return assert(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function(){return assert(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function(){return assert(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function(num){return assert(this.red&&!num.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,num)};var primes={k256:null,p224:null,p192:null,p25519:null};MPrime.prototype._tmp=function(){var tmp=new BN(null);return tmp.words=new Array(Math.ceil(this.n/13)),tmp},MPrime.prototype.ireduce=function(num){var rlen,r=num;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),rlen=r.bitLength();while(rlen>this.n);var cmp=rlen<this.n?-1:r.ucmp(this.p);return 0===cmp?(r.words[0]=0,r.length=1):cmp>0?r.isub(this.p):r.strip(),r},MPrime.prototype.split=function(input,out){input.iushrn(this.n,0,out)},MPrime.prototype.imulK=function(num){return num.imul(this.k)},inherits(K256,MPrime),K256.prototype.split=function(input,output){for(var mask=4194303,outLen=Math.min(input.length,9),i=0;outLen>i;i++)output.words[i]=input.words[i];if(output.length=outLen,input.length<=9)return input.words[0]=0,void(input.length=1);var prev=input.words[9];for(output.words[output.length++]=prev&mask,i=10;i<input.length;i++){var next=0|input.words[i];input.words[i-10]=(next&mask)<<4|prev>>>22,prev=next}prev>>>=22,input.words[i-10]=prev,input.length-=0===prev&&input.length>10?10:9},K256.prototype.imulK=function(num){num.words[num.length]=0,num.words[num.length+1]=0,num.length+=2;for(var lo=0,i=0;i<num.length;i++){var w=0|num.words[i];lo+=977*w,num.words[i]=67108863&lo,lo=64*w+(lo/67108864|0)}return 0===num.words[num.length-1]&&(num.length--,0===num.words[num.length-1]&&num.length--),num},inherits(P224,MPrime),inherits(P192,MPrime),inherits(P25519,MPrime),P25519.prototype.imulK=function(num){for(var carry=0,i=0;i<num.length;i++){var hi=19*(0|num.words[i])+carry,lo=67108863&hi;hi>>>=26,num.words[i]=lo,carry=hi}return 0!==carry&&(num.words[num.length++]=carry),num},BN._prime=function prime(name){if(primes[name])return primes[name];var prime;if("k256"===name)prime=new K256;else if("p224"===name)prime=new P224;else if("p192"===name)prime=new P192;else{if("p25519"!==name)throw new Error("Unknown prime "+name);prime=new P25519}return primes[name]=prime,prime},Red.prototype._verify1=function(a){assert(0===a.negative,"red works only with positives"),assert(a.red,"red works only with red numbers")},Red.prototype._verify2=function(a,b){assert(0===(a.negative|b.negative),"red works only with positives"),assert(a.red&&a.red===b.red,"red works only with red numbers")},Red.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):a.umod(this.m)._forceRed(this)},Red.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},Red.prototype.add=function(a,b){this._verify2(a,b);var res=a.add(b);return res.cmp(this.m)>=0&&res.isub(this.m),res._forceRed(this)},Red.prototype.iadd=function(a,b){this._verify2(a,b);var res=a.iadd(b);return res.cmp(this.m)>=0&&res.isub(this.m),res},Red.prototype.sub=function(a,b){this._verify2(a,b);var res=a.sub(b);return res.cmpn(0)<0&&res.iadd(this.m),res._forceRed(this)},Red.prototype.isub=function(a,b){this._verify2(a,b);var res=a.isub(b);return res.cmpn(0)<0&&res.iadd(this.m),res},Red.prototype.shl=function(a,num){return this._verify1(a),this.imod(a.ushln(num))},Red.prototype.imul=function(a,b){return this._verify2(a,b),this.imod(a.imul(b))},Red.prototype.mul=function(a,b){return this._verify2(a,b),this.imod(a.mul(b))},Red.prototype.isqr=function(a){return this.imul(a,a.clone())},Red.prototype.sqr=function(a){return this.mul(a,a)},Red.prototype.sqrt=function(a){if(a.isZero())return a.clone();var mod3=this.m.andln(3);if(assert(mod3%2===1),3===mod3){var pow=this.m.add(new BN(1)).iushrn(2);return this.pow(a,pow)}for(var q=this.m.subn(1),s=0;!q.isZero()&&0===q.andln(1);)s++,q.iushrn(1);assert(!q.isZero());var one=new BN(1).toRed(this),nOne=one.redNeg(),lpow=this.m.subn(1).iushrn(1),z=this.m.bitLength();for(z=new BN(2*z*z).toRed(this);0!==this.pow(z,lpow).cmp(nOne);)z.redIAdd(nOne);for(var c=this.pow(z,q),r=this.pow(a,q.addn(1).iushrn(1)),t=this.pow(a,q),m=s;0!==t.cmp(one);){for(var tmp=t,i=0;0!==tmp.cmp(one);i++)tmp=tmp.redSqr();assert(m>i);var b=this.pow(c,new BN(1).iushln(m-i-1));r=r.redMul(b),c=b.redSqr(),t=t.redMul(c),m=i}return r},Red.prototype.invm=function(a){var inv=a._invmp(this.m);return 0!==inv.negative?(inv.negative=0,this.imod(inv).redNeg()):this.imod(inv)},Red.prototype.pow=function(a,num){if(num.isZero())return new BN(1);if(0===num.cmpn(1))return a.clone();var windowSize=4,wnd=new Array(1<<windowSize);wnd[0]=new BN(1).toRed(this),wnd[1]=a;for(var i=2;i<wnd.length;i++)wnd[i]=this.mul(wnd[i-1],a);var res=wnd[0],current=0,currentLen=0,start=num.bitLength()%26;for(0===start&&(start=26),i=num.length-1;i>=0;i--){for(var word=num.words[i],j=start-1;j>=0;j--){var bit=word>>j&1;res!==wnd[0]&&(res=this.sqr(res)),0!==bit||0!==current?(current<<=1,current|=bit,currentLen++,(currentLen===windowSize||0===i&&0===j)&&(res=this.mul(res,wnd[current]),currentLen=0,current=0)):currentLen=0}start=26}return res},Red.prototype.convertTo=function(num){var r=num.umod(this.m);return r===num?r.clone():r},Red.prototype.convertFrom=function(num){var res=num.clone();return res.red=null,res},BN.mont=function(num){return new Mont(num)},inherits(Mont,Red),Mont.prototype.convertTo=function(num){return this.imod(num.ushln(this.shift))},Mont.prototype.convertFrom=function(num){var r=this.imod(num.mul(this.rinv));return r.red=null,r},Mont.prototype.imul=function(a,b){if(a.isZero()||b.isZero())return a.words[0]=0,a.length=1,a;var t=a.imul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).iushrn(this.shift),res=u;return u.cmp(this.m)>=0?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.mul=function(a,b){if(a.isZero()||b.isZero())return new BN(0)._forceRed(this);var t=a.mul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).iushrn(this.shift),res=u;return u.cmp(this.m)>=0?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.invm=function(a){var res=this.imod(a._invmp(this.m).mul(this.r2));return res._forceRed(this)}}("undefined"==typeof module||module,this)},{}],17:[function(require,module){function Rand(rand){this.rand=rand}var r;if(module.exports=function(len){return r||(r=new Rand(null)),r.generate(len)},module.exports.Rand=Rand,Rand.prototype.generate=function(len){return this._rand(len)},"object"==typeof window)Rand.prototype._rand=window.crypto&&window.crypto.getRandomValues?function(n){var arr=new Uint8Array(n);return window.crypto.getRandomValues(arr),arr}:window.msCrypto&&window.msCrypto.getRandomValues?function(n){var arr=new Uint8Array(n);return window.msCrypto.getRandomValues(arr),arr}:function(){throw new Error("Not implemented yet")};else try{var crypto=require("crypto");Rand.prototype._rand=function(n){return crypto.randomBytes(n)}}catch(e){Rand.prototype._rand=function(n){for(var res=new Uint8Array(n),i=0;i<res.length;i++)res[i]=this.rand.getByte();return res}}},{crypto:18}],18:[function(){},{}],19:[function(require,module,exports){(function(Buffer){function fixup_uint32(x){var ret,x_pos;return ret=x>uint_max||0>x?(x_pos=Math.abs(x)%uint_max,0>x?uint_max-x_pos:x_pos):x}function scrub_vec(v){for(var i=0;i<v.length;v++)v[i]=0;return!1}function Global(){this.SBOX=[],this.INV_SBOX=[],this.SUB_MIX=[[],[],[],[]],this.INV_SUB_MIX=[[],[],[],[]],this.init(),this.RCON=[0,1,2,4,8,16,32,64,128,27,54]}function bufferToArray(buf){for(var len=buf.length/4,out=new Array(len),i=-1;++i<len;)out[i]=buf.readUInt32BE(4*i);return out}function AES(key){this._key=bufferToArray(key),this._doReset()}var uint_max=Math.pow(2,32);Global.prototype.init=function(){var d,i,sx,t,x,x2,x4,x8,xi,_i;for(d=function(){var _i,_results;for(_results=[],i=_i=0;256>_i;i=++_i)_results.push(128>i?i<<1:i<<1^283);return _results}(),x=0,xi=0,i=_i=0;256>_i;i=++_i)sx=xi^xi<<1^xi<<2^xi<<3^xi<<4,sx=sx>>>8^255&sx^99,this.SBOX[x]=sx,this.INV_SBOX[sx]=x,x2=d[x],x4=d[x2],x8=d[x4],t=257*d[sx]^16843008*sx,this.SUB_MIX[0][x]=t<<24|t>>>8,this.SUB_MIX[1][x]=t<<16|t>>>16,this.SUB_MIX[2][x]=t<<8|t>>>24,this.SUB_MIX[3][x]=t,t=16843009*x8^65537*x4^257*x2^16843008*x,this.INV_SUB_MIX[0][sx]=t<<24|t>>>8,this.INV_SUB_MIX[1][sx]=t<<16|t>>>16,this.INV_SUB_MIX[2][sx]=t<<8|t>>>24,this.INV_SUB_MIX[3][sx]=t,0===x?x=xi=1:(x=x2^d[d[d[x8^x2]]],xi^=d[d[xi]]);return!0};var G=new Global;AES.blockSize=16,AES.prototype.blockSize=AES.blockSize,AES.keySize=32,AES.prototype.keySize=AES.keySize,AES.prototype._doReset=function(){var invKsRow,keySize,keyWords,ksRow,ksRows,t;for(keyWords=this._key,keySize=keyWords.length,this._nRounds=keySize+6,ksRows=4*(this._nRounds+1),this._keySchedule=[],ksRow=0;ksRows>ksRow;ksRow++)this._keySchedule[ksRow]=keySize>ksRow?keyWords[ksRow]:(t=this._keySchedule[ksRow-1],ksRow%keySize===0?(t=t<<8|t>>>24,t=G.SBOX[t>>>24]<<24|G.SBOX[t>>>16&255]<<16|G.SBOX[t>>>8&255]<<8|G.SBOX[255&t],t^=G.RCON[ksRow/keySize|0]<<24):keySize>6&&ksRow%keySize===4?t=G.SBOX[t>>>24]<<24|G.SBOX[t>>>16&255]<<16|G.SBOX[t>>>8&255]<<8|G.SBOX[255&t]:void 0,this._keySchedule[ksRow-keySize]^t);for(this._invKeySchedule=[],invKsRow=0;ksRows>invKsRow;invKsRow++)ksRow=ksRows-invKsRow,t=this._keySchedule[ksRow-(invKsRow%4?0:4)],this._invKeySchedule[invKsRow]=4>invKsRow||4>=ksRow?t:G.INV_SUB_MIX[0][G.SBOX[t>>>24]]^G.INV_SUB_MIX[1][G.SBOX[t>>>16&255]]^G.INV_SUB_MIX[2][G.SBOX[t>>>8&255]]^G.INV_SUB_MIX[3][G.SBOX[255&t]];return!0},AES.prototype.encryptBlock=function(M){M=bufferToArray(new Buffer(M));var out=this._doCryptBlock(M,this._keySchedule,G.SUB_MIX,G.SBOX),buf=new Buffer(16);return buf.writeUInt32BE(out[0],0),buf.writeUInt32BE(out[1],4),buf.writeUInt32BE(out[2],8),buf.writeUInt32BE(out[3],12),buf},AES.prototype.decryptBlock=function(M){M=bufferToArray(new Buffer(M));var temp=[M[3],M[1]];M[1]=temp[0],M[3]=temp[1];var out=this._doCryptBlock(M,this._invKeySchedule,G.INV_SUB_MIX,G.INV_SBOX),buf=new Buffer(16);return buf.writeUInt32BE(out[0],0),buf.writeUInt32BE(out[3],4),buf.writeUInt32BE(out[2],8),buf.writeUInt32BE(out[1],12),buf},AES.prototype.scrub=function(){scrub_vec(this._keySchedule),scrub_vec(this._invKeySchedule),scrub_vec(this._key)},AES.prototype._doCryptBlock=function(M,keySchedule,SUB_MIX,SBOX){var ksRow,s0,s1,s2,s3,t0,t1,t2,t3;s0=M[0]^keySchedule[0],s1=M[1]^keySchedule[1],s2=M[2]^keySchedule[2],s3=M[3]^keySchedule[3],ksRow=4;for(var round=1;round<this._nRounds;round++)t0=SUB_MIX[0][s0>>>24]^SUB_MIX[1][s1>>>16&255]^SUB_MIX[2][s2>>>8&255]^SUB_MIX[3][255&s3]^keySchedule[ksRow++],t1=SUB_MIX[0][s1>>>24]^SUB_MIX[1][s2>>>16&255]^SUB_MIX[2][s3>>>8&255]^SUB_MIX[3][255&s0]^keySchedule[ksRow++],t2=SUB_MIX[0][s2>>>24]^SUB_MIX[1][s3>>>16&255]^SUB_MIX[2][s0>>>8&255]^SUB_MIX[3][255&s1]^keySchedule[ksRow++],t3=SUB_MIX[0][s3>>>24]^SUB_MIX[1][s0>>>16&255]^SUB_MIX[2][s1>>>8&255]^SUB_MIX[3][255&s2]^keySchedule[ksRow++],s0=t0,s1=t1,s2=t2,s3=t3;return t0=(SBOX[s0>>>24]<<24|SBOX[s1>>>16&255]<<16|SBOX[s2>>>8&255]<<8|SBOX[255&s3])^keySchedule[ksRow++],t1=(SBOX[s1>>>24]<<24|SBOX[s2>>>16&255]<<16|SBOX[s3>>>8&255]<<8|SBOX[255&s0])^keySchedule[ksRow++],t2=(SBOX[s2>>>24]<<24|SBOX[s3>>>16&255]<<16|SBOX[s0>>>8&255]<<8|SBOX[255&s1])^keySchedule[ksRow++],t3=(SBOX[s3>>>24]<<24|SBOX[s0>>>16&255]<<16|SBOX[s1>>>8&255]<<8|SBOX[255&s2])^keySchedule[ksRow++],[fixup_uint32(t0),fixup_uint32(t1),fixup_uint32(t2),fixup_uint32(t3)]},exports.AES=AES}).call(this,require("buffer").Buffer)},{buffer:45}],20:[function(require,module){(function(Buffer){function StreamCipher(mode,key,iv,decrypt){if(!(this instanceof StreamCipher))return new StreamCipher(mode,key,iv);Transform.call(this),this._finID=Buffer.concat([iv,new Buffer([0,0,0,1])]),iv=Buffer.concat([iv,new Buffer([0,0,0,2])]),this._cipher=new aes.AES(key),this._prev=new Buffer(iv.length),this._cache=new Buffer(""),this._secCache=new Buffer(""),this._decrypt=decrypt,this._alen=0,this._len=0,iv.copy(this._prev),this._mode=mode;var h=new Buffer(4);h.fill(0),this._ghash=new GHASH(this._cipher.encryptBlock(h)),this._authTag=null,this._called=!1}function xorTest(a,b){var out=0;a.length!==b.length&&out++;for(var len=Math.min(a.length,b.length),i=-1;++i<len;)out+=a[i]^b[i];return out}var aes=require("./aes"),Transform=require("cipher-base"),inherits=require("inherits"),GHASH=require("./ghash"),xor=require("buffer-xor");inherits(StreamCipher,Transform),module.exports=StreamCipher,StreamCipher.prototype._update=function(chunk){if(!this._called&&this._alen){var rump=16-this._alen%16;16>rump&&(rump=new Buffer(rump),rump.fill(0),this._ghash.update(rump))}this._called=!0;var out=this._mode.encrypt(this,chunk);return this._ghash.update(this._decrypt?chunk:out),this._len+=chunk.length,out},StreamCipher.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var tag=xor(this._ghash["final"](8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt){if(xorTest(tag,this._authTag))throw new Error("Unsupported state or unable to authenticate data")}else this._authTag=tag;this._cipher.scrub()},StreamCipher.prototype.getAuthTag=function(){if(!this._decrypt&&Buffer.isBuffer(this._authTag))return this._authTag;throw new Error("Attempting to get auth tag in unsupported state")},StreamCipher.prototype.setAuthTag=function(tag){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=tag},StreamCipher.prototype.setAAD=function(buf){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(buf),this._alen+=buf.length}}).call(this,require("buffer").Buffer)},{"./aes":19,"./ghash":24,buffer:45,"buffer-xor":44,"cipher-base":47,inherits:93}],21:[function(require,module,exports){function getCiphers(){return Object.keys(modes)}var ciphers=require("./encrypter");exports.createCipher=exports.Cipher=ciphers.createCipher,exports.createCipheriv=exports.Cipheriv=ciphers.createCipheriv;var deciphers=require("./decrypter");exports.createDecipher=exports.Decipher=deciphers.createDecipher,exports.createDecipheriv=exports.Decipheriv=deciphers.createDecipheriv;var modes=require("./modes");exports.listCiphers=exports.getCiphers=getCiphers},{"./decrypter":22,"./encrypter":23,"./modes":25}],22:[function(require,module,exports){(function(Buffer){function Decipher(mode,key,iv){return this instanceof Decipher?(Transform.call(this),this._cache=new Splitter,this._last=void 0,this._cipher=new aes.AES(key),this._prev=new Buffer(iv.length),iv.copy(this._prev),this._mode=mode,void(this._autopadding=!0)):new Decipher(mode,key,iv)}function Splitter(){return this instanceof Splitter?void(this.cache=new Buffer("")):new Splitter}function unpad(last){for(var padded=last[15],i=-1;++i<padded;)if(last[i+(16-padded)]!==padded)throw new Error("unable to decrypt data");return 16!==padded?last.slice(0,16-padded):void 0}function createDecipheriv(suite,password,iv){var config=modes[suite.toLowerCase()];if(!config)throw new TypeError("invalid suite type");if("string"==typeof iv&&(iv=new Buffer(iv)),"string"==typeof password&&(password=new Buffer(password)),password.length!==config.key/8)throw new TypeError("invalid key length "+password.length);if(iv.length!==config.iv)throw new TypeError("invalid iv length "+iv.length);return"stream"===config.type?new StreamCipher(modelist[config.mode],password,iv,!0):"auth"===config.type?new AuthCipher(modelist[config.mode],password,iv,!0):new Decipher(modelist[config.mode],password,iv)}function createDecipher(suite,password){var config=modes[suite.toLowerCase()];if(!config)throw new TypeError("invalid suite type");var keys=ebtk(password,!1,config.key,config.iv);return createDecipheriv(suite,keys.key,keys.iv)}var aes=require("./aes"),Transform=require("cipher-base"),inherits=require("inherits"),modes=require("./modes"),StreamCipher=require("./streamCipher"),AuthCipher=require("./authCipher"),ebtk=require("evp_bytestokey");inherits(Decipher,Transform),Decipher.prototype._update=function(data){this._cache.add(data);for(var chunk,thing,out=[];chunk=this._cache.get(this._autopadding);)thing=this._mode.decrypt(this,chunk),out.push(thing);return Buffer.concat(out)},Decipher.prototype._final=function(){var chunk=this._cache.flush();if(this._autopadding)return unpad(this._mode.decrypt(this,chunk));if(chunk)throw new Error("data not multiple of block length")},Decipher.prototype.setAutoPadding=function(setTo){return this._autopadding=!!setTo,
  this},Splitter.prototype.add=function(data){this.cache=Buffer.concat([this.cache,data])},Splitter.prototype.get=function(autoPadding){var out;if(autoPadding){if(this.cache.length>16)return out=this.cache.slice(0,16),this.cache=this.cache.slice(16),out}else if(this.cache.length>=16)return out=this.cache.slice(0,16),this.cache=this.cache.slice(16),out;return null},Splitter.prototype.flush=function(){return this.cache.length?this.cache:void 0};var modelist={ECB:require("./modes/ecb"),CBC:require("./modes/cbc"),CFB:require("./modes/cfb"),CFB8:require("./modes/cfb8"),CFB1:require("./modes/cfb1"),OFB:require("./modes/ofb"),CTR:require("./modes/ctr"),GCM:require("./modes/ctr")};exports.createDecipher=createDecipher,exports.createDecipheriv=createDecipheriv}).call(this,require("buffer").Buffer)},{"./aes":19,"./authCipher":20,"./modes":25,"./modes/cbc":26,"./modes/cfb":27,"./modes/cfb1":28,"./modes/cfb8":29,"./modes/ctr":30,"./modes/ecb":31,"./modes/ofb":32,"./streamCipher":33,buffer:45,"cipher-base":47,evp_bytestokey:83,inherits:93}],23:[function(require,module,exports){(function(Buffer){function Cipher(mode,key,iv){return this instanceof Cipher?(Transform.call(this),this._cache=new Splitter,this._cipher=new aes.AES(key),this._prev=new Buffer(iv.length),iv.copy(this._prev),this._mode=mode,void(this._autopadding=!0)):new Cipher(mode,key,iv)}function Splitter(){return this instanceof Splitter?void(this.cache=new Buffer("")):new Splitter}function createCipheriv(suite,password,iv){var config=modes[suite.toLowerCase()];if(!config)throw new TypeError("invalid suite type");if("string"==typeof iv&&(iv=new Buffer(iv)),"string"==typeof password&&(password=new Buffer(password)),password.length!==config.key/8)throw new TypeError("invalid key length "+password.length);if(iv.length!==config.iv)throw new TypeError("invalid iv length "+iv.length);return"stream"===config.type?new StreamCipher(modelist[config.mode],password,iv):"auth"===config.type?new AuthCipher(modelist[config.mode],password,iv):new Cipher(modelist[config.mode],password,iv)}function createCipher(suite,password){var config=modes[suite.toLowerCase()];if(!config)throw new TypeError("invalid suite type");var keys=ebtk(password,!1,config.key,config.iv);return createCipheriv(suite,keys.key,keys.iv)}var aes=require("./aes"),Transform=require("cipher-base"),inherits=require("inherits"),modes=require("./modes"),ebtk=require("evp_bytestokey"),StreamCipher=require("./streamCipher"),AuthCipher=require("./authCipher");inherits(Cipher,Transform),Cipher.prototype._update=function(data){this._cache.add(data);for(var chunk,thing,out=[];chunk=this._cache.get();)thing=this._mode.encrypt(this,chunk),out.push(thing);return Buffer.concat(out)},Cipher.prototype._final=function(){var chunk=this._cache.flush();if(this._autopadding)return chunk=this._mode.encrypt(this,chunk),this._cipher.scrub(),chunk;if("10101010101010101010101010101010"!==chunk.toString("hex"))throw this._cipher.scrub(),new Error("data not multiple of block length")},Cipher.prototype.setAutoPadding=function(setTo){return this._autopadding=!!setTo,this},Splitter.prototype.add=function(data){this.cache=Buffer.concat([this.cache,data])},Splitter.prototype.get=function(){if(this.cache.length>15){var out=this.cache.slice(0,16);return this.cache=this.cache.slice(16),out}return null},Splitter.prototype.flush=function(){for(var len=16-this.cache.length,padBuff=new Buffer(len),i=-1;++i<len;)padBuff.writeUInt8(len,i);var out=Buffer.concat([this.cache,padBuff]);return out};var modelist={ECB:require("./modes/ecb"),CBC:require("./modes/cbc"),CFB:require("./modes/cfb"),CFB8:require("./modes/cfb8"),CFB1:require("./modes/cfb1"),OFB:require("./modes/ofb"),CTR:require("./modes/ctr"),GCM:require("./modes/ctr")};exports.createCipheriv=createCipheriv,exports.createCipher=createCipher}).call(this,require("buffer").Buffer)},{"./aes":19,"./authCipher":20,"./modes":25,"./modes/cbc":26,"./modes/cfb":27,"./modes/cfb1":28,"./modes/cfb8":29,"./modes/ctr":30,"./modes/ecb":31,"./modes/ofb":32,"./streamCipher":33,buffer:45,"cipher-base":47,evp_bytestokey:83,inherits:93}],24:[function(require,module){(function(Buffer){function GHASH(key){this.h=key,this.state=new Buffer(16),this.state.fill(0),this.cache=new Buffer("")}function toArray(buf){return[buf.readUInt32BE(0),buf.readUInt32BE(4),buf.readUInt32BE(8),buf.readUInt32BE(12)]}function fromArray(out){out=out.map(fixup_uint32);var buf=new Buffer(16);return buf.writeUInt32BE(out[0],0),buf.writeUInt32BE(out[1],4),buf.writeUInt32BE(out[2],8),buf.writeUInt32BE(out[3],12),buf}function fixup_uint32(x){var ret,x_pos;return ret=x>uint_max||0>x?(x_pos=Math.abs(x)%uint_max,0>x?uint_max-x_pos:x_pos):x}function xor(a,b){return[a[0]^b[0],a[1]^b[1],a[2]^b[2],a[3]^b[3]]}var zeros=new Buffer(16);zeros.fill(0),module.exports=GHASH,GHASH.prototype.ghash=function(block){for(var i=-1;++i<block.length;)this.state[i]^=block[i];this._multiply()},GHASH.prototype._multiply=function(){for(var j,xi,lsb_Vi,Vi=toArray(this.h),Zi=[0,0,0,0],i=-1;++i<128;){for(xi=0!==(this.state[~~(i/8)]&1<<7-i%8),xi&&(Zi=xor(Zi,Vi)),lsb_Vi=0!==(1&Vi[3]),j=3;j>0;j--)Vi[j]=Vi[j]>>>1|(1&Vi[j-1])<<31;Vi[0]=Vi[0]>>>1,lsb_Vi&&(Vi[0]=Vi[0]^225<<24)}this.state=fromArray(Zi)},GHASH.prototype.update=function(buf){this.cache=Buffer.concat([this.cache,buf]);for(var chunk;this.cache.length>=16;)chunk=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(chunk)},GHASH.prototype["final"]=function(abl,bl){return this.cache.length&&this.ghash(Buffer.concat([this.cache,zeros],16)),this.ghash(fromArray([0,abl,0,bl])),this.state};var uint_max=Math.pow(2,32)}).call(this,require("buffer").Buffer)},{buffer:45}],25:[function(require,module,exports){exports["aes-128-ecb"]={cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},exports["aes-192-ecb"]={cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},exports["aes-256-ecb"]={cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},exports["aes-128-cbc"]={cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},exports["aes-192-cbc"]={cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},exports["aes-256-cbc"]={cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},exports.aes128=exports["aes-128-cbc"],exports.aes192=exports["aes-192-cbc"],exports.aes256=exports["aes-256-cbc"],exports["aes-128-cfb"]={cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},exports["aes-192-cfb"]={cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},exports["aes-256-cfb"]={cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"},exports["aes-128-cfb8"]={cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},exports["aes-192-cfb8"]={cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},exports["aes-256-cfb8"]={cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},exports["aes-128-cfb1"]={cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},exports["aes-192-cfb1"]={cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},exports["aes-256-cfb1"]={cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},exports["aes-128-ofb"]={cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},exports["aes-192-ofb"]={cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},exports["aes-256-ofb"]={cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},exports["aes-128-ctr"]={cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},exports["aes-192-ctr"]={cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},exports["aes-256-ctr"]={cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},exports["aes-128-gcm"]={cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},exports["aes-192-gcm"]={cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},exports["aes-256-gcm"]={cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}},{}],26:[function(require,module,exports){var xor=require("buffer-xor");exports.encrypt=function(self,block){var data=xor(block,self._prev);return self._prev=self._cipher.encryptBlock(data),self._prev},exports.decrypt=function(self,block){var pad=self._prev;self._prev=block;var out=self._cipher.decryptBlock(block);return xor(out,pad)}},{"buffer-xor":44}],27:[function(require,module,exports){(function(Buffer){function encryptStart(self,data,decrypt){var len=data.length,out=xor(data,self._cache);return self._cache=self._cache.slice(len),self._prev=Buffer.concat([self._prev,decrypt?data:out]),out}var xor=require("buffer-xor");exports.encrypt=function(self,data,decrypt){for(var len,out=new Buffer("");data.length;){if(0===self._cache.length&&(self._cache=self._cipher.encryptBlock(self._prev),self._prev=new Buffer("")),!(self._cache.length<=data.length)){out=Buffer.concat([out,encryptStart(self,data,decrypt)]);break}len=self._cache.length,out=Buffer.concat([out,encryptStart(self,data.slice(0,len),decrypt)]),data=data.slice(len)}return out}}).call(this,require("buffer").Buffer)},{buffer:45,"buffer-xor":44}],28:[function(require,module,exports){(function(Buffer){function encryptByte(self,byteParam,decrypt){for(var pad,bit,value,i=-1,len=8,out=0;++i<len;)pad=self._cipher.encryptBlock(self._prev),bit=byteParam&1<<7-i?128:0,value=pad[0]^bit,out+=(128&value)>>i%8,self._prev=shiftIn(self._prev,decrypt?bit:value);return out}function shiftIn(buffer,value){var len=buffer.length,i=-1,out=new Buffer(buffer.length);for(buffer=Buffer.concat([buffer,new Buffer([value])]);++i<len;)out[i]=buffer[i]<<1|buffer[i+1]>>7;return out}exports.encrypt=function(self,chunk,decrypt){for(var len=chunk.length,out=new Buffer(len),i=-1;++i<len;)out[i]=encryptByte(self,chunk[i],decrypt);return out}}).call(this,require("buffer").Buffer)},{buffer:45}],29:[function(require,module,exports){(function(Buffer){function encryptByte(self,byteParam,decrypt){var pad=self._cipher.encryptBlock(self._prev),out=pad[0]^byteParam;return self._prev=Buffer.concat([self._prev.slice(1),new Buffer([decrypt?byteParam:out])]),out}exports.encrypt=function(self,chunk,decrypt){for(var len=chunk.length,out=new Buffer(len),i=-1;++i<len;)out[i]=encryptByte(self,chunk[i],decrypt);return out}}).call(this,require("buffer").Buffer)},{buffer:45}],30:[function(require,module,exports){(function(Buffer){function incr32(iv){for(var item,len=iv.length;len--;){if(item=iv.readUInt8(len),255!==item){item++,iv.writeUInt8(item,len);break}iv.writeUInt8(0,len)}}function getBlock(self){var out=self._cipher.encryptBlock(self._prev);return incr32(self._prev),out}var xor=require("buffer-xor");exports.encrypt=function(self,chunk){for(;self._cache.length<chunk.length;)self._cache=Buffer.concat([self._cache,getBlock(self)]);var pad=self._cache.slice(0,chunk.length);return self._cache=self._cache.slice(chunk.length),xor(chunk,pad)}}).call(this,require("buffer").Buffer)},{buffer:45,"buffer-xor":44}],31:[function(require,module,exports){exports.encrypt=function(self,block){return self._cipher.encryptBlock(block)},exports.decrypt=function(self,block){return self._cipher.decryptBlock(block)}},{}],32:[function(require,module,exports){(function(Buffer){function getBlock(self){return self._prev=self._cipher.encryptBlock(self._prev),self._prev}var xor=require("buffer-xor");exports.encrypt=function(self,chunk){for(;self._cache.length<chunk.length;)self._cache=Buffer.concat([self._cache,getBlock(self)]);var pad=self._cache.slice(0,chunk.length);return self._cache=self._cache.slice(chunk.length),xor(chunk,pad)}}).call(this,require("buffer").Buffer)},{buffer:45,"buffer-xor":44}],33:[function(require,module){(function(Buffer){function StreamCipher(mode,key,iv,decrypt){return this instanceof StreamCipher?(Transform.call(this),this._cipher=new aes.AES(key),this._prev=new Buffer(iv.length),this._cache=new Buffer(""),this._secCache=new Buffer(""),this._decrypt=decrypt,iv.copy(this._prev),void(this._mode=mode)):new StreamCipher(mode,key,iv)}var aes=require("./aes"),Transform=require("cipher-base"),inherits=require("inherits");inherits(StreamCipher,Transform),module.exports=StreamCipher,StreamCipher.prototype._update=function(chunk){return this._mode.encrypt(this,chunk,this._decrypt)},StreamCipher.prototype._final=function(){this._cipher.scrub()}}).call(this,require("buffer").Buffer)},{"./aes":19,buffer:45,"cipher-base":47,inherits:93}],34:[function(require,module,exports){function createCipher(suite,password){var keyLen,ivLen;if(suite=suite.toLowerCase(),aesModes[suite])keyLen=aesModes[suite].key,ivLen=aesModes[suite].iv;else{if(!desModes[suite])throw new TypeError("invalid suite type");keyLen=8*desModes[suite].key,ivLen=desModes[suite].iv}var keys=ebtk(password,!1,keyLen,ivLen);return createCipheriv(suite,keys.key,keys.iv)}function createDecipher(suite,password){var keyLen,ivLen;if(suite=suite.toLowerCase(),aesModes[suite])keyLen=aesModes[suite].key,ivLen=aesModes[suite].iv;else{if(!desModes[suite])throw new TypeError("invalid suite type");keyLen=8*desModes[suite].key,ivLen=desModes[suite].iv}var keys=ebtk(password,!1,keyLen,ivLen);return createDecipheriv(suite,keys.key,keys.iv)}function createCipheriv(suite,key,iv){if(suite=suite.toLowerCase(),aesModes[suite])return aes.createCipheriv(suite,key,iv);if(desModes[suite])return new DES({key:key,iv:iv,mode:suite});throw new TypeError("invalid suite type")}function createDecipheriv(suite,key,iv){if(suite=suite.toLowerCase(),aesModes[suite])return aes.createDecipheriv(suite,key,iv);if(desModes[suite])return new DES({key:key,iv:iv,mode:suite,decrypt:!0});throw new TypeError("invalid suite type")}function getCiphers(){return Object.keys(desModes).concat(aes.getCiphers())}var ebtk=require("evp_bytestokey"),aes=require("browserify-aes/browser"),DES=require("browserify-des"),desModes=require("browserify-des/modes"),aesModes=require("browserify-aes/modes");exports.createCipher=exports.Cipher=createCipher,exports.createCipheriv=exports.Cipheriv=createCipheriv,exports.createDecipher=exports.Decipher=createDecipher,exports.createDecipheriv=exports.Decipheriv=createDecipheriv,exports.listCiphers=exports.getCiphers=getCiphers},{"browserify-aes/browser":21,"browserify-aes/modes":25,"browserify-des":35,"browserify-des/modes":36,evp_bytestokey:83}],35:[function(require,module){(function(Buffer){function DES(opts){CipherBase.call(this);var type,modeName=opts.mode.toLowerCase(),mode=modes[modeName];type=opts.decrypt?"decrypt":"encrypt";var key=opts.key;("des-ede"===modeName||"des-ede-cbc"===modeName)&&(key=Buffer.concat([key,key.slice(0,8)]));var iv=opts.iv;this._des=mode.create({key:key,iv:iv,type:type})}var CipherBase=require("cipher-base"),des=require("des.js"),inherits=require("inherits"),modes={"des-ede3-cbc":des.CBC.instantiate(des.EDE),"des-ede3":des.EDE,"des-ede-cbc":des.CBC.instantiate(des.EDE),"des-ede":des.EDE,"des-cbc":des.CBC.instantiate(des.DES),"des-ecb":des.DES};modes.des=modes["des-cbc"],modes.des3=modes["des-ede3-cbc"],module.exports=DES,inherits(DES,CipherBase),DES.prototype._update=function(data){return new Buffer(this._des.update(data))},DES.prototype._final=function(){return new Buffer(this._des["final"]())}}).call(this,require("buffer").Buffer)},{buffer:45,"cipher-base":47,"des.js":55,inherits:93}],36:[function(require,module,exports){exports["des-ecb"]={key:8,iv:0},exports["des-cbc"]=exports.des={key:8,iv:8},exports["des-ede3-cbc"]=exports.des3={key:24,iv:8},exports["des-ede3"]={key:24,iv:0},exports["des-ede-cbc"]={key:16,iv:8},exports["des-ede"]={key:16,iv:0}},{}],37:[function(require,module){(function(Buffer){function blind(priv){var r=getr(priv),blinder=r.toRed(bn.mont(priv.modulus)).redPow(new bn(priv.publicExponent)).fromRed();return{blinder:blinder,unblinder:r.invm(priv.modulus)}}function crt(msg,priv){var blinds=blind(priv),len=priv.modulus.byteLength(),blinded=(bn.mont(priv.modulus),new bn(msg).mul(blinds.blinder).umod(priv.modulus)),c1=blinded.toRed(bn.mont(priv.prime1)),c2=blinded.toRed(bn.mont(priv.prime2)),qinv=priv.coefficient,p=priv.prime1,q=priv.prime2,m1=c1.redPow(priv.exponent1),m2=c2.redPow(priv.exponent2);m1=m1.fromRed(),m2=m2.fromRed();var h=m1.isub(m2).imul(qinv).umod(p);return h.imul(q),m2.iadd(h),new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(!1,len))}function getr(priv){for(var len=priv.modulus.byteLength(),r=new bn(randomBytes(len));r.cmp(priv.modulus)>=0||!r.umod(priv.prime1)||!r.umod(priv.prime2);)r=new bn(randomBytes(len));return r}var bn=require("bn.js"),randomBytes=require("randombytes");module.exports=crt,crt.getr=getr}).call(this,require("buffer").Buffer)},{"bn.js":16,buffer:45,randombytes:116}],38:[function(require,module,exports){(function(Buffer){"use strict";exports["RSA-SHA224"]=exports.sha224WithRSAEncryption={sign:"rsa",hash:"sha224",id:new Buffer("302d300d06096086480165030402040500041c","hex")},exports["RSA-SHA256"]=exports.sha256WithRSAEncryption={sign:"rsa",hash:"sha256",id:new Buffer("3031300d060960864801650304020105000420","hex")},exports["RSA-SHA384"]=exports.sha384WithRSAEncryption={sign:"rsa",hash:"sha384",id:new Buffer("3041300d060960864801650304020205000430","hex")},exports["RSA-SHA512"]=exports.sha512WithRSAEncryption={sign:"rsa",hash:"sha512",id:new Buffer("3051300d060960864801650304020305000440","hex")},exports["RSA-SHA1"]={sign:"rsa",hash:"sha1",id:new Buffer("3021300906052b0e03021a05000414","hex")},exports["ecdsa-with-SHA1"]={sign:"ecdsa",hash:"sha1",id:new Buffer("","hex")},exports.DSA=exports["DSA-SHA1"]=exports["DSA-SHA"]={sign:"dsa",hash:"sha1",id:new Buffer("","hex")},exports["DSA-SHA224"]=exports["DSA-WITH-SHA224"]={sign:"dsa",hash:"sha224",id:new Buffer("","hex")},exports["DSA-SHA256"]=exports["DSA-WITH-SHA256"]={sign:"dsa",hash:"sha256",id:new Buffer("","hex")},exports["DSA-SHA384"]=exports["DSA-WITH-SHA384"]={sign:"dsa",hash:"sha384",id:new Buffer("","hex")},exports["DSA-SHA512"]=exports["DSA-WITH-SHA512"]={sign:"dsa",hash:"sha512",id:new Buffer("","hex")},exports["DSA-RIPEMD160"]={sign:"dsa",hash:"rmd160",id:new Buffer("","hex")},exports["RSA-RIPEMD160"]=exports.ripemd160WithRSA={sign:"rsa",hash:"rmd160",id:new Buffer("3021300906052b2403020105000414","hex")},exports["RSA-MD5"]=exports.md5WithRSAEncryption={sign:"rsa",hash:"md5",id:new Buffer("3020300c06082a864886f70d020505000410","hex")}}).call(this,require("buffer").Buffer)},{buffer:45}],39:[function(require,module){(function(Buffer){function Sign(algorithm){stream.Writable.call(this);var data=algos[algorithm];if(!data)throw new Error("Unknown message digest");this._hashType=data.hash,this._hash=createHash(data.hash),this._tag=data.id,this._signType=data.sign}function Verify(algorithm){stream.Writable.call(this);var data=algos[algorithm];if(!data)throw new Error("Unknown message digest");this._hash=createHash(data.hash),this._tag=data.id,this._signType=data.sign}function createSign(algorithm){return new Sign(algorithm)}function createVerify(algorithm){return new Verify(algorithm)}var _algos=require("./algos"),createHash=require("create-hash"),inherits=require("inherits"),sign=require("./sign"),stream=require("stream"),verify=require("./verify"),algos={};Object.keys(_algos).forEach(function(key){algos[key]=algos[key.toLowerCase()]=_algos[key]}),inherits(Sign,stream.Writable),Sign.prototype._write=function(data,_,done){this._hash.update(data),done()},Sign.prototype.update=function(data,enc){return"string"==typeof data&&(data=new Buffer(data,enc)),this._hash.update(data),this},Sign.prototype.sign=function(key,enc){this.end();var hash=this._hash.digest(),sig=sign(Buffer.concat([this._tag,hash]),key,this._hashType,this._signType);return enc?sig.toString(enc):sig},inherits(Verify,stream.Writable),Verify.prototype._write=function(data,_,done){this._hash.update(data),done()},Verify.prototype.update=function(data,enc){return"string"==typeof data&&(data=new Buffer(data,enc)),this._hash.update(data),this},Verify.prototype.verify=function(key,sig,enc){"string"==typeof sig&&(sig=new Buffer(sig,enc)),this.end();var hash=this._hash.digest();return verify(sig,Buffer.concat([this._tag,hash]),key,this._signType)},module.exports={Sign:createSign,Verify:createVerify,createSign:createSign,createVerify:createVerify}}).call(this,require("buffer").Buffer)},{"./algos":38,"./sign":41,"./verify":42,buffer:45,"create-hash":50,inherits:93,stream:137}],40:[function(require,module,exports){"use strict";exports["1.3.132.0.10"]="secp256k1",exports["1.3.132.0.33"]="p224",exports["1.2.840.10045.3.1.1"]="p192",exports["1.2.840.10045.3.1.7"]="p256",exports["1.3.132.0.34"]="p384",exports["1.3.132.0.35"]="p521"},{}],41:[function(require,module){(function(Buffer){function sign(hash,key,hashType,signType){var priv=parseKeys(key);if(priv.curve){if("ecdsa"!==signType)throw new Error("wrong private key type");return ecSign(hash,priv)}if("dsa"===priv.type){if("dsa"!==signType)throw new Error("wrong private key type");return dsaSign(hash,priv,hashType)}if("rsa"!==signType)throw new Error("wrong private key type");for(var len=priv.modulus.byteLength(),pad=[0,1];hash.length+pad.length+1<len;)pad.push(255);pad.push(0);for(var i=-1;++i<hash.length;)pad.push(hash[i]);var out=crt(pad,priv);return out}function ecSign(hash,priv){var curveId=curves[priv.curve.join(".")];if(!curveId)throw new Error("unknown curve "+priv.curve.join("."));var curve=new EC(curveId),key=curve.genKeyPair();key._importPrivate(priv.privateKey);var out=key.sign(hash);return new Buffer(out.toDER())}function dsaSign(hash,priv,algo){for(var k,x=priv.params.priv_key,p=priv.params.p,q=priv.params.q,g=priv.params.g,r=new BN(0),H=bits2int(hash,q).mod(q),s=!1,kv=getKey(x,q,hash,algo);s===!1;)k=makeKey(q,kv,algo),r=makeR(g,k,p,q),s=k.invm(q).imul(H.add(x.mul(r))).mod(q),s.cmpn(0)||(s=!1,r=new BN(0));return toDER(r,s)}function toDER(r,s){r=r.toArray(),s=s.toArray(),128&r[0]&&(r=[0].concat(r)),128&s[0]&&(s=[0].concat(s));var total=r.length+s.length+4,res=[48,total,2,r.length];return res=res.concat(r,[2,s.length],s),new Buffer(res)}function getKey(x,q,hash,algo){if(x=new Buffer(x.toArray()),x.length<q.byteLength()){var zeros=new Buffer(q.byteLength()-x.length);zeros.fill(0),x=Buffer.concat([zeros,x])}var hlen=hash.length,hbits=bits2octets(hash,q),v=new Buffer(hlen);v.fill(1);var k=new Buffer(hlen);return k.fill(0),k=createHmac(algo,k).update(v).update(new Buffer([0])).update(x).update(hbits).digest(),v=createHmac(algo,k).update(v).digest(),k=createHmac(algo,k).update(v).update(new Buffer([1])).update(x).update(hbits).digest(),v=createHmac(algo,k).update(v).digest(),{k:k,v:v}}function bits2int(obits,q){var bits=new BN(obits),shift=(obits.length<<3)-q.bitLength();return shift>0&&bits.ishrn(shift),bits}function bits2octets(bits,q){bits=bits2int(bits,q),bits=bits.mod(q);var out=new Buffer(bits.toArray());if(out.length<q.byteLength()){var zeros=new Buffer(q.byteLength()-out.length);zeros.fill(0),out=Buffer.concat([zeros,out])}return out}function makeKey(q,kv,algo){var t,k;do{for(t=new Buffer("");8*t.length<q.bitLength();)kv.v=createHmac(algo,kv.k).update(kv.v).digest(),t=Buffer.concat([t,kv.v]);k=bits2int(t,q),kv.k=createHmac(algo,kv.k).update(kv.v).update(new Buffer([0])).digest(),kv.v=createHmac(algo,kv.k).update(kv.v).digest()}while(-1!==k.cmp(q));return k}function makeR(g,k,p,q){return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)}var createHmac=require("create-hmac"),crt=require("browserify-rsa"),curves=require("./curves"),elliptic=require("elliptic"),parseKeys=require("parse-asn1"),BN=require("bn.js"),EC=elliptic.ec;module.exports=sign,module.exports.getKey=getKey,module.exports.makeKey=makeKey}).call(this,require("buffer").Buffer)},{"./curves":40,"bn.js":16,"browserify-rsa":37,buffer:45,"create-hmac":53,elliptic:65,"parse-asn1":101}],42:[function(require,module){(function(Buffer){function verify(sig,hash,key,signType){var pub=parseKeys(key);if("ec"===pub.type){if("ecdsa"!==signType)throw new Error("wrong public key type");return ecVerify(sig,hash,pub)}if("dsa"===pub.type){if("dsa"!==signType)throw new Error("wrong public key type");return dsaVerify(sig,hash,pub)}if("rsa"!==signType)throw new Error("wrong public key type");for(var len=pub.modulus.byteLength(),pad=[1],padNum=0;hash.length+pad.length+2<len;)pad.push(255),padNum++;pad.push(0);for(var i=-1;++i<hash.length;)pad.push(hash[i]);pad=new Buffer(pad);var red=BN.mont(pub.modulus);sig=new BN(sig).toRed(red),sig=sig.redPow(new BN(pub.publicExponent)),sig=new Buffer(sig.fromRed().toArray());var out=0;for(8>padNum&&(out=1),len=Math.min(sig.length,pad.length),sig.length!==pad.length&&(out=1),i=-1;++i<len;)out|=sig[i]^pad[i];return 0===out}function ecVerify(sig,hash,pub){var curveId=curves[pub.data.algorithm.curve.join(".")];if(!curveId)throw new Error("unknown curve "+pub.data.algorithm.curve.join("."));var curve=new EC(curveId),pubkey=pub.data.subjectPrivateKey.data;return curve.verify(hash,sig,pubkey)}function dsaVerify(sig,hash,pub){var p=pub.data.p,q=pub.data.q,g=pub.data.g,y=pub.data.pub_key,unpacked=parseKeys.signature.decode(sig,"der"),s=unpacked.s,r=unpacked.r;checkValue(s,q),checkValue(r,q);var montp=BN.mont(p),w=s.invm(q),v=g.toRed(montp).redPow(new BN(hash).mul(w).mod(q)).fromRed().mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()).mod(p).mod(q);return!v.cmp(r)}function checkValue(b,q){if(b.cmpn(0)<=0)throw new Error("invalid sig");if(b.cmp(q)>=q)throw new Error("invalid sig")}var curves=require("./curves"),elliptic=require("elliptic"),parseKeys=require("parse-asn1"),BN=require("bn.js"),EC=elliptic.ec;module.exports=verify}).call(this,require("buffer").Buffer)},{"./curves":40,"bn.js":16,buffer:45,elliptic:65,"parse-asn1":101}],43:[function(require,module,exports){(function(global){"use strict";var buffer=require("buffer"),Buffer=buffer.Buffer,SlowBuffer=buffer.SlowBuffer,MAX_LEN=buffer.kMaxLength||2147483647;exports.alloc=function(size,fill,encoding){if("function"==typeof Buffer.alloc)return Buffer.alloc(size,fill,encoding);if("number"==typeof encoding)throw new TypeError("encoding must not be number");if("number"!=typeof size)throw new TypeError("size must be a number");if(size>MAX_LEN)throw new RangeError("size is too large");var enc=encoding,_fill=fill;void 0===_fill&&(enc=void 0,_fill=0);var buf=new Buffer(size);if("string"==typeof _fill)for(var fillBuf=new Buffer(_fill,enc),flen=fillBuf.length,i=-1;++i<size;)buf[i]=fillBuf[i%flen];else buf.fill(_fill);return buf},exports.allocUnsafe=function(size){if("function"==typeof Buffer.allocUnsafe)return Buffer.allocUnsafe(size);if("number"!=typeof size)throw new TypeError("size must be a number");if(size>MAX_LEN)throw new RangeError("size is too large");return new Buffer(size)},exports.from=function(value,encodingOrOffset,length){if("function"==typeof Buffer.from&&(!global.Uint8Array||Uint8Array.from!==Buffer.from))return Buffer.from(value,encodingOrOffset,length);if("number"==typeof value)throw new TypeError('"value" argument must not be a number');if("string"==typeof value)return new Buffer(value,encodingOrOffset);if("undefined"!=typeof ArrayBuffer&&value instanceof ArrayBuffer){var offset=encodingOrOffset;if(1===arguments.length)return new Buffer(value);"undefined"==typeof offset&&(offset=0);var len=length;if("undefined"==typeof len&&(len=value.byteLength-offset),offset>=value.byteLength)throw new RangeError("'offset' is out of bounds");if(len>value.byteLength-offset)throw new RangeError("'length' is out of bounds");return new Buffer(value.slice(offset,offset+len))}if(Buffer.isBuffer(value)){var out=new Buffer(value.length);return value.copy(out,0,0,value.length),out}if(value){if(Array.isArray(value)||"undefined"!=typeof ArrayBuffer&&value.buffer instanceof ArrayBuffer||"length"in value)return new Buffer(value);if("Buffer"===value.type&&Array.isArray(value.data))return new Buffer(value.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},exports.allocUnsafeSlow=function(size){if("function"==typeof Buffer.allocUnsafeSlow)return Buffer.allocUnsafeSlow(size);if("number"!=typeof size)throw new TypeError("size must be a number");if(size>=MAX_LEN)throw new RangeError("size is too large");return new SlowBuffer(size)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{buffer:45}],44:[function(require,module){(function(Buffer){module.exports=function(a,b){for(var length=Math.min(a.length,b.length),buffer=new Buffer(length),i=0;length>i;++i)buffer[i]=a[i]^b[i];return buffer}}).call(this,require("buffer").Buffer)},{buffer:45}],45:[function(require,module,exports){(function(global){"use strict";function typedArraySupport(){try{var arr=new Uint8Array(1);return arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===arr.foo()&&"function"==typeof arr.subarray&&0===arr.subarray(1,1).byteLength}catch(e){return!1}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(that,length){if(kMaxLength()<length)throw new RangeError("Invalid typed array length");return Buffer.TYPED_ARRAY_SUPPORT?(that=new Uint8Array(length),that.__proto__=Buffer.prototype):(null===that&&(that=new Buffer(length)),that.length=length),that}function Buffer(arg,encodingOrOffset,length){if(!(Buffer.TYPED_ARRAY_SUPPORT||this instanceof Buffer))return new Buffer(arg,encodingOrOffset,length);if("number"==typeof arg){if("string"==typeof encodingOrOffset)throw new Error("If encoding is specified then the first argument must be a string");return allocUnsafe(this,arg)}return from(this,arg,encodingOrOffset,length)}function from(that,value,encodingOrOffset,length){if("number"==typeof value)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&value instanceof ArrayBuffer?fromArrayBuffer(that,value,encodingOrOffset,length):"string"==typeof value?fromString(that,value,encodingOrOffset):fromObject(that,value)}function assertSize(size){if("number"!=typeof size)throw new TypeError('"size" argument must be a number');if(0>size)throw new RangeError('"size" argument must not be negative')}function alloc(that,size,fill,encoding){return assertSize(size),0>=size?createBuffer(that,size):void 0!==fill?"string"==typeof encoding?createBuffer(that,size).fill(fill,encoding):createBuffer(that,size).fill(fill):createBuffer(that,size)}function allocUnsafe(that,size){if(assertSize(size),that=createBuffer(that,0>size?0:0|checked(size)),!Buffer.TYPED_ARRAY_SUPPORT)for(var i=0;size>i;++i)that[i]=0;return that}function fromString(that,string,encoding){if(("string"!=typeof encoding||""===encoding)&&(encoding="utf8"),!Buffer.isEncoding(encoding))throw new TypeError('"encoding" must be a valid string encoding');var length=0|byteLength(string,encoding);that=createBuffer(that,length);var actual=that.write(string,encoding);return actual!==length&&(that=that.slice(0,actual)),that}function fromArrayLike(that,array){var length=array.length<0?0:0|checked(array.length);that=createBuffer(that,length);for(var i=0;length>i;i+=1)that[i]=255&array[i];return that}function fromArrayBuffer(that,array,byteOffset,length){if(array.byteLength,0>byteOffset||array.byteLength<byteOffset)throw new RangeError("'offset' is out of bounds");if(array.byteLength<byteOffset+(length||0))throw new RangeError("'length' is out of bounds");return array=void 0===byteOffset&&void 0===length?new Uint8Array(array):void 0===length?new Uint8Array(array,byteOffset):new Uint8Array(array,byteOffset,length),Buffer.TYPED_ARRAY_SUPPORT?(that=array,that.__proto__=Buffer.prototype):that=fromArrayLike(that,array),that}function fromObject(that,obj){if(Buffer.isBuffer(obj)){var len=0|checked(obj.length);return that=createBuffer(that,len),0===that.length?that:(obj.copy(that,0,0,len),that)}if(obj){if("undefined"!=typeof ArrayBuffer&&obj.buffer instanceof ArrayBuffer||"length"in obj)return"number"!=typeof obj.length||isnan(obj.length)?createBuffer(that,0):fromArrayLike(that,obj);if("Buffer"===obj.type&&isArray(obj.data))return fromArrayLike(that,obj.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(length){if(length>=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|length}function SlowBuffer(length){return+length!=length&&(length=0),
  Buffer.alloc(+length)}function byteLength(string,encoding){if(Buffer.isBuffer(string))return string.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(string)||string instanceof ArrayBuffer))return string.byteLength;"string"!=typeof string&&(string=""+string);var len=string.length;if(0===len)return 0;for(var loweredCase=!1;;)switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":case void 0:return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*len;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase(),loweredCase=!0}}function slowToString(encoding,start,end){var loweredCase=!1;if((void 0===start||0>start)&&(start=0),start>this.length)return"";if((void 0===end||end>this.length)&&(end=this.length),0>=end)return"";if(end>>>=0,start>>>=0,start>=end)return"";for(encoding||(encoding="utf8");;)switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase(),loweredCase=!0}}function swap(b,n,m){var i=b[n];b[n]=b[m],b[m]=i}function bidirectionalIndexOf(buffer,val,byteOffset,encoding,dir){if(0===buffer.length)return-1;if("string"==typeof byteOffset?(encoding=byteOffset,byteOffset=0):byteOffset>2147483647?byteOffset=2147483647:-2147483648>byteOffset&&(byteOffset=-2147483648),byteOffset=+byteOffset,isNaN(byteOffset)&&(byteOffset=dir?0:buffer.length-1),0>byteOffset&&(byteOffset=buffer.length+byteOffset),byteOffset>=buffer.length){if(dir)return-1;byteOffset=buffer.length-1}else if(0>byteOffset){if(!dir)return-1;byteOffset=0}if("string"==typeof val&&(val=Buffer.from(val,encoding)),Buffer.isBuffer(val))return 0===val.length?-1:arrayIndexOf(buffer,val,byteOffset,encoding,dir);if("number"==typeof val)return val=255&val,Buffer.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?dir?Uint8Array.prototype.indexOf.call(buffer,val,byteOffset):Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset):arrayIndexOf(buffer,[val],byteOffset,encoding,dir);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){function read(buf,i){return 1===indexSize?buf[i]:buf.readUInt16BE(i*indexSize)}var indexSize=1,arrLength=arr.length,valLength=val.length;if(void 0!==encoding&&(encoding=String(encoding).toLowerCase(),"ucs2"===encoding||"ucs-2"===encoding||"utf16le"===encoding||"utf-16le"===encoding)){if(arr.length<2||val.length<2)return-1;indexSize=2,arrLength/=2,valLength/=2,byteOffset/=2}var i;if(dir){var foundIndex=-1;for(i=byteOffset;arrLength>i;i++)if(read(arr,i)===read(val,-1===foundIndex?0:i-foundIndex)){if(-1===foundIndex&&(foundIndex=i),i-foundIndex+1===valLength)return foundIndex*indexSize}else-1!==foundIndex&&(i-=i-foundIndex),foundIndex=-1}else for(byteOffset+valLength>arrLength&&(byteOffset=arrLength-valLength),i=byteOffset;i>=0;i--){for(var found=!0,j=0;valLength>j;j++)if(read(arr,i+j)!==read(val,j)){found=!1;break}if(found)return i}return-1}function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;length?(length=Number(length),length>remaining&&(length=remaining)):length=remaining;var strLen=string.length;if(strLen%2!==0)throw new TypeError("Invalid hex string");length>strLen/2&&(length=strLen/2);for(var i=0;length>i;++i){var parsed=parseInt(string.substr(2*i,2),16);if(isNaN(parsed))return i;buf[offset+i]=parsed}return i}function utf8Write(buf,string,offset,length){return blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length)}function asciiWrite(buf,string,offset,length){return blitBuffer(asciiToBytes(string),buf,offset,length)}function latin1Write(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){return blitBuffer(base64ToBytes(string),buf,offset,length)}function ucs2Write(buf,string,offset,length){return blitBuffer(utf16leToBytes(string,buf.length-offset),buf,offset,length)}function base64Slice(buf,start,end){return base64.fromByteArray(0===start&&end===buf.length?buf:buf.slice(start,end))}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);for(var res=[],i=start;end>i;){var firstByte=buf[i],codePoint=null,bytesPerSequence=firstByte>239?4:firstByte>223?3:firstByte>191?2:1;if(end>=i+bytesPerSequence){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:128>firstByte&&(codePoint=firstByte);break;case 2:secondByte=buf[i+1],128===(192&secondByte)&&(tempCodePoint=(31&firstByte)<<6|63&secondByte,tempCodePoint>127&&(codePoint=tempCodePoint));break;case 3:secondByte=buf[i+1],thirdByte=buf[i+2],128===(192&secondByte)&&128===(192&thirdByte)&&(tempCodePoint=(15&firstByte)<<12|(63&secondByte)<<6|63&thirdByte,tempCodePoint>2047&&(55296>tempCodePoint||tempCodePoint>57343)&&(codePoint=tempCodePoint));break;case 4:secondByte=buf[i+1],thirdByte=buf[i+2],fourthByte=buf[i+3],128===(192&secondByte)&&128===(192&thirdByte)&&128===(192&fourthByte)&&(tempCodePoint=(15&firstByte)<<18|(63&secondByte)<<12|(63&thirdByte)<<6|63&fourthByte,tempCodePoint>65535&&1114112>tempCodePoint&&(codePoint=tempCodePoint))}}null===codePoint?(codePoint=65533,bytesPerSequence=1):codePoint>65535&&(codePoint-=65536,res.push(codePoint>>>10&1023|55296),codePoint=56320|1023&codePoint),res.push(codePoint),i+=bytesPerSequence}return decodeCodePointsArray(res)}function decodeCodePointsArray(codePoints){var len=codePoints.length;if(MAX_ARGUMENTS_LENGTH>=len)return String.fromCharCode.apply(String,codePoints);for(var res="",i=0;len>i;)res+=String.fromCharCode.apply(String,codePoints.slice(i,i+=MAX_ARGUMENTS_LENGTH));return res}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;end>i;++i)ret+=String.fromCharCode(127&buf[i]);return ret}function latin1Slice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;end>i;++i)ret+=String.fromCharCode(buf[i]);return ret}function hexSlice(buf,start,end){var len=buf.length;(!start||0>start)&&(start=0),(!end||0>end||end>len)&&(end=len);for(var out="",i=start;end>i;++i)out+=toHex(buf[i]);return out}function utf16leSlice(buf,start,end){for(var bytes=buf.slice(start,end),res="",i=0;i<bytes.length;i+=2)res+=String.fromCharCode(bytes[i]+256*bytes[i+1]);return res}function checkOffset(offset,ext,length){if(offset%1!==0||0>offset)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||min>value)throw new RangeError('"value" argument is out of bounds');if(offset+ext>buf.length)throw new RangeError("Index out of range")}function objectWriteUInt16(buf,value,offset,littleEndian){0>value&&(value=65535+value+1);for(var i=0,j=Math.min(buf.length-offset,2);j>i;++i)buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>8*(littleEndian?i:1-i)}function objectWriteUInt32(buf,value,offset,littleEndian){0>value&&(value=4294967295+value+1);for(var i=0,j=Math.min(buf.length-offset,4);j>i;++i)buf[offset+i]=value>>>8*(littleEndian?i:3-i)&255}function checkIEEE754(buf,value,offset,ext){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(0>offset)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){return noAssert||checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38),ieee754.write(buf,value,offset,littleEndian,23,4),offset+4}function writeDouble(buf,value,offset,littleEndian,noAssert){return noAssert||checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308),ieee754.write(buf,value,offset,littleEndian,52,8),offset+8}function base64clean(str){if(str=stringtrim(str).replace(INVALID_BASE64_RE,""),str.length<2)return"";for(;str.length%4!==0;)str+="=";return str}function stringtrim(str){return str.trim?str.trim():str.replace(/^\s+|\s+$/g,"")}function toHex(n){return 16>n?"0"+n.toString(16):n.toString(16)}function utf8ToBytes(string,units){units=units||1/0;for(var codePoint,length=string.length,leadSurrogate=null,bytes=[],i=0;length>i;++i){if(codePoint=string.charCodeAt(i),codePoint>55295&&57344>codePoint){if(!leadSurrogate){if(codePoint>56319){(units-=3)>-1&&bytes.push(239,191,189);continue}if(i+1===length){(units-=3)>-1&&bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(56320>codePoint){(units-=3)>-1&&bytes.push(239,191,189),leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else leadSurrogate&&(units-=3)>-1&&bytes.push(239,191,189);if(leadSurrogate=null,128>codePoint){if((units-=1)<0)break;bytes.push(codePoint)}else if(2048>codePoint){if((units-=2)<0)break;bytes.push(codePoint>>6|192,63&codePoint|128)}else if(65536>codePoint){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,63&codePoint|128)}else{if(!(1114112>codePoint))throw new Error("Invalid code point");if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,63&codePoint|128)}}return bytes}function asciiToBytes(str){for(var byteArray=[],i=0;i<str.length;++i)byteArray.push(255&str.charCodeAt(i));return byteArray}function utf16leToBytes(str,units){for(var c,hi,lo,byteArray=[],i=0;i<str.length&&!((units-=2)<0);++i)c=str.charCodeAt(i),hi=c>>8,lo=c%256,byteArray.push(lo),byteArray.push(hi);return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;length>i&&!(i+offset>=dst.length||i>=src.length);++i)dst[i+offset]=src[i];return i}function isnan(val){return val!==val}var base64=require("base64-js"),ieee754=require("ieee754"),isArray=require("isarray");exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50,Buffer.TYPED_ARRAY_SUPPORT=void 0!==global.TYPED_ARRAY_SUPPORT?global.TYPED_ARRAY_SUPPORT:typedArraySupport(),exports.kMaxLength=kMaxLength(),Buffer.poolSize=8192,Buffer._augment=function(arr){return arr.__proto__=Buffer.prototype,arr},Buffer.from=function(value,encodingOrOffset,length){return from(null,value,encodingOrOffset,length)},Buffer.TYPED_ARRAY_SUPPORT&&(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0})),Buffer.alloc=function(size,fill,encoding){return alloc(null,size,fill,encoding)},Buffer.allocUnsafe=function(size){return allocUnsafe(null,size)},Buffer.allocUnsafeSlow=function(size){return allocUnsafe(null,size)},Buffer.isBuffer=function(b){return!(null==b||!b._isBuffer)},Buffer.compare=function(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var x=a.length,y=b.length,i=0,len=Math.min(x,y);len>i;++i)if(a[i]!==b[i]){x=a[i],y=b[i];break}return y>x?-1:x>y?1:0},Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(list,length){if(!isArray(list))throw new TypeError('"list" argument must be an Array of Buffers');if(0===list.length)return Buffer.alloc(0);var i;if(void 0===length)for(length=0,i=0;i<list.length;++i)length+=list[i].length;var buffer=Buffer.allocUnsafe(length),pos=0;for(i=0;i<list.length;++i){var buf=list[i];if(!Buffer.isBuffer(buf))throw new TypeError('"list" argument must be an Array of Buffers');buf.copy(buffer,pos),pos+=buf.length}return buffer},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function(){var len=this.length;if(len%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var i=0;len>i;i+=2)swap(this,i,i+1);return this},Buffer.prototype.swap32=function(){var len=this.length;if(len%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var i=0;len>i;i+=4)swap(this,i,i+3),swap(this,i+1,i+2);return this},Buffer.prototype.swap64=function(){var len=this.length;if(len%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var i=0;len>i;i+=8)swap(this,i,i+7),swap(this,i+1,i+6),swap(this,i+2,i+5),swap(this,i+3,i+4);return this},Buffer.prototype.toString=function(){var length=0|this.length;return 0===length?"":0===arguments.length?utf8Slice(this,0,length):slowToString.apply(this,arguments)},Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b?!0:0===Buffer.compare(this,b)},Buffer.prototype.inspect=function(){var str="",max=exports.INSPECT_MAX_BYTES;return this.length>0&&(str=this.toString("hex",0,max).match(/.{2}/g).join(" "),this.length>max&&(str+=" ... ")),"<Buffer "+str+">"},Buffer.prototype.compare=function(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target))throw new TypeError("Argument must be a Buffer");if(void 0===start&&(start=0),void 0===end&&(end=target?target.length:0),void 0===thisStart&&(thisStart=0),void 0===thisEnd&&(thisEnd=this.length),0>start||end>target.length||0>thisStart||thisEnd>this.length)throw new RangeError("out of range index");if(thisStart>=thisEnd&&start>=end)return 0;if(thisStart>=thisEnd)return-1;if(start>=end)return 1;if(start>>>=0,end>>>=0,thisStart>>>=0,thisEnd>>>=0,this===target)return 0;for(var x=thisEnd-thisStart,y=end-start,len=Math.min(x,y),thisCopy=this.slice(thisStart,thisEnd),targetCopy=target.slice(start,end),i=0;len>i;++i)if(thisCopy[i]!==targetCopy[i]){x=thisCopy[i],y=targetCopy[i];break}return y>x?-1:x>y?1:0},Buffer.prototype.includes=function(val,byteOffset,encoding){return-1!==this.indexOf(val,byteOffset,encoding)},Buffer.prototype.indexOf=function(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,!0)},Buffer.prototype.lastIndexOf=function(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,!1)},Buffer.prototype.write=function(string,offset,length,encoding){if(void 0===offset)encoding="utf8",length=this.length,offset=0;else if(void 0===length&&"string"==typeof offset)encoding=offset,length=this.length,offset=0;else{if(!isFinite(offset))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");offset=0|offset,isFinite(length)?(length=0|length,void 0===encoding&&(encoding="utf8")):(encoding=length,length=void 0)}var remaining=this.length-offset;if((void 0===length||length>remaining)&&(length=remaining),string.length>0&&(0>length||0>offset)||offset>this.length)throw new RangeError("Attempt to write outside buffer bounds");encoding||(encoding="utf8");for(var loweredCase=!1;;)switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase(),loweredCase=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;Buffer.prototype.slice=function(start,end){var len=this.length;start=~~start,end=void 0===end?len:~~end,0>start?(start+=len,0>start&&(start=0)):start>len&&(start=len),0>end?(end+=len,0>end&&(end=0)):end>len&&(end=len),start>end&&(end=start);var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT)newBuf=this.subarray(start,end),newBuf.__proto__=Buffer.prototype;else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,void 0);for(var i=0;sliceLen>i;++i)newBuf[i]=this[i+start]}return newBuf},Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset=0|offset,byteLength=0|byteLength,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return val},Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset=0|offset,byteLength=0|byteLength,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset+--byteLength],mul=1;byteLength>0&&(mul*=256);)val+=this[offset+--byteLength]*mul;return val},Buffer.prototype.readUInt8=function(offset,noAssert){return noAssert||checkOffset(offset,1,this.length),this[offset]},Buffer.prototype.readUInt16LE=function(offset,noAssert){return noAssert||checkOffset(offset,2,this.length),this[offset]|this[offset+1]<<8},Buffer.prototype.readUInt16BE=function(offset,noAssert){return noAssert||checkOffset(offset,2,this.length),this[offset]<<8|this[offset+1]},Buffer.prototype.readUInt32LE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+16777216*this[offset+3]},Buffer.prototype.readUInt32BE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),16777216*this[offset]+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])},Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset=0|offset,byteLength=0|byteLength,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return mul*=128,val>=mul&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset=0|offset,byteLength=0|byteLength,noAssert||checkOffset(offset,byteLength,this.length);for(var i=byteLength,mul=1,val=this[offset+--i];i>0&&(mul*=256);)val+=this[offset+--i]*mul;return mul*=128,val>=mul&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readInt8=function(offset,noAssert){return noAssert||checkOffset(offset,1,this.length),128&this[offset]?-1*(255-this[offset]+1):this[offset]},Buffer.prototype.readInt16LE=function(offset,noAssert){noAssert||checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return 32768&val?4294901760|val:val},Buffer.prototype.readInt16BE=function(offset,noAssert){noAssert||checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return 32768&val?4294901760|val:val},Buffer.prototype.readInt32LE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24},Buffer.prototype.readInt32BE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]},Buffer.prototype.readFloatLE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!0,23,4)},Buffer.prototype.readFloatBE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!1,23,4)},Buffer.prototype.readDoubleLE=function(offset,noAssert){return noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!0,52,8)},Buffer.prototype.readDoubleBE=function(offset,noAssert){return noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!1,52,8)},Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){if(value=+value,offset=0|offset,byteLength=0|byteLength,!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1,i=0;for(this[offset]=255&value;++i<byteLength&&(mul*=256);)this[offset+i]=value/mul&255;return offset+byteLength},Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){if(value=+value,offset=0|offset,byteLength=0|byteLength,!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1,mul=1;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)this[offset+i]=value/mul&255;return offset+byteLength},Buffer.prototype.writeUInt8=function(value,offset,noAssert){return value=+value,offset=0|offset,noAssert||checkInt(this,value,offset,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(value=Math.floor(value)),this[offset]=255&value,offset+1},Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){return value=+value,offset=0|offset,noAssert||checkInt(this,value,offset,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=255&value,this[offset+1]=value>>>8):objectWriteUInt16(this,value,offset,!0),offset+2},Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){return value=+value,offset=0|offset,noAssert||checkInt(this,value,offset,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value>>>8,this[offset+1]=255&value):objectWriteUInt16(this,value,offset,!1),offset+2},Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){return value=+value,offset=0|offset,noAssert||checkInt(this,value,offset,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[offset+3]=value>>>24,this[offset+2]=value>>>16,this[offset+1]=value>>>8,this[offset]=255&value):objectWriteUInt32(this,value,offset,!0),offset+4},Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){return value=+value,offset=0|offset,noAssert||checkInt(this,value,offset,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value>>>24,this[offset+1]=value>>>16,this[offset+2]=value>>>8,this[offset+3]=255&value):objectWriteUInt32(this,value,offset,!1),offset+4},Buffer.prototype.writeIntLE=function(value,offset,byteLength,noAssert){if(value=+value,offset=0|offset,!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0,mul=1,sub=0;for(this[offset]=255&value;++i<byteLength&&(mul*=256);)0>value&&0===sub&&0!==this[offset+i-1]&&(sub=1),this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength},Buffer.prototype.writeIntBE=function(value,offset,byteLength,noAssert){if(value=+value,offset=0|offset,!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1,mul=1,sub=0;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)0>value&&0===sub&&0!==this[offset+i+1]&&(sub=1),this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength},Buffer.prototype.writeInt8=function(value,offset,noAssert){return value=+value,offset=0|offset,noAssert||checkInt(this,value,offset,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(value=Math.floor(value)),0>value&&(value=255+value+1),this[offset]=255&value,offset+1},Buffer.prototype.writeInt16LE=function(value,offset,noAssert){return value=+value,offset=0|offset,noAssert||checkInt(this,value,offset,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=255&value,this[offset+1]=value>>>8):objectWriteUInt16(this,value,offset,!0),offset+2},Buffer.prototype.writeInt16BE=function(value,offset,noAssert){return value=+value,offset=0|offset,noAssert||checkInt(this,value,offset,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value>>>8,this[offset+1]=255&value):objectWriteUInt16(this,value,offset,!1),offset+2},Buffer.prototype.writeInt32LE=function(value,offset,noAssert){return value=+value,offset=0|offset,noAssert||checkInt(this,value,offset,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=255&value,this[offset+1]=value>>>8,this[offset+2]=value>>>16,this[offset+3]=value>>>24):objectWriteUInt32(this,value,offset,!0),offset+4},Buffer.prototype.writeInt32BE=function(value,offset,noAssert){return value=+value,offset=0|offset,noAssert||checkInt(this,value,offset,4,2147483647,-2147483648),0>value&&(value=4294967295+value+1),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value>>>24,this[offset+1]=value>>>16,this[offset+2]=value>>>8,this[offset+3]=255&value):objectWriteUInt32(this,value,offset,!1),offset+4},Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,!0,noAssert)},Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,!1,noAssert)},Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,!0,noAssert)},Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,!1,noAssert)},Buffer.prototype.copy=function(target,targetStart,start,end){if(start||(start=0),end||0===end||(end=this.length),targetStart>=target.length&&(targetStart=target.length),targetStart||(targetStart=0),end>0&&start>end&&(end=start),end===start)return 0;if(0===target.length||0===this.length)return 0;if(0>targetStart)throw new RangeError("targetStart out of bounds");if(0>start||start>=this.length)throw new RangeError("sourceStart out of bounds");if(0>end)throw new RangeError("sourceEnd out of bounds");end>this.length&&(end=this.length),target.length-targetStart<end-start&&(end=target.length-targetStart+start);var i,len=end-start;if(this===target&&targetStart>start&&end>targetStart)for(i=len-1;i>=0;--i)target[i+targetStart]=this[i+start];else if(1e3>len||!Buffer.TYPED_ARRAY_SUPPORT)for(i=0;len>i;++i)target[i+targetStart]=this[i+start];else Uint8Array.prototype.set.call(target,this.subarray(start,start+len),targetStart);return len},Buffer.prototype.fill=function(val,start,end,encoding){if("string"==typeof val){if("string"==typeof start?(encoding=start,start=0,end=this.length):"string"==typeof end&&(encoding=end,end=this.length),1===val.length){var code=val.charCodeAt(0);256>code&&(val=code)}if(void 0!==encoding&&"string"!=typeof encoding)throw new TypeError("encoding must be a string");if("string"==typeof encoding&&!Buffer.isEncoding(encoding))throw new TypeError("Unknown encoding: "+encoding)}else"number"==typeof val&&(val=255&val);if(0>start||this.length<start||this.length<end)throw new RangeError("Out of range index");if(start>=end)return this;start>>>=0,end=void 0===end?this.length:end>>>0,val||(val=0);var i;if("number"==typeof val)for(i=start;end>i;++i)this[i]=val;else{var bytes=Buffer.isBuffer(val)?val:utf8ToBytes(new Buffer(val,encoding).toString()),len=bytes.length;for(i=0;end-start>i;++i)this[i+start]=bytes[i%len]}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":15,ieee754:91,isarray:95}],46:[function(require,module){module.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],47:[function(require,module){(function(Buffer){function CipherBase(hashMode){Transform.call(this),this.hashMode="string"==typeof hashMode,this.hashMode?this[hashMode]=this._finalOrDigest:this["final"]=this._finalOrDigest,this._decoder=null,this._encoding=null}var Transform=require("stream").Transform,inherits=require("inherits"),StringDecoder=require("string_decoder").StringDecoder;module.exports=CipherBase,inherits(CipherBase,Transform),CipherBase.prototype.update=function(data,inputEnc,outputEnc){"string"==typeof data&&(data=new Buffer(data,inputEnc));var outData=this._update(data);return this.hashMode?this:(outputEnc&&(outData=this._toString(outData,outputEnc)),outData)},CipherBase.prototype.setAutoPadding=function(){},CipherBase.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},CipherBase.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},CipherBase.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},CipherBase.prototype._transform=function(data,_,next){var err;try{this.hashMode?this._update(data):this.push(this._update(data))}catch(e){err=e}finally{next(err)}},CipherBase.prototype._flush=function(done){var err;try{this.push(this._final())}catch(e){err=e}finally{done(err)}},CipherBase.prototype._finalOrDigest=function(outputEnc){var outData=this._final()||new Buffer("");return outputEnc&&(outData=this._toString(outData,outputEnc,!0)),outData},CipherBase.prototype._toString=function(value,enc,fin){if(this._decoder||(this._decoder=new StringDecoder(enc),this._encoding=enc),this._encoding!==enc)throw new Error("can't switch encodings");var out=this._decoder.write(value);return fin&&(out+=this._decoder.end()),out}}).call(this,require("buffer").Buffer)},{buffer:45,inherits:93,stream:137,string_decoder:142}],48:[function(require,module,exports){(function(Buffer){function isArray(arg){return Array.isArray?Array.isArray(arg):"[object Array]"===objectToString(arg)}function isBoolean(arg){return"boolean"==typeof arg}function isNull(arg){return null===arg}function isNullOrUndefined(arg){return null==arg}function isNumber(arg){return"number"==typeof arg}function isString(arg){return"string"==typeof arg}function isSymbol(arg){return"symbol"==typeof arg}function isUndefined(arg){return void 0===arg}function isRegExp(re){return"[object RegExp]"===objectToString(re)}function isObject(arg){return"object"==typeof arg&&null!==arg}function isDate(d){return"[object Date]"===objectToString(d)}function isError(e){return"[object Error]"===objectToString(e)||e instanceof Error}function isFunction(arg){return"function"==typeof arg}function isPrimitive(arg){return null===arg||"boolean"==typeof arg||"number"==typeof arg||"string"==typeof arg||"symbol"==typeof arg||"undefined"==typeof arg}function objectToString(o){return Object.prototype.toString.call(o)}exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=Buffer.isBuffer}).call(this,{isBuffer:require("../../is-buffer/index.js")})},{"../../is-buffer/index.js":94}],49:[function(require,module){(function(Buffer){function ECDH(curve){this.curveType=aliases[curve],this.curveType||(this.curveType={name:curve}),this.curve=new elliptic.ec(this.curveType.name),this.keys=void 0}function formatReturnValue(bn,enc,len){Array.isArray(bn)||(bn=bn.toArray());var buf=new Buffer(bn);if(len&&buf.length<len){var zeros=new Buffer(len-buf.length);
  
  zeros.fill(0),buf=Buffer.concat([zeros,buf])}return enc?buf.toString(enc):buf}var elliptic=require("elliptic"),BN=require("bn.js");module.exports=function(curve){return new ECDH(curve)};var aliases={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};aliases.p224=aliases.secp224r1,aliases.p256=aliases.secp256r1=aliases.prime256v1,aliases.p192=aliases.secp192r1=aliases.prime192v1,aliases.p384=aliases.secp384r1,aliases.p521=aliases.secp521r1,ECDH.prototype.generateKeys=function(enc,format){return this.keys=this.curve.genKeyPair(),this.getPublicKey(enc,format)},ECDH.prototype.computeSecret=function(other,inenc,enc){inenc=inenc||"utf8",Buffer.isBuffer(other)||(other=new Buffer(other,inenc));var otherPub=this.curve.keyFromPublic(other).getPublic(),out=otherPub.mul(this.keys.getPrivate()).getX();return formatReturnValue(out,enc,this.curveType.byteLength)},ECDH.prototype.getPublicKey=function(enc,format){var key=this.keys.getPublic("compressed"===format,!0);return"hybrid"===format&&(key[0]=key[key.length-1]%2?7:6),formatReturnValue(key,enc)},ECDH.prototype.getPrivateKey=function(enc){return formatReturnValue(this.keys.getPrivate(),enc)},ECDH.prototype.setPublicKey=function(pub,enc){return enc=enc||"utf8",Buffer.isBuffer(pub)||(pub=new Buffer(pub,enc)),this.keys._importPublic(pub),this},ECDH.prototype.setPrivateKey=function(priv,enc){enc=enc||"utf8",Buffer.isBuffer(priv)||(priv=new Buffer(priv,enc));var _priv=new BN(priv);return _priv=_priv.toString(16),this.keys._importPrivate(_priv),this}}).call(this,require("buffer").Buffer)},{"bn.js":16,buffer:45,elliptic:65}],50:[function(require,module){(function(Buffer){"use strict";function HashNoConstructor(hash){Base.call(this,"digest"),this._hash=hash,this.buffers=[]}function Hash(hash){Base.call(this,"digest"),this._hash=hash}var inherits=require("inherits"),md5=require("./md5"),rmd160=require("ripemd160"),sha=require("sha.js"),Base=require("cipher-base");inherits(HashNoConstructor,Base),HashNoConstructor.prototype._update=function(data){this.buffers.push(data)},HashNoConstructor.prototype._final=function(){var buf=Buffer.concat(this.buffers),r=this._hash(buf);return this.buffers=null,r},inherits(Hash,Base),Hash.prototype._update=function(data){this._hash.update(data)},Hash.prototype._final=function(){return this._hash.digest()},module.exports=function(alg){return alg=alg.toLowerCase(),"md5"===alg?new HashNoConstructor(md5):"rmd160"===alg||"ripemd160"===alg?new HashNoConstructor(rmd160):new Hash(sha(alg))}}).call(this,require("buffer").Buffer)},{"./md5":52,buffer:45,"cipher-base":47,inherits:93,ripemd160:128,"sha.js":130}],51:[function(require,module,exports){(function(Buffer){"use strict";function toArray(buf,bigEndian){if(buf.length%intSize!==0){var len=buf.length+(intSize-buf.length%intSize);buf=Buffer.concat([buf,zeroBuffer],len)}for(var arr=[],fn=bigEndian?buf.readInt32BE:buf.readInt32LE,i=0;i<buf.length;i+=intSize)arr.push(fn.call(buf,i));return arr}function toBuffer(arr,size,bigEndian){for(var buf=new Buffer(size),fn=bigEndian?buf.writeInt32BE:buf.writeInt32LE,i=0;i<arr.length;i++)fn.call(buf,arr[i],4*i,!0);return buf}function hash(buf,fn,hashSize,bigEndian){Buffer.isBuffer(buf)||(buf=new Buffer(buf));var arr=fn(toArray(buf,bigEndian),buf.length*chrsz);return toBuffer(arr,hashSize,bigEndian)}var intSize=4,zeroBuffer=new Buffer(intSize);zeroBuffer.fill(0);var chrsz=8;exports.hash=hash}).call(this,require("buffer").Buffer)},{buffer:45}],52:[function(require,module){"use strict";function core_md5(x,len){x[len>>5]|=128<<len%32,x[(len+64>>>9<<4)+14]=len;for(var a=1732584193,b=-271733879,c=-1732584194,d=271733878,i=0;i<x.length;i+=16){var olda=a,oldb=b,oldc=c,oldd=d;a=md5_ff(a,b,c,d,x[i+0],7,-680876936),d=md5_ff(d,a,b,c,x[i+1],12,-389564586),c=md5_ff(c,d,a,b,x[i+2],17,606105819),b=md5_ff(b,c,d,a,x[i+3],22,-1044525330),a=md5_ff(a,b,c,d,x[i+4],7,-176418897),d=md5_ff(d,a,b,c,x[i+5],12,1200080426),c=md5_ff(c,d,a,b,x[i+6],17,-1473231341),b=md5_ff(b,c,d,a,x[i+7],22,-45705983),a=md5_ff(a,b,c,d,x[i+8],7,1770035416),d=md5_ff(d,a,b,c,x[i+9],12,-1958414417),c=md5_ff(c,d,a,b,x[i+10],17,-42063),b=md5_ff(b,c,d,a,x[i+11],22,-1990404162),a=md5_ff(a,b,c,d,x[i+12],7,1804603682),d=md5_ff(d,a,b,c,x[i+13],12,-40341101),c=md5_ff(c,d,a,b,x[i+14],17,-1502002290),b=md5_ff(b,c,d,a,x[i+15],22,1236535329),a=md5_gg(a,b,c,d,x[i+1],5,-165796510),d=md5_gg(d,a,b,c,x[i+6],9,-1069501632),c=md5_gg(c,d,a,b,x[i+11],14,643717713),b=md5_gg(b,c,d,a,x[i+0],20,-373897302),a=md5_gg(a,b,c,d,x[i+5],5,-701558691),d=md5_gg(d,a,b,c,x[i+10],9,38016083),c=md5_gg(c,d,a,b,x[i+15],14,-660478335),b=md5_gg(b,c,d,a,x[i+4],20,-405537848),a=md5_gg(a,b,c,d,x[i+9],5,568446438),d=md5_gg(d,a,b,c,x[i+14],9,-1019803690),c=md5_gg(c,d,a,b,x[i+3],14,-187363961),b=md5_gg(b,c,d,a,x[i+8],20,1163531501),a=md5_gg(a,b,c,d,x[i+13],5,-1444681467),d=md5_gg(d,a,b,c,x[i+2],9,-51403784),c=md5_gg(c,d,a,b,x[i+7],14,1735328473),b=md5_gg(b,c,d,a,x[i+12],20,-1926607734),a=md5_hh(a,b,c,d,x[i+5],4,-378558),d=md5_hh(d,a,b,c,x[i+8],11,-2022574463),c=md5_hh(c,d,a,b,x[i+11],16,1839030562),b=md5_hh(b,c,d,a,x[i+14],23,-35309556),a=md5_hh(a,b,c,d,x[i+1],4,-1530992060),d=md5_hh(d,a,b,c,x[i+4],11,1272893353),c=md5_hh(c,d,a,b,x[i+7],16,-155497632),b=md5_hh(b,c,d,a,x[i+10],23,-1094730640),a=md5_hh(a,b,c,d,x[i+13],4,681279174),d=md5_hh(d,a,b,c,x[i+0],11,-358537222),c=md5_hh(c,d,a,b,x[i+3],16,-722521979),b=md5_hh(b,c,d,a,x[i+6],23,76029189),a=md5_hh(a,b,c,d,x[i+9],4,-640364487),d=md5_hh(d,a,b,c,x[i+12],11,-421815835),c=md5_hh(c,d,a,b,x[i+15],16,530742520),b=md5_hh(b,c,d,a,x[i+2],23,-995338651),a=md5_ii(a,b,c,d,x[i+0],6,-198630844),d=md5_ii(d,a,b,c,x[i+7],10,1126891415),c=md5_ii(c,d,a,b,x[i+14],15,-1416354905),b=md5_ii(b,c,d,a,x[i+5],21,-57434055),a=md5_ii(a,b,c,d,x[i+12],6,1700485571),d=md5_ii(d,a,b,c,x[i+3],10,-1894986606),c=md5_ii(c,d,a,b,x[i+10],15,-1051523),b=md5_ii(b,c,d,a,x[i+1],21,-2054922799),a=md5_ii(a,b,c,d,x[i+8],6,1873313359),d=md5_ii(d,a,b,c,x[i+15],10,-30611744),c=md5_ii(c,d,a,b,x[i+6],15,-1560198380),b=md5_ii(b,c,d,a,x[i+13],21,1309151649),a=md5_ii(a,b,c,d,x[i+4],6,-145523070),d=md5_ii(d,a,b,c,x[i+11],10,-1120210379),c=md5_ii(c,d,a,b,x[i+2],15,718787259),b=md5_ii(b,c,d,a,x[i+9],21,-343485551),a=safe_add(a,olda),b=safe_add(b,oldb),c=safe_add(c,oldc),d=safe_add(d,oldd)}return Array(a,b,c,d)}function md5_cmn(q,a,b,x,s,t){return safe_add(bit_rol(safe_add(safe_add(a,q),safe_add(x,t)),s),b)}function md5_ff(a,b,c,d,x,s,t){return md5_cmn(b&c|~b&d,a,b,x,s,t)}function md5_gg(a,b,c,d,x,s,t){return md5_cmn(b&d|c&~d,a,b,x,s,t)}function md5_hh(a,b,c,d,x,s,t){return md5_cmn(b^c^d,a,b,x,s,t)}function md5_ii(a,b,c,d,x,s,t){return md5_cmn(c^(b|~d),a,b,x,s,t)}function safe_add(x,y){var lsw=(65535&x)+(65535&y),msw=(x>>16)+(y>>16)+(lsw>>16);return msw<<16|65535&lsw}function bit_rol(num,cnt){return num<<cnt|num>>>32-cnt}var helpers=require("./helpers");module.exports=function(buf){return helpers.hash(buf,core_md5,16)}},{"./helpers":51}],53:[function(require,module){(function(Buffer){"use strict";function Hmac(alg,key){Transform.call(this),alg=alg.toLowerCase(),"string"==typeof key&&(key=new Buffer(key));var blocksize="sha512"===alg||"sha384"===alg?128:64;this._alg=alg,this._key=key,key.length>blocksize?key=createHash(alg).update(key).digest():key.length<blocksize&&(key=Buffer.concat([key,ZEROS],blocksize));for(var ipad=this._ipad=new Buffer(blocksize),opad=this._opad=new Buffer(blocksize),i=0;blocksize>i;i++)ipad[i]=54^key[i],opad[i]=92^key[i];this._hash=createHash(alg).update(ipad)}var createHash=require("create-hash/browser"),inherits=require("inherits"),Transform=require("stream").Transform,ZEROS=new Buffer(128);ZEROS.fill(0),inherits(Hmac,Transform),Hmac.prototype.update=function(data,enc){return this._hash.update(data,enc),this},Hmac.prototype._transform=function(data,_,next){this._hash.update(data),next()},Hmac.prototype._flush=function(next){this.push(this.digest()),next()},Hmac.prototype.digest=function(enc){var h=this._hash.digest();return createHash(this._alg).update(this._opad).update(h).digest(enc)},module.exports=function(alg,key){return new Hmac(alg,key)}}).call(this,require("buffer").Buffer)},{buffer:45,"create-hash/browser":50,inherits:93,stream:137}],54:[function(require,module,exports){"use strict";exports.randomBytes=exports.rng=exports.pseudoRandomBytes=exports.prng=require("randombytes"),exports.createHash=exports.Hash=require("create-hash"),exports.createHmac=exports.Hmac=require("create-hmac");var hashes=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(Object.keys(require("browserify-sign/algos")));exports.getHashes=function(){return hashes};var p=require("pbkdf2");exports.pbkdf2=p.pbkdf2,exports.pbkdf2Sync=p.pbkdf2Sync;var aes=require("browserify-cipher");["Cipher","createCipher","Cipheriv","createCipheriv","Decipher","createDecipher","Decipheriv","createDecipheriv","getCiphers","listCiphers"].forEach(function(key){exports[key]=aes[key]});var dh=require("diffie-hellman");["DiffieHellmanGroup","createDiffieHellmanGroup","getDiffieHellman","createDiffieHellman","DiffieHellman"].forEach(function(key){exports[key]=dh[key]});var sign=require("browserify-sign");["createSign","Sign","createVerify","Verify"].forEach(function(key){exports[key]=sign[key]}),exports.createECDH=require("create-ecdh");var publicEncrypt=require("public-encrypt");["publicEncrypt","privateEncrypt","publicDecrypt","privateDecrypt"].forEach(function(key){exports[key]=publicEncrypt[key]}),["createCredentials"].forEach(function(name){exports[name]=function(){throw new Error(["sorry, "+name+" is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))}})},{"browserify-cipher":34,"browserify-sign":39,"browserify-sign/algos":38,"create-ecdh":49,"create-hash":50,"create-hmac":53,"diffie-hellman":61,pbkdf2:102,"public-encrypt":106,randombytes:116}],55:[function(require,module,exports){"use strict";exports.utils=require("./des/utils"),exports.Cipher=require("./des/cipher"),exports.DES=require("./des/des"),exports.CBC=require("./des/cbc"),exports.EDE=require("./des/ede")},{"./des/cbc":56,"./des/cipher":57,"./des/des":58,"./des/ede":59,"./des/utils":60}],56:[function(require,module,exports){"use strict";function CBCState(iv){assert.equal(iv.length,8,"Invalid IV length"),this.iv=new Array(8);for(var i=0;i<this.iv.length;i++)this.iv[i]=iv[i]}function instantiate(Base){function CBC(options){Base.call(this,options),this._cbcInit()}inherits(CBC,Base);for(var keys=Object.keys(proto),i=0;i<keys.length;i++){var key=keys[i];CBC.prototype[key]=proto[key]}return CBC.create=function(options){return new CBC(options)},CBC}var assert=require("minimalistic-assert"),inherits=require("inherits"),proto={};exports.instantiate=instantiate,proto._cbcInit=function(){var state=new CBCState(this.options.iv);this._cbcState=state},proto._update=function(inp,inOff,out,outOff){var state=this._cbcState,superProto=this.constructor.super_.prototype,iv=state.iv;if("encrypt"===this.type){for(var i=0;i<this.blockSize;i++)iv[i]^=inp[inOff+i];superProto._update.call(this,iv,0,out,outOff);for(var i=0;i<this.blockSize;i++)iv[i]=out[outOff+i]}else{superProto._update.call(this,inp,inOff,out,outOff);for(var i=0;i<this.blockSize;i++)out[outOff+i]^=iv[i];for(var i=0;i<this.blockSize;i++)iv[i]=inp[inOff+i]}}},{inherits:93,"minimalistic-assert":97}],57:[function(require,module){"use strict";function Cipher(options){this.options=options,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0}var assert=require("minimalistic-assert");module.exports=Cipher,Cipher.prototype._init=function(){},Cipher.prototype.update=function(data){return 0===data.length?[]:"decrypt"===this.type?this._updateDecrypt(data):this._updateEncrypt(data)},Cipher.prototype._buffer=function(data,off){for(var min=Math.min(this.buffer.length-this.bufferOff,data.length-off),i=0;min>i;i++)this.buffer[this.bufferOff+i]=data[off+i];return this.bufferOff+=min,min},Cipher.prototype._flushBuffer=function(out,off){return this._update(this.buffer,0,out,off),this.bufferOff=0,this.blockSize},Cipher.prototype._updateEncrypt=function(data){var inputOff=0,outputOff=0,count=(this.bufferOff+data.length)/this.blockSize|0,out=new Array(count*this.blockSize);0!==this.bufferOff&&(inputOff+=this._buffer(data,inputOff),this.bufferOff===this.buffer.length&&(outputOff+=this._flushBuffer(out,outputOff)));for(var max=data.length-(data.length-inputOff)%this.blockSize;max>inputOff;inputOff+=this.blockSize)this._update(data,inputOff,out,outputOff),outputOff+=this.blockSize;for(;inputOff<data.length;inputOff++,this.bufferOff++)this.buffer[this.bufferOff]=data[inputOff];return out},Cipher.prototype._updateDecrypt=function(data){for(var inputOff=0,outputOff=0,count=Math.ceil((this.bufferOff+data.length)/this.blockSize)-1,out=new Array(count*this.blockSize);count>0;count--)inputOff+=this._buffer(data,inputOff),outputOff+=this._flushBuffer(out,outputOff);return inputOff+=this._buffer(data,inputOff),out},Cipher.prototype["final"]=function(buffer){var first;buffer&&(first=this.update(buffer));var last;return last="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),first?first.concat(last):last},Cipher.prototype._pad=function(buffer,off){if(0===off)return!1;for(;off<buffer.length;)buffer[off++]=0;return!0},Cipher.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var out=new Array(this.blockSize);return this._update(this.buffer,0,out,0),out},Cipher.prototype._unpad=function(buffer){return buffer},Cipher.prototype._finalDecrypt=function(){assert.equal(this.bufferOff,this.blockSize,"Not enough data to decrypt");var out=new Array(this.blockSize);return this._flushBuffer(out,0),this._unpad(out)}},{"minimalistic-assert":97}],58:[function(require,module){"use strict";function DESState(){this.tmp=new Array(2),this.keys=null}function DES(options){Cipher.call(this,options);var state=new DESState;this._desState=state,this.deriveKeys(state,options.key)}var assert=require("minimalistic-assert"),inherits=require("inherits"),des=require("../des"),utils=des.utils,Cipher=des.Cipher;inherits(DES,Cipher),module.exports=DES,DES.create=function(options){return new DES(options)};var shiftTable=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];DES.prototype.deriveKeys=function(state,key){state.keys=new Array(32),assert.equal(key.length,this.blockSize,"Invalid key length");var kL=utils.readUInt32BE(key,0),kR=utils.readUInt32BE(key,4);utils.pc1(kL,kR,state.tmp,0),kL=state.tmp[0],kR=state.tmp[1];for(var i=0;i<state.keys.length;i+=2){var shift=shiftTable[i>>>1];kL=utils.r28shl(kL,shift),kR=utils.r28shl(kR,shift),utils.pc2(kL,kR,state.keys,i)}},DES.prototype._update=function(inp,inOff,out,outOff){var state=this._desState,l=utils.readUInt32BE(inp,inOff),r=utils.readUInt32BE(inp,inOff+4);utils.ip(l,r,state.tmp,0),l=state.tmp[0],r=state.tmp[1],"encrypt"===this.type?this._encrypt(state,l,r,state.tmp,0):this._decrypt(state,l,r,state.tmp,0),l=state.tmp[0],r=state.tmp[1],utils.writeUInt32BE(out,l,outOff),utils.writeUInt32BE(out,r,outOff+4)},DES.prototype._pad=function(buffer,off){for(var value=buffer.length-off,i=off;i<buffer.length;i++)buffer[i]=value;return!0},DES.prototype._unpad=function(buffer){for(var pad=buffer[buffer.length-1],i=buffer.length-pad;i<buffer.length;i++)assert.equal(buffer[i],pad);return buffer.slice(0,buffer.length-pad)},DES.prototype._encrypt=function(state,lStart,rStart,out,off){for(var l=lStart,r=rStart,i=0;i<state.keys.length;i+=2){var keyL=state.keys[i],keyR=state.keys[i+1];utils.expand(r,state.tmp,0),keyL^=state.tmp[0],keyR^=state.tmp[1];var s=utils.substitute(keyL,keyR),f=utils.permute(s),t=r;r=(l^f)>>>0,l=t}utils.rip(r,l,out,off)},DES.prototype._decrypt=function(state,lStart,rStart,out,off){for(var l=rStart,r=lStart,i=state.keys.length-2;i>=0;i-=2){var keyL=state.keys[i],keyR=state.keys[i+1];utils.expand(l,state.tmp,0),keyL^=state.tmp[0],keyR^=state.tmp[1];var s=utils.substitute(keyL,keyR),f=utils.permute(s),t=l;l=(r^f)>>>0,r=t}utils.rip(l,r,out,off)}},{"../des":55,inherits:93,"minimalistic-assert":97}],59:[function(require,module){"use strict";function EDEState(type,key){assert.equal(key.length,24,"Invalid key length");var k1=key.slice(0,8),k2=key.slice(8,16),k3=key.slice(16,24);this.ciphers="encrypt"===type?[DES.create({type:"encrypt",key:k1}),DES.create({type:"decrypt",key:k2}),DES.create({type:"encrypt",key:k3})]:[DES.create({type:"decrypt",key:k3}),DES.create({type:"encrypt",key:k2}),DES.create({type:"decrypt",key:k1})]}function EDE(options){Cipher.call(this,options);var state=new EDEState(this.type,this.options.key);this._edeState=state}var assert=require("minimalistic-assert"),inherits=require("inherits"),des=require("../des"),Cipher=des.Cipher,DES=des.DES;inherits(EDE,Cipher),module.exports=EDE,EDE.create=function(options){return new EDE(options)},EDE.prototype._update=function(inp,inOff,out,outOff){var state=this._edeState;state.ciphers[0]._update(inp,inOff,out,outOff),state.ciphers[1]._update(out,outOff,out,outOff),state.ciphers[2]._update(out,outOff,out,outOff)},EDE.prototype._pad=DES.prototype._pad,EDE.prototype._unpad=DES.prototype._unpad},{"../des":55,inherits:93,"minimalistic-assert":97}],60:[function(require,module,exports){"use strict";exports.readUInt32BE=function(bytes,off){var res=bytes[0+off]<<24|bytes[1+off]<<16|bytes[2+off]<<8|bytes[3+off];return res>>>0},exports.writeUInt32BE=function(bytes,value,off){bytes[0+off]=value>>>24,bytes[1+off]=value>>>16&255,bytes[2+off]=value>>>8&255,bytes[3+off]=255&value},exports.ip=function(inL,inR,out,off){for(var outL=0,outR=0,i=6;i>=0;i-=2){for(var j=0;24>=j;j+=8)outL<<=1,outL|=inR>>>j+i&1;for(var j=0;24>=j;j+=8)outL<<=1,outL|=inL>>>j+i&1}for(var i=6;i>=0;i-=2){for(var j=1;25>=j;j+=8)outR<<=1,outR|=inR>>>j+i&1;for(var j=1;25>=j;j+=8)outR<<=1,outR|=inL>>>j+i&1}out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.rip=function(inL,inR,out,off){for(var outL=0,outR=0,i=0;4>i;i++)for(var j=24;j>=0;j-=8)outL<<=1,outL|=inR>>>j+i&1,outL<<=1,outL|=inL>>>j+i&1;for(var i=4;8>i;i++)for(var j=24;j>=0;j-=8)outR<<=1,outR|=inR>>>j+i&1,outR<<=1,outR|=inL>>>j+i&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.pc1=function(inL,inR,out,off){for(var outL=0,outR=0,i=7;i>=5;i--){for(var j=0;24>=j;j+=8)outL<<=1,outL|=inR>>j+i&1;for(var j=0;24>=j;j+=8)outL<<=1,outL|=inL>>j+i&1}for(var j=0;24>=j;j+=8)outL<<=1,outL|=inR>>j+i&1;for(var i=1;3>=i;i++){for(var j=0;24>=j;j+=8)outR<<=1,outR|=inR>>j+i&1;for(var j=0;24>=j;j+=8)outR<<=1,outR|=inL>>j+i&1}for(var j=0;24>=j;j+=8)outR<<=1,outR|=inL>>j+i&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.r28shl=function(num,shift){return num<<shift&268435455|num>>>28-shift};var pc2table=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];exports.pc2=function(inL,inR,out,off){for(var outL=0,outR=0,len=pc2table.length>>>1,i=0;len>i;i++)outL<<=1,outL|=inL>>>pc2table[i]&1;for(var i=len;i<pc2table.length;i++)outR<<=1,outR|=inR>>>pc2table[i]&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.expand=function(r,out,off){var outL=0,outR=0;outL=(1&r)<<5|r>>>27;for(var i=23;i>=15;i-=4)outL<<=6,outL|=r>>>i&63;for(var i=11;i>=3;i-=4)outR|=r>>>i&63,outR<<=6;outR|=(31&r)<<1|r>>>31,out[off+0]=outL>>>0,out[off+1]=outR>>>0};var sTable=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];exports.substitute=function(inL,inR){for(var out=0,i=0;4>i;i++){var b=inL>>>18-6*i&63,sb=sTable[64*i+b];out<<=4,out|=sb}for(var i=0;4>i;i++){var b=inR>>>18-6*i&63,sb=sTable[256+64*i+b];out<<=4,out|=sb}return out>>>0};var permuteTable=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];exports.permute=function(num){for(var out=0,i=0;i<permuteTable.length;i++)out<<=1,out|=num>>>permuteTable[i]&1;return out>>>0},exports.padSplit=function(num,size,group){for(var str=num.toString(2);str.length<size;)str="0"+str;for(var out=[],i=0;size>i;i+=group)out.push(str.slice(i,i+group));return out.join(" ")}},{}],61:[function(require,module,exports){(function(Buffer){function getDiffieHellman(mod){var prime=new Buffer(primes[mod].prime,"hex"),gen=new Buffer(primes[mod].gen,"hex");return new DH(prime,gen)}function createDiffieHellman(prime,enc,generator,genc){return Buffer.isBuffer(enc)||void 0===ENCODINGS[enc]?createDiffieHellman(prime,"binary",enc,generator):(enc=enc||"binary",genc=genc||"binary",generator=generator||new Buffer([2]),Buffer.isBuffer(generator)||(generator=new Buffer(generator,genc)),"number"==typeof prime?new DH(generatePrime(prime,generator),generator,!0):(Buffer.isBuffer(prime)||(prime=new Buffer(prime,enc)),new DH(prime,generator,!0)))}var generatePrime=require("./lib/generatePrime"),primes=require("./lib/primes.json"),DH=require("./lib/dh"),ENCODINGS={binary:!0,hex:!0,base64:!0};exports.DiffieHellmanGroup=exports.createDiffieHellmanGroup=exports.getDiffieHellman=getDiffieHellman,exports.createDiffieHellman=exports.DiffieHellman=createDiffieHellman}).call(this,require("buffer").Buffer)},{"./lib/dh":62,"./lib/generatePrime":63,"./lib/primes.json":64,buffer:45}],62:[function(require,module){(function(Buffer){function setPublicKey(pub,enc){return enc=enc||"utf8",Buffer.isBuffer(pub)||(pub=new Buffer(pub,enc)),this._pub=new BN(pub),this}function setPrivateKey(priv,enc){return enc=enc||"utf8",Buffer.isBuffer(priv)||(priv=new Buffer(priv,enc)),this._priv=new BN(priv),this}function checkPrime(prime,generator){var gen=generator.toString("hex"),hex=[gen,prime.toString(16)].join("_");if(hex in primeCache)return primeCache[hex];var error=0;if(prime.isEven()||!primes.simpleSieve||!primes.fermatTest(prime)||!millerRabin.test(prime))return error+=1,error+="02"===gen||"05"===gen?8:4,primeCache[hex]=error,error;millerRabin.test(prime.shrn(1))||(error+=2);var rem;switch(gen){case"02":prime.mod(TWENTYFOUR).cmp(ELEVEN)&&(error+=8);break;case"05":rem=prime.mod(TEN),rem.cmp(THREE)&&rem.cmp(SEVEN)&&(error+=8);break;default:error+=4}return primeCache[hex]=error,error}function DH(prime,generator,malleable){this.setGenerator(generator),this.__prime=new BN(prime),this._prime=BN.mont(this.__prime),this._primeLen=prime.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,malleable?(this.setPublicKey=setPublicKey,this.setPrivateKey=setPrivateKey):this._primeCode=8}function formatReturnValue(bn,enc){var buf=new Buffer(bn.toArray());return enc?buf.toString(enc):buf}var BN=require("bn.js"),MillerRabin=require("miller-rabin"),millerRabin=new MillerRabin,TWENTYFOUR=new BN(24),ELEVEN=new BN(11),TEN=new BN(10),THREE=new BN(3),SEVEN=new BN(7),primes=require("./generatePrime"),randomBytes=require("randombytes");module.exports=DH;var primeCache={};Object.defineProperty(DH.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=checkPrime(this.__prime,this.__gen)),this._primeCode}}),DH.prototype.generateKeys=function(){return this._priv||(this._priv=new BN(randomBytes(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},DH.prototype.computeSecret=function(other){other=new BN(other),other=other.toRed(this._prime);var secret=other.redPow(this._priv).fromRed(),out=new Buffer(secret.toArray()),prime=this.getPrime();if(out.length<prime.length){var front=new Buffer(prime.length-out.length);front.fill(0),out=Buffer.concat([front,out])}return out},DH.prototype.getPublicKey=function(enc){return formatReturnValue(this._pub,enc)},DH.prototype.getPrivateKey=function(enc){return formatReturnValue(this._priv,enc)},DH.prototype.getPrime=function(enc){return formatReturnValue(this.__prime,enc)},DH.prototype.getGenerator=function(enc){return formatReturnValue(this._gen,enc)},DH.prototype.setGenerator=function(gen,enc){return enc=enc||"utf8",Buffer.isBuffer(gen)||(gen=new Buffer(gen,enc)),this.__gen=gen,this._gen=new BN(gen),this}}).call(this,require("buffer").Buffer)},{"./generatePrime":63,"bn.js":16,buffer:45,"miller-rabin":96,randombytes:116}],63:[function(require,module){function _getPrimes(){if(null!==primes)return primes;var limit=1048576,res=[];res[0]=2;for(var i=1,k=3;limit>k;k+=2){for(var sqrt=Math.ceil(Math.sqrt(k)),j=0;i>j&&res[j]<=sqrt&&k%res[j]!==0;j++);i!==j&&res[j]<=sqrt||(res[i++]=k)}return primes=res,res}function simpleSieve(p){for(var primes=_getPrimes(),i=0;i<primes.length;i++)if(0===p.modn(primes[i]))return 0===p.cmpn(primes[i])?!0:!1;return!0}function fermatTest(p){var red=BN.mont(p);return 0===TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1)}function findPrime(bits,gen){if(16>bits)return new BN(2===gen||5===gen?[140,123]:[140,39]);gen=new BN(gen);for(var num,n2;;){for(num=new BN(randomBytes(Math.ceil(bits/8)));num.bitLength()>bits;)num.ishrn(1);if(num.isEven()&&num.iadd(ONE),num.testn(1)||num.iadd(TWO),gen.cmp(TWO)){if(!gen.cmp(FIVE))for(;num.mod(TEN).cmp(THREE);)num.iadd(FOUR)}else for(;num.mod(TWENTYFOUR).cmp(ELEVEN);)num.iadd(FOUR);if(n2=num.shrn(1),simpleSieve(n2)&&simpleSieve(num)&&fermatTest(n2)&&fermatTest(num)&&millerRabin.test(n2)&&millerRabin.test(num))return num}}var randomBytes=require("randombytes");module.exports=findPrime,findPrime.simpleSieve=simpleSieve,findPrime.fermatTest=fermatTest;var BN=require("bn.js"),TWENTYFOUR=new BN(24),MillerRabin=require("miller-rabin"),millerRabin=new MillerRabin,ONE=new BN(1),TWO=new BN(2),FIVE=new BN(5),TEN=(new BN(16),new BN(8),new BN(10)),THREE=new BN(3),ELEVEN=(new BN(7),new BN(11)),FOUR=new BN(4),primes=(new BN(12),null)},{"bn.js":16,"miller-rabin":96,randombytes:116}],64:[function(require,module){module.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"
  }}},{}],65:[function(require,module,exports){"use strict";var elliptic=exports;elliptic.version=require("../package.json").version,elliptic.utils=require("./elliptic/utils"),elliptic.rand=require("brorand"),elliptic.hmacDRBG=require("./elliptic/hmac-drbg"),elliptic.curve=require("./elliptic/curve"),elliptic.curves=require("./elliptic/curves"),elliptic.ec=require("./elliptic/ec"),elliptic.eddsa=require("./elliptic/eddsa")},{"../package.json":81,"./elliptic/curve":68,"./elliptic/curves":71,"./elliptic/ec":72,"./elliptic/eddsa":75,"./elliptic/hmac-drbg":78,"./elliptic/utils":80,brorand:17}],66:[function(require,module){"use strict";function BaseCurve(type,conf){this.type=type,this.p=new BN(conf.p,16),this.red=conf.prime?BN.red(conf.prime):BN.mont(this.p),this.zero=new BN(0).toRed(this.red),this.one=new BN(1).toRed(this.red),this.two=new BN(2).toRed(this.red),this.n=conf.n&&new BN(conf.n,16),this.g=conf.g&&this.pointFromJSON(conf.g,conf.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var adjustCount=this.n&&this.p.div(this.n);!adjustCount||adjustCount.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function BasePoint(curve,type){this.curve=curve,this.type=type,this.precomputed=null}var BN=require("bn.js"),elliptic=require("../../elliptic"),utils=elliptic.utils,getNAF=utils.getNAF,getJSF=utils.getJSF,assert=utils.assert;module.exports=BaseCurve,BaseCurve.prototype.point=function(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function(p,k){assert(p.precomputed);var doubles=p._getDoubles(),naf=getNAF(k,1),I=(1<<doubles.step+1)-(doubles.step%2===0?2:1);I/=3;for(var repr=[],j=0;j<naf.length;j+=doubles.step){for(var nafW=0,k=j+doubles.step-1;k>=j;k--)nafW=(nafW<<1)+naf[k];repr.push(nafW)}for(var a=this.jpoint(null,null,null),b=this.jpoint(null,null,null),i=I;i>0;i--){for(var j=0;j<repr.length;j++){var nafW=repr[j];nafW===i?b=b.mixedAdd(doubles.points[j]):nafW===-i&&(b=b.mixedAdd(doubles.points[j].neg()))}a=a.add(b)}return a.toP()},BaseCurve.prototype._wnafMul=function(p,k){var w=4,nafPoints=p._getNAFPoints(w);w=nafPoints.wnd;for(var wnd=nafPoints.points,naf=getNAF(k,w),acc=this.jpoint(null,null,null),i=naf.length-1;i>=0;i--){for(var k=0;i>=0&&0===naf[i];i--)k++;if(i>=0&&k++,acc=acc.dblp(k),0>i)break;var z=naf[i];assert(0!==z),acc="affine"===p.type?acc.mixedAdd(z>0?wnd[z-1>>1]:wnd[-z-1>>1].neg()):acc.add(z>0?wnd[z-1>>1]:wnd[-z-1>>1].neg())}return"affine"===p.type?acc.toP():acc},BaseCurve.prototype._wnafMulAdd=function(defW,points,coeffs,len,jacobianResult){for(var wndWidth=this._wnafT1,wnd=this._wnafT2,naf=this._wnafT3,max=0,i=0;len>i;i++){var p=points[i],nafPoints=p._getNAFPoints(defW);wndWidth[i]=nafPoints.wnd,wnd[i]=nafPoints.points}for(var i=len-1;i>=1;i-=2){var a=i-1,b=i;if(1===wndWidth[a]&&1===wndWidth[b]){var comb=[points[a],null,null,points[b]];0===points[a].y.cmp(points[b].y)?(comb[1]=points[a].add(points[b]),comb[2]=points[a].toJ().mixedAdd(points[b].neg())):0===points[a].y.cmp(points[b].y.redNeg())?(comb[1]=points[a].toJ().mixedAdd(points[b]),comb[2]=points[a].add(points[b].neg())):(comb[1]=points[a].toJ().mixedAdd(points[b]),comb[2]=points[a].toJ().mixedAdd(points[b].neg()));var index=[-3,-1,-5,-7,0,7,5,1,3],jsf=getJSF(coeffs[a],coeffs[b]);max=Math.max(jsf[0].length,max),naf[a]=new Array(max),naf[b]=new Array(max);for(var j=0;max>j;j++){var ja=0|jsf[0][j],jb=0|jsf[1][j];naf[a][j]=index[3*(ja+1)+(jb+1)],naf[b][j]=0,wnd[a]=comb}}else naf[a]=getNAF(coeffs[a],wndWidth[a]),naf[b]=getNAF(coeffs[b],wndWidth[b]),max=Math.max(naf[a].length,max),max=Math.max(naf[b].length,max)}for(var acc=this.jpoint(null,null,null),tmp=this._wnafT4,i=max;i>=0;i--){for(var k=0;i>=0;){for(var zero=!0,j=0;len>j;j++)tmp[j]=0|naf[j][i],0!==tmp[j]&&(zero=!1);if(!zero)break;k++,i--}if(i>=0&&k++,acc=acc.dblp(k),0>i)break;for(var j=0;len>j;j++){var p,z=tmp[j];0!==z&&(z>0?p=wnd[j][z-1>>1]:0>z&&(p=wnd[j][-z-1>>1].neg()),acc="affine"===p.type?acc.mixedAdd(p):acc.add(p))}}for(var i=0;len>i;i++)wnd[i]=null;return jacobianResult?acc:acc.toP()},BaseCurve.BasePoint=BasePoint,BasePoint.prototype.eq=function(){throw new Error("Not implemented")},BasePoint.prototype.validate=function(){return this.curve.validate(this)},BaseCurve.prototype.decodePoint=function(bytes,enc){bytes=utils.toArray(bytes,enc);var len=this.p.byteLength();if((4===bytes[0]||6===bytes[0]||7===bytes[0])&&bytes.length-1===2*len){6===bytes[0]?assert(bytes[bytes.length-1]%2===0):7===bytes[0]&&assert(bytes[bytes.length-1]%2===1);var res=this.point(bytes.slice(1,1+len),bytes.slice(1+len,1+2*len));return res}if((2===bytes[0]||3===bytes[0])&&bytes.length-1===len)return this.pointFromX(bytes.slice(1,1+len),3===bytes[0]);throw new Error("Unknown point format")},BasePoint.prototype.encodeCompressed=function(enc){return this.encode(enc,!0)},BasePoint.prototype._encode=function(compact){var len=this.curve.p.byteLength(),x=this.getX().toArray("be",len);return compact?[this.getY().isEven()?2:3].concat(x):[4].concat(x,this.getY().toArray("be",len))},BasePoint.prototype.encode=function(enc,compact){return utils.encode(this._encode(compact),enc)},BasePoint.prototype.precompute=function(power){if(this.precomputed)return this;var precomputed={doubles:null,naf:null,beta:null};return precomputed.naf=this._getNAFPoints(8),precomputed.doubles=this._getDoubles(4,power),precomputed.beta=this._getBeta(),this.precomputed=precomputed,this},BasePoint.prototype._hasDoubles=function(k){if(!this.precomputed)return!1;var doubles=this.precomputed.doubles;return doubles?doubles.points.length>=Math.ceil((k.bitLength()+1)/doubles.step):!1},BasePoint.prototype._getDoubles=function(step,power){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var doubles=[this],acc=this,i=0;power>i;i+=step){for(var j=0;step>j;j++)acc=acc.dbl();doubles.push(acc)}return{step:step,points:doubles}},BasePoint.prototype._getNAFPoints=function(wnd){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var res=[this],max=(1<<wnd)-1,dbl=1===max?null:this.dbl(),i=1;max>i;i++)res[i]=res[i-1].add(dbl);return{wnd:wnd,points:res}},BasePoint.prototype._getBeta=function(){return null},BasePoint.prototype.dblp=function(k){for(var r=this,i=0;k>i;i++)r=r.dbl();return r}},{"../../elliptic":65,"bn.js":16}],67:[function(require,module){"use strict";function EdwardsCurve(conf){this.twisted=1!==(0|conf.a),this.mOneA=this.twisted&&-1===(0|conf.a),this.extended=this.mOneA,Base.call(this,"edwards",conf),this.a=new BN(conf.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new BN(conf.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new BN(conf.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),assert(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1===(0|conf.c)}function Point(curve,x,y,z,t){Base.BasePoint.call(this,curve,"projective"),null===x&&null===y&&null===z?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new BN(x,16),this.y=new BN(y,16),this.z=z?new BN(z,16):this.curve.one,this.t=t&&new BN(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}var curve=require("../curve"),elliptic=require("../../elliptic"),BN=require("bn.js"),inherits=require("inherits"),Base=curve.base,assert=elliptic.utils.assert;inherits(EdwardsCurve,Base),module.exports=EdwardsCurve,EdwardsCurve.prototype._mulA=function(num){return this.mOneA?num.redNeg():this.a.redMul(num)},EdwardsCurve.prototype._mulC=function(num){return this.oneC?num:this.c.redMul(num)},EdwardsCurve.prototype.jpoint=function(x,y,z,t){return this.point(x,y,z,t)},EdwardsCurve.prototype.pointFromX=function(x,odd){x=new BN(x,16),x.red||(x=x.toRed(this.red));var x2=x.redSqr(),rhs=this.c2.redSub(this.a.redMul(x2)),lhs=this.one.redSub(this.c2.redMul(this.d).redMul(x2)),y2=rhs.redMul(lhs.redInvm()),y=y2.redSqrt();if(0!==y.redSqr().redSub(y2).cmp(this.zero))throw new Error("invalid point");var isOdd=y.fromRed().isOdd();return(odd&&!isOdd||!odd&&isOdd)&&(y=y.redNeg()),this.point(x,y)},EdwardsCurve.prototype.pointFromY=function(y,odd){y=new BN(y,16),y.red||(y=y.toRed(this.red));var y2=y.redSqr(),lhs=y2.redSub(this.one),rhs=y2.redMul(this.d).redAdd(this.one),x2=lhs.redMul(rhs.redInvm());if(0===x2.cmp(this.zero)){if(odd)throw new Error("invalid point");return this.point(this.zero,y)}var x=x2.redSqrt();if(0!==x.redSqr().redSub(x2).cmp(this.zero))throw new Error("invalid point");return x.isOdd()!==odd&&(x=x.redNeg()),this.point(x,y)},EdwardsCurve.prototype.validate=function(point){if(point.isInfinity())return!0;point.normalize();var x2=point.x.redSqr(),y2=point.y.redSqr(),lhs=x2.redMul(this.a).redAdd(y2),rhs=this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));return 0===lhs.cmp(rhs)},inherits(Point,Base.BasePoint),EdwardsCurve.prototype.pointFromJSON=function(obj){return Point.fromJSON(this,obj)},EdwardsCurve.prototype.point=function(x,y,z,t){return new Point(this,x,y,z,t)},Point.fromJSON=function(curve,obj){return new Point(curve,obj[0],obj[1],obj[2])},Point.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},Point.prototype._extDbl=function(){var a=this.x.redSqr(),b=this.y.redSqr(),c=this.z.redSqr();c=c.redIAdd(c);var d=this.curve._mulA(a),e=this.x.redAdd(this.y).redSqr().redISub(a).redISub(b),g=d.redAdd(b),f=g.redSub(c),h=d.redSub(b),nx=e.redMul(f),ny=g.redMul(h),nt=e.redMul(h),nz=f.redMul(g);return this.curve.point(nx,ny,nz,nt)},Point.prototype._projDbl=function(){var nx,ny,nz,b=this.x.redAdd(this.y).redSqr(),c=this.x.redSqr(),d=this.y.redSqr();if(this.curve.twisted){var e=this.curve._mulA(c),f=e.redAdd(d);if(this.zOne)nx=b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)),ny=f.redMul(e.redSub(d)),nz=f.redSqr().redSub(f).redSub(f);else{var h=this.z.redSqr(),j=f.redSub(h).redISub(h);nx=b.redSub(c).redISub(d).redMul(j),ny=f.redMul(e.redSub(d)),nz=f.redMul(j)}}else{var e=c.redAdd(d),h=this.curve._mulC(this.c.redMul(this.z)).redSqr(),j=e.redSub(h).redSub(h);nx=this.curve._mulC(b.redISub(e)).redMul(j),ny=this.curve._mulC(e).redMul(c.redISub(d)),nz=e.redMul(j)}return this.curve.point(nx,ny,nz)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(p){var a=this.y.redSub(this.x).redMul(p.y.redSub(p.x)),b=this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)),c=this.t.redMul(this.curve.dd).redMul(p.t),d=this.z.redMul(p.z.redAdd(p.z)),e=b.redSub(a),f=d.redSub(c),g=d.redAdd(c),h=b.redAdd(a),nx=e.redMul(f),ny=g.redMul(h),nt=e.redMul(h),nz=f.redMul(g);return this.curve.point(nx,ny,nz,nt)},Point.prototype._projAdd=function(p){var ny,nz,a=this.z.redMul(p.z),b=a.redSqr(),c=this.x.redMul(p.x),d=this.y.redMul(p.y),e=this.curve.d.redMul(c).redMul(d),f=b.redSub(e),g=b.redAdd(e),tmp=this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d),nx=a.redMul(f).redMul(tmp);return this.curve.twisted?(ny=a.redMul(g).redMul(d.redSub(this.curve._mulA(c))),nz=f.redMul(g)):(ny=a.redMul(g).redMul(d.redSub(c)),nz=this.curve._mulC(f).redMul(g)),this.curve.point(nx,ny,nz)},Point.prototype.add=function(p){return this.isInfinity()?p:p.isInfinity()?this:this.curve.extended?this._extAdd(p):this._projAdd(p)},Point.prototype.mul=function(k){return this._hasDoubles(k)?this.curve._fixedNafMul(this,k):this.curve._wnafMul(this,k)},Point.prototype.mulAdd=function(k1,p,k2){return this.curve._wnafMulAdd(1,[this,p],[k1,k2],2,!1)},Point.prototype.jmulAdd=function(k1,p,k2){return this.curve._wnafMulAdd(1,[this,p],[k1,k2],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var zi=this.z.redInvm();return this.x=this.x.redMul(zi),this.y=this.y.redMul(zi),this.t&&(this.t=this.t.redMul(zi)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(other){return this===other||0===this.getX().cmp(other.getX())&&0===this.getY().cmp(other.getY())},Point.prototype.eqXToP=function(x){var rx=x.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(rx))return!0;for(var xc=x.clone(),t=this.curve.redN.redMul(this.z);;){if(xc.iadd(this.curve.n),xc.cmp(this.curve.p)>=0)return!1;if(rx.redIAdd(t),0===this.x.cmp(rx))return!0}return!1},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../../elliptic":65,"../curve":68,"bn.js":16,inherits:93}],68:[function(require,module,exports){"use strict";var curve=exports;curve.base=require("./base"),curve["short"]=require("./short"),curve.mont=require("./mont"),curve.edwards=require("./edwards")},{"./base":66,"./edwards":67,"./mont":69,"./short":70}],69:[function(require,module){"use strict";function MontCurve(conf){Base.call(this,"mont",conf),this.a=new BN(conf.a,16).toRed(this.red),this.b=new BN(conf.b,16).toRed(this.red),this.i4=new BN(4).toRed(this.red).redInvm(),this.two=new BN(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(curve,x,z){Base.BasePoint.call(this,curve,"projective"),null===x&&null===z?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new BN(x,16),this.z=new BN(z,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}var curve=require("../curve"),BN=require("bn.js"),inherits=require("inherits"),Base=curve.base,elliptic=require("../../elliptic"),utils=elliptic.utils;inherits(MontCurve,Base),module.exports=MontCurve,MontCurve.prototype.validate=function(point){var x=point.normalize().x,x2=x.redSqr(),rhs=x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x),y=rhs.redSqrt();return 0===y.redSqr().cmp(rhs)},inherits(Point,Base.BasePoint),MontCurve.prototype.decodePoint=function(bytes,enc){return this.point(utils.toArray(bytes,enc),1)},MontCurve.prototype.point=function(x,z){return new Point(this,x,z)},MontCurve.prototype.pointFromJSON=function(obj){return Point.fromJSON(this,obj)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(curve,obj){return new Point(curve,obj[0],obj[1]||curve.one)},Point.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var a=this.x.redAdd(this.z),aa=a.redSqr(),b=this.x.redSub(this.z),bb=b.redSqr(),c=aa.redSub(bb),nx=aa.redMul(bb),nz=c.redMul(bb.redAdd(this.curve.a24.redMul(c)));return this.curve.point(nx,nz)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(p,diff){var a=this.x.redAdd(this.z),b=this.x.redSub(this.z),c=p.x.redAdd(p.z),d=p.x.redSub(p.z),da=d.redMul(a),cb=c.redMul(b),nx=diff.z.redMul(da.redAdd(cb).redSqr()),nz=diff.x.redMul(da.redISub(cb).redSqr());return this.curve.point(nx,nz)},Point.prototype.mul=function(k){for(var t=k.clone(),a=this,b=this.curve.point(null,null),c=this,bits=[];0!==t.cmpn(0);t.iushrn(1))bits.push(t.andln(1));for(var i=bits.length-1;i>=0;i--)0===bits[i]?(a=a.diffAdd(b,c),b=b.dbl()):(b=a.diffAdd(b,c),a=a.dbl());return b},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(other){return 0===this.getX().cmp(other.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":65,"../curve":68,"bn.js":16,inherits:93}],70:[function(require,module){"use strict";function ShortCurve(conf){Base.call(this,"short",conf),this.a=new BN(conf.a,16).toRed(this.red),this.b=new BN(conf.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(conf),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(curve,x,y,isRed){Base.BasePoint.call(this,curve,"affine"),null===x&&null===y?(this.x=null,this.y=null,this.inf=!0):(this.x=new BN(x,16),this.y=new BN(y,16),isRed&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function JPoint(curve,x,y,z){Base.BasePoint.call(this,curve,"jacobian"),null===x&&null===y&&null===z?(this.x=this.curve.one,this.y=this.curve.one,this.z=new BN(0)):(this.x=new BN(x,16),this.y=new BN(y,16),this.z=new BN(z,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}var curve=require("../curve"),elliptic=require("../../elliptic"),BN=require("bn.js"),inherits=require("inherits"),Base=curve.base,assert=elliptic.utils.assert;inherits(ShortCurve,Base),module.exports=ShortCurve,ShortCurve.prototype._getEndomorphism=function(conf){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var beta,lambda;if(conf.beta)beta=new BN(conf.beta,16).toRed(this.red);else{var betas=this._getEndoRoots(this.p);beta=betas[0].cmp(betas[1])<0?betas[0]:betas[1],beta=beta.toRed(this.red)}if(conf.lambda)lambda=new BN(conf.lambda,16);else{var lambdas=this._getEndoRoots(this.n);0===this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta))?lambda=lambdas[0]:(lambda=lambdas[1],assert(0===this.g.mul(lambda).x.cmp(this.g.x.redMul(beta))))}var basis;return basis=conf.basis?conf.basis.map(function(vec){return{a:new BN(vec.a,16),b:new BN(vec.b,16)}}):this._getEndoBasis(lambda),{beta:beta,lambda:lambda,basis:basis}}},ShortCurve.prototype._getEndoRoots=function(num){var red=num===this.p?this.red:BN.mont(num),tinv=new BN(2).toRed(red).redInvm(),ntinv=tinv.redNeg(),s=new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv),l1=ntinv.redAdd(s).fromRed(),l2=ntinv.redSub(s).fromRed();return[l1,l2]},ShortCurve.prototype._getEndoBasis=function(lambda){for(var a0,b0,a1,b1,a2,b2,prevR,r,x,aprxSqrt=this.n.ushrn(Math.floor(this.n.bitLength()/2)),u=lambda,v=this.n.clone(),x1=new BN(1),y1=new BN(0),x2=new BN(0),y2=new BN(1),i=0;0!==u.cmpn(0);){var q=v.div(u);r=v.sub(q.mul(u)),x=x2.sub(q.mul(x1));var y=y2.sub(q.mul(y1));if(!a1&&r.cmp(aprxSqrt)<0)a0=prevR.neg(),b0=x1,a1=r.neg(),b1=x;else if(a1&&2===++i)break;prevR=r,v=u,u=r,x2=x1,x1=x,y2=y1,y1=y}a2=r.neg(),b2=x;var len1=a1.sqr().add(b1.sqr()),len2=a2.sqr().add(b2.sqr());return len2.cmp(len1)>=0&&(a2=a0,b2=b0),a1.negative&&(a1=a1.neg(),b1=b1.neg()),a2.negative&&(a2=a2.neg(),b2=b2.neg()),[{a:a1,b:b1},{a:a2,b:b2}]},ShortCurve.prototype._endoSplit=function(k){var basis=this.endo.basis,v1=basis[0],v2=basis[1],c1=v2.b.mul(k).divRound(this.n),c2=v1.b.neg().mul(k).divRound(this.n),p1=c1.mul(v1.a),p2=c2.mul(v2.a),q1=c1.mul(v1.b),q2=c2.mul(v2.b),k1=k.sub(p1).sub(p2),k2=q1.add(q2).neg();return{k1:k1,k2:k2}},ShortCurve.prototype.pointFromX=function(x,odd){x=new BN(x,16),x.red||(x=x.toRed(this.red));var y2=x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b),y=y2.redSqrt();if(0!==y.redSqr().redSub(y2).cmp(this.zero))throw new Error("invalid point");var isOdd=y.fromRed().isOdd();return(odd&&!isOdd||!odd&&isOdd)&&(y=y.redNeg()),this.point(x,y)},ShortCurve.prototype.validate=function(point){if(point.inf)return!0;var x=point.x,y=point.y,ax=this.a.redMul(x),rhs=x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);return 0===y.redSqr().redISub(rhs).cmpn(0)},ShortCurve.prototype._endoWnafMulAdd=function(points,coeffs,jacobianResult){for(var npoints=this._endoWnafT1,ncoeffs=this._endoWnafT2,i=0;i<points.length;i++){var split=this._endoSplit(coeffs[i]),p=points[i],beta=p._getBeta();split.k1.negative&&(split.k1.ineg(),p=p.neg(!0)),split.k2.negative&&(split.k2.ineg(),beta=beta.neg(!0)),npoints[2*i]=p,npoints[2*i+1]=beta,ncoeffs[2*i]=split.k1,ncoeffs[2*i+1]=split.k2}for(var res=this._wnafMulAdd(1,npoints,ncoeffs,2*i,jacobianResult),j=0;2*i>j;j++)npoints[j]=null,ncoeffs[j]=null;return res},inherits(Point,Base.BasePoint),ShortCurve.prototype.point=function(x,y,isRed){return new Point(this,x,y,isRed)},ShortCurve.prototype.pointFromJSON=function(obj,red){return Point.fromJSON(this,obj,red)},Point.prototype._getBeta=function(){if(this.curve.endo){var pre=this.precomputed;if(pre&&pre.beta)return pre.beta;var beta=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(pre){var curve=this.curve,endoMul=function(p){return curve.point(p.x.redMul(curve.endo.beta),p.y)};pre.beta=beta,beta.precomputed={beta:null,naf:pre.naf&&{wnd:pre.naf.wnd,points:pre.naf.points.map(endoMul)},doubles:pre.doubles&&{step:pre.doubles.step,points:pre.doubles.points.map(endoMul)}}}return beta}},Point.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},Point.fromJSON=function(curve,obj,red){function obj2point(obj){return curve.point(obj[0],obj[1],red)}"string"==typeof obj&&(obj=JSON.parse(obj));var res=curve.point(obj[0],obj[1],red);if(!obj[2])return res;var pre=obj[2];return res.precomputed={beta:null,doubles:pre.doubles&&{step:pre.doubles.step,points:[res].concat(pre.doubles.points.map(obj2point))},naf:pre.naf&&{wnd:pre.naf.wnd,points:[res].concat(pre.naf.points.map(obj2point))}},res},Point.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(p){if(this.inf)return p;if(p.inf)return this;if(this.eq(p))return this.dbl();if(this.neg().eq(p))return this.curve.point(null,null);if(0===this.x.cmp(p.x))return this.curve.point(null,null);var c=this.y.redSub(p.y);0!==c.cmpn(0)&&(c=c.redMul(this.x.redSub(p.x).redInvm()));var nx=c.redSqr().redISub(this.x).redISub(p.x),ny=c.redMul(this.x.redSub(nx)).redISub(this.y);return this.curve.point(nx,ny)},Point.prototype.dbl=function(){if(this.inf)return this;var ys1=this.y.redAdd(this.y);if(0===ys1.cmpn(0))return this.curve.point(null,null);var a=this.curve.a,x2=this.x.redSqr(),dyinv=ys1.redInvm(),c=x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv),nx=c.redSqr().redISub(this.x.redAdd(this.x)),ny=c.redMul(this.x.redSub(nx)).redISub(this.y);return this.curve.point(nx,ny)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(k){return k=new BN(k,16),this._hasDoubles(k)?this.curve._fixedNafMul(this,k):this.curve.endo?this.curve._endoWnafMulAdd([this],[k]):this.curve._wnafMul(this,k)},Point.prototype.mulAdd=function(k1,p2,k2){var points=[this,p2],coeffs=[k1,k2];return this.curve.endo?this.curve._endoWnafMulAdd(points,coeffs):this.curve._wnafMulAdd(1,points,coeffs,2)},Point.prototype.jmulAdd=function(k1,p2,k2){var points=[this,p2],coeffs=[k1,k2];return this.curve.endo?this.curve._endoWnafMulAdd(points,coeffs,!0):this.curve._wnafMulAdd(1,points,coeffs,2,!0)},Point.prototype.eq=function(p){return this===p||this.inf===p.inf&&(this.inf||0===this.x.cmp(p.x)&&0===this.y.cmp(p.y))},Point.prototype.neg=function(_precompute){if(this.inf)return this;var res=this.curve.point(this.x,this.y.redNeg());if(_precompute&&this.precomputed){var pre=this.precomputed,negate=function(p){return p.neg()};res.precomputed={naf:pre.naf&&{wnd:pre.naf.wnd,points:pre.naf.points.map(negate)},doubles:pre.doubles&&{step:pre.doubles.step,points:pre.doubles.points.map(negate)}}}return res},Point.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var res=this.curve.jpoint(this.x,this.y,this.curve.one);return res},inherits(JPoint,Base.BasePoint),ShortCurve.prototype.jpoint=function(x,y,z){return new JPoint(this,x,y,z)},JPoint.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var zinv=this.z.redInvm(),zinv2=zinv.redSqr(),ax=this.x.redMul(zinv2),ay=this.y.redMul(zinv2).redMul(zinv);return this.curve.point(ax,ay)},JPoint.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},JPoint.prototype.add=function(p){if(this.isInfinity())return p;if(p.isInfinity())return this;var pz2=p.z.redSqr(),z2=this.z.redSqr(),u1=this.x.redMul(pz2),u2=p.x.redMul(z2),s1=this.y.redMul(pz2.redMul(p.z)),s2=p.y.redMul(z2.redMul(this.z)),h=u1.redSub(u2),r=s1.redSub(s2);if(0===h.cmpn(0))return 0!==r.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h2=h.redSqr(),h3=h2.redMul(h),v=u1.redMul(h2),nx=r.redSqr().redIAdd(h3).redISub(v).redISub(v),ny=r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)),nz=this.z.redMul(p.z).redMul(h);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.mixedAdd=function(p){if(this.isInfinity())return p.toJ();if(p.isInfinity())return this;var z2=this.z.redSqr(),u1=this.x,u2=p.x.redMul(z2),s1=this.y,s2=p.y.redMul(z2).redMul(this.z),h=u1.redSub(u2),r=s1.redSub(s2);if(0===h.cmpn(0))return 0!==r.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h2=h.redSqr(),h3=h2.redMul(h),v=u1.redMul(h2),nx=r.redSqr().redIAdd(h3).redISub(v).redISub(v),ny=r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)),nz=this.z.redMul(h);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.dblp=function(pow){if(0===pow)return this;if(this.isInfinity())return this;if(!pow)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var r=this,i=0;pow>i;i++)r=r.dbl();return r}for(var a=this.curve.a,tinv=this.curve.tinv,jx=this.x,jy=this.y,jz=this.z,jz4=jz.redSqr().redSqr(),jyd=jy.redAdd(jy),i=0;pow>i;i++){var jx2=jx.redSqr(),jyd2=jyd.redSqr(),jyd4=jyd2.redSqr(),c=jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)),t1=jx.redMul(jyd2),nx=c.redSqr().redISub(t1.redAdd(t1)),t2=t1.redISub(nx),dny=c.redMul(t2);dny=dny.redIAdd(dny).redISub(jyd4);var nz=jyd.redMul(jz);pow>i+1&&(jz4=jz4.redMul(jyd4)),jx=nx,jz=nz,jyd=dny}return this.curve.jpoint(jx,jyd.redMul(tinv),jz)},JPoint.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},JPoint.prototype._zeroDbl=function(){var nx,ny,nz;if(this.zOne){var xx=this.x.redSqr(),yy=this.y.redSqr(),yyyy=yy.redSqr(),s=this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);s=s.redIAdd(s);var m=xx.redAdd(xx).redIAdd(xx),t=m.redSqr().redISub(s).redISub(s),yyyy8=yyyy.redIAdd(yyyy);yyyy8=yyyy8.redIAdd(yyyy8),yyyy8=yyyy8.redIAdd(yyyy8),nx=t,ny=m.redMul(s.redISub(t)).redISub(yyyy8),nz=this.y.redAdd(this.y)}else{var a=this.x.redSqr(),b=this.y.redSqr(),c=b.redSqr(),d=this.x.redAdd(b).redSqr().redISub(a).redISub(c);d=d.redIAdd(d);var e=a.redAdd(a).redIAdd(a),f=e.redSqr(),c8=c.redIAdd(c);c8=c8.redIAdd(c8),c8=c8.redIAdd(c8),nx=f.redISub(d).redISub(d),ny=e.redMul(d.redISub(nx)).redISub(c8),nz=this.y.redMul(this.z),nz=nz.redIAdd(nz)}return this.curve.jpoint(nx,ny,nz)},JPoint.prototype._threeDbl=function(){var nx,ny,nz;if(this.zOne){var xx=this.x.redSqr(),yy=this.y.redSqr(),yyyy=yy.redSqr(),s=this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);s=s.redIAdd(s);var m=xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a),t=m.redSqr().redISub(s).redISub(s);nx=t;var yyyy8=yyyy.redIAdd(yyyy);yyyy8=yyyy8.redIAdd(yyyy8),yyyy8=yyyy8.redIAdd(yyyy8),ny=m.redMul(s.redISub(t)).redISub(yyyy8),nz=this.y.redAdd(this.y)}else{var delta=this.z.redSqr(),gamma=this.y.redSqr(),beta=this.x.redMul(gamma),alpha=this.x.redSub(delta).redMul(this.x.redAdd(delta));alpha=alpha.redAdd(alpha).redIAdd(alpha);var beta4=beta.redIAdd(beta);beta4=beta4.redIAdd(beta4);var beta8=beta4.redAdd(beta4);nx=alpha.redSqr().redISub(beta8),nz=this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);var ggamma8=gamma.redSqr();ggamma8=ggamma8.redIAdd(ggamma8),ggamma8=ggamma8.redIAdd(ggamma8),ggamma8=ggamma8.redIAdd(ggamma8),ny=alpha.redMul(beta4.redISub(nx)).redISub(ggamma8)}return this.curve.jpoint(nx,ny,nz)},JPoint.prototype._dbl=function(){var a=this.curve.a,jx=this.x,jy=this.y,jz=this.z,jz4=jz.redSqr().redSqr(),jx2=jx.redSqr(),jy2=jy.redSqr(),c=jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)),jxd4=jx.redAdd(jx);jxd4=jxd4.redIAdd(jxd4);var t1=jxd4.redMul(jy2),nx=c.redSqr().redISub(t1.redAdd(t1)),t2=t1.redISub(nx),jyd8=jy2.redSqr();jyd8=jyd8.redIAdd(jyd8),jyd8=jyd8.redIAdd(jyd8),jyd8=jyd8.redIAdd(jyd8);var ny=c.redMul(t2).redISub(jyd8),nz=jy.redAdd(jy).redMul(jz);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var xx=this.x.redSqr(),yy=this.y.redSqr(),zz=this.z.redSqr(),yyyy=yy.redSqr(),m=xx.redAdd(xx).redIAdd(xx),mm=m.redSqr(),e=this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);e=e.redIAdd(e),e=e.redAdd(e).redIAdd(e),e=e.redISub(mm);var ee=e.redSqr(),t=yyyy.redIAdd(yyyy);t=t.redIAdd(t),t=t.redIAdd(t),t=t.redIAdd(t);var u=m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t),yyu4=yy.redMul(u);yyu4=yyu4.redIAdd(yyu4),yyu4=yyu4.redIAdd(yyu4);var nx=this.x.redMul(ee).redISub(yyu4);nx=nx.redIAdd(nx),nx=nx.redIAdd(nx);var ny=this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));ny=ny.redIAdd(ny),ny=ny.redIAdd(ny),ny=ny.redIAdd(ny);var nz=this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.mul=function(k,kbase){return k=new BN(k,kbase),this.curve._wnafMul(this,k)},JPoint.prototype.eq=function(p){if("affine"===p.type)return this.eq(p.toJ());if(this===p)return!0;var z2=this.z.redSqr(),pz2=p.z.redSqr();if(0!==this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0))return!1;var z3=z2.redMul(this.z),pz3=pz2.redMul(p.z);return 0===this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0)},JPoint.prototype.eqXToP=function(x){var zs=this.z.redSqr(),rx=x.toRed(this.curve.red).redMul(zs);if(0===this.x.cmp(rx))return!0;for(var xc=x.clone(),t=this.curve.redN.redMul(zs);;){if(xc.iadd(this.curve.n),xc.cmp(this.curve.p)>=0)return!1;if(rx.redIAdd(t),0===this.x.cmp(rx))return!0}return!1},JPoint.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},JPoint.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":65,"../curve":68,"bn.js":16,inherits:93}],71:[function(require,module,exports){"use strict";function PresetCurve(options){this.curve="short"===options.type?new elliptic.curve["short"](options):"edwards"===options.type?new elliptic.curve.edwards(options):new elliptic.curve.mont(options),this.g=this.curve.g,this.n=this.curve.n,this.hash=options.hash,assert(this.g.validate(),"Invalid curve"),assert(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function defineCurve(name,options){Object.defineProperty(curves,name,{configurable:!0,enumerable:!0,get:function(){var curve=new PresetCurve(options);return Object.defineProperty(curves,name,{configurable:!0,enumerable:!0,value:curve}),curve}})}var curves=exports,hash=require("hash.js"),elliptic=require("../elliptic"),assert=elliptic.utils.assert;
  
  curves.PresetCurve=PresetCurve,defineCurve("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:hash.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),defineCurve("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:hash.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),defineCurve("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:hash.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),defineCurve("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:hash.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),defineCurve("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:hash.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),defineCurve("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"0",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash.sha256,gRed:!1,g:["9"]}),defineCurve("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var pre;try{pre=require("./precomputed/secp256k1")}catch(e){pre=void 0}defineCurve("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:hash.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",pre]})},{"../elliptic":65,"./precomputed/secp256k1":79,"hash.js":84}],72:[function(require,module){"use strict";function EC(options){return this instanceof EC?("string"==typeof options&&(assert(elliptic.curves.hasOwnProperty(options),"Unknown curve "+options),options=elliptic.curves[options]),options instanceof elliptic.curves.PresetCurve&&(options={curve:options}),this.curve=options.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=options.curve.g,this.g.precompute(options.curve.n.bitLength()+1),void(this.hash=options.hash||options.curve.hash)):new EC(options)}var BN=require("bn.js"),elliptic=require("../../elliptic"),utils=elliptic.utils,assert=utils.assert,KeyPair=require("./key"),Signature=require("./signature");module.exports=EC,EC.prototype.keyPair=function(options){return new KeyPair(this,options)},EC.prototype.keyFromPrivate=function(priv,enc){return KeyPair.fromPrivate(this,priv,enc)},EC.prototype.keyFromPublic=function(pub,enc){return KeyPair.fromPublic(this,pub,enc)},EC.prototype.genKeyPair=function(options){options||(options={});for(var drbg=new elliptic.hmacDRBG({hash:this.hash,pers:options.pers,entropy:options.entropy||elliptic.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),bytes=this.n.byteLength(),ns2=this.n.sub(new BN(2));;){var priv=new BN(drbg.generate(bytes));if(!(priv.cmp(ns2)>0))return priv.iaddn(1),this.keyFromPrivate(priv)}},EC.prototype._truncateToN=function(msg,truncOnly){var delta=8*msg.byteLength()-this.n.bitLength();return delta>0&&(msg=msg.ushrn(delta)),!truncOnly&&msg.cmp(this.n)>=0?msg.sub(this.n):msg},EC.prototype.sign=function(msg,key,enc,options){"object"==typeof enc&&(options=enc,enc=null),options||(options={}),key=this.keyFromPrivate(key,enc),msg=this._truncateToN(new BN(msg,16));for(var bytes=this.n.byteLength(),bkey=key.getPrivate().toArray("be",bytes),nonce=msg.toArray("be",bytes),drbg=new elliptic.hmacDRBG({hash:this.hash,entropy:bkey,nonce:nonce,pers:options.pers,persEnc:options.persEnc}),ns1=this.n.sub(new BN(1)),iter=0;!0;iter++){var k=options.k?options.k(iter):new BN(drbg.generate(this.n.byteLength()));if(k=this._truncateToN(k,!0),!(k.cmpn(1)<=0||k.cmp(ns1)>=0)){var kp=this.g.mul(k);if(!kp.isInfinity()){var kpX=kp.getX(),r=kpX.umod(this.n);if(0!==r.cmpn(0)){var s=k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));if(s=s.umod(this.n),0!==s.cmpn(0)){var recoveryParam=(kp.getY().isOdd()?1:0)|(0!==kpX.cmp(r)?2:0);return options.canonical&&s.cmp(this.nh)>0&&(s=this.n.sub(s),recoveryParam^=1),new Signature({r:r,s:s,recoveryParam:recoveryParam})}}}}}},EC.prototype.verify=function(msg,signature,key,enc){msg=this._truncateToN(new BN(msg,16)),key=this.keyFromPublic(key,enc),signature=new Signature(signature,"hex");var r=signature.r,s=signature.s;if(r.cmpn(1)<0||r.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var sinv=s.invm(this.n),u1=sinv.mul(msg).umod(this.n),u2=sinv.mul(r).umod(this.n);if(!this.curve._maxwellTrick){var p=this.g.mulAdd(u1,key.getPublic(),u2);return p.isInfinity()?!1:0===p.getX().umod(this.n).cmp(r)}var p=this.g.jmulAdd(u1,key.getPublic(),u2);return p.isInfinity()?!1:p.eqXToP(r)},EC.prototype.recoverPubKey=function(msg,signature,j,enc){assert((3&j)===j,"The recovery param is more than two bits"),signature=new Signature(signature,enc);var n=this.n,e=new BN(msg),r=signature.r,s=signature.s,isYOdd=1&j,isSecondKey=j>>1;if(r.cmp(this.curve.p.umod(this.curve.n))>=0&&isSecondKey)throw new Error("Unable to find sencond key candinate");r=isSecondKey?this.curve.pointFromX(r.add(this.curve.n),isYOdd):this.curve.pointFromX(r,isYOdd);var rInv=signature.r.invm(n),s1=n.sub(e).mul(rInv).umod(n),s2=s.mul(rInv).umod(n);return this.g.mulAdd(s1,r,s2)},EC.prototype.getKeyRecoveryParam=function(e,signature,Q,enc){if(signature=new Signature(signature,enc),null!==signature.recoveryParam)return signature.recoveryParam;for(var i=0;4>i;i++){var Qprime;try{Qprime=this.recoverPubKey(e,signature,i)}catch(e){continue}if(Qprime.eq(Q))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":65,"./key":73,"./signature":74,"bn.js":16}],73:[function(require,module){"use strict";function KeyPair(ec,options){this.ec=ec,this.priv=null,this.pub=null,options.priv&&this._importPrivate(options.priv,options.privEnc),options.pub&&this._importPublic(options.pub,options.pubEnc)}var BN=require("bn.js");module.exports=KeyPair,KeyPair.fromPublic=function(ec,pub,enc){return pub instanceof KeyPair?pub:new KeyPair(ec,{pub:pub,pubEnc:enc})},KeyPair.fromPrivate=function(ec,priv,enc){return priv instanceof KeyPair?priv:new KeyPair(ec,{priv:priv,privEnc:enc})},KeyPair.prototype.validate=function(){var pub=this.getPublic();return pub.isInfinity()?{result:!1,reason:"Invalid public key"}:pub.validate()?pub.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},KeyPair.prototype.getPublic=function(compact,enc){return"string"==typeof compact&&(enc=compact,compact=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),enc?this.pub.encode(enc,compact):this.pub},KeyPair.prototype.getPrivate=function(enc){return"hex"===enc?this.priv.toString(16,2):this.priv},KeyPair.prototype._importPrivate=function(key,enc){this.priv=new BN(key,enc||16),this.priv=this.priv.umod(this.ec.curve.n)},KeyPair.prototype._importPublic=function(key,enc){return key.x||key.y?void(this.pub=this.ec.curve.point(key.x,key.y)):void(this.pub=this.ec.curve.decodePoint(key,enc))},KeyPair.prototype.derive=function(pub){return pub.mul(this.priv).getX()},KeyPair.prototype.sign=function(msg,enc,options){return this.ec.sign(msg,this,enc,options)},KeyPair.prototype.verify=function(msg,signature){return this.ec.verify(msg,signature,this)},KeyPair.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},{"bn.js":16}],74:[function(require,module){"use strict";function Signature(options,enc){return options instanceof Signature?options:void(this._importDER(options,enc)||(assert(options.r&&options.s,"Signature without r or s"),this.r=new BN(options.r,16),this.s=new BN(options.s,16),this.recoveryParam=void 0===options.recoveryParam?null:options.recoveryParam))}function Position(){this.place=0}function getLength(buf,p){var initial=buf[p.place++];if(!(128&initial))return initial;for(var octetLen=15&initial,val=0,i=0,off=p.place;octetLen>i;i++,off++)val<<=8,val|=buf[off];return p.place=off,val}function rmPadding(buf){for(var i=0,len=buf.length-1;!buf[i]&&!(128&buf[i+1])&&len>i;)i++;return 0===i?buf:buf.slice(i)}function constructLength(arr,len){if(128>len)return void arr.push(len);var octets=1+(Math.log(len)/Math.LN2>>>3);for(arr.push(128|octets);--octets;)arr.push(len>>>(octets<<3)&255);arr.push(len)}var BN=require("bn.js"),elliptic=require("../../elliptic"),utils=elliptic.utils,assert=utils.assert;module.exports=Signature,Signature.prototype._importDER=function(data,enc){data=utils.toArray(data,enc);var p=new Position;if(48!==data[p.place++])return!1;var len=getLength(data,p);if(len+p.place!==data.length)return!1;if(2!==data[p.place++])return!1;var rlen=getLength(data,p),r=data.slice(p.place,rlen+p.place);if(p.place+=rlen,2!==data[p.place++])return!1;var slen=getLength(data,p);if(data.length!==slen+p.place)return!1;var s=data.slice(p.place,slen+p.place);return 0===r[0]&&128&r[1]&&(r=r.slice(1)),0===s[0]&&128&s[1]&&(s=s.slice(1)),this.r=new BN(r),this.s=new BN(s),this.recoveryParam=null,!0},Signature.prototype.toDER=function(enc){var r=this.r.toArray(),s=this.s.toArray();for(128&r[0]&&(r=[0].concat(r)),128&s[0]&&(s=[0].concat(s)),r=rmPadding(r),s=rmPadding(s);!(s[0]||128&s[1]);)s=s.slice(1);var arr=[2];constructLength(arr,r.length),arr=arr.concat(r),arr.push(2),constructLength(arr,s.length);var backHalf=arr.concat(s),res=[48];return constructLength(res,backHalf.length),res=res.concat(backHalf),utils.encode(res,enc)}},{"../../elliptic":65,"bn.js":16}],75:[function(require,module){"use strict";function EDDSA(curve){if(assert("ed25519"===curve,"only tested with ed25519 so far"),!(this instanceof EDDSA))return new EDDSA(curve);var curve=elliptic.curves[curve].curve;this.curve=curve,this.g=curve.g,this.g.precompute(curve.n.bitLength()+1),this.pointClass=curve.point().constructor,this.encodingLength=Math.ceil(curve.n.bitLength()/8),this.hash=hash.sha512}var hash=require("hash.js"),elliptic=require("../../elliptic"),utils=elliptic.utils,assert=utils.assert,parseBytes=utils.parseBytes,KeyPair=require("./key"),Signature=require("./signature");module.exports=EDDSA,EDDSA.prototype.sign=function(message,secret){message=parseBytes(message);var key=this.keyFromSecret(secret),r=this.hashInt(key.messagePrefix(),message),R=this.g.mul(r),Rencoded=this.encodePoint(R),s_=this.hashInt(Rencoded,key.pubBytes(),message).mul(key.priv()),S=r.add(s_).umod(this.curve.n);return this.makeSignature({R:R,S:S,Rencoded:Rencoded})},EDDSA.prototype.verify=function(message,sig,pub){message=parseBytes(message),sig=this.makeSignature(sig);var key=this.keyFromPublic(pub),h=this.hashInt(sig.Rencoded(),key.pubBytes(),message),SG=this.g.mul(sig.S()),RplusAh=sig.R().add(key.pub().mul(h));return RplusAh.eq(SG)},EDDSA.prototype.hashInt=function(){for(var hash=this.hash(),i=0;i<arguments.length;i++)hash.update(arguments[i]);return utils.intFromLE(hash.digest()).umod(this.curve.n)},EDDSA.prototype.keyFromPublic=function(pub){return KeyPair.fromPublic(this,pub)},EDDSA.prototype.keyFromSecret=function(secret){return KeyPair.fromSecret(this,secret)},EDDSA.prototype.makeSignature=function(sig){return sig instanceof Signature?sig:new Signature(this,sig)},EDDSA.prototype.encodePoint=function(point){var enc=point.getY().toArray("le",this.encodingLength);return enc[this.encodingLength-1]|=point.getX().isOdd()?128:0,enc},EDDSA.prototype.decodePoint=function(bytes){bytes=utils.parseBytes(bytes);var lastIx=bytes.length-1,normed=bytes.slice(0,lastIx).concat(-129&bytes[lastIx]),xIsOdd=0!==(128&bytes[lastIx]),y=utils.intFromLE(normed);return this.curve.pointFromY(y,xIsOdd)},EDDSA.prototype.encodeInt=function(num){return num.toArray("le",this.encodingLength)},EDDSA.prototype.decodeInt=function(bytes){return utils.intFromLE(bytes)},EDDSA.prototype.isPoint=function(val){return val instanceof this.pointClass}},{"../../elliptic":65,"./key":76,"./signature":77,"hash.js":84}],76:[function(require,module){"use strict";function KeyPair(eddsa,params){this.eddsa=eddsa,this._secret=parseBytes(params.secret),eddsa.isPoint(params.pub)?this._pub=params.pub:this._pubBytes=parseBytes(params.pub)}var elliptic=require("../../elliptic"),utils=elliptic.utils,assert=utils.assert,parseBytes=utils.parseBytes,cachedProperty=utils.cachedProperty;KeyPair.fromPublic=function(eddsa,pub){return pub instanceof KeyPair?pub:new KeyPair(eddsa,{pub:pub})},KeyPair.fromSecret=function(eddsa,secret){return secret instanceof KeyPair?secret:new KeyPair(eddsa,{secret:secret})},KeyPair.prototype.secret=function(){return this._secret},cachedProperty(KeyPair,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),cachedProperty(KeyPair,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),cachedProperty(KeyPair,"privBytes",function(){var eddsa=this.eddsa,hash=this.hash(),lastIx=eddsa.encodingLength-1,a=hash.slice(0,eddsa.encodingLength);return a[0]&=248,a[lastIx]&=127,a[lastIx]|=64,a}),cachedProperty(KeyPair,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),cachedProperty(KeyPair,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),cachedProperty(KeyPair,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),KeyPair.prototype.sign=function(message){return assert(this._secret,"KeyPair can only verify"),this.eddsa.sign(message,this)},KeyPair.prototype.verify=function(message,sig){return this.eddsa.verify(message,sig,this)},KeyPair.prototype.getSecret=function(enc){return assert(this._secret,"KeyPair is public only"),utils.encode(this.secret(),enc)},KeyPair.prototype.getPublic=function(enc){return utils.encode(this.pubBytes(),enc)},module.exports=KeyPair},{"../../elliptic":65}],77:[function(require,module){"use strict";function Signature(eddsa,sig){this.eddsa=eddsa,"object"!=typeof sig&&(sig=parseBytes(sig)),Array.isArray(sig)&&(sig={R:sig.slice(0,eddsa.encodingLength),S:sig.slice(eddsa.encodingLength)}),assert(sig.R&&sig.S,"Signature without R or S"),eddsa.isPoint(sig.R)&&(this._R=sig.R),sig.S instanceof BN&&(this._S=sig.S),this._Rencoded=Array.isArray(sig.R)?sig.R:sig.Rencoded,this._Sencoded=Array.isArray(sig.S)?sig.S:sig.Sencoded}var BN=require("bn.js"),elliptic=require("../../elliptic"),utils=elliptic.utils,assert=utils.assert,cachedProperty=utils.cachedProperty,parseBytes=utils.parseBytes;cachedProperty(Signature,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),cachedProperty(Signature,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),cachedProperty(Signature,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),cachedProperty(Signature,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Signature.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Signature.prototype.toHex=function(){return utils.encode(this.toBytes(),"hex").toUpperCase()},module.exports=Signature},{"../../elliptic":65,"bn.js":16}],78:[function(require,module){"use strict";function HmacDRBG(options){if(!(this instanceof HmacDRBG))return new HmacDRBG(options);this.hash=options.hash,this.predResist=!!options.predResist,this.outLen=this.hash.outSize,this.minEntropy=options.minEntropy||this.hash.hmacStrength,this.reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var entropy=utils.toArray(options.entropy,options.entropyEnc),nonce=utils.toArray(options.nonce,options.nonceEnc),pers=utils.toArray(options.pers,options.persEnc);assert(entropy.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(entropy,nonce,pers)}var hash=require("hash.js"),elliptic=require("../elliptic"),utils=elliptic.utils,assert=utils.assert;module.exports=HmacDRBG,HmacDRBG.prototype._init=function(entropy,nonce,pers){var seed=entropy.concat(nonce).concat(pers);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(seed),this.reseed=1,this.reseedInterval=281474976710656},HmacDRBG.prototype._hmac=function(){return new hash.hmac(this.hash,this.K)},HmacDRBG.prototype._update=function(seed){var kmac=this._hmac().update(this.V).update([0]);seed&&(kmac=kmac.update(seed)),this.K=kmac.digest(),this.V=this._hmac().update(this.V).digest(),seed&&(this.K=this._hmac().update(this.V).update([1]).update(seed).digest(),this.V=this._hmac().update(this.V).digest())},HmacDRBG.prototype.reseed=function(entropy,entropyEnc,add,addEnc){"string"!=typeof entropyEnc&&(addEnc=add,add=entropyEnc,entropyEnc=null),entropy=utils.toBuffer(entropy,entropyEnc),add=utils.toBuffer(add,addEnc),assert(entropy.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(entropy.concat(add||[])),this.reseed=1},HmacDRBG.prototype.generate=function(len,enc,add,addEnc){if(this.reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof enc&&(addEnc=add,add=enc,enc=null),add&&(add=utils.toArray(add,addEnc),this._update(add));for(var temp=[];temp.length<len;)this.V=this._hmac().update(this.V).digest(),temp=temp.concat(this.V);var res=temp.slice(0,len);return this._update(add),this.reseed++,utils.encode(res,enc)}},{"../elliptic":65,"hash.js":84}],79:[function(require,module){module.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]
  }}},{}],80:[function(require,module,exports){"use strict";function toArray(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if("string"!=typeof msg){for(var i=0;i<msg.length;i++)res[i]=0|msg[i];return res}if(enc){if("hex"===enc){msg=msg.replace(/[^a-z0-9]+/gi,""),msg.length%2!==0&&(msg="0"+msg);for(var i=0;i<msg.length;i+=2)res.push(parseInt(msg[i]+msg[i+1],16))}}else for(var i=0;i<msg.length;i++){var c=msg.charCodeAt(i),hi=c>>8,lo=255&c;hi?res.push(hi,lo):res.push(lo)}return res}function zero2(word){return 1===word.length?"0"+word:word}function toHex(msg){for(var res="",i=0;i<msg.length;i++)res+=zero2(msg[i].toString(16));return res}function getNAF(num,w){for(var naf=[],ws=1<<w+1,k=num.clone();k.cmpn(1)>=0;){var z;if(k.isOdd()){var mod=k.andln(ws-1);z=mod>(ws>>1)-1?(ws>>1)-mod:mod,k.isubn(z)}else z=0;naf.push(z);for(var shift=0!==k.cmpn(0)&&0===k.andln(ws-1)?w+1:1,i=1;shift>i;i++)naf.push(0);k.iushrn(shift)}return naf}function getJSF(k1,k2){var jsf=[[],[]];k1=k1.clone(),k2=k2.clone();for(var d1=0,d2=0;k1.cmpn(-d1)>0||k2.cmpn(-d2)>0;){var m14=k1.andln(3)+d1&3,m24=k2.andln(3)+d2&3;3===m14&&(m14=-1),3===m24&&(m24=-1);var u1;if(0===(1&m14))u1=0;else{var m8=k1.andln(7)+d1&7;u1=3!==m8&&5!==m8||2!==m24?m14:-m14}jsf[0].push(u1);var u2;if(0===(1&m24))u2=0;else{var m8=k2.andln(7)+d2&7;u2=3!==m8&&5!==m8||2!==m14?m24:-m24}jsf[1].push(u2),2*d1===u1+1&&(d1=1-d1),2*d2===u2+1&&(d2=1-d2),k1.iushrn(1),k2.iushrn(1)}return jsf}function cachedProperty(obj,name,computer){var key="_"+name;obj.prototype[name]=function(){return void 0!==this[key]?this[key]:this[key]=computer.call(this)}}function parseBytes(bytes){return"string"==typeof bytes?utils.toArray(bytes,"hex"):bytes}function intFromLE(bytes){return new BN(bytes,"hex","le")}var utils=exports,BN=require("bn.js");utils.assert=function(val,msg){if(!val)throw new Error(msg||"Assertion failed")},utils.toArray=toArray,utils.zero2=zero2,utils.toHex=toHex,utils.encode=function(arr,enc){return"hex"===enc?toHex(arr):arr},utils.getNAF=getNAF,utils.getJSF=getJSF,utils.cachedProperty=cachedProperty,utils.parseBytes=parseBytes,utils.intFromLE=intFromLE},{"bn.js":16}],81:[function(require,module){module.exports={_args:[[{raw:"elliptic@^6.0.0",scope:null,escapedName:"elliptic",name:"elliptic",rawSpec:"^6.0.0",spec:">=6.0.0 <7.0.0",type:"range"},"/home/csarven/.nvm/versions/node/v7.0.0/lib/node_modules/browserify/node_modules/browserify-sign"]],_from:"elliptic@>=6.0.0 <7.0.0",_id:"elliptic@6.3.2",_inCache:!0,_location:"/browserify/elliptic",_nodeVersion:"6.3.0",_npmOperationalInternal:{host:"packages-16-east.internal.npmjs.com",tmp:"tmp/elliptic-6.3.2.tgz_1473938837205_0.3108903462998569"},_npmUser:{name:"indutny",email:"fedor@indutny.com"},_npmVersion:"3.10.3",_phantomChildren:{},_requested:{raw:"elliptic@^6.0.0",scope:null,escapedName:"elliptic",name:"elliptic",rawSpec:"^6.0.0",spec:">=6.0.0 <7.0.0",type:"range"},_requiredBy:["/browserify/browserify-sign","/browserify/create-ecdh"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.3.2.tgz",_shasum:"e4c81e0829cf0a65ab70e998b8232723b5c1bc48",_shrinkwrap:null,_spec:"elliptic@^6.0.0",_where:"/home/csarven/.nvm/versions/node/v7.0.0/lib/node_modules/browserify/node_modules/browserify-sign",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0",inherits:"^2.0.1"},description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},directories:{},dist:{shasum:"e4c81e0829cf0a65ab70e998b8232723b5c1bc48",tarball:"https://registry.npmjs.org/elliptic/-/elliptic-6.3.2.tgz"},files:["lib"],gitHead:"cbace4683a4a548dc0306ef36756151a20299cd5",homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",maintainers:[{name:"indutny",email:"fedor@indutny.com"}],name:"elliptic",optionalDependencies:{},readme:"ERROR: No README data found!",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.3.2"}},{}],82:[function(require,module){function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(arg){return"function"==typeof arg}function isNumber(arg){return"number"==typeof arg}function isObject(arg){return"object"==typeof arg&&null!==arg}function isUndefined(arg){return void 0===arg}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||0>n||isNaN(n))throw TypeError("n must be a positive number");return this._maxListeners=n,this},EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(this._events||(this._events={}),"error"===type&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if(er=arguments[1],er instanceof Error)throw er;var err=new Error('Uncaught, unspecified "error" event. ('+er+")");throw err.context=er,err}if(handler=this._events[type],isUndefined(handler))return!1;if(isFunction(handler))switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:args=Array.prototype.slice.call(arguments,1),handler.apply(this,args)}else if(isObject(handler))for(args=Array.prototype.slice.call(arguments,1),listeners=handler.slice(),len=listeners.length,i=0;len>i;i++)listeners[i].apply(this,args);return!0},EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener),this._events[type]?isObject(this._events[type])?this._events[type].push(listener):this._events[type]=[this._events[type],listener]:this._events[type]=listener,isObject(this._events[type])&&!this._events[type].warned&&(m=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,m&&m>0&&this._events[type].length>m&&(this._events[type].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[type].length),"function"==typeof console.trace&&console.trace())),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(type,listener){function g(){this.removeListener(type,g),fired||(fired=!0,listener.apply(this,arguments))}if(!isFunction(listener))throw TypeError("listener must be a function");var fired=!1;return g.listener=listener,this.on(type,g),this},EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;if(list=this._events[type],length=list.length,position=-1,list===listener||isFunction(list.listener)&&list.listener===listener)delete this._events[type],this._events.removeListener&&this.emit("removeListener",type,listener);else if(isObject(list)){for(i=length;i-->0;)if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}if(0>position)return this;1===list.length?(list.length=0,delete this._events[type]):list.splice(position,1),this._events.removeListener&&this.emit("removeListener",type,listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[type]&&delete this._events[type],this;if(0===arguments.length){for(key in this._events)"removeListener"!==key&&this.removeAllListeners(key);return this.removeAllListeners("removeListener"),this._events={},this}if(listeners=this._events[type],isFunction(listeners))this.removeListener(type,listeners);else if(listeners)for(;listeners.length;)this.removeListener(type,listeners[listeners.length-1]);return delete this._events[type],this},EventEmitter.prototype.listeners=function(type){var ret;return ret=this._events&&this._events[type]?isFunction(this._events[type])?[this._events[type]]:this._events[type].slice():[]},EventEmitter.prototype.listenerCount=function(type){if(this._events){var evlistener=this._events[type];if(isFunction(evlistener))return 1;if(evlistener)return evlistener.length}return 0},EventEmitter.listenerCount=function(emitter,type){return emitter.listenerCount(type)}},{}],83:[function(require,module){(function(Buffer){function EVP_BytesToKey(password,salt,keyLen,ivLen){Buffer.isBuffer(password)||(password=new Buffer(password,"binary")),salt&&!Buffer.isBuffer(salt)&&(salt=new Buffer(salt,"binary")),keyLen/=8,ivLen=ivLen||0;for(var md_buf,i,ki=0,ii=0,key=new Buffer(keyLen),iv=new Buffer(ivLen),addmd=0,bufs=[];;){if(addmd++>0&&bufs.push(md_buf),bufs.push(password),salt&&bufs.push(salt),md_buf=md5(Buffer.concat(bufs)),bufs=[],i=0,keyLen>0)for(;;){if(0===keyLen)break;if(i===md_buf.length)break;key[ki++]=md_buf[i],keyLen--,i++}if(ivLen>0&&i!==md_buf.length)for(;;){if(0===ivLen)break;if(i===md_buf.length)break;iv[ii++]=md_buf[i],ivLen--,i++}if(0===keyLen&&0===ivLen)break}for(i=0;i<md_buf.length;i++)md_buf[i]=0;return{key:key,iv:iv}}var md5=require("create-hash/md5");module.exports=EVP_BytesToKey}).call(this,require("buffer").Buffer)},{buffer:45,"create-hash/md5":52}],84:[function(require,module,exports){var hash=exports;hash.utils=require("./hash/utils"),hash.common=require("./hash/common"),hash.sha=require("./hash/sha"),hash.ripemd=require("./hash/ripemd"),hash.hmac=require("./hash/hmac"),hash.sha1=hash.sha.sha1,hash.sha256=hash.sha.sha256,hash.sha224=hash.sha.sha224,hash.sha384=hash.sha.sha384,hash.sha512=hash.sha.sha512,hash.ripemd160=hash.ripemd.ripemd160},{"./hash/common":85,"./hash/hmac":86,"./hash/ripemd":87,"./hash/sha":88,"./hash/utils":89}],85:[function(require,module,exports){function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var hash=require("../hash"),utils=hash.utils,assert=utils.assert;exports.BlockHash=BlockHash,BlockHash.prototype.update=function(msg,enc){if(msg=utils.toArray(msg,enc),this.pending=this.pending?this.pending.concat(msg):msg,this.pendingTotal+=msg.length,this.pending.length>=this._delta8){msg=this.pending;var r=msg.length%this._delta8;this.pending=msg.slice(msg.length-r,msg.length),0===this.pending.length&&(this.pending=null),msg=utils.join32(msg,0,msg.length-r,this.endian);for(var i=0;i<msg.length;i+=this._delta32)this._update(msg,i,i+this._delta32)}return this},BlockHash.prototype.digest=function(enc){return this.update(this._pad()),assert(null===this.pending),this._digest(enc)},BlockHash.prototype._pad=function(){var len=this.pendingTotal,bytes=this._delta8,k=bytes-(len+this.padLength)%bytes,res=new Array(k+this.padLength);res[0]=128;for(var i=1;k>i;i++)res[i]=0;if(len<<=3,"big"===this.endian){for(var t=8;t<this.padLength;t++)res[i++]=0;res[i++]=0,res[i++]=0,res[i++]=0,res[i++]=0,res[i++]=len>>>24&255,res[i++]=len>>>16&255,res[i++]=len>>>8&255,res[i++]=255&len}else{res[i++]=255&len,res[i++]=len>>>8&255,res[i++]=len>>>16&255,res[i++]=len>>>24&255,res[i++]=0,res[i++]=0,res[i++]=0,res[i++]=0;for(var t=8;t<this.padLength;t++)res[i++]=0}return res}},{"../hash":84}],86:[function(require,module,exports){function Hmac(hash,key,enc){return this instanceof Hmac?(this.Hash=hash,this.blockSize=hash.blockSize/8,this.outSize=hash.outSize/8,this.inner=null,this.outer=null,void this._init(utils.toArray(key,enc))):new Hmac(hash,key,enc)}var hash=require("../hash"),utils=hash.utils,assert=utils.assert;module.exports=Hmac,Hmac.prototype._init=function(key){key.length>this.blockSize&&(key=(new this.Hash).update(key).digest()),assert(key.length<=this.blockSize);for(var i=key.length;i<this.blockSize;i++)key.push(0);for(var i=0;i<key.length;i++)key[i]^=54;this.inner=(new this.Hash).update(key);for(var i=0;i<key.length;i++)key[i]^=106;this.outer=(new this.Hash).update(key)},Hmac.prototype.update=function(msg,enc){return this.inner.update(msg,enc),this},Hmac.prototype.digest=function(enc){return this.outer.update(this.inner.digest()),this.outer.digest(enc)}},{"../hash":84}],87:[function(require,module,exports){function RIPEMD160(){return this instanceof RIPEMD160?(BlockHash.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],void(this.endian="little")):new RIPEMD160}function f(j,x,y,z){return 15>=j?x^y^z:31>=j?x&y|~x&z:47>=j?(x|~y)^z:63>=j?x&z|y&~z:x^(y|~z)}function K(j){return 15>=j?0:31>=j?1518500249:47>=j?1859775393:63>=j?2400959708:2840853838}function Kh(j){return 15>=j?1352829926:31>=j?1548603684:47>=j?1836072691:63>=j?2053994217:0}var hash=require("../hash"),utils=hash.utils,rotl32=utils.rotl32,sum32=utils.sum32,sum32_3=utils.sum32_3,sum32_4=utils.sum32_4,BlockHash=hash.common.BlockHash;utils.inherits(RIPEMD160,BlockHash),exports.ripemd160=RIPEMD160,RIPEMD160.blockSize=512,RIPEMD160.outSize=160,RIPEMD160.hmacStrength=192,RIPEMD160.padLength=64,RIPEMD160.prototype._update=function(msg,start){for(var A=this.h[0],B=this.h[1],C=this.h[2],D=this.h[3],E=this.h[4],Ah=A,Bh=B,Ch=C,Dh=D,Eh=E,j=0;80>j;j++){var T=sum32(rotl32(sum32_4(A,f(j,B,C,D),msg[r[j]+start],K(j)),s[j]),E);A=E,E=D,D=rotl32(C,10),C=B,B=T,T=sum32(rotl32(sum32_4(Ah,f(79-j,Bh,Ch,Dh),msg[rh[j]+start],Kh(j)),sh[j]),Eh),Ah=Eh,Eh=Dh,Dh=rotl32(Ch,10),Ch=Bh,Bh=T}T=sum32_3(this.h[1],C,Dh),this.h[1]=sum32_3(this.h[2],D,Eh),this.h[2]=sum32_3(this.h[3],E,Ah),this.h[3]=sum32_3(this.h[4],A,Bh),this.h[4]=sum32_3(this.h[0],B,Ch),this.h[0]=T},RIPEMD160.prototype._digest=function(enc){return"hex"===enc?utils.toHex32(this.h,"little"):utils.split32(this.h,"little")};var r=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],rh=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],s=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sh=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},{"../hash":84}],88:[function(require,module,exports){function SHA256(){return this instanceof SHA256?(BlockHash.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=sha256_K,void(this.W=new Array(64))):new SHA256}function SHA224(){return this instanceof SHA224?(SHA256.call(this),void(this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])):new SHA224}function SHA512(){return this instanceof SHA512?(BlockHash.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=sha512_K,void(this.W=new Array(160))):new SHA512}function SHA384(){return this instanceof SHA384?(SHA512.call(this),void(this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428])):new SHA384}function SHA1(){return this instanceof SHA1?(BlockHash.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],void(this.W=new Array(80))):new SHA1}function ch32(x,y,z){return x&y^~x&z}function maj32(x,y,z){return x&y^x&z^y&z}function p32(x,y,z){return x^y^z}function s0_256(x){return rotr32(x,2)^rotr32(x,13)^rotr32(x,22)}function s1_256(x){return rotr32(x,6)^rotr32(x,11)^rotr32(x,25)}function g0_256(x){return rotr32(x,7)^rotr32(x,18)^x>>>3}function g1_256(x){return rotr32(x,17)^rotr32(x,19)^x>>>10}function ft_1(s,x,y,z){return 0===s?ch32(x,y,z):1===s||3===s?p32(x,y,z):2===s?maj32(x,y,z):void 0}function ch64_hi(xh,xl,yh,yl,zh){var r=xh&yh^~xh&zh;return 0>r&&(r+=4294967296),r}function ch64_lo(xh,xl,yh,yl,zh,zl){var r=xl&yl^~xl&zl;return 0>r&&(r+=4294967296),r}function maj64_hi(xh,xl,yh,yl,zh){var r=xh&yh^xh&zh^yh&zh;return 0>r&&(r+=4294967296),r}function maj64_lo(xh,xl,yh,yl,zh,zl){var r=xl&yl^xl&zl^yl&zl;return 0>r&&(r+=4294967296),r}function s0_512_hi(xh,xl){var c0_hi=rotr64_hi(xh,xl,28),c1_hi=rotr64_hi(xl,xh,2),c2_hi=rotr64_hi(xl,xh,7),r=c0_hi^c1_hi^c2_hi;return 0>r&&(r+=4294967296),r}function s0_512_lo(xh,xl){var c0_lo=rotr64_lo(xh,xl,28),c1_lo=rotr64_lo(xl,xh,2),c2_lo=rotr64_lo(xl,xh,7),r=c0_lo^c1_lo^c2_lo;return 0>r&&(r+=4294967296),r}function s1_512_hi(xh,xl){var c0_hi=rotr64_hi(xh,xl,14),c1_hi=rotr64_hi(xh,xl,18),c2_hi=rotr64_hi(xl,xh,9),r=c0_hi^c1_hi^c2_hi;return 0>r&&(r+=4294967296),r}function s1_512_lo(xh,xl){var c0_lo=rotr64_lo(xh,xl,14),c1_lo=rotr64_lo(xh,xl,18),c2_lo=rotr64_lo(xl,xh,9),r=c0_lo^c1_lo^c2_lo;return 0>r&&(r+=4294967296),r}function g0_512_hi(xh,xl){var c0_hi=rotr64_hi(xh,xl,1),c1_hi=rotr64_hi(xh,xl,8),c2_hi=shr64_hi(xh,xl,7),r=c0_hi^c1_hi^c2_hi;return 0>r&&(r+=4294967296),r}function g0_512_lo(xh,xl){var c0_lo=rotr64_lo(xh,xl,1),c1_lo=rotr64_lo(xh,xl,8),c2_lo=shr64_lo(xh,xl,7),r=c0_lo^c1_lo^c2_lo;return 0>r&&(r+=4294967296),r}function g1_512_hi(xh,xl){var c0_hi=rotr64_hi(xh,xl,19),c1_hi=rotr64_hi(xl,xh,29),c2_hi=shr64_hi(xh,xl,6),r=c0_hi^c1_hi^c2_hi;return 0>r&&(r+=4294967296),r}function g1_512_lo(xh,xl){var c0_lo=rotr64_lo(xh,xl,19),c1_lo=rotr64_lo(xl,xh,29),c2_lo=shr64_lo(xh,xl,6),r=c0_lo^c1_lo^c2_lo;return 0>r&&(r+=4294967296),r}var hash=require("../hash"),utils=hash.utils,assert=utils.assert,rotr32=utils.rotr32,rotl32=utils.rotl32,sum32=utils.sum32,sum32_4=utils.sum32_4,sum32_5=utils.sum32_5,rotr64_hi=utils.rotr64_hi,rotr64_lo=utils.rotr64_lo,shr64_hi=utils.shr64_hi,shr64_lo=utils.shr64_lo,sum64=utils.sum64,sum64_hi=utils.sum64_hi,sum64_lo=utils.sum64_lo,sum64_4_hi=utils.sum64_4_hi,sum64_4_lo=utils.sum64_4_lo,sum64_5_hi=utils.sum64_5_hi,sum64_5_lo=utils.sum64_5_lo,BlockHash=hash.common.BlockHash,sha256_K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],sha512_K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],sha1_K=[1518500249,1859775393,2400959708,3395469782];utils.inherits(SHA256,BlockHash),exports.sha256=SHA256,SHA256.blockSize=512,SHA256.outSize=256,SHA256.hmacStrength=192,SHA256.padLength=64,SHA256.prototype._update=function(msg,start){for(var W=this.W,i=0;16>i;i++)W[i]=msg[start+i];for(;i<W.length;i++)W[i]=sum32_4(g1_256(W[i-2]),W[i-7],g0_256(W[i-15]),W[i-16]);var a=this.h[0],b=this.h[1],c=this.h[2],d=this.h[3],e=this.h[4],f=this.h[5],g=this.h[6],h=this.h[7];assert(this.k.length===W.length);for(var i=0;i<W.length;i++){var T1=sum32_5(h,s1_256(e),ch32(e,f,g),this.k[i],W[i]),T2=sum32(s0_256(a),maj32(a,b,c));h=g,g=f,f=e,e=sum32(d,T1),d=c,c=b,b=a,a=sum32(T1,T2)}this.h[0]=sum32(this.h[0],a),this.h[1]=sum32(this.h[1],b),this.h[2]=sum32(this.h[2],c),this.h[3]=sum32(this.h[3],d),this.h[4]=sum32(this.h[4],e),this.h[5]=sum32(this.h[5],f),this.h[6]=sum32(this.h[6],g),this.h[7]=sum32(this.h[7],h)},SHA256.prototype._digest=function(enc){return"hex"===enc?utils.toHex32(this.h,"big"):utils.split32(this.h,"big")},utils.inherits(SHA224,SHA256),exports.sha224=SHA224,SHA224.blockSize=512,SHA224.outSize=224,SHA224.hmacStrength=192,SHA224.padLength=64,SHA224.prototype._digest=function(enc){return"hex"===enc?utils.toHex32(this.h.slice(0,7),"big"):utils.split32(this.h.slice(0,7),"big")},utils.inherits(SHA512,BlockHash),exports.sha512=SHA512,SHA512.blockSize=1024,SHA512.outSize=512,SHA512.hmacStrength=192,SHA512.padLength=128,SHA512.prototype._prepareBlock=function(msg,start){for(var W=this.W,i=0;32>i;i++)W[i]=msg[start+i];for(;i<W.length;i+=2){var c0_hi=g1_512_hi(W[i-4],W[i-3]),c0_lo=g1_512_lo(W[i-4],W[i-3]),c1_hi=W[i-14],c1_lo=W[i-13],c2_hi=g0_512_hi(W[i-30],W[i-29]),c2_lo=g0_512_lo(W[i-30],W[i-29]),c3_hi=W[i-32],c3_lo=W[i-31];W[i]=sum64_4_hi(c0_hi,c0_lo,c1_hi,c1_lo,c2_hi,c2_lo,c3_hi,c3_lo),W[i+1]=sum64_4_lo(c0_hi,c0_lo,c1_hi,c1_lo,c2_hi,c2_lo,c3_hi,c3_lo)}},SHA512.prototype._update=function(msg,start){this._prepareBlock(msg,start);var W=this.W,ah=this.h[0],al=this.h[1],bh=this.h[2],bl=this.h[3],ch=this.h[4],cl=this.h[5],dh=this.h[6],dl=this.h[7],eh=this.h[8],el=this.h[9],fh=this.h[10],fl=this.h[11],gh=this.h[12],gl=this.h[13],hh=this.h[14],hl=this.h[15];assert(this.k.length===W.length);for(var i=0;i<W.length;i+=2){var c0_hi=hh,c0_lo=hl,c1_hi=s1_512_hi(eh,el),c1_lo=s1_512_lo(eh,el),c2_hi=ch64_hi(eh,el,fh,fl,gh,gl),c2_lo=ch64_lo(eh,el,fh,fl,gh,gl),c3_hi=this.k[i],c3_lo=this.k[i+1],c4_hi=W[i],c4_lo=W[i+1],T1_hi=sum64_5_hi(c0_hi,c0_lo,c1_hi,c1_lo,c2_hi,c2_lo,c3_hi,c3_lo,c4_hi,c4_lo),T1_lo=sum64_5_lo(c0_hi,c0_lo,c1_hi,c1_lo,c2_hi,c2_lo,c3_hi,c3_lo,c4_hi,c4_lo),c0_hi=s0_512_hi(ah,al),c0_lo=s0_512_lo(ah,al),c1_hi=maj64_hi(ah,al,bh,bl,ch,cl),c1_lo=maj64_lo(ah,al,bh,bl,ch,cl),T2_hi=sum64_hi(c0_hi,c0_lo,c1_hi,c1_lo),T2_lo=sum64_lo(c0_hi,c0_lo,c1_hi,c1_lo);hh=gh,hl=gl,gh=fh,gl=fl,fh=eh,fl=el,eh=sum64_hi(dh,dl,T1_hi,T1_lo),el=sum64_lo(dl,dl,T1_hi,T1_lo),dh=ch,dl=cl,ch=bh,cl=bl,bh=ah,bl=al,ah=sum64_hi(T1_hi,T1_lo,T2_hi,T2_lo),al=sum64_lo(T1_hi,T1_lo,T2_hi,T2_lo)}sum64(this.h,0,ah,al),sum64(this.h,2,bh,bl),sum64(this.h,4,ch,cl),sum64(this.h,6,dh,dl),sum64(this.h,8,eh,el),sum64(this.h,10,fh,fl),sum64(this.h,12,gh,gl),sum64(this.h,14,hh,hl)},SHA512.prototype._digest=function(enc){return"hex"===enc?utils.toHex32(this.h,"big"):utils.split32(this.h,"big")},utils.inherits(SHA384,SHA512),exports.sha384=SHA384,SHA384.blockSize=1024,SHA384.outSize=384,SHA384.hmacStrength=192,SHA384.padLength=128,SHA384.prototype._digest=function(enc){return"hex"===enc?utils.toHex32(this.h.slice(0,12),"big"):utils.split32(this.h.slice(0,12),"big")},utils.inherits(SHA1,BlockHash),exports.sha1=SHA1,SHA1.blockSize=512,SHA1.outSize=160,SHA1.hmacStrength=80,SHA1.padLength=64,SHA1.prototype._update=function(msg,start){for(var W=this.W,i=0;16>i;i++)W[i]=msg[start+i];for(;i<W.length;i++)W[i]=rotl32(W[i-3]^W[i-8]^W[i-14]^W[i-16],1);for(var a=this.h[0],b=this.h[1],c=this.h[2],d=this.h[3],e=this.h[4],i=0;i<W.length;i++){var s=~~(i/20),t=sum32_5(rotl32(a,5),ft_1(s,b,c,d),e,W[i],sha1_K[s]);e=d,d=c,c=rotl32(b,30),b=a,a=t}this.h[0]=sum32(this.h[0],a),this.h[1]=sum32(this.h[1],b),this.h[2]=sum32(this.h[2],c),this.h[3]=sum32(this.h[3],d),this.h[4]=sum32(this.h[4],e)},SHA1.prototype._digest=function(enc){return"hex"===enc?utils.toHex32(this.h,"big"):utils.split32(this.h,"big")}},{"../hash":84}],89:[function(require,module,exports){function toArray(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if("string"==typeof msg)if(enc){if("hex"===enc){msg=msg.replace(/[^a-z0-9]+/gi,""),msg.length%2!==0&&(msg="0"+msg);for(var i=0;i<msg.length;i+=2)res.push(parseInt(msg[i]+msg[i+1],16))}}else for(var i=0;i<msg.length;i++){var c=msg.charCodeAt(i),hi=c>>8,lo=255&c;hi?res.push(hi,lo):res.push(lo)}else for(var i=0;i<msg.length;i++)res[i]=0|msg[i];return res}function toHex(msg){for(var res="",i=0;i<msg.length;i++)res+=zero2(msg[i].toString(16));return res}function htonl(w){var res=w>>>24|w>>>8&65280|w<<8&16711680|(255&w)<<24;return res>>>0}function toHex32(msg,endian){for(var res="",i=0;i<msg.length;i++){var w=msg[i];"little"===endian&&(w=htonl(w)),res+=zero8(w.toString(16))}return res}function zero2(word){return 1===word.length?"0"+word:word}function zero8(word){return 7===word.length?"0"+word:6===word.length?"00"+word:5===word.length?"000"+word:4===word.length?"0000"+word:3===word.length?"00000"+word:2===word.length?"000000"+word:1===word.length?"0000000"+word:word}function join32(msg,start,end,endian){var len=end-start;assert(len%4===0);for(var res=new Array(len/4),i=0,k=start;i<res.length;i++,k+=4){var w;w="big"===endian?msg[k]<<24|msg[k+1]<<16|msg[k+2]<<8|msg[k+3]:msg[k+3]<<24|msg[k+2]<<16|msg[k+1]<<8|msg[k],res[i]=w>>>0}return res}function split32(msg,endian){for(var res=new Array(4*msg.length),i=0,k=0;i<msg.length;i++,k+=4){var m=msg[i];"big"===endian?(res[k]=m>>>24,res[k+1]=m>>>16&255,res[k+2]=m>>>8&255,res[k+3]=255&m):(res[k+3]=m>>>24,res[k+2]=m>>>16&255,res[k+1]=m>>>8&255,res[k]=255&m)}return res}function rotr32(w,b){return w>>>b|w<<32-b}function rotl32(w,b){return w<<b|w>>>32-b}function sum32(a,b){return a+b>>>0}function sum32_3(a,b,c){return a+b+c>>>0}function sum32_4(a,b,c,d){return a+b+c+d>>>0}function sum32_5(a,b,c,d,e){return a+b+c+d+e>>>0}function assert(cond,msg){if(!cond)throw new Error(msg||"Assertion failed")}function sum64(buf,pos,ah,al){var bh=buf[pos],bl=buf[pos+1],lo=al+bl>>>0,hi=(al>lo?1:0)+ah+bh;buf[pos]=hi>>>0,buf[pos+1]=lo}function sum64_hi(ah,al,bh,bl){var lo=al+bl>>>0,hi=(al>lo?1:0)+ah+bh;return hi>>>0}function sum64_lo(ah,al,bh,bl){var lo=al+bl;return lo>>>0}function sum64_4_hi(ah,al,bh,bl,ch,cl,dh,dl){var carry=0,lo=al;lo=lo+bl>>>0,carry+=al>lo?1:0,lo=lo+cl>>>0,carry+=cl>lo?1:0,lo=lo+dl>>>0,carry+=dl>lo?1:0;var hi=ah+bh+ch+dh+carry;return hi>>>0}function sum64_4_lo(ah,al,bh,bl,ch,cl,dh,dl){var lo=al+bl+cl+dl;return lo>>>0}function sum64_5_hi(ah,al,bh,bl,ch,cl,dh,dl,eh,el){var carry=0,lo=al;lo=lo+bl>>>0,carry+=al>lo?1:0,lo=lo+cl>>>0,carry+=cl>lo?1:0,lo=lo+dl>>>0,carry+=dl>lo?1:0,lo=lo+el>>>0,carry+=el>lo?1:0;var hi=ah+bh+ch+dh+eh+carry;return hi>>>0}function sum64_5_lo(ah,al,bh,bl,ch,cl,dh,dl,eh,el){var lo=al+bl+cl+dl+el;return lo>>>0}function rotr64_hi(ah,al,num){var r=al<<32-num|ah>>>num;return r>>>0}function rotr64_lo(ah,al,num){var r=ah<<32-num|al>>>num;return r>>>0}function shr64_hi(ah,al,num){return ah>>>num}function shr64_lo(ah,al,num){var r=ah<<32-num|al>>>num;return r>>>0}var utils=exports,inherits=require("inherits");utils.toArray=toArray,utils.toHex=toHex,utils.htonl=htonl,utils.toHex32=toHex32,utils.zero2=zero2,utils.zero8=zero8,utils.join32=join32,utils.split32=split32,utils.rotr32=rotr32,utils.rotl32=rotl32,utils.sum32=sum32,utils.sum32_3=sum32_3,utils.sum32_4=sum32_4,utils.sum32_5=sum32_5,utils.assert=assert,utils.inherits=inherits,exports.sum64=sum64,exports.sum64_hi=sum64_hi,exports.sum64_lo=sum64_lo,exports.sum64_4_hi=sum64_4_hi,exports.sum64_4_lo=sum64_4_lo,exports.sum64_5_hi=sum64_5_hi,exports.sum64_5_lo=sum64_5_lo,exports.rotr64_hi=rotr64_hi,exports.rotr64_lo=rotr64_lo,exports.shr64_hi=shr64_hi,exports.shr64_lo=shr64_lo},{inherits:93}],90:[function(require,module){var http=require("http"),https=module.exports;for(var key in http)http.hasOwnProperty(key)&&(https[key]=http[key]);https.request=function(params,cb){return params||(params={}),params.scheme="https",params.protocol="https:",http.request.call(this,params,cb)}},{http:138}],91:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=8*nBytes-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];for(i+=d,e=s&(1<<-nBits)-1,s>>=-nBits,nBits+=eLen;nBits>0;e=256*e+buffer[offset+i],i+=d,nBits-=8);for(m=e&(1<<-nBits)-1,e>>=-nBits,nBits+=mLen;nBits>0;m=256*m+buffer[offset+i],i+=d,nBits-=8);if(0===e)e=1-eBias;else{if(e===eMax)return m?0/0:(s?-1:1)*(1/0);m+=Math.pow(2,mLen),e-=eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)},exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=8*nBytes-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=23===mLen?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=0>value||0===value&&0>1/value?1:0;for(value=Math.abs(value),isNaN(value)||value===1/0?(m=isNaN(value)?1:0,e=eMax):(e=Math.floor(Math.log(value)/Math.LN2),value*(c=Math.pow(2,-e))<1&&(e--,c*=2),value+=e+eBias>=1?rt/c:rt*Math.pow(2,1-eBias),value*c>=2&&(e++,c/=2),e+eBias>=eMax?(m=0,e=eMax):e+eBias>=1?(m=(value*c-1)*Math.pow(2,mLen),e+=eBias):(m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen),e=0));mLen>=8;buffer[offset+i]=255&m,i+=d,m/=256,mLen-=8);for(e=e<<mLen|m,eLen+=mLen;eLen>0;buffer[offset+i]=255&e,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=128*s}},{}],92:[function(require,module){var indexOf=[].indexOf;module.exports=function(arr,obj){if(indexOf)return arr.indexOf(obj);for(var i=0;i<arr.length;++i)if(arr[i]===obj)return i;return-1}},{}],93:[function(require,module){module.exports="function"==typeof Object.create?function(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})}:function(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}},{}],94:[function(require,module){function isBuffer(obj){
  return!!obj.constructor&&"function"==typeof obj.constructor.isBuffer&&obj.constructor.isBuffer(obj)}function isSlowBuffer(obj){return"function"==typeof obj.readFloatLE&&"function"==typeof obj.slice&&isBuffer(obj.slice(0,0))}module.exports=function(obj){return null!=obj&&(isBuffer(obj)||isSlowBuffer(obj)||!!obj._isBuffer)}},{}],95:[function(require,module){var toString={}.toString;module.exports=Array.isArray||function(arr){return"[object Array]"==toString.call(arr)}},{}],96:[function(require,module){function MillerRabin(rand){this.rand=rand||new brorand.Rand}var bn=require("bn.js"),brorand=require("brorand");module.exports=MillerRabin,MillerRabin.create=function(rand){return new MillerRabin(rand)},MillerRabin.prototype._rand=function(n){var len=n.bitLength(),buf=this.rand.generate(Math.ceil(len/8));buf[0]|=3;var mask=7&len;return 0!==mask&&(buf[buf.length-1]>>=7-mask),new bn(buf)},MillerRabin.prototype.test=function(n,k,cb){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=Math.max(1,len/48|0));for(var n1=n.subn(1),n2=n1.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red),prime=!0;k>0;k--){var a=this._rand(n2);cb&&cb(a);var x=a.toRed(red).redPow(d);if(0!==x.cmp(rone)&&0!==x.cmp(rn1)){for(var i=1;s>i;i++){if(x=x.redSqr(),0===x.cmp(rone))return!1;if(0===x.cmp(rn1))break}if(i===s)return!1}}return prime},MillerRabin.prototype.getDivisor=function(n,k){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=Math.max(1,len/48|0));for(var n1=n.subn(1),n2=n1.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red);k>0;k--){var a=this._rand(n2),g=n.gcd(a);if(0!==g.cmpn(1))return g;var x=a.toRed(red).redPow(d);if(0!==x.cmp(rone)&&0!==x.cmp(rn1)){for(var i=1;s>i;i++){if(x=x.redSqr(),0===x.cmp(rone))return x.fromRed().subn(1).gcd(n);if(0===x.cmp(rn1))break}if(i===s)return x=x.redSqr(),x.fromRed().subn(1).gcd(n)}}return!1}},{"bn.js":16,brorand:17}],97:[function(require,module){function assert(val,msg){if(!val)throw new Error(msg||"Assertion failed")}module.exports=assert,assert.equal=function(l,r,msg){if(l!=r)throw new Error(msg||"Assertion failed: "+l+" != "+r)}},{}],98:[function(require,module){module.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],99:[function(require,module,exports){var asn1=require("asn1.js"),RSAPrivateKey=asn1.define("RSAPrivateKey",function(){this.seq().obj(this.key("version")["int"](),this.key("modulus")["int"](),this.key("publicExponent")["int"](),this.key("privateExponent")["int"](),this.key("prime1")["int"](),this.key("prime2")["int"](),this.key("exponent1")["int"](),this.key("exponent2")["int"](),this.key("coefficient")["int"]())});exports.RSAPrivateKey=RSAPrivateKey;var RSAPublicKey=asn1.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus")["int"](),this.key("publicExponent")["int"]())});exports.RSAPublicKey=RSAPublicKey;var PublicKey=asn1.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(AlgorithmIdentifier),this.key("subjectPublicKey").bitstr())});exports.PublicKey=PublicKey;var AlgorithmIdentifier=asn1.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p")["int"](),this.key("q")["int"](),this.key("g")["int"]()).optional())}),PrivateKeyInfo=asn1.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version")["int"](),this.key("algorithm").use(AlgorithmIdentifier),this.key("subjectPrivateKey").octstr())});exports.PrivateKey=PrivateKeyInfo;var EncryptedPrivateKeyInfo=asn1.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters")["int"]())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});exports.EncryptedPrivateKey=EncryptedPrivateKeyInfo;var DSAPrivateKey=asn1.define("DSAPrivateKey",function(){this.seq().obj(this.key("version")["int"](),this.key("p")["int"](),this.key("q")["int"](),this.key("g")["int"](),this.key("pub_key")["int"](),this.key("priv_key")["int"]())});exports.DSAPrivateKey=DSAPrivateKey,exports.DSAparam=asn1.define("DSAparam",function(){this["int"]()});var ECPrivateKey=asn1.define("ECPrivateKey",function(){this.seq().obj(this.key("version")["int"](),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(ECParameters),this.key("publicKey").optional().explicit(1).bitstr())});exports.ECPrivateKey=ECPrivateKey;var ECParameters=asn1.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});exports.signature=asn1.define("signature",function(){this.seq().obj(this.key("r")["int"](),this.key("s")["int"]())})},{"asn1.js":1}],100:[function(require,module){(function(Buffer){var findProc=/Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\r?\n\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n/m,startRegex=/^-----BEGIN (.*) KEY-----\r?\n/m,fullRegex=/^-----BEGIN (.*) KEY-----\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n-----END \1 KEY-----$/m,evp=require("evp_bytestokey"),ciphers=require("browserify-aes");module.exports=function(okey,password){var decrypted,key=okey.toString(),match=key.match(findProc);if(match){var suite="aes"+match[1],iv=new Buffer(match[2],"hex"),cipherText=new Buffer(match[3].replace(/\r?\n/g,""),"base64"),cipherKey=evp(password,iv.slice(0,8),parseInt(match[1],10)).key,out=[],cipher=ciphers.createDecipheriv(suite,cipherKey,iv);out.push(cipher.update(cipherText)),out.push(cipher["final"]()),decrypted=Buffer.concat(out)}else{var match2=key.match(fullRegex);decrypted=new Buffer(match2[2].replace(/\r?\n/g,""),"base64")}var tag=key.match(startRegex)[1]+" KEY";return{tag:tag,data:decrypted}}}).call(this,require("buffer").Buffer)},{"browserify-aes":21,buffer:45,evp_bytestokey:83}],101:[function(require,module){(function(Buffer){function parseKeys(buffer){var password;"object"!=typeof buffer||Buffer.isBuffer(buffer)||(password=buffer.passphrase,buffer=buffer.key),"string"==typeof buffer&&(buffer=new Buffer(buffer));var subtype,ndata,stripped=fixProc(buffer,password),type=stripped.tag,data=stripped.data;switch(type){case"PUBLIC KEY":switch(ndata=asn1.PublicKey.decode(data,"der"),subtype=ndata.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return ndata.subjectPrivateKey=ndata.subjectPublicKey,{type:"ec",data:ndata};case"1.2.840.10040.4.1":return ndata.algorithm.params.pub_key=asn1.DSAparam.decode(ndata.subjectPublicKey.data,"der"),{type:"dsa",data:ndata.algorithm.params};default:throw new Error("unknown key id "+subtype)}throw new Error("unknown key type "+type);case"ENCRYPTED PRIVATE KEY":data=asn1.EncryptedPrivateKey.decode(data,"der"),data=decrypt(data,password);case"PRIVATE KEY":switch(ndata=asn1.PrivateKey.decode(data,"der"),subtype=ndata.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:ndata.algorithm.curve,privateKey:asn1.ECPrivateKey.decode(ndata.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return ndata.algorithm.params.priv_key=asn1.DSAparam.decode(ndata.subjectPrivateKey,"der"),{type:"dsa",params:ndata.algorithm.params};default:throw new Error("unknown key id "+subtype)}throw new Error("unknown key type "+type);case"RSA PUBLIC KEY":return asn1.RSAPublicKey.decode(data,"der");case"RSA PRIVATE KEY":return asn1.RSAPrivateKey.decode(data,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:asn1.DSAPrivateKey.decode(data,"der")};case"EC PRIVATE KEY":return data=asn1.ECPrivateKey.decode(data,"der"),{curve:data.parameters.value,privateKey:data.privateKey};default:throw new Error("unknown key type "+type)}}function decrypt(data,password){var salt=data.algorithm.decrypt.kde.kdeparams.salt,iters=parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(),10),algo=aesid[data.algorithm.decrypt.cipher.algo.join(".")],iv=data.algorithm.decrypt.cipher.iv,cipherText=data.subjectPrivateKey,keylen=parseInt(algo.split("-")[1],10)/8,key=compat.pbkdf2Sync(password,salt,iters,keylen),cipher=ciphers.createDecipheriv(algo,key,iv),out=[];return out.push(cipher.update(cipherText)),out.push(cipher["final"]()),Buffer.concat(out)}var asn1=require("./asn1"),aesid=require("./aesid.json"),fixProc=require("./fixProc"),ciphers=require("browserify-aes"),compat=require("pbkdf2");module.exports=parseKeys,parseKeys.signature=asn1.signature}).call(this,require("buffer").Buffer)},{"./aesid.json":98,"./asn1":99,"./fixProc":100,"browserify-aes":21,buffer:45,pbkdf2:102}],102:[function(require,module,exports){(function(process,Buffer){var createHmac=require("create-hmac"),checkParameters=require("./precondition");exports.pbkdf2=function(password,salt,iterations,keylen,digest,callback){if("function"==typeof digest&&(callback=digest,digest=void 0),checkParameters(iterations,keylen),"function"!=typeof callback)throw new Error("No callback provided to pbkdf2");setTimeout(function(){callback(null,exports.pbkdf2Sync(password,salt,iterations,keylen,digest))})};var defaultEncoding;if(process.browser)defaultEncoding="utf-8";else{var pVersionMajor=parseInt(process.version.split(".")[0].slice(1),10);defaultEncoding=pVersionMajor>=6?"utf-8":"binary"}exports.pbkdf2Sync=function(password,salt,iterations,keylen,digest){Buffer.isBuffer(password)||(password=new Buffer(password,defaultEncoding)),Buffer.isBuffer(salt)||(salt=new Buffer(salt,defaultEncoding)),checkParameters(iterations,keylen),digest=digest||"sha1";var hLen,l=1,DK=new Buffer(keylen),block1=new Buffer(salt.length+4);salt.copy(block1,0,0,salt.length);for(var r,T,i=1;l>=i;i++){block1.writeUInt32BE(i,salt.length);var U=createHmac(digest,password).update(block1).digest();hLen||(hLen=U.length,T=new Buffer(hLen),l=Math.ceil(keylen/hLen),r=keylen-(l-1)*hLen),U.copy(T,0,0,hLen);for(var j=1;iterations>j;j++){U=createHmac(digest,password).update(U).digest();for(var k=0;hLen>k;k++)T[k]^=U[k]}var destPos=(i-1)*hLen,len=i===l?r:hLen;T.copy(DK,destPos,0,len)}return DK}}).call(this,require("_process"),require("buffer").Buffer)},{"./precondition":103,_process:105,buffer:45,"create-hmac":53}],103:[function(require,module){var MAX_ALLOC=Math.pow(2,30)-1;module.exports=function(iterations,keylen){if("number"!=typeof iterations)throw new TypeError("Iterations not a number");if(0>iterations)throw new TypeError("Bad iterations");if("number"!=typeof keylen)throw new TypeError("Key length not a number");if(0>keylen||keylen>MAX_ALLOC||keylen!==keylen)throw new TypeError("Bad key length")}},{}],104:[function(require,module){(function(process){"use strict";function nextTick(fn,arg1,arg2,arg3){if("function"!=typeof fn)throw new TypeError('"callback" argument must be a function');var args,i,len=arguments.length;switch(len){case 0:case 1:return process.nextTick(fn);case 2:return process.nextTick(function(){fn.call(null,arg1)});case 3:return process.nextTick(function(){fn.call(null,arg1,arg2)});case 4:return process.nextTick(function(){fn.call(null,arg1,arg2,arg3)});default:for(args=new Array(len-1),i=0;i<args.length;)args[i++]=arguments[i];return process.nextTick(function(){fn.apply(null,args)})}}module.exports=!process.version||0===process.version.indexOf("v0.")||0===process.version.indexOf("v1.")&&0!==process.version.indexOf("v1.8.")?nextTick:process.nextTick}).call(this,require("_process"))},{_process:105}],105:[function(require,module){function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(fun){if(cachedSetTimeout===setTimeout)return setTimeout(fun,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(fun,0);try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout)return clearTimeout(marker);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(marker);try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}function cleanUpNextTick(){draining&&currentQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var timeout=runTimeout(cleanUpNextTick);draining=!0;for(var len=queue.length;len;){for(currentQueue=queue,queue=[];++queueIndex<len;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,len=queue.length}currentQueue=null,draining=!1,runClearTimeout(timeout)}}function Item(fun,array){this.fun=fun,this.array=array}function noop(){}var cachedSetTimeout,cachedClearTimeout,process=module.exports={};!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var currentQueue,queue=[],draining=!1,queueIndex=-1;process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)args[i-1]=arguments[i];queue.push(new Item(fun,args)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.binding=function(){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}},{}],106:[function(require,module,exports){exports.publicEncrypt=require("./publicEncrypt"),exports.privateDecrypt=require("./privateDecrypt"),exports.privateEncrypt=function(key,buf){return exports.publicEncrypt(key,buf,!0)},exports.publicDecrypt=function(key,buf){return exports.privateDecrypt(key,buf,!0)}},{"./privateDecrypt":108,"./publicEncrypt":109}],107:[function(require,module){(function(Buffer){function i2ops(c){var out=new Buffer(4);return out.writeUInt32BE(c,0),out}var createHash=require("create-hash");module.exports=function(seed,len){for(var c,t=new Buffer(""),i=0;t.length<len;)c=i2ops(i++),t=Buffer.concat([t,createHash("sha1").update(seed).update(c).digest()]);return t.slice(0,len)}}).call(this,require("buffer").Buffer)},{buffer:45,"create-hash":50}],108:[function(require,module){(function(Buffer){function oaep(key,msg){var k=(key.modulus,key.modulus.byteLength()),iHash=(msg.length,createHash("sha1").update(new Buffer("")).digest()),hLen=iHash.length;if(0!==msg[0])throw new Error("decryption error");var maskedSeed=msg.slice(1,hLen+1),maskedDb=msg.slice(hLen+1),seed=xor(maskedSeed,mgf(maskedDb,hLen)),db=xor(maskedDb,mgf(seed,k-hLen-1));if(compare(iHash,db.slice(0,hLen)))throw new Error("decryption error");for(var i=hLen;0===db[i];)i++;if(1!==db[i++])throw new Error("decryption error");return db.slice(i)}function pkcs1(key,msg,reverse){for(var p1=msg.slice(0,2),i=2,status=0;0!==msg[i++];)if(i>=msg.length){status++;break}{var ps=msg.slice(2,i-1);msg.slice(i-1,i)}if(("0002"!==p1.toString("hex")&&!reverse||"0001"!==p1.toString("hex")&&reverse)&&status++,ps.length<8&&status++,status)throw new Error("decryption error");return msg.slice(i)}function compare(a,b){a=new Buffer(a),b=new Buffer(b);var dif=0,len=a.length;a.length!==b.length&&(dif++,len=Math.min(a.length,b.length));for(var i=-1;++i<len;)dif+=a[i]^b[i];return dif}var parseKeys=require("parse-asn1"),mgf=require("./mgf"),xor=require("./xor"),bn=require("bn.js"),crt=require("browserify-rsa"),createHash=require("create-hash"),withPublic=require("./withPublic");module.exports=function(private_key,enc,reverse){var padding;padding=private_key.padding?private_key.padding:reverse?1:4;var key=parseKeys(private_key),k=key.modulus.byteLength();if(enc.length>k||new bn(enc).cmp(key.modulus)>=0)throw new Error("decryption error");var msg;msg=reverse?withPublic(new bn(enc),key):crt(enc,key);var zBuffer=new Buffer(k-msg.length);if(zBuffer.fill(0),msg=Buffer.concat([zBuffer,msg],k),4===padding)return oaep(key,msg);if(1===padding)return pkcs1(key,msg,reverse);if(3===padding)return msg;throw new Error("unknown padding")}}).call(this,require("buffer").Buffer)},{"./mgf":107,"./withPublic":110,"./xor":111,"bn.js":16,"browserify-rsa":37,buffer:45,"create-hash":50,"parse-asn1":101}],109:[function(require,module){(function(Buffer){function oaep(key,msg){var k=key.modulus.byteLength(),mLen=msg.length,iHash=createHash("sha1").update(new Buffer("")).digest(),hLen=iHash.length,hLen2=2*hLen;if(mLen>k-hLen2-2)throw new Error("message too long");var ps=new Buffer(k-mLen-hLen2-2);ps.fill(0);var dblen=k-hLen-1,seed=randomBytes(hLen),maskedDb=xor(Buffer.concat([iHash,ps,new Buffer([1]),msg],dblen),mgf(seed,dblen)),maskedSeed=xor(seed,mgf(maskedDb,hLen));return new bn(Buffer.concat([new Buffer([0]),maskedSeed,maskedDb],k))}function pkcs1(key,msg,reverse){var mLen=msg.length,k=key.modulus.byteLength();if(mLen>k-11)throw new Error("message too long");var ps;return reverse?(ps=new Buffer(k-mLen-3),ps.fill(255)):ps=nonZero(k-mLen-3),new bn(Buffer.concat([new Buffer([0,reverse?1:2]),ps,new Buffer([0]),msg],k))}function nonZero(len){for(var num,out=new Buffer(len),i=0,cache=randomBytes(2*len),cur=0;len>i;)cur===cache.length&&(cache=randomBytes(2*len),cur=0),num=cache[cur++],num&&(out[i++]=num);return out}var parseKeys=require("parse-asn1"),randomBytes=require("randombytes"),createHash=require("create-hash"),mgf=require("./mgf"),xor=require("./xor"),bn=require("bn.js"),withPublic=require("./withPublic"),crt=require("browserify-rsa");module.exports=function(public_key,msg,reverse){var padding;padding=public_key.padding?public_key.padding:reverse?1:4;var paddedMsg,key=parseKeys(public_key);if(4===padding)paddedMsg=oaep(key,msg);else if(1===padding)paddedMsg=pkcs1(key,msg,reverse);else{if(3!==padding)throw new Error("unknown padding");if(paddedMsg=new bn(msg),paddedMsg.cmp(key.modulus)>=0)throw new Error("data too long for modulus")}return reverse?crt(paddedMsg,key):withPublic(paddedMsg,key)}}).call(this,require("buffer").Buffer)},{"./mgf":107,"./withPublic":110,"./xor":111,"bn.js":16,"browserify-rsa":37,buffer:45,"create-hash":50,"parse-asn1":101,randombytes:116}],110:[function(require,module){(function(Buffer){function withPublic(paddedMsg,key){return new Buffer(paddedMsg.toRed(bn.mont(key.modulus)).redPow(new bn(key.publicExponent)).fromRed().toArray())}var bn=require("bn.js");module.exports=withPublic}).call(this,require("buffer").Buffer)},{"bn.js":16,buffer:45}],111:[function(require,module){module.exports=function(a,b){for(var len=a.length,i=-1;++i<len;)a[i]^=b[i];return a}},{}],112:[function(require,module,exports){(function(global){!function(root){function error(type){throw new RangeError(errors[type])}function map(array,fn){for(var length=array.length,result=[];length--;)result[length]=fn(array[length]);return result}function mapDomain(string,fn){var parts=string.split("@"),result="";parts.length>1&&(result=parts[0]+"@",string=parts[1]),string=string.replace(regexSeparators,".");var labels=string.split("."),encoded=map(labels,fn).join(".");return result+encoded}function ucs2decode(string){for(var value,extra,output=[],counter=0,length=string.length;length>counter;)value=string.charCodeAt(counter++),value>=55296&&56319>=value&&length>counter?(extra=string.charCodeAt(counter++),56320==(64512&extra)?output.push(((1023&value)<<10)+(1023&extra)+65536):(output.push(value),counter--)):output.push(value);return output}function ucs2encode(array){return map(array,function(value){var output="";return value>65535&&(value-=65536,output+=stringFromCharCode(value>>>10&1023|55296),value=56320|1023&value),output+=stringFromCharCode(value)}).join("")}function basicToDigit(codePoint){return 10>codePoint-48?codePoint-22:26>codePoint-65?codePoint-65:26>codePoint-97?codePoint-97:base}function digitToBasic(digit,flag){return digit+22+75*(26>digit)-((0!=flag)<<5)}function adapt(delta,numPoints,firstTime){var k=0;for(delta=firstTime?floor(delta/damp):delta>>1,delta+=floor(delta/numPoints);delta>baseMinusTMin*tMax>>1;k+=base)delta=floor(delta/baseMinusTMin);return floor(k+(baseMinusTMin+1)*delta/(delta+skew))}function decode(input){var out,basic,j,index,oldi,w,k,digit,t,baseMinusT,output=[],inputLength=input.length,i=0,n=initialN,bias=initialBias;for(basic=input.lastIndexOf(delimiter),0>basic&&(basic=0),j=0;basic>j;++j)input.charCodeAt(j)>=128&&error("not-basic"),output.push(input.charCodeAt(j));for(index=basic>0?basic+1:0;inputLength>index;){for(oldi=i,w=1,k=base;index>=inputLength&&error("invalid-input"),digit=basicToDigit(input.charCodeAt(index++)),(digit>=base||digit>floor((maxInt-i)/w))&&error("overflow"),i+=digit*w,t=bias>=k?tMin:k>=bias+tMax?tMax:k-bias,!(t>digit);k+=base)baseMinusT=base-t,w>floor(maxInt/baseMinusT)&&error("overflow"),w*=baseMinusT;out=output.length+1,bias=adapt(i-oldi,out,0==oldi),floor(i/out)>maxInt-n&&error("overflow"),n+=floor(i/out),i%=out,output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,inputLength,handledCPCountPlusOne,baseMinusT,qMinusT,output=[];for(input=ucs2decode(input),inputLength=input.length,n=initialN,delta=0,bias=initialBias,j=0;inputLength>j;++j)currentValue=input[j],128>currentValue&&output.push(stringFromCharCode(currentValue));for(handledCPCount=basicLength=output.length,basicLength&&output.push(delimiter);inputLength>handledCPCount;){for(m=maxInt,j=0;inputLength>j;++j)currentValue=input[j],currentValue>=n&&m>currentValue&&(m=currentValue);for(handledCPCountPlusOne=handledCPCount+1,m-n>floor((maxInt-delta)/handledCPCountPlusOne)&&error("overflow"),delta+=(m-n)*handledCPCountPlusOne,n=m,j=0;inputLength>j;++j)if(currentValue=input[j],n>currentValue&&++delta>maxInt&&error("overflow"),currentValue==n){for(q=delta,k=base;t=bias>=k?tMin:k>=bias+tMax?tMax:k-bias,!(t>q);k+=base)qMinusT=q-t,baseMinusT=base-t,output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0))),q=floor(qMinusT/baseMinusT);output.push(stringFromCharCode(digitToBasic(q,0))),bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength),delta=0,++handledCPCount}++delta,++n}return output.join("")}function toUnicode(input){return mapDomain(input,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string})}function toASCII(input){return mapDomain(input,function(string){return regexNonASCII.test(string)?"xn--"+encode(string):string})}var freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule="object"==typeof module&&module&&!module.nodeType&&module,freeGlobal="object"==typeof global&&global;(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal||freeGlobal.self===freeGlobal)&&(root=freeGlobal);var punycode,key,maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^\x20-\x7E]/,regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;if(punycode={version:"1.4.1",ucs2:{decode:ucs2decode,encode:ucs2encode},decode:decode,encode:encode,toASCII:toASCII,toUnicode:toUnicode},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return punycode});else if(freeExports&&freeModule)if(module.exports==freeExports)freeModule.exports=punycode;else for(key in punycode)punycode.hasOwnProperty(key)&&(freeExports[key]=punycode[key]);else root.punycode=punycode}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],113:[function(require,module){"use strict";function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}module.exports=function(qs,sep,eq,options){sep=sep||"&",eq=eq||"=";var obj={};if("string"!=typeof qs||0===qs.length)return obj;var regexp=/\+/g;qs=qs.split(sep);var maxKeys=1e3;options&&"number"==typeof options.maxKeys&&(maxKeys=options.maxKeys);var len=qs.length;maxKeys>0&&len>maxKeys&&(len=maxKeys);for(var i=0;len>i;++i){var kstr,vstr,k,v,x=qs[i].replace(regexp,"%20"),idx=x.indexOf(eq);idx>=0?(kstr=x.substr(0,idx),vstr=x.substr(idx+1)):(kstr=x,vstr=""),k=decodeURIComponent(kstr),v=decodeURIComponent(vstr),hasOwnProperty(obj,k)?isArray(obj[k])?obj[k].push(v):obj[k]=[obj[k],v]:obj[k]=v}return obj};var isArray=Array.isArray||function(xs){return"[object Array]"===Object.prototype.toString.call(xs)}},{}],114:[function(require,module){"use strict";function map(xs,f){if(xs.map)return xs.map(f);for(var res=[],i=0;i<xs.length;i++)res.push(f(xs[i],i));return res}var stringifyPrimitive=function(v){switch(typeof v){case"string":return v;case"boolean":return v?"true":"false";case"number":return isFinite(v)?v:"";default:return""}};module.exports=function(obj,sep,eq,name){return sep=sep||"&",eq=eq||"=",null===obj&&(obj=void 0),"object"==typeof obj?map(objectKeys(obj),function(k){var ks=encodeURIComponent(stringifyPrimitive(k))+eq;return isArray(obj[k])?map(obj[k],function(v){return ks+encodeURIComponent(stringifyPrimitive(v))}).join(sep):ks+encodeURIComponent(stringifyPrimitive(obj[k]))}).join(sep):name?encodeURIComponent(stringifyPrimitive(name))+eq+encodeURIComponent(stringifyPrimitive(obj)):""};var isArray=Array.isArray||function(xs){return"[object Array]"===Object.prototype.toString.call(xs)},objectKeys=Object.keys||function(obj){var res=[];for(var key in obj)Object.prototype.hasOwnProperty.call(obj,key)&&res.push(key);return res}},{}],115:[function(require,module,exports){"use strict";exports.decode=exports.parse=require("./decode"),exports.encode=exports.stringify=require("./encode")},{"./decode":113,"./encode":114}],116:[function(require,module){(function(process,global,Buffer){"use strict";function oldBrowser(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}function randomBytes(size,cb){if(size>65536)throw new Error("requested too many random bytes");var rawBytes=new global.Uint8Array(size);size>0&&crypto.getRandomValues(rawBytes);var bytes=new Buffer(rawBytes.buffer);return"function"==typeof cb?process.nextTick(function(){cb(null,bytes)}):bytes}var crypto=global.crypto||global.msCrypto;module.exports=crypto&&crypto.getRandomValues?randomBytes:oldBrowser}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},require("buffer").Buffer)},{_process:105,buffer:45}],117:[function(require,module){module.exports=require("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":118}],118:[function(require,module){"use strict";function Duplex(options){return this instanceof Duplex?(Readable.call(this,options),Writable.call(this,options),options&&options.readable===!1&&(this.readable=!1),options&&options.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,options&&options.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",onend)):new Duplex(options)}function onend(){this.allowHalfOpen||this._writableState.ended||processNextTick(onEndNT,this)}function onEndNT(self){self.end()}var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)keys.push(key);return keys};module.exports=Duplex;var processNextTick=require("process-nextick-args"),util=require("core-util-is");util.inherits=require("inherits");var Readable=require("./_stream_readable"),Writable=require("./_stream_writable");util.inherits(Duplex,Readable);for(var keys=objectKeys(Writable.prototype),v=0;v<keys.length;v++){var method=keys[v];Duplex.prototype[method]||(Duplex.prototype[method]=Writable.prototype[method])}},{"./_stream_readable":120,"./_stream_writable":122,"core-util-is":48,inherits:93,"process-nextick-args":104}],119:[function(require,module){"use strict";function PassThrough(options){return this instanceof PassThrough?void Transform.call(this,options):new PassThrough(options)}module.exports=PassThrough;var Transform=require("./_stream_transform"),util=require("core-util-is");util.inherits=require("inherits"),util.inherits(PassThrough,Transform),PassThrough.prototype._transform=function(chunk,encoding,cb){cb(null,chunk)}},{"./_stream_transform":121,"core-util-is":48,inherits:93}],120:[function(require,module){(function(process){"use strict";function prependListener(emitter,event,fn){return"function"==typeof emitter.prependListener?emitter.prependListener(event,fn):void(emitter._events&&emitter._events[event]?isArray(emitter._events[event])?emitter._events[event].unshift(fn):emitter._events[event]=[fn,emitter._events[event]]:emitter.on(event,fn))}function ReadableState(options,stream){Duplex=Duplex||require("./_stream_duplex"),options=options||{},this.objectMode=!!options.objectMode,stream instanceof Duplex&&(this.objectMode=this.objectMode||!!options.readableObjectMode);var hwm=options.highWaterMark,defaultHwm=this.objectMode?16:16384;this.highWaterMark=hwm||0===hwm?hwm:defaultHwm,this.highWaterMark=~~this.highWaterMark,this.buffer=new BufferList,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=options.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,options.encoding&&(StringDecoder||(StringDecoder=require("string_decoder/").StringDecoder),this.decoder=new StringDecoder(options.encoding),this.encoding=options.encoding)}function Readable(options){return Duplex=Duplex||require("./_stream_duplex"),this instanceof Readable?(this._readableState=new ReadableState(options,this),this.readable=!0,options&&"function"==typeof options.read&&(this._read=options.read),void Stream.call(this)):new Readable(options)}function readableAddChunk(stream,state,chunk,encoding,addToFront){var er=chunkInvalid(state,chunk);if(er)stream.emit("error",er);else if(null===chunk)state.reading=!1,onEofChunk(stream,state);else if(state.objectMode||chunk&&chunk.length>0)if(state.ended&&!addToFront){var e=new Error("stream.push() after EOF");stream.emit("error",e)}else if(state.endEmitted&&addToFront){var _e=new Error("stream.unshift() after end event");stream.emit("error",_e)}else{var skipAdd;!state.decoder||addToFront||encoding||(chunk=state.decoder.write(chunk),skipAdd=!state.objectMode&&0===chunk.length),addToFront||(state.reading=!1),skipAdd||(state.flowing&&0===state.length&&!state.sync?(stream.emit("data",chunk),stream.read(0)):(state.length+=state.objectMode?1:chunk.length,
  addToFront?state.buffer.unshift(chunk):state.buffer.push(chunk),state.needReadable&&emitReadable(stream))),maybeReadMore(stream,state)}else addToFront||(state.reading=!1);return needMoreData(state)}function needMoreData(state){return!state.ended&&(state.needReadable||state.length<state.highWaterMark||0===state.length)}function computeNewHighWaterMark(n){return n>=MAX_HWM?n=MAX_HWM:(n--,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n++),n}function howMuchToRead(n,state){return 0>=n||0===state.length&&state.ended?0:state.objectMode?1:n!==n?state.flowing&&state.length?state.buffer.head.data.length:state.length:(n>state.highWaterMark&&(state.highWaterMark=computeNewHighWaterMark(n)),n<=state.length?n:state.ended?state.length:(state.needReadable=!0,0))}function chunkInvalid(state,chunk){var er=null;return Buffer.isBuffer(chunk)||"string"==typeof chunk||null===chunk||void 0===chunk||state.objectMode||(er=new TypeError("Invalid non-string/buffer chunk")),er}function onEofChunk(stream,state){if(!state.ended){if(state.decoder){var chunk=state.decoder.end();chunk&&chunk.length&&(state.buffer.push(chunk),state.length+=state.objectMode?1:chunk.length)}state.ended=!0,emitReadable(stream)}}function emitReadable(stream){var state=stream._readableState;state.needReadable=!1,state.emittedReadable||(debug("emitReadable",state.flowing),state.emittedReadable=!0,state.sync?processNextTick(emitReadable_,stream):emitReadable_(stream))}function emitReadable_(stream){debug("emit readable"),stream.emit("readable"),flow(stream)}function maybeReadMore(stream,state){state.readingMore||(state.readingMore=!0,processNextTick(maybeReadMore_,stream,state))}function maybeReadMore_(stream,state){for(var len=state.length;!state.reading&&!state.flowing&&!state.ended&&state.length<state.highWaterMark&&(debug("maybeReadMore read 0"),stream.read(0),len!==state.length);)len=state.length;state.readingMore=!1}function pipeOnDrain(src){return function(){var state=src._readableState;debug("pipeOnDrain",state.awaitDrain),state.awaitDrain&&state.awaitDrain--,0===state.awaitDrain&&EElistenerCount(src,"data")&&(state.flowing=!0,flow(src))}}function nReadingNextTick(self){debug("readable nexttick read 0"),self.read(0)}function resume(stream,state){state.resumeScheduled||(state.resumeScheduled=!0,processNextTick(resume_,stream,state))}function resume_(stream,state){state.reading||(debug("resume read 0"),stream.read(0)),state.resumeScheduled=!1,state.awaitDrain=0,stream.emit("resume"),flow(stream),state.flowing&&!state.reading&&stream.read(0)}function flow(stream){var state=stream._readableState;for(debug("flow",state.flowing);state.flowing&&null!==stream.read(););}function fromList(n,state){if(0===state.length)return null;var ret;return state.objectMode?ret=state.buffer.shift():!n||n>=state.length?(ret=state.decoder?state.buffer.join(""):1===state.buffer.length?state.buffer.head.data:state.buffer.concat(state.length),state.buffer.clear()):ret=fromListPartial(n,state.buffer,state.decoder),ret}function fromListPartial(n,list,hasStrings){var ret;return n<list.head.data.length?(ret=list.head.data.slice(0,n),list.head.data=list.head.data.slice(n)):ret=n===list.head.data.length?list.shift():hasStrings?copyFromBufferString(n,list):copyFromBuffer(n,list),ret}function copyFromBufferString(n,list){var p=list.head,c=1,ret=p.data;for(n-=ret.length;p=p.next;){var str=p.data,nb=n>str.length?str.length:n;if(ret+=nb===str.length?str:str.slice(0,n),n-=nb,0===n){nb===str.length?(++c,list.head=p.next?p.next:list.tail=null):(list.head=p,p.data=str.slice(nb));break}++c}return list.length-=c,ret}function copyFromBuffer(n,list){var ret=bufferShim.allocUnsafe(n),p=list.head,c=1;for(p.data.copy(ret),n-=p.data.length;p=p.next;){var buf=p.data,nb=n>buf.length?buf.length:n;if(buf.copy(ret,ret.length-n,0,nb),n-=nb,0===n){nb===buf.length?(++c,list.head=p.next?p.next:list.tail=null):(list.head=p,p.data=buf.slice(nb));break}++c}return list.length-=c,ret}function endReadable(stream){var state=stream._readableState;if(state.length>0)throw new Error('"endReadable()" called on non-empty stream');state.endEmitted||(state.ended=!0,processNextTick(endReadableNT,state,stream))}function endReadableNT(state,stream){state.endEmitted||0!==state.length||(state.endEmitted=!0,stream.readable=!1,stream.emit("end"))}function forEach(xs,f){for(var i=0,l=xs.length;l>i;i++)f(xs[i],i)}function indexOf(xs,x){for(var i=0,l=xs.length;l>i;i++)if(xs[i]===x)return i;return-1}module.exports=Readable;var Duplex,processNextTick=require("process-nextick-args"),isArray=require("isarray");Readable.ReadableState=ReadableState;var Stream,EElistenerCount=(require("events").EventEmitter,function(emitter,type){return emitter.listeners(type).length});!function(){try{Stream=require("stream")}catch(_){}finally{Stream||(Stream=require("events").EventEmitter)}}();var Buffer=require("buffer").Buffer,bufferShim=require("buffer-shims"),util=require("core-util-is");util.inherits=require("inherits");var debugUtil=require("util"),debug=void 0;debug=debugUtil&&debugUtil.debuglog?debugUtil.debuglog("stream"):function(){};var StringDecoder,BufferList=require("./internal/streams/BufferList");util.inherits(Readable,Stream),Readable.prototype.push=function(chunk,encoding){var state=this._readableState;return state.objectMode||"string"!=typeof chunk||(encoding=encoding||state.defaultEncoding,encoding!==state.encoding&&(chunk=bufferShim.from(chunk,encoding),encoding="")),readableAddChunk(this,state,chunk,encoding,!1)},Readable.prototype.unshift=function(chunk){var state=this._readableState;return readableAddChunk(this,state,chunk,"",!0)},Readable.prototype.isPaused=function(){return this._readableState.flowing===!1},Readable.prototype.setEncoding=function(enc){return StringDecoder||(StringDecoder=require("string_decoder/").StringDecoder),this._readableState.decoder=new StringDecoder(enc),this._readableState.encoding=enc,this};var MAX_HWM=8388608;Readable.prototype.read=function(n){debug("read",n),n=parseInt(n,10);var state=this._readableState,nOrig=n;if(0!==n&&(state.emittedReadable=!1),0===n&&state.needReadable&&(state.length>=state.highWaterMark||state.ended))return debug("read: emitReadable",state.length,state.ended),0===state.length&&state.ended?endReadable(this):emitReadable(this),null;if(n=howMuchToRead(n,state),0===n&&state.ended)return 0===state.length&&endReadable(this),null;var doRead=state.needReadable;debug("need readable",doRead),(0===state.length||state.length-n<state.highWaterMark)&&(doRead=!0,debug("length less than watermark",doRead)),state.ended||state.reading?(doRead=!1,debug("reading or ended",doRead)):doRead&&(debug("do read"),state.reading=!0,state.sync=!0,0===state.length&&(state.needReadable=!0),this._read(state.highWaterMark),state.sync=!1,state.reading||(n=howMuchToRead(nOrig,state)));var ret;return ret=n>0?fromList(n,state):null,null===ret?(state.needReadable=!0,n=0):state.length-=n,0===state.length&&(state.ended||(state.needReadable=!0),nOrig!==n&&state.ended&&endReadable(this)),null!==ret&&this.emit("data",ret),ret},Readable.prototype._read=function(){this.emit("error",new Error("_read() is not implemented"))},Readable.prototype.pipe=function(dest,pipeOpts){function onunpipe(readable){debug("onunpipe"),readable===src&&cleanup()}function onend(){debug("onend"),dest.end()}function cleanup(){debug("cleanup"),dest.removeListener("close",onclose),dest.removeListener("finish",onfinish),dest.removeListener("drain",ondrain),dest.removeListener("error",onerror),dest.removeListener("unpipe",onunpipe),src.removeListener("end",onend),src.removeListener("end",cleanup),src.removeListener("data",ondata),cleanedUp=!0,!state.awaitDrain||dest._writableState&&!dest._writableState.needDrain||ondrain()}function ondata(chunk){debug("ondata"),increasedAwaitDrain=!1;var ret=dest.write(chunk);!1!==ret||increasedAwaitDrain||((1===state.pipesCount&&state.pipes===dest||state.pipesCount>1&&-1!==indexOf(state.pipes,dest))&&!cleanedUp&&(debug("false write response, pause",src._readableState.awaitDrain),src._readableState.awaitDrain++,increasedAwaitDrain=!0),src.pause())}function onerror(er){debug("onerror",er),unpipe(),dest.removeListener("error",onerror),0===EElistenerCount(dest,"error")&&dest.emit("error",er)}function onclose(){dest.removeListener("finish",onfinish),unpipe()}function onfinish(){debug("onfinish"),dest.removeListener("close",onclose),unpipe()}function unpipe(){debug("unpipe"),src.unpipe(dest)}var src=this,state=this._readableState;switch(state.pipesCount){case 0:state.pipes=dest;break;case 1:state.pipes=[state.pipes,dest];break;default:state.pipes.push(dest)}state.pipesCount+=1,debug("pipe count=%d opts=%j",state.pipesCount,pipeOpts);var doEnd=(!pipeOpts||pipeOpts.end!==!1)&&dest!==process.stdout&&dest!==process.stderr,endFn=doEnd?onend:cleanup;state.endEmitted?processNextTick(endFn):src.once("end",endFn),dest.on("unpipe",onunpipe);var ondrain=pipeOnDrain(src);dest.on("drain",ondrain);var cleanedUp=!1,increasedAwaitDrain=!1;return src.on("data",ondata),prependListener(dest,"error",onerror),dest.once("close",onclose),dest.once("finish",onfinish),dest.emit("pipe",src),state.flowing||(debug("pipe resume"),src.resume()),dest},Readable.prototype.unpipe=function(dest){var state=this._readableState;if(0===state.pipesCount)return this;if(1===state.pipesCount)return dest&&dest!==state.pipes?this:(dest||(dest=state.pipes),state.pipes=null,state.pipesCount=0,state.flowing=!1,dest&&dest.emit("unpipe",this),this);if(!dest){var dests=state.pipes,len=state.pipesCount;state.pipes=null,state.pipesCount=0,state.flowing=!1;for(var i=0;len>i;i++)dests[i].emit("unpipe",this);return this}var index=indexOf(state.pipes,dest);return-1===index?this:(state.pipes.splice(index,1),state.pipesCount-=1,1===state.pipesCount&&(state.pipes=state.pipes[0]),dest.emit("unpipe",this),this)},Readable.prototype.on=function(ev,fn){var res=Stream.prototype.on.call(this,ev,fn);if("data"===ev)this._readableState.flowing!==!1&&this.resume();else if("readable"===ev){var state=this._readableState;state.endEmitted||state.readableListening||(state.readableListening=state.needReadable=!0,state.emittedReadable=!1,state.reading?state.length&&emitReadable(this,state):processNextTick(nReadingNextTick,this))}return res},Readable.prototype.addListener=Readable.prototype.on,Readable.prototype.resume=function(){var state=this._readableState;return state.flowing||(debug("resume"),state.flowing=!0,resume(this,state)),this},Readable.prototype.pause=function(){return debug("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(debug("pause"),this._readableState.flowing=!1,this.emit("pause")),this},Readable.prototype.wrap=function(stream){var state=this._readableState,paused=!1,self=this;stream.on("end",function(){if(debug("wrapped end"),state.decoder&&!state.ended){var chunk=state.decoder.end();chunk&&chunk.length&&self.push(chunk)}self.push(null)}),stream.on("data",function(chunk){if(debug("wrapped data"),state.decoder&&(chunk=state.decoder.write(chunk)),(!state.objectMode||null!==chunk&&void 0!==chunk)&&(state.objectMode||chunk&&chunk.length)){var ret=self.push(chunk);ret||(paused=!0,stream.pause())}});for(var i in stream)void 0===this[i]&&"function"==typeof stream[i]&&(this[i]=function(method){return function(){return stream[method].apply(stream,arguments)}}(i));var events=["error","close","destroy","pause","resume"];return forEach(events,function(ev){stream.on(ev,self.emit.bind(self,ev))}),self._read=function(n){debug("wrapped _read",n),paused&&(paused=!1,stream.resume())},self},Readable._fromList=fromList}).call(this,require("_process"))},{"./_stream_duplex":118,"./internal/streams/BufferList":123,_process:105,buffer:45,"buffer-shims":43,"core-util-is":48,events:82,inherits:93,isarray:95,"process-nextick-args":104,"string_decoder/":142,util:18}],121:[function(require,module){"use strict";function TransformState(stream){this.afterTransform=function(er,data){return afterTransform(stream,er,data)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function afterTransform(stream,er,data){var ts=stream._transformState;ts.transforming=!1;var cb=ts.writecb;if(!cb)return stream.emit("error",new Error("no writecb in Transform class"));ts.writechunk=null,ts.writecb=null,null!==data&&void 0!==data&&stream.push(data),cb(er);var rs=stream._readableState;rs.reading=!1,(rs.needReadable||rs.length<rs.highWaterMark)&&stream._read(rs.highWaterMark)}function Transform(options){if(!(this instanceof Transform))return new Transform(options);Duplex.call(this,options),this._transformState=new TransformState(this);var stream=this;this._readableState.needReadable=!0,this._readableState.sync=!1,options&&("function"==typeof options.transform&&(this._transform=options.transform),"function"==typeof options.flush&&(this._flush=options.flush)),this.once("prefinish",function(){"function"==typeof this._flush?this._flush(function(er,data){done(stream,er,data)}):done(stream)})}function done(stream,er,data){if(er)return stream.emit("error",er);null!==data&&void 0!==data&&stream.push(data);var ws=stream._writableState,ts=stream._transformState;if(ws.length)throw new Error("Calling transform done when ws.length != 0");if(ts.transforming)throw new Error("Calling transform done when still transforming");return stream.push(null)}module.exports=Transform;var Duplex=require("./_stream_duplex"),util=require("core-util-is");util.inherits=require("inherits"),util.inherits(Transform,Duplex),Transform.prototype.push=function(chunk,encoding){return this._transformState.needTransform=!1,Duplex.prototype.push.call(this,chunk,encoding)},Transform.prototype._transform=function(){throw new Error("_transform() is not implemented")},Transform.prototype._write=function(chunk,encoding,cb){var ts=this._transformState;if(ts.writecb=cb,ts.writechunk=chunk,ts.writeencoding=encoding,!ts.transforming){var rs=this._readableState;(ts.needTransform||rs.needReadable||rs.length<rs.highWaterMark)&&this._read(rs.highWaterMark)}},Transform.prototype._read=function(){var ts=this._transformState;null!==ts.writechunk&&ts.writecb&&!ts.transforming?(ts.transforming=!0,this._transform(ts.writechunk,ts.writeencoding,ts.afterTransform)):ts.needTransform=!0}},{"./_stream_duplex":118,"core-util-is":48,inherits:93}],122:[function(require,module){(function(process){"use strict";function nop(){}function WriteReq(chunk,encoding,cb){this.chunk=chunk,this.encoding=encoding,this.callback=cb,this.next=null}function WritableState(options,stream){Duplex=Duplex||require("./_stream_duplex"),options=options||{},this.objectMode=!!options.objectMode,stream instanceof Duplex&&(this.objectMode=this.objectMode||!!options.writableObjectMode);var hwm=options.highWaterMark,defaultHwm=this.objectMode?16:16384;this.highWaterMark=hwm||0===hwm?hwm:defaultHwm,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var noDecode=options.decodeStrings===!1;this.decodeStrings=!noDecode,this.defaultEncoding=options.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(er){onwrite(stream,er)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new CorkedRequest(this)}function Writable(options){return Duplex=Duplex||require("./_stream_duplex"),realHasInstance.call(Writable,this)||this instanceof Duplex?(this._writableState=new WritableState(options,this),this.writable=!0,options&&("function"==typeof options.write&&(this._write=options.write),"function"==typeof options.writev&&(this._writev=options.writev)),void Stream.call(this)):new Writable(options)}function writeAfterEnd(stream,cb){var er=new Error("write after end");stream.emit("error",er),processNextTick(cb,er)}function validChunk(stream,state,chunk,cb){var valid=!0,er=!1;return null===chunk?er=new TypeError("May not write null values to stream"):Buffer.isBuffer(chunk)||"string"==typeof chunk||void 0===chunk||state.objectMode||(er=new TypeError("Invalid non-string/buffer chunk")),er&&(stream.emit("error",er),processNextTick(cb,er),valid=!1),valid}function decodeChunk(state,chunk,encoding){return state.objectMode||state.decodeStrings===!1||"string"!=typeof chunk||(chunk=bufferShim.from(chunk,encoding)),chunk}function writeOrBuffer(stream,state,chunk,encoding,cb){chunk=decodeChunk(state,chunk,encoding),Buffer.isBuffer(chunk)&&(encoding="buffer");var len=state.objectMode?1:chunk.length;state.length+=len;var ret=state.length<state.highWaterMark;if(ret||(state.needDrain=!0),state.writing||state.corked){var last=state.lastBufferedRequest;state.lastBufferedRequest=new WriteReq(chunk,encoding,cb),last?last.next=state.lastBufferedRequest:state.bufferedRequest=state.lastBufferedRequest,state.bufferedRequestCount+=1}else doWrite(stream,state,!1,len,chunk,encoding,cb);return ret}function doWrite(stream,state,writev,len,chunk,encoding,cb){state.writelen=len,state.writecb=cb,state.writing=!0,state.sync=!0,writev?stream._writev(chunk,state.onwrite):stream._write(chunk,encoding,state.onwrite),state.sync=!1}function onwriteError(stream,state,sync,er,cb){--state.pendingcb,sync?processNextTick(cb,er):cb(er),stream._writableState.errorEmitted=!0,stream.emit("error",er)}function onwriteStateUpdate(state){state.writing=!1,state.writecb=null,state.length-=state.writelen,state.writelen=0}function onwrite(stream,er){var state=stream._writableState,sync=state.sync,cb=state.writecb;if(onwriteStateUpdate(state),er)onwriteError(stream,state,sync,er,cb);else{var finished=needFinish(state);finished||state.corked||state.bufferProcessing||!state.bufferedRequest||clearBuffer(stream,state),sync?asyncWrite(afterWrite,stream,state,finished,cb):afterWrite(stream,state,finished,cb)}}function afterWrite(stream,state,finished,cb){finished||onwriteDrain(stream,state),state.pendingcb--,cb(),finishMaybe(stream,state)}function onwriteDrain(stream,state){0===state.length&&state.needDrain&&(state.needDrain=!1,stream.emit("drain"))}function clearBuffer(stream,state){state.bufferProcessing=!0;var entry=state.bufferedRequest;if(stream._writev&&entry&&entry.next){var l=state.bufferedRequestCount,buffer=new Array(l),holder=state.corkedRequestsFree;holder.entry=entry;for(var count=0;entry;)buffer[count]=entry,entry=entry.next,count+=1;doWrite(stream,state,!0,state.length,buffer,"",holder.finish),state.pendingcb++,state.lastBufferedRequest=null,holder.next?(state.corkedRequestsFree=holder.next,holder.next=null):state.corkedRequestsFree=new CorkedRequest(state)}else{for(;entry;){var chunk=entry.chunk,encoding=entry.encoding,cb=entry.callback,len=state.objectMode?1:chunk.length;if(doWrite(stream,state,!1,len,chunk,encoding,cb),entry=entry.next,state.writing)break}null===entry&&(state.lastBufferedRequest=null)}state.bufferedRequestCount=0,state.bufferedRequest=entry,state.bufferProcessing=!1}function needFinish(state){return state.ending&&0===state.length&&null===state.bufferedRequest&&!state.finished&&!state.writing}function prefinish(stream,state){state.prefinished||(state.prefinished=!0,stream.emit("prefinish"))}function finishMaybe(stream,state){var need=needFinish(state);return need&&(0===state.pendingcb?(prefinish(stream,state),state.finished=!0,stream.emit("finish")):prefinish(stream,state)),need}function endWritable(stream,state,cb){state.ending=!0,finishMaybe(stream,state),cb&&(state.finished?processNextTick(cb):stream.once("finish",cb)),state.ended=!0,stream.writable=!1}function CorkedRequest(state){var _this=this;this.next=null,this.entry=null,this.finish=function(err){var entry=_this.entry;for(_this.entry=null;entry;){var cb=entry.callback;state.pendingcb--,cb(err),entry=entry.next}state.corkedRequestsFree?state.corkedRequestsFree.next=_this:state.corkedRequestsFree=_this}}module.exports=Writable;var Duplex,processNextTick=require("process-nextick-args"),asyncWrite=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:processNextTick;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var Stream,internalUtil={deprecate:require("util-deprecate")};!function(){try{Stream=require("stream")}catch(_){}finally{Stream||(Stream=require("events").EventEmitter)}}();var Buffer=require("buffer").Buffer,bufferShim=require("buffer-shims");util.inherits(Writable,Stream),WritableState.prototype.getBuffer=function(){for(var current=this.bufferedRequest,out=[];current;)out.push(current),current=current.next;return out},function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(_){}}();var realHasInstance;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(realHasInstance=Function.prototype[Symbol.hasInstance],Object.defineProperty(Writable,Symbol.hasInstance,{value:function(object){return realHasInstance.call(this,object)?!0:object&&object._writableState instanceof WritableState}})):realHasInstance=function(object){return object instanceof this},Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Writable.prototype.write=function(chunk,encoding,cb){var state=this._writableState,ret=!1;return"function"==typeof encoding&&(cb=encoding,encoding=null),Buffer.isBuffer(chunk)?encoding="buffer":encoding||(encoding=state.defaultEncoding),"function"!=typeof cb&&(cb=nop),state.ended?writeAfterEnd(this,cb):validChunk(this,state,chunk,cb)&&(state.pendingcb++,ret=writeOrBuffer(this,state,chunk,encoding,cb)),ret},Writable.prototype.cork=function(){var state=this._writableState;state.corked++},Writable.prototype.uncork=function(){var state=this._writableState;state.corked&&(state.corked--,state.writing||state.corked||state.finished||state.bufferProcessing||!state.bufferedRequest||clearBuffer(this,state))},Writable.prototype.setDefaultEncoding=function(encoding){if("string"==typeof encoding&&(encoding=encoding.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((encoding+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+encoding);return this._writableState.defaultEncoding=encoding,this},Writable.prototype._write=function(chunk,encoding,cb){cb(new Error("_write() is not implemented"))},Writable.prototype._writev=null,Writable.prototype.end=function(chunk,encoding,cb){var state=this._writableState;"function"==typeof chunk?(cb=chunk,chunk=null,encoding=null):"function"==typeof encoding&&(cb=encoding,encoding=null),null!==chunk&&void 0!==chunk&&this.write(chunk,encoding),state.corked&&(state.corked=1,this.uncork()),state.ending||state.finished||endWritable(this,state,cb)}}).call(this,require("_process"))},{"./_stream_duplex":118,_process:105,buffer:45,"buffer-shims":43,"core-util-is":48,events:82,inherits:93,"process-nextick-args":104,"util-deprecate":146}],123:[function(require,module){"use strict";function BufferList(){this.head=null,this.tail=null,this.length=0}var bufferShim=(require("buffer").Buffer,require("buffer-shims"));module.exports=BufferList,BufferList.prototype.push=function(v){var entry={data:v,next:null};this.length>0?this.tail.next=entry:this.head=entry,this.tail=entry,++this.length},BufferList.prototype.unshift=function(v){var entry={data:v,next:this.head};0===this.length&&(this.tail=entry),this.head=entry,++this.length},BufferList.prototype.shift=function(){if(0!==this.length){var ret=this.head.data;return this.head=1===this.length?this.tail=null:this.head.next,--this.length,ret}},BufferList.prototype.clear=function(){this.head=this.tail=null,this.length=0},BufferList.prototype.join=function(s){if(0===this.length)return"";for(var p=this.head,ret=""+p.data;p=p.next;)ret+=s+p.data;return ret},BufferList.prototype.concat=function(n){if(0===this.length)return bufferShim.alloc(0);if(1===this.length)return this.head.data;for(var ret=bufferShim.allocUnsafe(n>>>0),p=this.head,i=0;p;)p.data.copy(ret,i),i+=p.data.length,p=p.next;return ret}},{buffer:45,"buffer-shims":43}],124:[function(require,module){module.exports=require("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":119}],125:[function(require,module,exports){(function(process){var Stream=function(){try{return require("stream")}catch(_){}}();exports=module.exports=require("./lib/_stream_readable.js"),exports.Stream=Stream||exports,exports.Readable=exports,exports.Writable=require("./lib/_stream_writable.js"),exports.Duplex=require("./lib/_stream_duplex.js"),exports.Transform=require("./lib/_stream_transform.js"),exports.PassThrough=require("./lib/_stream_passthrough.js"),!process.browser&&"disable"===process.env.READABLE_STREAM&&Stream&&(module.exports=Stream)}).call(this,require("_process"))},{"./lib/_stream_duplex.js":118,"./lib/_stream_passthrough.js":119,"./lib/_stream_readable.js":120,"./lib/_stream_transform.js":121,"./lib/_stream_writable.js":122,_process:105}],126:[function(require,module){module.exports=require("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":121}],127:[function(require,module){module.exports=require("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":122}],128:[function(require,module){(function(Buffer){function bytesToWords(bytes){for(var words=[],i=0,b=0;i<bytes.length;i++,b+=8)words[b>>>5]|=bytes[i]<<24-b%32;return words}function wordsToBytes(words){for(var bytes=[],b=0;b<32*words.length;b+=8)bytes.push(words[b>>>5]>>>24-b%32&255);return bytes}function processBlock(H,M,offset){for(var i=0;16>i;i++){var offset_i=offset+i,M_offset_i=M[offset_i];M[offset_i]=16711935&(M_offset_i<<8|M_offset_i>>>24)|4278255360&(M_offset_i<<24|M_offset_i>>>8)}var al,bl,cl,dl,el,ar,br,cr,dr,er;ar=al=H[0],br=bl=H[1],cr=cl=H[2],dr=dl=H[3],er=el=H[4];var t;for(i=0;80>i;i+=1)t=al+M[offset+zl[i]]|0,t+=16>i?f1(bl,cl,dl)+hl[0]:32>i?f2(bl,cl,dl)+hl[1]:48>i?f3(bl,cl,dl)+hl[2]:64>i?f4(bl,cl,dl)+hl[3]:f5(bl,cl,dl)+hl[4],t=0|t,t=rotl(t,sl[i]),t=t+el|0,al=el,el=dl,dl=rotl(cl,10),cl=bl,bl=t,t=ar+M[offset+zr[i]]|0,t+=16>i?f5(br,cr,dr)+hr[0]:32>i?f4(br,cr,dr)+hr[1]:48>i?f3(br,cr,dr)+hr[2]:64>i?f2(br,cr,dr)+hr[3]:f1(br,cr,dr)+hr[4],t=0|t,t=rotl(t,sr[i]),t=t+er|0,ar=er,er=dr,dr=rotl(cr,10),cr=br,br=t;t=H[1]+cl+dr|0,H[1]=H[2]+dl+er|0,H[2]=H[3]+el+ar|0,H[3]=H[4]+al+br|0,H[4]=H[0]+bl+cr|0,H[0]=t}function f1(x,y,z){return x^y^z}function f2(x,y,z){return x&y|~x&z}function f3(x,y,z){return(x|~y)^z}function f4(x,y,z){return x&z|y&~z}function f5(x,y,z){return x^(y|~z)}function rotl(x,n){return x<<n|x>>>32-n}function ripemd160(message){var H=[1732584193,4023233417,2562383102,271733878,3285377520];"string"==typeof message&&(message=new Buffer(message,"utf8"));var m=bytesToWords(message),nBitsLeft=8*message.length,nBitsTotal=8*message.length;m[nBitsLeft>>>5]|=128<<24-nBitsLeft%32,m[(nBitsLeft+64>>>9<<4)+14]=16711935&(nBitsTotal<<8|nBitsTotal>>>24)|4278255360&(nBitsTotal<<24|nBitsTotal>>>8);for(var i=0;i<m.length;i+=16)processBlock(H,m,i);for(i=0;5>i;i++){var H_i=H[i];H[i]=16711935&(H_i<<8|H_i>>>24)|4278255360&(H_i<<24|H_i>>>8)}var digestbytes=wordsToBytes(H);return new Buffer(digestbytes)}var zl=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],zr=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],sl=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sr=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],hl=[0,1518500249,1859775393,2400959708,2840853838],hr=[1352829926,1548603684,1836072691,2053994217,0];module.exports=ripemd160}).call(this,require("buffer").Buffer)},{buffer:45}],129:[function(require,module){(function(Buffer){function Hash(blockSize,finalSize){this._block=new Buffer(blockSize),this._finalSize=finalSize,this._blockSize=blockSize,this._len=0,this._s=0}Hash.prototype.update=function(data,enc){"string"==typeof data&&(enc=enc||"utf8",data=new Buffer(data,enc));for(var l=this._len+=data.length,s=this._s||0,f=0,buffer=this._block;l>s;){for(var t=Math.min(data.length,f+this._blockSize-s%this._blockSize),ch=t-f,i=0;ch>i;i++)buffer[s%this._blockSize+i]=data[i+f];s+=ch,f+=ch,s%this._blockSize===0&&this._update(buffer)}return this._s=s,this},Hash.prototype.digest=function(enc){var l=8*this._len;this._block[this._len%this._blockSize]=128,this._block.fill(0,this._len%this._blockSize+1),l%(8*this._blockSize)>=8*this._finalSize&&(this._update(this._block),this._block.fill(0)),this._block.writeInt32BE(l,this._blockSize-4);var hash=this._update(this._block)||this._hash();return enc?hash.toString(enc):hash},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")},module.exports=Hash}).call(this,require("buffer").Buffer)},{buffer:45}],130:[function(require,module,exports){var exports=module.exports=function(algorithm){algorithm=algorithm.toLowerCase();var Algorithm=exports[algorithm];if(!Algorithm)throw new Error(algorithm+" is not supported (we accept pull requests)");return new Algorithm};exports.sha=require("./sha"),exports.sha1=require("./sha1"),exports.sha224=require("./sha224"),exports.sha256=require("./sha256"),exports.sha384=require("./sha384"),exports.sha512=require("./sha512")},{"./sha":131,"./sha1":132,"./sha224":133,"./sha256":134,"./sha384":135,"./sha512":136}],131:[function(require,module){(function(Buffer){function Sha(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return 0===s?b&c|~b&d:2===s?b&c|b&d|c&d:b^c^d}var inherits=require("inherits"),Hash=require("./hash"),K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);inherits(Sha,Hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;80>i;++i)W[i]=W[i-3]^W[i-8]^W[i-14]^W[i-16];for(var j=0;80>j;++j){var s=~~(j/20),t=rotl5(a)+ft(s,b,c,d)+e+W[j]+K[s]|0;e=d,d=c,c=rotl30(b),b=a,a=t}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0},Sha.prototype._hash=function(){var H=new Buffer(20);return H.writeInt32BE(0|this._a,0),H.writeInt32BE(0|this._b,4),H.writeInt32BE(0|this._c,8),H.writeInt32BE(0|this._d,12),H.writeInt32BE(0|this._e,16),H},module.exports=Sha}).call(this,require("buffer").Buffer)},{"./hash":129,buffer:45,inherits:93}],132:[function(require,module){(function(Buffer){function Sha1(){this.init(),this._w=W,Hash.call(this,64,56)}function rotl1(num){return num<<1|num>>>31}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return 0===s?b&c|~b&d:2===s?b&c|b&d|c&d:b^c^d}var inherits=require("inherits"),Hash=require("./hash"),K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);inherits(Sha1,Hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha1.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;80>i;++i)W[i]=rotl1(W[i-3]^W[i-8]^W[i-14]^W[i-16]);
  
  for(var j=0;80>j;++j){var s=~~(j/20),t=rotl5(a)+ft(s,b,c,d)+e+W[j]+K[s]|0;e=d,d=c,c=rotl30(b),b=a,a=t}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0},Sha1.prototype._hash=function(){var H=new Buffer(20);return H.writeInt32BE(0|this._a,0),H.writeInt32BE(0|this._b,4),H.writeInt32BE(0|this._c,8),H.writeInt32BE(0|this._d,12),H.writeInt32BE(0|this._e,16),H},module.exports=Sha1}).call(this,require("buffer").Buffer)},{"./hash":129,buffer:45,inherits:93}],133:[function(require,module){(function(Buffer){function Sha224(){this.init(),this._w=W,Hash.call(this,64,56)}var inherits=require("inherits"),Sha256=require("./sha256"),Hash=require("./hash"),W=new Array(64);inherits(Sha224,Sha256),Sha224.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},Sha224.prototype._hash=function(){var H=new Buffer(28);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H},module.exports=Sha224}).call(this,require("buffer").Buffer)},{"./hash":129,"./sha256":134,buffer:45,inherits:93}],134:[function(require,module){(function(Buffer){function Sha256(){this.init(),this._w=W,Hash.call(this,64,56)}function ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x){return(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10)}function sigma1(x){return(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7)}function gamma0(x){return(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3}function gamma1(x){return(x>>>17|x<<15)^(x>>>19|x<<13)^x>>>10}var inherits=require("inherits"),Hash=require("./hash"),K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],W=new Array(64);inherits(Sha256,Hash),Sha256.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},Sha256.prototype._update=function(M){for(var W=this._w,a=0|this._a,b=0|this._b,c=0|this._c,d=0|this._d,e=0|this._e,f=0|this._f,g=0|this._g,h=0|this._h,i=0;16>i;++i)W[i]=M.readInt32BE(4*i);for(;64>i;++i)W[i]=gamma1(W[i-2])+W[i-7]+gamma0(W[i-15])+W[i-16]|0;for(var j=0;64>j;++j){var T1=h+sigma1(e)+ch(e,f,g)+K[j]+W[j]|0,T2=sigma0(a)+maj(a,b,c)|0;h=g,g=f,f=e,e=d+T1|0,d=c,c=b,b=a,a=T1+T2|0}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0,this._f=f+this._f|0,this._g=g+this._g|0,this._h=h+this._h|0},Sha256.prototype._hash=function(){var H=new Buffer(32);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H.writeInt32BE(this._h,28),H},module.exports=Sha256}).call(this,require("buffer").Buffer)},{"./hash":129,buffer:45,inherits:93}],135:[function(require,module){(function(Buffer){function Sha384(){this.init(),this._w=W,Hash.call(this,128,112)}var inherits=require("inherits"),SHA512=require("./sha512"),Hash=require("./hash"),W=new Array(160);inherits(Sha384,SHA512),Sha384.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Sha384.prototype._hash=function(){function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}var H=new Buffer(48);return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),H},module.exports=Sha384}).call(this,require("buffer").Buffer)},{"./hash":129,"./sha512":136,buffer:45,inherits:93}],136:[function(require,module){(function(Buffer){function Sha512(){this.init(),this._w=W,Hash.call(this,128,112)}function Ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x,xl){return(x>>>28|xl<<4)^(xl>>>2|x<<30)^(xl>>>7|x<<25)}function sigma1(x,xl){return(x>>>14|xl<<18)^(x>>>18|xl<<14)^(xl>>>9|x<<23)}function Gamma0(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^x>>>7}function Gamma0l(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^(x>>>7|xl<<25)}function Gamma1(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^x>>>6}function Gamma1l(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^(x>>>6|xl<<26)}function getCarry(a,b){return b>>>0>a>>>0?1:0}var inherits=require("inherits"),Hash=require("./hash"),K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],W=new Array(160);inherits(Sha512,Hash),Sha512.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},Sha512.prototype._update=function(M){for(var W=this._w,ah=0|this._ah,bh=0|this._bh,ch=0|this._ch,dh=0|this._dh,eh=0|this._eh,fh=0|this._fh,gh=0|this._gh,hh=0|this._hh,al=0|this._al,bl=0|this._bl,cl=0|this._cl,dl=0|this._dl,el=0|this._el,fl=0|this._fl,gl=0|this._gl,hl=0|this._hl,i=0;32>i;i+=2)W[i]=M.readInt32BE(4*i),W[i+1]=M.readInt32BE(4*i+4);for(;160>i;i+=2){var xh=W[i-30],xl=W[i-30+1],gamma0=Gamma0(xh,xl),gamma0l=Gamma0l(xl,xh);xh=W[i-4],xl=W[i-4+1];var gamma1=Gamma1(xh,xl),gamma1l=Gamma1l(xl,xh),Wi7h=W[i-14],Wi7l=W[i-14+1],Wi16h=W[i-32],Wi16l=W[i-32+1],Wil=gamma0l+Wi7l|0,Wih=gamma0+Wi7h+getCarry(Wil,gamma0l)|0;Wil=Wil+gamma1l|0,Wih=Wih+gamma1+getCarry(Wil,gamma1l)|0,Wil=Wil+Wi16l|0,Wih=Wih+Wi16h+getCarry(Wil,Wi16l)|0,W[i]=Wih,W[i+1]=Wil}for(var j=0;160>j;j+=2){Wih=W[j],Wil=W[j+1];var majh=maj(ah,bh,ch),majl=maj(al,bl,cl),sigma0h=sigma0(ah,al),sigma0l=sigma0(al,ah),sigma1h=sigma1(eh,el),sigma1l=sigma1(el,eh),Kih=K[j],Kil=K[j+1],chh=Ch(eh,fh,gh),chl=Ch(el,fl,gl),t1l=hl+sigma1l|0,t1h=hh+sigma1h+getCarry(t1l,hl)|0;t1l=t1l+chl|0,t1h=t1h+chh+getCarry(t1l,chl)|0,t1l=t1l+Kil|0,t1h=t1h+Kih+getCarry(t1l,Kil)|0,t1l=t1l+Wil|0,t1h=t1h+Wih+getCarry(t1l,Wil)|0;var t2l=sigma0l+majl|0,t2h=sigma0h+majh+getCarry(t2l,sigma0l)|0;hh=gh,hl=gl,gh=fh,gl=fl,fh=eh,fl=el,el=dl+t1l|0,eh=dh+t1h+getCarry(el,dl)|0,dh=ch,dl=cl,ch=bh,cl=bl,bh=ah,bl=al,al=t1l+t2l|0,ah=t1h+t2h+getCarry(al,t1l)|0}this._al=this._al+al|0,this._bl=this._bl+bl|0,this._cl=this._cl+cl|0,this._dl=this._dl+dl|0,this._el=this._el+el|0,this._fl=this._fl+fl|0,this._gl=this._gl+gl|0,this._hl=this._hl+hl|0,this._ah=this._ah+ah+getCarry(this._al,al)|0,this._bh=this._bh+bh+getCarry(this._bl,bl)|0,this._ch=this._ch+ch+getCarry(this._cl,cl)|0,this._dh=this._dh+dh+getCarry(this._dl,dl)|0,this._eh=this._eh+eh+getCarry(this._el,el)|0,this._fh=this._fh+fh+getCarry(this._fl,fl)|0,this._gh=this._gh+gh+getCarry(this._gl,gl)|0,this._hh=this._hh+hh+getCarry(this._hl,hl)|0},Sha512.prototype._hash=function(){function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}var H=new Buffer(64);return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),writeInt64BE(this._gh,this._gl,48),writeInt64BE(this._hh,this._hl,56),H},module.exports=Sha512}).call(this,require("buffer").Buffer)},{"./hash":129,buffer:45,inherits:93}],137:[function(require,module){function Stream(){EE.call(this)}module.exports=Stream;var EE=require("events").EventEmitter,inherits=require("inherits");inherits(Stream,EE),Stream.Readable=require("readable-stream/readable.js"),Stream.Writable=require("readable-stream/writable.js"),Stream.Duplex=require("readable-stream/duplex.js"),Stream.Transform=require("readable-stream/transform.js"),Stream.PassThrough=require("readable-stream/passthrough.js"),Stream.Stream=Stream,Stream.prototype.pipe=function(dest,options){function ondata(chunk){dest.writable&&!1===dest.write(chunk)&&source.pause&&source.pause()}function ondrain(){source.readable&&source.resume&&source.resume()}function onend(){didOnEnd||(didOnEnd=!0,dest.end())}function onclose(){didOnEnd||(didOnEnd=!0,"function"==typeof dest.destroy&&dest.destroy())}function onerror(er){if(cleanup(),0===EE.listenerCount(this,"error"))throw er}function cleanup(){source.removeListener("data",ondata),dest.removeListener("drain",ondrain),source.removeListener("end",onend),source.removeListener("close",onclose),source.removeListener("error",onerror),dest.removeListener("error",onerror),source.removeListener("end",cleanup),source.removeListener("close",cleanup),dest.removeListener("close",cleanup)}var source=this;source.on("data",ondata),dest.on("drain",ondrain),dest._isStdio||options&&options.end===!1||(source.on("end",onend),source.on("close",onclose));var didOnEnd=!1;return source.on("error",onerror),dest.on("error",onerror),source.on("end",cleanup),source.on("close",cleanup),dest.on("close",cleanup),dest.emit("pipe",source),dest}},{events:82,inherits:93,"readable-stream/duplex.js":117,"readable-stream/passthrough.js":124,"readable-stream/readable.js":125,"readable-stream/transform.js":126,"readable-stream/writable.js":127}],138:[function(require,module,exports){(function(global){var ClientRequest=require("./lib/request"),extend=require("xtend"),statusCodes=require("builtin-status-codes"),url=require("url"),http=exports;http.request=function(opts,cb){opts="string"==typeof opts?url.parse(opts):extend(opts);var defaultProtocol=-1===global.location.protocol.search(/^https?:$/)?"http:":"",protocol=opts.protocol||defaultProtocol,host=opts.hostname||opts.host,port=opts.port,path=opts.path||"/";host&&-1!==host.indexOf(":")&&(host="["+host+"]"),opts.url=(host?protocol+"//"+host:"")+(port?":"+port:"")+path,opts.method=(opts.method||"GET").toUpperCase(),opts.headers=opts.headers||{};var req=new ClientRequest(opts);return cb&&req.on("response",cb),req},http.get=function(opts,cb){var req=http.request(opts,cb);return req.end(),req},http.Agent=function(){},http.Agent.defaultMaxSockets=4,http.STATUS_CODES=statusCodes,http.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":140,"builtin-status-codes":46,url:144,xtend:151}],139:[function(require,module,exports){(function(global){function checkTypeSupport(type){try{return xhr.responseType=type,xhr.responseType===type}catch(e){}return!1}function isFunction(value){return"function"==typeof value}exports.fetch=isFunction(global.fetch)&&isFunction(global.ReadableStream),exports.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),exports.blobConstructor=!0}catch(e){}var xhr=new global.XMLHttpRequest;xhr.open("GET",global.XDomainRequest?"/":"https://example.com");var haveArrayBuffer="undefined"!=typeof global.ArrayBuffer,haveSlice=haveArrayBuffer&&isFunction(global.ArrayBuffer.prototype.slice);exports.arraybuffer=haveArrayBuffer&&checkTypeSupport("arraybuffer"),exports.msstream=!exports.fetch&&haveSlice&&checkTypeSupport("ms-stream"),exports.mozchunkedarraybuffer=!exports.fetch&&haveArrayBuffer&&checkTypeSupport("moz-chunked-arraybuffer"),exports.overrideMimeType=isFunction(xhr.overrideMimeType),exports.vbArray=isFunction(global.VBArray),xhr=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],140:[function(require,module){(function(process,global,Buffer){function decideMode(preferBinary,useFetch){return capability.fetch&&useFetch?"fetch":capability.mozchunkedarraybuffer?"moz-chunked-arraybuffer":capability.msstream?"ms-stream":capability.arraybuffer&&preferBinary?"arraybuffer":capability.vbArray&&preferBinary?"text:vbarray":"text"}function statusValid(xhr){try{var status=xhr.status;return null!==status&&0!==status}catch(e){return!1}}var capability=require("./capability"),inherits=require("inherits"),response=require("./response"),stream=require("readable-stream"),toArrayBuffer=require("to-arraybuffer"),IncomingMessage=response.IncomingMessage,rStates=response.readyStates,ClientRequest=module.exports=function(opts){var self=this;stream.Writable.call(self),self._opts=opts,self._body=[],self._headers={},opts.auth&&self.setHeader("Authorization","Basic "+new Buffer(opts.auth).toString("base64")),Object.keys(opts.headers).forEach(function(name){self.setHeader(name,opts.headers[name])});var preferBinary,useFetch=!0;if("disable-fetch"===opts.mode)useFetch=!1,preferBinary=!0;else if("prefer-streaming"===opts.mode)preferBinary=!1;else if("allow-wrong-content-type"===opts.mode)preferBinary=!capability.overrideMimeType;else{if(opts.mode&&"default"!==opts.mode&&"prefer-fast"!==opts.mode)throw new Error("Invalid value for opts.mode");preferBinary=!0}self._mode=decideMode(preferBinary,useFetch),self.on("finish",function(){self._onFinish()})};inherits(ClientRequest,stream.Writable),ClientRequest.prototype.setHeader=function(name,value){var self=this,lowerName=name.toLowerCase();-1===unsafeHeaders.indexOf(lowerName)&&(self._headers[lowerName]={name:name,value:value})},ClientRequest.prototype.getHeader=function(name){var self=this;return self._headers[name.toLowerCase()].value},ClientRequest.prototype.removeHeader=function(name){var self=this;delete self._headers[name.toLowerCase()]},ClientRequest.prototype._onFinish=function(){var self=this;if(!self._destroyed){var body,opts=self._opts,headersObj=self._headers;if(("POST"===opts.method||"PUT"===opts.method||"PATCH"===opts.method||"MERGE"===opts.method)&&(body=capability.blobConstructor?new global.Blob(self._body.map(function(buffer){return toArrayBuffer(buffer)}),{type:(headersObj["content-type"]||{}).value||""}):Buffer.concat(self._body).toString()),"fetch"===self._mode){var headers=Object.keys(headersObj).map(function(name){return[headersObj[name].name,headersObj[name].value]});global.fetch(self._opts.url,{method:self._opts.method,headers:headers,body:body,mode:"cors",credentials:opts.withCredentials?"include":"same-origin"}).then(function(response){self._fetchResponse=response,self._connect()},function(reason){self.emit("error",reason)})}else{var xhr=self._xhr=new global.XMLHttpRequest;try{xhr.open(self._opts.method,self._opts.url,!0)}catch(err){return void process.nextTick(function(){self.emit("error",err)})}"responseType"in xhr&&(xhr.responseType=self._mode.split(":")[0]),"withCredentials"in xhr&&(xhr.withCredentials=!!opts.withCredentials),"text"===self._mode&&"overrideMimeType"in xhr&&xhr.overrideMimeType("text/plain; charset=x-user-defined"),Object.keys(headersObj).forEach(function(name){xhr.setRequestHeader(headersObj[name].name,headersObj[name].value)}),self._response=null,xhr.onreadystatechange=function(){switch(xhr.readyState){case rStates.LOADING:case rStates.DONE:self._onXHRProgress()}},"moz-chunked-arraybuffer"===self._mode&&(xhr.onprogress=function(){self._onXHRProgress()}),xhr.onerror=function(){self._destroyed||self.emit("error",new Error("XHR error"))};try{xhr.send(body)}catch(err){return void process.nextTick(function(){self.emit("error",err)})}}}},ClientRequest.prototype._onXHRProgress=function(){var self=this;statusValid(self._xhr)&&!self._destroyed&&(self._response||self._connect(),self._response._onXHRProgress())},ClientRequest.prototype._connect=function(){var self=this;self._destroyed||(self._response=new IncomingMessage(self._xhr,self._fetchResponse,self._mode),self.emit("response",self._response))},ClientRequest.prototype._write=function(chunk,encoding,cb){var self=this;self._body.push(chunk),cb()},ClientRequest.prototype.abort=ClientRequest.prototype.destroy=function(){var self=this;self._destroyed=!0,self._response&&(self._response._destroyed=!0),self._xhr&&self._xhr.abort()},ClientRequest.prototype.end=function(data,encoding,cb){var self=this;"function"==typeof data&&(cb=data,data=void 0),stream.Writable.prototype.end.call(self,data,encoding,cb)},ClientRequest.prototype.flushHeaders=function(){},ClientRequest.prototype.setTimeout=function(){},ClientRequest.prototype.setNoDelay=function(){},ClientRequest.prototype.setSocketKeepAlive=function(){};var unsafeHeaders=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},require("buffer").Buffer)},{"./capability":139,"./response":141,_process:105,buffer:45,inherits:93,"readable-stream":125,"to-arraybuffer":143}],141:[function(require,module,exports){(function(process,global,Buffer){var capability=require("./capability"),inherits=require("inherits"),stream=require("readable-stream"),rStates=exports.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},IncomingMessage=exports.IncomingMessage=function(xhr,response,mode){function read(){reader.read().then(function(result){if(!self._destroyed){if(result.done)return void self.push(null);self.push(new Buffer(result.value)),read()}})}var self=this;if(stream.Readable.call(self),self._mode=mode,self.headers={},self.rawHeaders=[],self.trailers={},self.rawTrailers=[],self.on("end",function(){process.nextTick(function(){self.emit("close")})}),"fetch"===mode){self._fetchResponse=response,self.url=response.url,self.statusCode=response.status,self.statusMessage=response.statusText,response.headers.forEach(function(header,key){self.headers[key.toLowerCase()]=header,self.rawHeaders.push(key,header)});var reader=response.body.getReader();read()}else{self._xhr=xhr,self._pos=0,self.url=xhr.responseURL,self.statusCode=xhr.status,self.statusMessage=xhr.statusText;var headers=xhr.getAllResponseHeaders().split(/\r?\n/);if(headers.forEach(function(header){var matches=header.match(/^([^:]+):\s*(.*)/);if(matches){var key=matches[1].toLowerCase();"set-cookie"===key?(void 0===self.headers[key]&&(self.headers[key]=[]),self.headers[key].push(matches[2])):void 0!==self.headers[key]?self.headers[key]+=", "+matches[2]:self.headers[key]=matches[2],self.rawHeaders.push(matches[1],matches[2])}}),self._charset="x-user-defined",!capability.overrideMimeType){var mimeType=self.rawHeaders["mime-type"];if(mimeType){var charsetMatch=mimeType.match(/;\s*charset=([^;])(;|$)/);charsetMatch&&(self._charset=charsetMatch[1].toLowerCase())}self._charset||(self._charset="utf-8")}}};inherits(IncomingMessage,stream.Readable),IncomingMessage.prototype._read=function(){},IncomingMessage.prototype._onXHRProgress=function(){var self=this,xhr=self._xhr,response=null;switch(self._mode){case"text:vbarray":if(xhr.readyState!==rStates.DONE)break;try{response=new global.VBArray(xhr.responseBody).toArray()}catch(e){}if(null!==response){self.push(new Buffer(response));break}case"text":try{response=xhr.responseText}catch(e){self._mode="text:vbarray";break}if(response.length>self._pos){var newData=response.substr(self._pos);if("x-user-defined"===self._charset){for(var buffer=new Buffer(newData.length),i=0;i<newData.length;i++)buffer[i]=255&newData.charCodeAt(i);self.push(buffer)}else self.push(newData,self._charset);self._pos=response.length}break;case"arraybuffer":if(xhr.readyState!==rStates.DONE||!xhr.response)break;response=xhr.response,self.push(new Buffer(new Uint8Array(response)));break;case"moz-chunked-arraybuffer":if(response=xhr.response,xhr.readyState!==rStates.LOADING||!response)break;self.push(new Buffer(new Uint8Array(response)));break;case"ms-stream":if(response=xhr.response,xhr.readyState!==rStates.LOADING)break;var reader=new global.MSStreamReader;reader.onprogress=function(){reader.result.byteLength>self._pos&&(self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos)))),self._pos=reader.result.byteLength)},reader.onload=function(){self.push(null)},reader.readAsArrayBuffer(response)}self._xhr.readyState===rStates.DONE&&"ms-stream"!==self._mode&&self.push(null)}}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},require("buffer").Buffer)},{"./capability":139,_process:105,buffer:45,inherits:93,"readable-stream":125}],142:[function(require,module,exports){function assertEncoding(encoding){if(encoding&&!isBufferEncoding(encoding))throw new Error("Unknown encoding: "+encoding)}function passThroughWrite(buffer){return buffer.toString(this.encoding)}function utf16DetectIncompleteChar(buffer){this.charReceived=buffer.length%2,this.charLength=this.charReceived?2:0}function base64DetectIncompleteChar(buffer){this.charReceived=buffer.length%3,this.charLength=this.charReceived?3:0}var Buffer=require("buffer").Buffer,isBufferEncoding=Buffer.isEncoding||function(encoding){switch(encoding&&encoding.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},StringDecoder=exports.StringDecoder=function(encoding){switch(this.encoding=(encoding||"utf8").toLowerCase().replace(/[-_]/,""),assertEncoding(encoding),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=utf16DetectIncompleteChar;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=base64DetectIncompleteChar;break;default:return void(this.write=passThroughWrite)}this.charBuffer=new Buffer(6),this.charReceived=0,this.charLength=0};StringDecoder.prototype.write=function(buffer){for(var charStr="";this.charLength;){var available=buffer.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:buffer.length;if(buffer.copy(this.charBuffer,this.charReceived,0,available),this.charReceived+=available,this.charReceived<this.charLength)return"";buffer=buffer.slice(available,buffer.length),charStr=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var charCode=charStr.charCodeAt(charStr.length-1);if(!(charCode>=55296&&56319>=charCode)){if(this.charReceived=this.charLength=0,0===buffer.length)return charStr;break}this.charLength+=this.surrogateSize,charStr=""}this.detectIncompleteChar(buffer);var end=buffer.length;this.charLength&&(buffer.copy(this.charBuffer,0,buffer.length-this.charReceived,end),end-=this.charReceived),charStr+=buffer.toString(this.encoding,0,end);var end=charStr.length-1,charCode=charStr.charCodeAt(end);if(charCode>=55296&&56319>=charCode){var size=this.surrogateSize;return this.charLength+=size,this.charReceived+=size,this.charBuffer.copy(this.charBuffer,size,0,size),buffer.copy(this.charBuffer,0,0,size),charStr.substring(0,end)}return charStr},StringDecoder.prototype.detectIncompleteChar=function(buffer){for(var i=buffer.length>=3?3:buffer.length;i>0;i--){var c=buffer[buffer.length-i];if(1==i&&c>>5==6){this.charLength=2;break}if(2>=i&&c>>4==14){this.charLength=3;break}if(3>=i&&c>>3==30){this.charLength=4;break}}this.charReceived=i},StringDecoder.prototype.end=function(buffer){var res="";if(buffer&&buffer.length&&(res=this.write(buffer)),this.charReceived){var cr=this.charReceived,buf=this.charBuffer,enc=this.encoding;res+=buf.slice(0,cr).toString(enc)}return res}},{buffer:45}],143:[function(require,module){var Buffer=require("buffer").Buffer;module.exports=function(buf){if(buf instanceof Uint8Array){if(0===buf.byteOffset&&buf.byteLength===buf.buffer.byteLength)return buf.buffer;if("function"==typeof buf.buffer.slice)return buf.buffer.slice(buf.byteOffset,buf.byteOffset+buf.byteLength)}if(Buffer.isBuffer(buf)){for(var arrayCopy=new Uint8Array(buf.length),len=buf.length,i=0;len>i;i++)arrayCopy[i]=buf[i];return arrayCopy.buffer}throw new Error("Argument must be a Buffer")}},{buffer:45}],144:[function(require,module,exports){"use strict";function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&util.isObject(url)&&url instanceof Url)return url;var u=new Url;return u.parse(url,parseQueryString,slashesDenoteHost),u}function urlFormat(obj){return util.isString(obj)&&(obj=urlParse(obj)),obj instanceof Url?obj.format():Url.prototype.format.call(obj)}function urlResolve(source,relative){return urlParse(source,!1,!0).resolve(relative)}function urlResolveObject(source,relative){return source?urlParse(source,!1,!0).resolveObject(relative):relative}var punycode=require("punycode"),util=require("./util");exports.parse=urlParse,exports.resolve=urlResolve,exports.resolveObject=urlResolveObject,exports.format=urlFormat,exports.Url=Url;var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,simplePathPattern=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,delims=["<",">",'"',"`"," ","\r","\n","	"],unwise=["{","}","|","\\","^","`"].concat(delims),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnameMaxLen=255,hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,"javascript:":!0},hostlessProtocol={javascript:!0,"javascript:":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},querystring=require("querystring");Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(!util.isString(url))throw new TypeError("Parameter 'url' must be a string, not "+typeof url);var queryIndex=url.indexOf("?"),splitter=-1!==queryIndex&&queryIndex<url.indexOf("#")?"?":"#",uSplit=url.split(splitter),slashRegex=/\\/g;uSplit[0]=uSplit[0].replace(slashRegex,"/"),url=uSplit.join(splitter);var rest=url;if(rest=rest.trim(),!slashesDenoteHost&&1===url.split("#").length){var simplePath=simplePathPattern.exec(rest);if(simplePath)return this.path=rest,this.href=rest,this.pathname=simplePath[1],simplePath[2]?(this.search=simplePath[2],this.query=parseQueryString?querystring.parse(this.search.substr(1)):this.search.substr(1)):parseQueryString&&(this.search="",this.query={}),this}var proto=protocolPattern.exec(rest);if(proto){proto=proto[0];var lowerProto=proto.toLowerCase();this.protocol=lowerProto,rest=rest.substr(proto.length)}if(slashesDenoteHost||proto||rest.match(/^\/\/[^@\/]+@[^@\/]+/)){var slashes="//"===rest.substr(0,2);!slashes||proto&&hostlessProtocol[proto]||(rest=rest.substr(2),this.slashes=!0)}if(!hostlessProtocol[proto]&&(slashes||proto&&!slashedProtocol[proto])){for(var hostEnd=-1,i=0;i<hostEndingChars.length;i++){var hec=rest.indexOf(hostEndingChars[i]);-1!==hec&&(-1===hostEnd||hostEnd>hec)&&(hostEnd=hec)}var auth,atSign;atSign=-1===hostEnd?rest.lastIndexOf("@"):rest.lastIndexOf("@",hostEnd),-1!==atSign&&(auth=rest.slice(0,atSign),rest=rest.slice(atSign+1),this.auth=decodeURIComponent(auth)),hostEnd=-1;for(var i=0;i<nonHostChars.length;i++){var hec=rest.indexOf(nonHostChars[i]);-1!==hec&&(-1===hostEnd||hostEnd>hec)&&(hostEnd=hec)}-1===hostEnd&&(hostEnd=rest.length),this.host=rest.slice(0,hostEnd),rest=rest.slice(hostEnd),this.parseHost(),this.hostname=this.hostname||"";var ipv6Hostname="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!ipv6Hostname)for(var hostparts=this.hostname.split(/\./),i=0,l=hostparts.length;l>i;i++){var part=hostparts[i];if(part&&!part.match(hostnamePartPattern)){for(var newpart="",j=0,k=part.length;k>j;j++)newpart+=part.charCodeAt(j)>127?"x":part[j];if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i),notHost=hostparts.slice(i+1),bit=part.match(hostnamePartStart);bit&&(validParts.push(bit[1]),notHost.unshift(bit[2])),notHost.length&&(rest="/"+notHost.join(".")+rest),this.hostname=validParts.join(".");break}}}this.hostname=this.hostname.length>hostnameMaxLen?"":this.hostname.toLowerCase(),ipv6Hostname||(this.hostname=punycode.toASCII(this.hostname));var p=this.port?":"+this.port:"",h=this.hostname||"";this.host=h+p,this.href+=this.host,ipv6Hostname&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==rest[0]&&(rest="/"+rest))}if(!unsafeProtocol[lowerProto])for(var i=0,l=autoEscape.length;l>i;i++){var ae=autoEscape[i];if(-1!==rest.indexOf(ae)){var esc=encodeURIComponent(ae);esc===ae&&(esc=escape(ae)),rest=rest.split(ae).join(esc)}}var hash=rest.indexOf("#");-1!==hash&&(this.hash=rest.substr(hash),rest=rest.slice(0,hash));var qm=rest.indexOf("?");if(-1!==qm?(this.search=rest.substr(qm),this.query=rest.substr(qm+1),parseQueryString&&(this.query=querystring.parse(this.query)),rest=rest.slice(0,qm)):parseQueryString&&(this.search="",this.query={}),rest&&(this.pathname=rest),slashedProtocol[lowerProto]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var p=this.pathname||"",s=this.search||"";this.path=p+s}return this.href=this.format(),this},Url.prototype.format=function(){var auth=this.auth||"";auth&&(auth=encodeURIComponent(auth),auth=auth.replace(/%3A/i,":"),auth+="@");var protocol=this.protocol||"",pathname=this.pathname||"",hash=this.hash||"",host=!1,query="";
  
  this.host?host=auth+this.host:this.hostname&&(host=auth+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(host+=":"+this.port)),this.query&&util.isObject(this.query)&&Object.keys(this.query).length&&(query=querystring.stringify(this.query));var search=this.search||query&&"?"+query||"";return protocol&&":"!==protocol.substr(-1)&&(protocol+=":"),this.slashes||(!protocol||slashedProtocol[protocol])&&host!==!1?(host="//"+(host||""),pathname&&"/"!==pathname.charAt(0)&&(pathname="/"+pathname)):host||(host=""),hash&&"#"!==hash.charAt(0)&&(hash="#"+hash),search&&"?"!==search.charAt(0)&&(search="?"+search),pathname=pathname.replace(/[?#]/g,function(match){return encodeURIComponent(match)}),search=search.replace("#","%23"),protocol+host+pathname+search+hash},Url.prototype.resolve=function(relative){return this.resolveObject(urlParse(relative,!1,!0)).format()},Url.prototype.resolveObject=function(relative){if(util.isString(relative)){var rel=new Url;rel.parse(relative,!1,!0),relative=rel}for(var result=new Url,tkeys=Object.keys(this),tk=0;tk<tkeys.length;tk++){var tkey=tkeys[tk];result[tkey]=this[tkey]}if(result.hash=relative.hash,""===relative.href)return result.href=result.format(),result;if(relative.slashes&&!relative.protocol){for(var rkeys=Object.keys(relative),rk=0;rk<rkeys.length;rk++){var rkey=rkeys[rk];"protocol"!==rkey&&(result[rkey]=relative[rkey])}return slashedProtocol[result.protocol]&&result.hostname&&!result.pathname&&(result.path=result.pathname="/"),result.href=result.format(),result}if(relative.protocol&&relative.protocol!==result.protocol){if(!slashedProtocol[relative.protocol]){for(var keys=Object.keys(relative),v=0;v<keys.length;v++){var k=keys[v];result[k]=relative[k]}return result.href=result.format(),result}if(result.protocol=relative.protocol,relative.host||hostlessProtocol[relative.protocol])result.pathname=relative.pathname;else{for(var relPath=(relative.pathname||"").split("/");relPath.length&&!(relative.host=relPath.shift()););relative.host||(relative.host=""),relative.hostname||(relative.hostname=""),""!==relPath[0]&&relPath.unshift(""),relPath.length<2&&relPath.unshift(""),result.pathname=relPath.join("/")}if(result.search=relative.search,result.query=relative.query,result.host=relative.host||"",result.auth=relative.auth,result.hostname=relative.hostname||relative.host,result.port=relative.port,result.pathname||result.search){var p=result.pathname||"",s=result.search||"";result.path=p+s}return result.slashes=result.slashes||relative.slashes,result.href=result.format(),result}var isSourceAbs=result.pathname&&"/"===result.pathname.charAt(0),isRelAbs=relative.host||relative.pathname&&"/"===relative.pathname.charAt(0),mustEndAbs=isRelAbs||isSourceAbs||result.host&&relative.pathname,removeAllDots=mustEndAbs,srcPath=result.pathname&&result.pathname.split("/")||[],relPath=relative.pathname&&relative.pathname.split("/")||[],psychotic=result.protocol&&!slashedProtocol[result.protocol];if(psychotic&&(result.hostname="",result.port=null,result.host&&(""===srcPath[0]?srcPath[0]=result.host:srcPath.unshift(result.host)),result.host="",relative.protocol&&(relative.hostname=null,relative.port=null,relative.host&&(""===relPath[0]?relPath[0]=relative.host:relPath.unshift(relative.host)),relative.host=null),mustEndAbs=mustEndAbs&&(""===relPath[0]||""===srcPath[0])),isRelAbs)result.host=relative.host||""===relative.host?relative.host:result.host,result.hostname=relative.hostname||""===relative.hostname?relative.hostname:result.hostname,result.search=relative.search,result.query=relative.query,srcPath=relPath;else if(relPath.length)srcPath||(srcPath=[]),srcPath.pop(),srcPath=srcPath.concat(relPath),result.search=relative.search,result.query=relative.query;else if(!util.isNullOrUndefined(relative.search)){if(psychotic){result.hostname=result.host=srcPath.shift();var authInHost=result.host&&result.host.indexOf("@")>0?result.host.split("@"):!1;authInHost&&(result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift())}return result.search=relative.search,result.query=relative.query,util.isNull(result.pathname)&&util.isNull(result.search)||(result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")),result.href=result.format(),result}if(!srcPath.length)return result.pathname=null,result.path=result.search?"/"+result.search:null,result.href=result.format(),result;for(var last=srcPath.slice(-1)[0],hasTrailingSlash=(result.host||relative.host||srcPath.length>1)&&("."===last||".."===last)||""===last,up=0,i=srcPath.length;i>=0;i--)last=srcPath[i],"."===last?srcPath.splice(i,1):".."===last?(srcPath.splice(i,1),up++):up&&(srcPath.splice(i,1),up--);if(!mustEndAbs&&!removeAllDots)for(;up--;up)srcPath.unshift("..");!mustEndAbs||""===srcPath[0]||srcPath[0]&&"/"===srcPath[0].charAt(0)||srcPath.unshift(""),hasTrailingSlash&&"/"!==srcPath.join("/").substr(-1)&&srcPath.push("");var isAbsolute=""===srcPath[0]||srcPath[0]&&"/"===srcPath[0].charAt(0);if(psychotic){result.hostname=result.host=isAbsolute?"":srcPath.length?srcPath.shift():"";var authInHost=result.host&&result.host.indexOf("@")>0?result.host.split("@"):!1;authInHost&&(result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift())}return mustEndAbs=mustEndAbs||result.host&&srcPath.length,mustEndAbs&&!isAbsolute&&srcPath.unshift(""),srcPath.length?result.pathname=srcPath.join("/"):(result.pathname=null,result.path=null),util.isNull(result.pathname)&&util.isNull(result.search)||(result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")),result.auth=relative.auth||result.auth,result.slashes=result.slashes||relative.slashes,result.href=result.format(),result},Url.prototype.parseHost=function(){var host=this.host,port=portPattern.exec(host);port&&(port=port[0],":"!==port&&(this.port=port.substr(1)),host=host.substr(0,host.length-port.length)),host&&(this.hostname=host)}},{"./util":145,punycode:112,querystring:115}],145:[function(require,module){"use strict";module.exports={isString:function(arg){return"string"==typeof arg},isObject:function(arg){return"object"==typeof arg&&null!==arg},isNull:function(arg){return null===arg},isNullOrUndefined:function(arg){return null==arg}}},{}],146:[function(require,module){(function(global){function deprecate(fn,msg){function deprecated(){if(!warned){if(config("throwDeprecation"))throw new Error(msg);config("traceDeprecation")?console.trace(msg):console.warn(msg),warned=!0}return fn.apply(this,arguments)}if(config("noDeprecation"))return fn;var warned=!1;return deprecated}function config(name){try{if(!global.localStorage)return!1}catch(_){return!1}var val=global.localStorage[name];return null==val?!1:"true"===String(val).toLowerCase()}module.exports=deprecate}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],147:[function(require,module,exports){arguments[4][93][0].apply(exports,arguments)},{dup:93}],148:[function(require,module){module.exports=function(arg){return arg&&"object"==typeof arg&&"function"==typeof arg.copy&&"function"==typeof arg.fill&&"function"==typeof arg.readUInt8}},{}],149:[function(require,module,exports){(function(process,global){function inspect(obj,opts){var ctx={seen:[],stylize:stylizeNoColor};return arguments.length>=3&&(ctx.depth=arguments[2]),arguments.length>=4&&(ctx.colors=arguments[3]),isBoolean(opts)?ctx.showHidden=opts:opts&&exports._extend(ctx,opts),isUndefined(ctx.showHidden)&&(ctx.showHidden=!1),isUndefined(ctx.depth)&&(ctx.depth=2),isUndefined(ctx.colors)&&(ctx.colors=!1),isUndefined(ctx.customInspect)&&(ctx.customInspect=!0),ctx.colors&&(ctx.stylize=stylizeWithColor),formatValue(ctx,obj,ctx.depth)}function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];return style?"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m":str}function stylizeNoColor(str){return str}function arrayToHash(array){var hash={};return array.forEach(function(val){hash[val]=!0}),hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&(!value.constructor||value.constructor.prototype!==value)){var ret=value.inspect(recurseTimes,ctx);return isString(ret)||(ret=formatValue(ctx,ret,recurseTimes)),ret}var primitive=formatPrimitive(ctx,value);if(primitive)return primitive;var keys=Object.keys(value),visibleKeys=arrayToHash(keys);if(ctx.showHidden&&(keys=Object.getOwnPropertyNames(value)),isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0))return formatError(value);if(0===keys.length){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value))return ctx.stylize(RegExp.prototype.toString.call(value),"regexp");if(isDate(value))return ctx.stylize(Date.prototype.toString.call(value),"date");if(isError(value))return formatError(value)}var base="",array=!1,braces=["{","}"];if(isArray(value)&&(array=!0,braces=["[","]"]),isFunction(value)){var n=value.name?": "+value.name:"";base=" [Function"+n+"]"}if(isRegExp(value)&&(base=" "+RegExp.prototype.toString.call(value)),isDate(value)&&(base=" "+Date.prototype.toUTCString.call(value)),isError(value)&&(base=" "+formatError(value)),0===keys.length&&(!array||0==value.length))return braces[0]+base+braces[1];if(0>recurseTimes)return isRegExp(value)?ctx.stylize(RegExp.prototype.toString.call(value),"regexp"):ctx.stylize("[Object]","special");ctx.seen.push(value);var output;return output=array?formatArray(ctx,value,recurseTimes,visibleKeys,keys):keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)}),ctx.seen.pop(),reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}return isNumber(value)?ctx.stylize(""+value,"number"):isBoolean(value)?ctx.stylize(""+value,"boolean"):isNull(value)?ctx.stylize("null","null"):void 0}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){for(var output=[],i=0,l=value.length;l>i;++i)output.push(hasOwnProperty(value,String(i))?formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),!0):"");return keys.forEach(function(key){key.match(/^\d+$/)||output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,!0))}),output}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str,desc;if(desc=Object.getOwnPropertyDescriptor(value,key)||{value:value[key]},desc.get?str=desc.set?ctx.stylize("[Getter/Setter]","special"):ctx.stylize("[Getter]","special"):desc.set&&(str=ctx.stylize("[Setter]","special")),hasOwnProperty(visibleKeys,key)||(name="["+key+"]"),str||(ctx.seen.indexOf(desc.value)<0?(str=isNull(recurseTimes)?formatValue(ctx,desc.value,null):formatValue(ctx,desc.value,recurseTimes-1),str.indexOf("\n")>-1&&(str=array?str.split("\n").map(function(line){return"  "+line}).join("\n").substr(2):"\n"+str.split("\n").map(function(line){return"   "+line}).join("\n"))):str=ctx.stylize("[Circular]","special")),isUndefined(name)){if(array&&key.match(/^\d+$/))return str;name=JSON.stringify(""+key),name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(name=name.substr(1,name.length-2),name=ctx.stylize(name,"name")):(name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),name=ctx.stylize(name,"string"))}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0,length=output.reduce(function(prev,cur){return numLinesEst++,cur.indexOf("\n")>=0&&numLinesEst++,prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0);return length>60?braces[0]+(""===base?"":base+"\n ")+" "+output.join(",\n  ")+" "+braces[1]:braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)}function isBoolean(arg){return"boolean"==typeof arg}function isNull(arg){return null===arg}function isNullOrUndefined(arg){return null==arg}function isNumber(arg){return"number"==typeof arg}function isString(arg){return"string"==typeof arg}function isSymbol(arg){return"symbol"==typeof arg}function isUndefined(arg){return void 0===arg}function isRegExp(re){return isObject(re)&&"[object RegExp]"===objectToString(re)}function isObject(arg){return"object"==typeof arg&&null!==arg}function isDate(d){return isObject(d)&&"[object Date]"===objectToString(d)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(arg){return"function"==typeof arg}function isPrimitive(arg){return null===arg||"boolean"==typeof arg||"number"==typeof arg||"string"==typeof arg||"symbol"==typeof arg||"undefined"==typeof arg}function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return 10>n?"0"+n.toString(10):n.toString(10)}function timestamp(){var d=new Date,time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){for(var objects=[],i=0;i<arguments.length;i++)objects.push(inspect(arguments[i]));return objects.join(" ")}for(var i=1,args=arguments,len=args.length,str=String(f).replace(formatRegExp,function(x){if("%%"===x)return"%";if(i>=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}}),x=args[i];len>i;x=args[++i])str+=isNull(x)||!isObject(x)?" "+x:" "+inspect(x);return str},exports.deprecate=function(fn,msg){function deprecated(){if(!warned){if(process.throwDeprecation)throw new Error(msg);process.traceDeprecation?console.trace(msg):console.error(msg),warned=!0}return fn.apply(this,arguments)}if(isUndefined(global.process))return function(){return exports.deprecate(fn,msg).apply(this,arguments)};if(process.noDeprecation===!0)return fn;var warned=!1;return deprecated};var debugEnviron,debugs={};exports.debuglog=function(set){if(isUndefined(debugEnviron)&&(debugEnviron=process.env.NODE_DEBUG||""),set=set.toUpperCase(),!debugs[set])if(new RegExp("\\b"+set+"\\b","i").test(debugEnviron)){var pid=process.pid;debugs[set]=function(){var msg=exports.format.apply(exports,arguments);console.error("%s %d: %s",set,pid,msg)}}else debugs[set]=function(){};return debugs[set]},exports.inspect=inspect,inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=require("./support/isBuffer");var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))},exports.inherits=require("inherits"),exports._extend=function(origin,add){if(!add||!isObject(add))return origin;for(var keys=Object.keys(add),i=keys.length;i--;)origin[keys[i]]=add[keys[i]];return origin}}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":148,_process:105,inherits:147}],150:[function(require,module,exports){function Context(){}var indexOf=require("indexof"),Object_keys=function(obj){if(Object.keys)return Object.keys(obj);var res=[];for(var key in obj)res.push(key);return res},forEach=function(xs,fn){if(xs.forEach)return xs.forEach(fn);for(var i=0;i<xs.length;i++)fn(xs[i],i,xs)},defineProp=function(){try{return Object.defineProperty({},"_",{}),function(obj,name,value){Object.defineProperty(obj,name,{writable:!0,enumerable:!1,configurable:!0,value:value})}}catch(e){return function(obj,name,value){obj[name]=value}}}(),globals=["Array","Boolean","Date","Error","EvalError","Function","Infinity","JSON","Math","NaN","Number","Object","RangeError","ReferenceError","RegExp","String","SyntaxError","TypeError","URIError","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","eval","isFinite","isNaN","parseFloat","parseInt","undefined","unescape"];Context.prototype={};var Script=exports.Script=function(code){return this instanceof Script?void(this.code=code):new Script(code)};Script.prototype.runInContext=function(context){if(!(context instanceof Context))throw new TypeError("needs a 'context' argument.");var iframe=document.createElement("iframe");iframe.style||(iframe.style={}),iframe.style.display="none",document.body.appendChild(iframe);var win=iframe.contentWindow,wEval=win.eval,wExecScript=win.execScript;!wEval&&wExecScript&&(wExecScript.call(win,"null"),wEval=win.eval),forEach(Object_keys(context),function(key){win[key]=context[key]}),forEach(globals,function(key){context[key]&&(win[key]=context[key])});var winKeys=Object_keys(win),res=wEval.call(win,this.code);return forEach(Object_keys(win),function(key){(key in context||-1===indexOf(winKeys,key))&&(context[key]=win[key])}),forEach(globals,function(key){key in context||defineProp(context,key,win[key])}),document.body.removeChild(iframe),res},Script.prototype.runInThisContext=function(){return eval(this.code)},Script.prototype.runInNewContext=function(context){var ctx=Script.createContext(context),res=this.runInContext(ctx);return forEach(Object_keys(ctx),function(key){context[key]=ctx[key]}),res},forEach(Object_keys(Script.prototype),function(name){exports[name]=Script[name]=function(code){var s=Script(code);return s[name].apply(s,[].slice.call(arguments,1))}}),exports.createScript=function(code){return exports.Script(code)},exports.createContext=Script.createContext=function(context){var copy=new Context;return"object"==typeof context&&forEach(Object_keys(context),function(key){copy[key]=context[key]}),copy}},{indexof:92}],151:[function(require,module){function extend(){for(var target={},i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source)hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target}module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty},{}],152:[function(require,module,exports){var LdpStore=require("rdf-store-ldp/lite"),SimpleRDF=require("simplerdf"),N3Parser=require("rdf-parser-n3"),JsonLdParser=require("rdf-parser-jsonld"),RdfaParser=require("rdf-parser-rdfa"),RdfXmlParser=require("rdf-parser-rdfxml"),SimpleRDFParse=require("simplerdf-parse"),formats={parsers:{}};formats.parsers["text/turtle"]=N3Parser,formats.parsers["application/ld+json"]=JsonLdParser,formats.parsers["application/xhtml+xml"]=RdfaParser,formats.parsers["text/html"]=RdfaParser,formats.parsers["application/rdf+xml"]=RdfXmlParser;var parser=SimpleRDFParse(formats.parsers);SimpleRDF.parse=parser.parse.bind(parser);var storeFormats={parsers:{}};storeFormats.parsers["text/turtle"]=N3Parser,storeFormats.parsers["application/ld+json"]=JsonLdParser,storeFormats.parsers["application/xhtml+xml"]=RdfaParser,storeFormats.parsers["text/html"]=RdfaParser,storeFormats.parsers["application/rdf+xml"]=RdfXmlParser,exports.store=new LdpStore(storeFormats),exports.SimpleRDF=SimpleRDF},{"rdf-parser-jsonld":189,"rdf-parser-n3":192,"rdf-parser-rdfa":193,"rdf-parser-rdfxml":194,"rdf-store-ldp/lite":203,simplerdf:212,"simplerdf-parse":211}],153:[function(require,module,exports){arguments[4][43][0].apply(exports,arguments)},{buffer:45,dup:43}],154:[function(require,module){(function(Buffer){function ConcatStream(opts,cb){if(!(this instanceof ConcatStream))return new ConcatStream(opts,cb);"function"==typeof opts&&(cb=opts,opts={}),opts||(opts={});var encoding=opts.encoding,shouldInferEncoding=!1;encoding?(encoding=String(encoding).toLowerCase(),("u8"===encoding||"uint8"===encoding)&&(encoding="uint8array")):shouldInferEncoding=!0,Writable.call(this,{objectMode:!0}),this.encoding=encoding,this.shouldInferEncoding=shouldInferEncoding,cb&&this.on("finish",function(){cb(this.getBody())}),this.body=[]}function isArrayish(arr){return/Array\]$/.test(Object.prototype.toString.call(arr))}function isBufferish(p){return"string"==typeof p||isArrayish(p)||p&&"function"==typeof p.subarray}function stringConcat(parts){for(var strings=[],i=0;i<parts.length;i++){var p=parts[i];strings.push("string"==typeof p?p:Buffer.isBuffer(p)?p:isBufferish(p)?new Buffer(p):new Buffer(String(p)))}return Buffer.isBuffer(parts[0])?(strings=Buffer.concat(strings),strings=strings.toString("utf8")):strings=strings.join(""),strings}function bufferConcat(parts){for(var bufs=[],i=0;i<parts.length;i++){var p=parts[i];bufs.push(Buffer.isBuffer(p)?p:isBufferish(p)?new Buffer(p):new Buffer(String(p)))}return Buffer.concat(bufs)}function arrayConcat(parts){for(var res=[],i=0;i<parts.length;i++)res.push.apply(res,parts[i]);return res}function u8Concat(parts){for(var len=0,i=0;i<parts.length;i++)"string"==typeof parts[i]&&(parts[i]=new Buffer(parts[i])),len+=parts[i].length;for(var u8=new U8(len),i=0,offset=0;i<parts.length;i++)for(var part=parts[i],j=0;j<part.length;j++)u8[offset++]=part[j];return u8}var Writable=require("readable-stream").Writable,inherits=require("inherits");if("undefined"==typeof Uint8Array)var U8=require("typedarray").Uint8Array;else var U8=Uint8Array;module.exports=ConcatStream,inherits(ConcatStream,Writable),ConcatStream.prototype._write=function(chunk,enc,next){this.body.push(chunk),next()},ConcatStream.prototype.inferEncoding=function(buff){var firstBuffer=void 0===buff?this.body[0]:buff;return Buffer.isBuffer(firstBuffer)?"buffer":"undefined"!=typeof Uint8Array&&firstBuffer instanceof Uint8Array?"uint8array":Array.isArray(firstBuffer)?"array":"string"==typeof firstBuffer?"string":"[object Object]"===Object.prototype.toString.call(firstBuffer)?"object":"buffer"},ConcatStream.prototype.getBody=function(){return this.encoding||0!==this.body.length?(this.shouldInferEncoding&&(this.encoding=this.inferEncoding()),"array"===this.encoding?arrayConcat(this.body):"string"===this.encoding?stringConcat(this.body):"buffer"===this.encoding?bufferConcat(this.body):"uint8array"===this.encoding?u8Concat(this.body):this.body):[]};Array.isArray||function(arr){return"[object Array]"==Object.prototype.toString.call(arr)}}).call(this,require("buffer").Buffer)},{buffer:45,inherits:159,"readable-stream":210,typedarray:217}],155:[function(require,module,exports){(function(Buffer){function isArray(arg){return Array.isArray?Array.isArray(arg):"[object Array]"===objectToString(arg)}function isBoolean(arg){return"boolean"==typeof arg}function isNull(arg){return null===arg}function isNullOrUndefined(arg){return null==arg}function isNumber(arg){return"number"==typeof arg}function isString(arg){return"string"==typeof arg}function isSymbol(arg){return"symbol"==typeof arg}function isUndefined(arg){return void 0===arg}function isRegExp(re){return"[object RegExp]"===objectToString(re)}function isObject(arg){return"object"==typeof arg&&null!==arg}function isDate(d){return"[object Date]"===objectToString(d)}function isError(e){return"[object Error]"===objectToString(e)||e instanceof Error}function isFunction(arg){return"function"==typeof arg}function isPrimitive(arg){return null===arg||"boolean"==typeof arg||"number"==typeof arg||"string"==typeof arg||"symbol"==typeof arg||"undefined"==typeof arg}function objectToString(o){return Object.prototype.toString.call(o)}exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=Buffer.isBuffer}).call(this,{isBuffer:require("../../../../../../../../home/csarven/.nvm/versions/node/v7.0.0/lib/node_modules/browserify/node_modules/is-buffer/index.js")})},{"../../../../../../../../home/csarven/.nvm/versions/node/v7.0.0/lib/node_modules/browserify/node_modules/is-buffer/index.js":94}],156:[function(require,module,exports){function RDFaProcessor(targetObject){this.target=targetObject?targetObject:{graph:{subjects:{},prefixes:{},terms:{}}},this.theOne="_:"+(new Date).getTime(),this.language=null,this.vocabulary=null,this.blankCounter=0,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"}],this.inXHTMLMode=!1,this.absURIRE=/[\w\_\-]+:\S+/,this.finishedHandlers=[],this.init()}if("object"==typeof exports)var URIResolver=require("./URI");RDFaProcessor.prototype=new URIResolver,RDFaProcessor.prototype.constructor=RDFaProcessor,RDFaProcessor.prototype.newBlankNode=function(){return this.blankCounter++,"_:"+this.blankCounter},RDFaProcessor.XMLLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",RDFaProcessor.HTMLLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML",RDFaProcessor.PlainLiteralURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral",RDFaProcessor.objectURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#object",RDFaProcessor.typeURI="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",RDFaProcessor.nameChar="[-A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�က0-F.0-9·̀-ͯ‿-⁀]",RDFaProcessor.nameStartChar="[A-Za-zÀ-ÖØ-öø-ÿĀ-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હઽૠଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହଽଡ଼-ଢ଼ୟ-ୡஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹൠ-ൡก-ฮะา-ำเ-ๅກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະາ-ຳຽເ-ໄཀ-ཇཉ-ཀྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼΩK-Å℮ↀ-ↂぁ-ゔァ-ヺㄅ-ㄬ가-힣一-龥〇〡-〩_]",RDFaProcessor.NCNAME=new RegExp("^"+RDFaProcessor.nameStartChar+RDFaProcessor.nameChar+"*$"),RDFaProcessor.trim=function(str){return str.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},RDFaProcessor.prototype.tokenize=function(str){return RDFaProcessor.trim(str).split(/\s+/)},RDFaProcessor.prototype.parseSafeCURIEOrCURIEOrURI=function(value,prefixes,base){return value=RDFaProcessor.trim(value),"["==value.charAt(0)&&"]"==value.charAt(value.length-1)?(value=value.substring(1,value.length-1),value=value.trim(value),0==value.length?null:"_:"==value?this.theOne:this.parseCURIE(value,prefixes,base)):this.parseCURIEOrURI(value,prefixes,base)},RDFaProcessor.prototype.parseCURIE=function(value,prefixes){var colon=value.indexOf(":");if(colon>=0){var prefix=value.substring(0,colon);if(""==prefix){var uri=prefixes[""];return uri?uri+value.substring(colon+1):null}if("_"==prefix)return"_:"+value.substring(colon+1);if(RDFaProcessor.NCNAME.test(prefix)){var uri=prefixes[prefix];if(uri)return uri+value.substring(colon+1)}}return null},RDFaProcessor.prototype.parseCURIEOrURI=function(value,prefixes,base){var curie=this.parseCURIE(value,prefixes,base);return curie?curie:this.resolveAndNormalize(base,value)},RDFaProcessor.prototype.parsePredicate=function(value,defaultVocabulary,terms,prefixes,base,ignoreTerms){if(""==value)return null;var predicate=this.parseTermOrCURIEOrAbsURI(value,defaultVocabulary,ignoreTerms?null:terms,prefixes,base);return predicate&&0==predicate.indexOf("_:")?null:predicate},RDFaProcessor.prototype.parseTermOrCURIEOrURI=function(value,defaultVocabulary,terms,prefixes,base){value=RDFaProcessor.trim(value);var curie=this.parseCURIE(value,prefixes,base);if(curie)return curie;var term=terms[value];if(term)return term;var lcvalue=value.toLowerCase();return(term=terms[lcvalue])?term:defaultVocabulary&&!this.absURIRE.exec(value)?defaultVocabulary+value:this.resolveAndNormalize(base,value)},RDFaProcessor.prototype.parseTermOrCURIEOrAbsURI=function(value,defaultVocabulary,terms,prefixes,base){value=RDFaProcessor.trim(value);var curie=this.parseCURIE(value,prefixes,base);if(curie)return curie;if(terms){if(defaultVocabulary&&!this.absURIRE.exec(value))return defaultVocabulary+value;var term=terms[value];if(term)return term;var lcvalue=value.toLowerCase();if(term=terms[lcvalue])return term}return this.absURIRE.exec(value)?this.resolveAndNormalize(base,value):null},RDFaProcessor.prototype.resolveAndNormalize=function(base,href){var u=base.resolve(href),parsed=this.parseURI(u);return parsed.normalize(),parsed.spec},RDFaProcessor.prototype.parsePrefixMappings=function(str,target){for(var values=this.tokenize(str),prefix=null,i=0;i<values.length;i++)":"==values[i][values[i].length-1]?prefix=values[i].substring(0,values[i].length-1):prefix&&(target[prefix]=this.target.baseURI?this.target.baseURI.resolve(values[i]):values[i],prefix=null)},RDFaProcessor.prototype.copyMappings=function(mappings){var newMappings={};for(var k in mappings)newMappings[k]=mappings[k];return newMappings},RDFaProcessor.prototype.ancestorPath=function(node){for(var path="";node&&9!=node.nodeType;)path="/"+node.localName+path,node=node.parentNode;return path},RDFaProcessor.prototype.setContext=function(node){"html"==node.localName&&"XHTML+RDFa 1.1"==node.getAttribute("version")?this.setXHTMLContext():"html"==node.localName||"http://www.w3.org/1999/xhtml"==node.namespaceURI?node.ownerDocument.doctype?"-//W3C//DTD XHTML+RDFa 1.0//EN"==document.doctype.publicId&&"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"==document.doctype.systemId?(console.log("WARNING: RDF 1.0 is not supported.  Defaulting to HTML5 mode."),this.setHTMLContext()):"-//W3C//DTD XHTML+RDFa 1.1//EN"==document.doctype.publicId&&"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd"==document.doctype.systemId?this.setXHTMLContext():this.setHTMLContext():this.setHTMLContext():this.setXMLContext()},RDFaProcessor.prototype.setInitialContext=function(){this.vocabulary=null,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"}]},RDFaProcessor.prototype.setXMLContext=function(){this.setInitialContext(),this.inXHTMLMode=!1,this.inHTMLMode=!1},RDFaProcessor.prototype.setHTMLContext=function(){this.setInitialContext(),this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"},{namespaceURI:null,localName:"lang"}],this.inXHTMLMode=!1,this.inHTMLMode=!0},RDFaProcessor.prototype.setXHTMLContext=function(){this.setInitialContext(),this.inXHTMLMode=!0,this.inHTMLMode=!1,this.langAttributes=[{namespaceURI:"http://www.w3.org/XML/1998/namespace",localName:"lang"},{namespaceURI:null,localName:"lang"}],this.target.graph.terms.alternate="http://www.w3.org/1999/xhtml/vocab#alternate",this.target.graph.terms.appendix="http://www.w3.org/1999/xhtml/vocab#appendix",this.target.graph.terms.bookmark="http://www.w3.org/1999/xhtml/vocab#bookmark",this.target.graph.terms.cite="http://www.w3.org/1999/xhtml/vocab#cite",this.target.graph.terms.chapter="http://www.w3.org/1999/xhtml/vocab#chapter",this.target.graph.terms.contents="http://www.w3.org/1999/xhtml/vocab#contents",this.target.graph.terms.copyright="http://www.w3.org/1999/xhtml/vocab#copyright",this.target.graph.terms.first="http://www.w3.org/1999/xhtml/vocab#first",this.target.graph.terms.glossary="http://www.w3.org/1999/xhtml/vocab#glossary",this.target.graph.terms.help="http://www.w3.org/1999/xhtml/vocab#help",this.target.graph.terms.icon="http://www.w3.org/1999/xhtml/vocab#icon",
  this.target.graph.terms.index="http://www.w3.org/1999/xhtml/vocab#index",this.target.graph.terms.last="http://www.w3.org/1999/xhtml/vocab#last",this.target.graph.terms.license="http://www.w3.org/1999/xhtml/vocab#license",this.target.graph.terms.meta="http://www.w3.org/1999/xhtml/vocab#meta",this.target.graph.terms.next="http://www.w3.org/1999/xhtml/vocab#next",this.target.graph.terms.prev="http://www.w3.org/1999/xhtml/vocab#prev",this.target.graph.terms.previous="http://www.w3.org/1999/xhtml/vocab#previous",this.target.graph.terms.section="http://www.w3.org/1999/xhtml/vocab#section",this.target.graph.terms.stylesheet="http://www.w3.org/1999/xhtml/vocab#stylesheet",this.target.graph.terms.subsection="http://www.w3.org/1999/xhtml/vocab#subsection",this.target.graph.terms.start="http://www.w3.org/1999/xhtml/vocab#start",this.target.graph.terms.top="http://www.w3.org/1999/xhtml/vocab#top",this.target.graph.terms.up="http://www.w3.org/1999/xhtml/vocab#up",this.target.graph.terms.p3pv1="http://www.w3.org/1999/xhtml/vocab#p3pv1",this.target.graph.terms.related="http://www.w3.org/1999/xhtml/vocab#related",this.target.graph.terms.role="http://www.w3.org/1999/xhtml/vocab#role",this.target.graph.terms.transformation="http://www.w3.org/1999/xhtml/vocab#transformation"},RDFaProcessor.prototype.init=function(){},RDFaProcessor.prototype.newSubjectOrigin=function(){},RDFaProcessor.prototype.addTriple=function(){},RDFaProcessor.dateTimeTypes=[{pattern:/-?P(?:[0-9]+Y)?(?:[0-9]+M)?(?:[0-9]+D)?(?:T(?:[0-9]+H)?(?:[0-9]+M)?(?:[0-9]+(?:\.[0-9]+)?S)?)?/,type:"http://www.w3.org/2001/XMLSchema#duration"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9]T(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#dateTime"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]-[0-9][0-9](?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#date"},{pattern:/(?:[0-1][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+\-][0-9][0-9]:[0-9][0-9])?/,type:"http://www.w3.org/2001/XMLSchema#time"},{pattern:/-?(?:[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9])-[0-9][0-9]/,type:"http://www.w3.org/2001/XMLSchema#gYearMonth"},{pattern:/-?[1-9][0-9][0-9][0-9]|0[1-9][0-9][0-9]|00[1-9][0-9]|000[1-9]/,type:"http://www.w3.org/2001/XMLSchema#gYear"}],RDFaProcessor.deriveDateTimeType=function(value){for(var i=0;i<RDFaProcessor.dateTimeTypes.length;i++){var matched=RDFaProcessor.dateTimeTypes[i].pattern.exec(value);if(matched&&matched[0].length==value.length)return RDFaProcessor.dateTimeTypes[i].type}return null},RDFaProcessor.prototype.process=function(node,options){9==node.nodeType?(node=node.documentElement,this.setContext(node)):9==node.parentNode.nodeType&&this.setContext(node);var queue=[],removeHash=function(baseURI){if(!baseURI&&options&&options.baseURI)return options.baseURI;var hash=baseURI.indexOf("#");return hash>=0&&(baseURI=baseURI.substring(0,hash)),options&&options.baseURIMap&&(baseURI=options.baseURIMap(baseURI)),baseURI};for(queue.push({current:node,context:this.push(null,removeHash(node.baseURI))});queue.length>0;){var item=queue.shift();if(item.parent){if(item.context.parent&&item.context.parent.listMapping==item.listMapping)continue;for(var predicate in item.listMapping){var list=item.listMapping[predicate];if(0!=list.length){for(var bnodes=[],i=0;i<list.length;i++)bnodes.push(this.newBlankNode());for(var i=0;i<bnodes.length;i++)this.addTriple(item.parent,bnodes[i],"http://www.w3.org/1999/02/22-rdf-syntax-ns#first",list[i]),this.addTriple(item.parent,bnodes[i],"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",{type:RDFaProcessor.objectURI,value:i+1<bnodes.length?bnodes[i+1]:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"});this.addTriple(item.parent,item.subject,predicate,{type:RDFaProcessor.objectURI,value:bnodes[0]})}else this.addTriple(item.parent,item.subject,predicate,{type:RDFaProcessor.objectURI,value:"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"})}}else{var current=item.current,context=item.context,skip=!1,newSubject=null,currentObjectResource=null,typedResource=null,prefixes=context.prefixes,prefixesCopied=!1,incomplete=[],listMapping=context.listMapping,listMappingDifferent=context.parent?!1:!0,language=context.language,vocabulary=context.vocabulary,base=this.parseURI(removeHash(current.baseURI));current.item=null;var vocabAtt=current.getAttributeNode("vocab");if(vocabAtt){var value=RDFaProcessor.trim(vocabAtt.value);if(value.length>0){vocabulary=value;var baseSubject=base.spec;this.addTriple(current,baseSubject,"http://www.w3.org/ns/rdfa#usesVocabulary",{type:RDFaProcessor.objectURI,value:vocabulary})}else vocabulary=this.vocabulary}for(var i=0;i<current.attributes.length;i++){var att=current.attributes[i];if("x"==att.nodeName.charAt(0)&&0==att.nodeName.indexOf("xmlns:")){prefixesCopied||(prefixes=this.copyMappings(prefixes),prefixesCopied=!0);var prefix=att.nodeName.substring(6),ref=RDFaProcessor.trim(att.value);prefixes[prefix]=this.target.baseURI?this.target.baseURI.resolve(ref):ref}}var prefixAtt=current.getAttributeNode("prefix");prefixAtt&&(prefixesCopied||(prefixes=this.copyMappings(prefixes),prefixesCopied=!0),this.parsePrefixMappings(prefixAtt.value,prefixes));for(var xmlLangAtt=null,i=0;!xmlLangAtt&&i<this.langAttributes.length;i++)xmlLangAtt=current.getAttributeNodeNS(this.langAttributes[i].namespaceURI,this.langAttributes[i].localName);if(xmlLangAtt){var value=RDFaProcessor.trim(xmlLangAtt.value);language=value.length>0?value:null}var relAtt=current.getAttributeNode("rel"),revAtt=current.getAttributeNode("rev"),typeofAtt=current.getAttributeNode("typeof"),propertyAtt=current.getAttributeNode("property"),datatypeAtt=current.getAttributeNode("datatype"),datetimeAtt=this.inHTMLMode?current.getAttributeNode("datetime"):null,contentAtt=current.getAttributeNode("content"),aboutAtt=current.getAttributeNode("about"),srcAtt=current.getAttributeNode("src"),resourceAtt=current.getAttributeNode("resource"),hrefAtt=current.getAttributeNode("href"),inlistAtt=current.getAttributeNode("inlist"),relAttPredicates=[];if(relAtt)for(var values=this.tokenize(relAtt.value),i=0;i<values.length;i++){var predicate=this.parsePredicate(values[i],vocabulary,context.terms,prefixes,base,this.inHTMLMode&&null!=propertyAtt);predicate&&relAttPredicates.push(predicate)}var revAttPredicates=[];if(revAtt)for(var values=this.tokenize(revAtt.value),i=0;i<values.length;i++){var predicate=this.parsePredicate(values[i],vocabulary,context.terms,prefixes,base,this.inHTMLMode&&null!=propertyAtt);predicate&&revAttPredicates.push(predicate)}!this.inHTMLMode||null==relAtt&&null==revAtt||null==propertyAtt||(0==relAttPredicates.length&&(relAtt=null),0==revAttPredicates.length&&(revAtt=null)),relAtt||revAtt?(aboutAtt&&(newSubject=this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value,prefixes,base)),typeofAtt&&(typedResource=newSubject),newSubject||(9==current.parentNode.nodeType?newSubject=removeHash(current.baseURI):context.parentObject&&(newSubject=removeHash(current.parentNode.baseURI)==context.parentObject?removeHash(current.baseURI):context.parentObject)),resourceAtt&&(currentObjectResource=this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value,prefixes,base)),currentObjectResource||(hrefAtt?currentObjectResource=this.resolveAndNormalize(base,encodeURI(hrefAtt.value)):srcAtt?currentObjectResource=this.resolveAndNormalize(base,encodeURI(srcAtt.value)):!typeofAtt||aboutAtt||this.inXHTMLMode&&("head"==current.localName||"body"==current.localName)||(currentObjectResource=this.newBlankNode())),!typeofAtt||aboutAtt||!this.inXHTMLMode||"head"!=current.localName&&"body"!=current.localName?typeofAtt&&!aboutAtt&&(typedResource=currentObjectResource):typedResource=newSubject):!propertyAtt||contentAtt||datatypeAtt?(aboutAtt&&(newSubject=this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value,prefixes,base)),!newSubject&&resourceAtt&&(newSubject=this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value,prefixes,base)),!newSubject&&hrefAtt&&(newSubject=this.resolveAndNormalize(base,encodeURI(hrefAtt.value))),!newSubject&&srcAtt&&(newSubject=this.resolveAndNormalize(base,encodeURI(srcAtt.value))),newSubject||(9==current.parentNode.nodeType?newSubject=removeHash(current.baseURI):!this.inXHTMLMode&&!this.inHTMLMode||"head"!=current.localName&&"body"!=current.localName?typeofAtt?newSubject=this.newBlankNode():context.parentObject&&(newSubject=removeHash(current.parentNode.baseURI)==context.parentObject?removeHash(current.baseURI):context.parentObject,propertyAtt||(skip=!0)):newSubject=removeHash(current.parentNode.baseURI)==context.parentObject?removeHash(current.baseURI):context.parentObject),typeofAtt&&(typedResource=newSubject)):(aboutAtt&&(newSubject=this.parseSafeCURIEOrCURIEOrURI(aboutAtt.value,prefixes,base),typeofAtt&&(typedResource=newSubject)),newSubject||9!=current.parentNode.nodeType?!newSubject&&context.parentObject&&(newSubject=removeHash(current.parentNode.baseURI)==context.parentObject?removeHash(current.baseURI):context.parentObject):(newSubject=removeHash(current.baseURI),typeofAtt&&(typedResource=newSubject)),typeofAtt&&!typedResource&&(resourceAtt&&(typedResource=this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value,prefixes,base)),!typedResource&&hrefAtt&&(typedResource=this.resolveAndNormalize(base,encodeURI(hrefAtt.value))),!typedResource&&srcAtt&&(typedResource=this.resolveAndNormalize(base,encodeURI(srcAtt.value))),typedResource||!this.inXHTMLMode&&!this.inHTMLMode||"head"!=current.localName&&"body"!=current.localName||(typedResource=newSubject),typedResource||(typedResource=this.newBlankNode()),currentObjectResource=typedResource));if(newSubject&&(aboutAtt||resourceAtt||typedResource)){var id=newSubject;typeofAtt&&!aboutAtt&&!resourceAtt&&currentObjectResource&&(id=currentObjectResource),this.newSubjectOrigin(current,id)}if(typedResource)for(var values=this.tokenize(typeofAtt.value),i=0;i<values.length;i++){var object=this.parseTermOrCURIEOrAbsURI(values[i],vocabulary,context.terms,prefixes,base);object&&this.addTriple(current,typedResource,RDFaProcessor.typeURI,{type:RDFaProcessor.objectURI,value:object})}if(newSubject&&newSubject!=context.parentObject&&(listMapping={},listMappingDifferent=!0),currentObjectResource){if(relAtt&&inlistAtt)for(var i=0;i<relAttPredicates.length;i++){var list=listMapping[relAttPredicates[i]];list||(list=[],listMapping[relAttPredicates[i]]=list),list.push({type:RDFaProcessor.objectURI,value:currentObjectResource})}else if(relAtt)for(var i=0;i<relAttPredicates.length;i++)this.addTriple(current,newSubject,relAttPredicates[i],{type:RDFaProcessor.objectURI,value:currentObjectResource});if(revAtt)for(var i=0;i<revAttPredicates.length;i++)this.addTriple(current,currentObjectResource,revAttPredicates[i],{type:RDFaProcessor.objectURI,value:newSubject})}else{if(newSubject&&!currentObjectResource&&(relAtt||revAtt)&&(currentObjectResource=this.newBlankNode()),relAtt&&inlistAtt)for(var i=0;i<relAttPredicates.length;i++){var list=listMapping[relAttPredicates[i]];list||(list=[],listMapping[predicate]=list),incomplete.push({predicate:relAttPredicates[i],list:list})}else if(relAtt)for(var i=0;i<relAttPredicates.length;i++)incomplete.push({predicate:relAttPredicates[i],forward:!0});if(revAtt)for(var i=0;i<revAttPredicates.length;i++)incomplete.push({predicate:revAttPredicates[i],forward:!1})}if(propertyAtt){var datatype=null,content=null;datatypeAtt?(datatype=""==datatypeAtt.value?RDFaProcessor.PlainLiteralURI:this.parseTermOrCURIEOrAbsURI(datatypeAtt.value,vocabulary,context.terms,prefixes,base),content=datetimeAtt&&!contentAtt?datetimeAtt.value:datatype==RDFaProcessor.XMLLiteralURI||datatype==RDFaProcessor.HTMLLiteralURI?null:contentAtt?contentAtt.value:current.textContent):contentAtt?(datatype=RDFaProcessor.PlainLiteralURI,content=contentAtt.value):datetimeAtt?(content=datetimeAtt.value,datatype=RDFaProcessor.deriveDateTimeType(content),datatype||(datatype=RDFaProcessor.PlainLiteralURI)):relAtt||revAtt||(resourceAtt&&(content=this.parseSafeCURIEOrCURIEOrURI(resourceAtt.value,prefixes,base)),!content&&hrefAtt?content=this.resolveAndNormalize(base,encodeURI(hrefAtt.value)):!content&&srcAtt&&(content=this.resolveAndNormalize(base,encodeURI(srcAtt.value))),content&&(datatype=RDFaProcessor.objectURI)),datatype||(typeofAtt&&!aboutAtt?(datatype=RDFaProcessor.objectURI,content=typedResource):(content=current.textContent,this.inHTMLMode&&"time"==current.localName&&(datatype=RDFaProcessor.deriveDateTimeType(content)),datatype||(datatype=RDFaProcessor.PlainLiteralURI)));for(var values=this.tokenize(propertyAtt.value),i=0;i<values.length;i++){var predicate=this.parsePredicate(values[i],vocabulary,context.terms,prefixes,base);if(predicate)if(inlistAtt){var list=listMapping[predicate];list||(list=[],listMapping[predicate]=list),list.push(datatype==RDFaProcessor.XMLLiteralURI||datatype==RDFaProcessor.HTMLLiteralURI?{type:datatype,value:current.childNodes}:{type:datatype?datatype:RDFaProcessor.PlainLiteralURI,value:content,language:language})}else datatype==RDFaProcessor.XMLLiteralURI||datatype==RDFaProcessor.HTMLLiteralURI?this.addTriple(current,newSubject,predicate,{type:datatype,value:current.childNodes}):this.addTriple(current,newSubject,predicate,{type:datatype?datatype:RDFaProcessor.PlainLiteralURI,value:content,language:language})}}if(newSubject&&!skip)for(var i=0;i<context.incomplete.length;i++)context.incomplete[i].list?context.incomplete[i].list.push({type:RDFaProcessor.objectURI,value:newSubject}):context.incomplete[i].forward?this.addTriple(current,context.subject,context.incomplete[i].predicate,{type:RDFaProcessor.objectURI,value:newSubject}):this.addTriple(current,newSubject,context.incomplete[i].predicate,{type:RDFaProcessor.objectURI,value:context.subject});var childContext=null,listSubject=newSubject;skip?(childContext=this.push(context,context.subject),childContext.parentObject=removeHash(current.parentNode.baseURI)==context.parentObject?removeHash(current.baseURI):context.parentObject,childContext.incomplete=context.incomplete,childContext.language=language,childContext.prefixes=prefixes,childContext.vocabulary=vocabulary):(childContext=this.push(context,newSubject),childContext.parentObject=currentObjectResource?currentObjectResource:newSubject?newSubject:context.subject,childContext.prefixes=prefixes,childContext.incomplete=incomplete,currentObjectResource&&(listSubject=currentObjectResource,listMapping={},listMappingDifferent=!0),childContext.listMapping=listMapping,childContext.language=language,childContext.vocabulary=vocabulary),listMappingDifferent&&queue.unshift({parent:current,context:context,subject:listSubject,listMapping:listMapping});for(var child=current.lastChild;child;child=child.previousSibling)1==child.nodeType&&queue.unshift({current:child,context:childContext})}}this.inHTMLMode&&this.copyProperties();for(var i=0;i<this.finishedHandlers.length;i++)this.finishedHandlers[i](node)},RDFaProcessor.prototype.copyProperties=function(){},RDFaProcessor.prototype.push=function(parent,subject){return{parent:parent,subject:subject?subject:parent?parent.subject:null,parentObject:null,incomplete:[],listMapping:parent?parent.listMapping:{},language:parent?parent.language:this.language,prefixes:parent?parent.prefixes:this.target.graph.prefixes,terms:parent?parent.terms:this.target.graph.terms,vocabulary:parent?parent.vocabulary:this.vocabulary}},"object"==typeof exports&&(module.exports=RDFaProcessor)},{"./URI":157}],157:[function(require,module,exports){function URIResolver(){}URIResolver.SCHEME=/^[A-Za-z][A-Za-z0-9\+\-\.]*\:/,URIResolver.prototype.parseURI=function(uri){var match=URIResolver.SCHEME.exec(uri);if(!match)throw"Bad URI value, no scheme: "+uri;var parsed={spec:uri};return parsed.scheme=match[0].substring(0,match[0].length-1),parsed.schemeSpecificPart=parsed.spec.substring(match[0].length),"/"==parsed.schemeSpecificPart.charAt(0)&&"/"==parsed.schemeSpecificPart.charAt(1)?this.parseGeneric(parsed):parsed.isGeneric=!1,parsed.normalize=function(){if(this.isGeneric&&0!=this.segments.length){if(this.path.length>1&&"/."==this.path.substring(this.path.length-2))return this.path=this.path.substring(0,this.path.length-1),this.segments.splice(this.segments.length-1,1),this.schemeSpecificPart="//"+this.authority+this.path,"undefined"!=typeof this.query&&(this.schemeSpecificPart+="?"+this.query),"undefined"!=typeof this.fragment&&(this.schemeSpecificPart+="#"+this.fragment),void(this.spec=this.scheme+":"+this.schemeSpecificPart);var end=this.path.charAt(this.path.length-1);"/"!=end&&(end="");for(var i=0;i<this.segments.length;i++)i>0&&".."==this.segments[i]&&(this.segments.splice(i-1,2),i-=2),"."==this.segments[i]&&(this.segments.splice(i,1),i--);this.path=0==this.segments.length?"/":"/"+this.segments.join("/")+end,this.schemeSpecificPart="//"+this.authority+this.path,"undefined"!=typeof this.query&&(this.schemeSpecificPart+="?"+this.query),"undefined"!=typeof this.fragment&&(this.schemeSpecificPart+="#"+this.fragment),this.spec=this.scheme+":"+this.schemeSpecificPart}},parsed.resolve=function(href){if(!href)return this.spec;if("#"==href.charAt(0)){var lastHash=this.spec.lastIndexOf("#");return 0>lastHash?this.spec+href:this.spec.substring(0,lastHash)+href}if(!this.isGeneric)throw"Cannot resolve uri against non-generic URI: "+this.spec;href.indexOf(":");if("/"==href.charAt(0))return this.scheme+"://"+this.authority+href;if("."==href.charAt(0)&&"/"==href.charAt(1)){if("/"==this.path.charAt(this.path.length-1))return this.scheme+"://"+this.authority+this.path+href.substring(2);var last=this.path.lastIndexOf("/");return this.scheme+"://"+this.authority+this.path.substring(0,last)+href.substring(1)}if(URIResolver.SCHEME.test(href))return href;if("?"==href.charAt(0))return this.scheme+"://"+this.authority+this.path+href;if("/"==this.path.charAt(this.path.length-1))return this.scheme+"://"+this.authority+this.path+href;var last=this.path.lastIndexOf("/");return this.scheme+"://"+this.authority+this.path.substring(0,last+1)+href},parsed.relativeTo=function(otherURI){if(otherURI.scheme!=this.scheme)return this.spec;if(!this.isGeneric)throw"A non generic URI cannot be made relative: "+this.spec;if(!otherURI.isGeneric)throw"Cannot make a relative URI against a non-generic URI: "+otherURI.spec;if(otherURI.authority!=this.authority)return this.spec;for(var i=0;i<this.segments.length&&i<otherURI.segments.length;i++)if(this.segments[i]!=otherURI.segments[i]){for(var offset="/"==otherURI.path.charAt(otherURI.path.length-1)?0:-1,relative="",j=i;j<otherURI.segments.length+offset;j++)relative+="../";for(var j=i;j<this.segments.length;j++)relative+=this.segments[j],j+1<this.segments.length&&(relative+="/");return"/"==this.path.charAt(this.path.length-1)&&(relative+="/"),relative}if(this.segments.length==otherURI.segments.length)return this.hash?this.hash:this.query?this.query:"";if(i<this.segments.length){for(var relative="",j=i;j<this.segments.length;j++)relative+=this.segments[j],j+1<this.segments.length&&(relative+="/");return"/"==this.path.charAt(this.path.length-1)&&(relative+="/"),relative}throw"Cannot calculate a relative URI for "+this.spec+" against "+otherURI.spec},parsed},URIResolver.prototype.parseGeneric=function(parsed){if("/"!=parsed.schemeSpecificPart.charAt(0)||"/"!=parsed.schemeSpecificPart.charAt(1))throw"Generic URI values should start with '//':"+parsed.spec;var work=parsed.schemeSpecificPart.substring(2),pathStart=work.indexOf("/");parsed.authority=0>pathStart?work:work.substring(0,pathStart),parsed.path=0>pathStart?"":work.substring(pathStart);var hash=parsed.path.indexOf("#");hash>=0&&(parsed.fragment=parsed.path.substring(hash+1),parsed.path=parsed.path.substring(0,hash));var questionMark=parsed.path.indexOf("?");if(questionMark>=0&&(parsed.query=parsed.path.substring(questionMark+1),parsed.path=parsed.path.substring(0,questionMark)),"/"==parsed.path||""==parsed.path)parsed.segments=[];else{parsed.segments=parsed.path.split(/\//),parsed.segments.length>0&&""==parsed.segments[0]&&parsed.path.length>1&&"/"!=parsed.path.charAt(1)&&parsed.segments.shift(),parsed.segments.length>0&&parsed.path.length>0&&"/"==parsed.path.charAt(parsed.path.length-1)&&""==parsed.segments[parsed.segments.length-1]&&parsed.path.length>1&&"/"!=parsed.path.charAt(parsed.path.length-2)&&parsed.segments.pop();for(var i=0;i<parsed.segments.length;i++)for(var check=parsed.segments[i].split(/%[A-Za-z0-9][A-Za-z0-9]|[\ud800-\udfff][\ud800-\udfff]|[A-Za-z0-9\-\._~!$&'()*+,;=@:\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/),j=0;j<check.length;j++)if(check[j].length>0)throw"Unecaped character "+check[j].charAt(0)+" ("+check[j].charCodeAt(0)+") in URI "+parsed.spec}parsed.isGeneric=!0},"object"==typeof exports&&(module.exports=URIResolver)},{}],158:[function(require,module){module.exports={RDFaProcessor:require("./RDFaProcessor")}},{"./RDFaProcessor":156}],159:[function(require,module,exports){arguments[4][93][0].apply(exports,arguments)},{dup:93}],160:[function(require,module,exports){arguments[4][95][0].apply(exports,arguments)},{dup:95}],161:[function(){},{}],162:[function(require,module){(function(process,global,__dirname){!function(){var _nodejs="undefined"!=typeof process&&process.versions&&process.versions.node,_browser=!_nodejs&&("undefined"!=typeof window||"undefined"!=typeof self);_browser&&"undefined"==typeof global&&("undefined"!=typeof window?global=window:"undefined"!=typeof self?global=self:"undefined"!=typeof $&&(global=$));var wrapper=function(jsonld){function JsonLdProcessor(){}function _expandLanguageMap(languageMap){for(var rval=[],keys=Object.keys(languageMap).sort(),ki=0;ki<keys.length;++ki){var key=keys[ki],val=languageMap[key];_isArray(val)||(val=[val]);for(var vi=0;vi<val.length;++vi){var item=val[vi];if(null!==item){if(!_isString(item))throw new JsonLdError("Invalid JSON-LD syntax; language map values must be strings.","jsonld.SyntaxError",{code:"invalid language map value",languageMap:languageMap});rval.push({"@value":item,"@language":key.toLowerCase()})}}}return rval}function _labelBlankNodes(issuer,element){if(_isArray(element))for(var i=0;i<element.length;++i)element[i]=_labelBlankNodes(issuer,element[i]);else if(_isList(element))element["@list"]=_labelBlankNodes(issuer,element["@list"]);else if(_isObject(element)){_isBlankNode(element)&&(element["@id"]=issuer.getId(element["@id"]));for(var keys=Object.keys(element).sort(),ki=0;ki<keys.length;++ki){var key=keys[ki];"@id"!==key&&(element[key]=_labelBlankNodes(issuer,element[key]))}}return element}function _expandValue(activeCtx,activeProperty,value){if(null===value||void 0===value)return null;var expandedProperty=_expandIri(activeCtx,activeProperty,{vocab:!0});if("@id"===expandedProperty)return _expandIri(activeCtx,value,{base:!0});if("@type"===expandedProperty)return _expandIri(activeCtx,value,{vocab:!0,base:!0});var type=jsonld.getContextValue(activeCtx,activeProperty,"@type");if("@id"===type||"@graph"===expandedProperty&&_isString(value))return{"@id":_expandIri(activeCtx,value,{base:!0})};if("@vocab"===type)return{"@id":_expandIri(activeCtx,value,{vocab:!0,base:!0})};if(_isKeyword(expandedProperty))return value;var rval={};if(null!==type)rval["@type"]=type;else if(_isString(value)){var language=jsonld.getContextValue(activeCtx,activeProperty,"@language");null!==language&&(rval["@language"]=language)}return-1===["boolean","number","string"].indexOf(typeof value)&&(value=value.toString()),rval["@value"]=value,rval}function _graphToRDF(graph,issuer,options){for(var rval=[],ids=Object.keys(graph).sort(),i=0;i<ids.length;++i)for(var id=ids[i],node=graph[id],properties=Object.keys(node).sort(),pi=0;pi<properties.length;++pi){var property=properties[pi],items=node[property];if("@type"===property)property=RDF_TYPE;else if(_isKeyword(property))continue;for(var ii=0;ii<items.length;++ii){var item=items[ii],subject={};if(subject.type=0===id.indexOf("_:")?"blank node":"IRI",subject.value=id,_isAbsoluteIri(id)){var predicate={};if(predicate.type=0===property.indexOf("_:")?"blank node":"IRI",predicate.value=property,_isAbsoluteIri(property)&&("blank node"!==predicate.type||options.produceGeneralizedRdf))if(_isList(item))_listToRDF(item["@list"],issuer,subject,predicate,rval);else{var object=_objectToRDF(item);object&&rval.push({subject:subject,predicate:predicate,object:object})}}}}return rval}function _listToRDF(list,issuer,subject,predicate,triples){for(var first={type:"IRI",value:RDF_FIRST},rest={type:"IRI",value:RDF_REST},nil={type:"IRI",value:RDF_NIL},i=0;i<list.length;++i){var item=list[i],blankNode={type:"blank node",value:issuer.getId()};triples.push({subject:subject,predicate:predicate,object:blankNode}),subject=blankNode,predicate=first;var object=_objectToRDF(item);object&&triples.push({subject:subject,predicate:predicate,object:object}),predicate=rest}triples.push({subject:subject,predicate:predicate,object:nil})}function _objectToRDF(item){var object={};if(_isValue(item)){object.type="literal";var value=item["@value"],datatype=item["@type"]||null;_isBoolean(value)?(object.value=value.toString(),object.datatype=datatype||XSD_BOOLEAN):_isDouble(value)||datatype===XSD_DOUBLE?(_isDouble(value)||(value=parseFloat(value)),object.value=value.toExponential(15).replace(/(\d)0*e\+?/,"$1E"),object.datatype=datatype||XSD_DOUBLE):_isNumber(value)?(object.value=value.toFixed(0),object.datatype=datatype||XSD_INTEGER):"@language"in item?(object.value=value,object.datatype=datatype||RDF_LANGSTRING,object.language=item["@language"]):(object.value=value,object.datatype=datatype||XSD_STRING)}else{var id=_isObject(item)?item["@id"]:item;object.type=0===id.indexOf("_:")?"blank node":"IRI",object.value=id}return"IRI"!==object.type||_isAbsoluteIri(object.value)?object:null}function _RDFToObject(o,useNativeTypes){if("IRI"===o.type||"blank node"===o.type)return{"@id":o.value};var rval={"@value":o.value};if(o.language)rval["@language"]=o.language;else{var type=o.datatype;if(type||(type=XSD_STRING),useNativeTypes){if(type===XSD_BOOLEAN)"true"===rval["@value"]?rval["@value"]=!0:"false"===rval["@value"]&&(rval["@value"]=!1);else if(_isNumeric(rval["@value"]))if(type===XSD_INTEGER){var i=parseInt(rval["@value"],10);i.toFixed(0)===rval["@value"]&&(rval["@value"]=i)}else type===XSD_DOUBLE&&(rval["@value"]=parseFloat(rval["@value"]));-1===[XSD_BOOLEAN,XSD_INTEGER,XSD_DOUBLE,XSD_STRING].indexOf(type)&&(rval["@type"]=type)}else type!==XSD_STRING&&(rval["@type"]=type)}return rval}function _compareRDFTriples(t1,t2){for(var attrs=["subject","predicate","object"],i=0;i<attrs.length;++i){var attr=attrs[i];if(t1[attr].type!==t2[attr].type||t1[attr].value!==t2[attr].value)return!1}return t1.object.language!==t2.object.language?!1:t1.object.datatype!==t2.object.datatype?!1:!0}function _createNodeMap(input,graphs,graph,issuer,name,list){if(_isArray(input))for(var i=0;i<input.length;++i)_createNodeMap(input[i],graphs,graph,issuer,void 0,list);else{if(!_isObject(input))return void(list&&list.push(input));if(_isValue(input)){if("@type"in input){var type=input["@type"];0===type.indexOf("_:")&&(input["@type"]=type=issuer.getId(type))}return void(list&&list.push(input))}if("@type"in input)for(var types=input["@type"],i=0;i<types.length;++i){var type=types[i];0===type.indexOf("_:")&&issuer.getId(type)}_isUndefined(name)&&(name=_isBlankNode(input)?issuer.getId(input["@id"]):input["@id"]),list&&list.push({"@id":name});var subjects=graphs[graph],subject=subjects[name]=subjects[name]||{};subject["@id"]=name;for(var properties=Object.keys(input).sort(),pi=0;pi<properties.length;++pi){var property=properties[pi];if("@id"!==property)if("@reverse"!==property)if("@graph"!==property)if("@type"!==property&&_isKeyword(property)){if("@index"===property&&property in subject&&(input[property]!==subject[property]||input[property]["@id"]!==subject[property]["@id"]))throw new JsonLdError("Invalid JSON-LD syntax; conflicting @index property detected.","jsonld.SyntaxError",{code:"conflicting indexes",subject:subject});subject[property]=input[property]}else{var objects=input[property];if(0===property.indexOf("_:")&&(property=issuer.getId(property)),0!==objects.length)for(var oi=0;oi<objects.length;++oi){var o=objects[oi];if("@type"===property&&(o=0===o.indexOf("_:")?issuer.getId(o):o),_isSubject(o)||_isSubjectReference(o)){var id=_isBlankNode(o)?issuer.getId(o["@id"]):o["@id"];jsonld.addValue(subject,property,{"@id":id},{propertyIsArray:!0,allowDuplicate:!1}),_createNodeMap(o,graphs,graph,issuer,id)}else if(_isList(o)){var _list=[];_createNodeMap(o["@list"],graphs,graph,issuer,name,_list),o={"@list":_list},jsonld.addValue(subject,property,o,{propertyIsArray:!0,allowDuplicate:!1})}else _createNodeMap(o,graphs,graph,issuer,name),jsonld.addValue(subject,property,o,{propertyIsArray:!0,allowDuplicate:!1})}else jsonld.addValue(subject,property,[],{propertyIsArray:!0})}else{name in graphs||(graphs[name]={});var g="@merged"===graph?graph:name;_createNodeMap(input[property],graphs,g,issuer)}else{var referencedNode={"@id":name},reverseMap=input["@reverse"];for(var reverseProperty in reverseMap)for(var items=reverseMap[reverseProperty],ii=0;ii<items.length;++ii){var item=items[ii],itemName=item["@id"];_isBlankNode(item)&&(itemName=issuer.getId(itemName)),_createNodeMap(item,graphs,graph,issuer,itemName),jsonld.addValue(subjects[itemName],reverseProperty,referencedNode,{propertyIsArray:!0,allowDuplicate:!1})}}}}}function _mergeNodeMaps(graphs){for(var defaultGraph=graphs["@default"],graphNames=Object.keys(graphs).sort(),i=0;i<graphNames.length;++i){var graphName=graphNames[i];if("@default"!==graphName){var nodeMap=graphs[graphName],subject=defaultGraph[graphName];subject?"@graph"in subject||(subject["@graph"]=[]):defaultGraph[graphName]=subject={"@id":graphName,"@graph":[]};for(var graph=subject["@graph"],ids=Object.keys(nodeMap).sort(),ii=0;ii<ids.length;++ii){var node=nodeMap[ids[ii]];_isSubjectReference(node)||graph.push(node)}}}return defaultGraph}function _frame(state,subjects,frame,parent,property){_validateFrame(frame),frame=frame[0];for(var options=state.options,flags={embed:_getFrameFlag(frame,options,"embed"),explicit:_getFrameFlag(frame,options,"explicit"),requireAll:_getFrameFlag(frame,options,"requireAll")},matches=_filterSubjects(state,subjects,frame,flags),ids=Object.keys(matches).sort(),idx=0;idx<ids.length;++idx){var id=ids[idx],subject=matches[id];if("@link"===flags.embed&&id in state.link)_addFrameOutput(parent,property,state.link[id]);else{null===property&&(state.uniqueEmbeds={});var output={};if(output["@id"]=id,state.link[id]=output,"@never"===flags.embed||_createsCircularReference(subject,state.subjectStack))_addFrameOutput(parent,property,output);else{"@last"===flags.embed&&(id in state.uniqueEmbeds&&_removeEmbed(state,id),state.uniqueEmbeds[id]={parent:parent,property:property}),state.subjectStack.push(subject);for(var props=Object.keys(subject).sort(),i=0;i<props.length;i++){var prop=props[i];if(_isKeyword(prop))output[prop]=_clone(subject[prop]);else if(!flags.explicit||prop in frame)for(var objects=subject[prop],oi=0;oi<objects.length;++oi){var o=objects[oi];if(_isList(o)){var list={"@list":[]};_addFrameOutput(output,prop,list);var src=o["@list"];for(var n in src)if(o=src[n],_isSubjectReference(o)){var subframe=prop in frame?frame[prop][0]["@list"]:_createImplicitFrame(flags);_frame(state,[o["@id"]],subframe,list,"@list")}else _addFrameOutput(list,"@list",_clone(o))}else if(_isSubjectReference(o)){var subframe=prop in frame?frame[prop]:_createImplicitFrame(flags);_frame(state,[o["@id"]],subframe,output,prop)}else _addFrameOutput(output,prop,_clone(o))}}for(var props=Object.keys(frame).sort(),i=0;i<props.length;++i){var prop=props[i];if(!_isKeyword(prop)){var next=frame[prop][0],omitDefaultOn=_getFrameFlag(next,options,"omitDefault");if(!(omitDefaultOn||prop in output)){var preserve="@null";"@default"in next&&(preserve=_clone(next["@default"])),_isArray(preserve)||(preserve=[preserve]),
  output[prop]=[{"@preserve":preserve}]}}}_addFrameOutput(parent,property,output),state.subjectStack.pop()}}}}function _createImplicitFrame(flags){var frame={};for(var key in flags)void 0!==flags[key]&&(frame["@"+key]=[flags[key]]);return[frame]}function _createsCircularReference(subjectToEmbed,subjectStack){for(var i=subjectStack.length-1;i>=0;--i)if(subjectStack[i]["@id"]===subjectToEmbed["@id"])return!0;return!1}function _getFrameFlag(frame,options,name){var flag="@"+name,rval=flag in frame?frame[flag][0]:options[name];return"embed"===name&&(rval===!0?rval="@last":rval===!1?rval="@never":"@always"!==rval&&"@never"!==rval&&"@link"!==rval&&(rval="@last")),rval}function _validateFrame(frame){if(!_isArray(frame)||1!==frame.length||!_isObject(frame[0]))throw new JsonLdError("Invalid JSON-LD syntax; a JSON-LD frame must be a single object.","jsonld.SyntaxError",{frame:frame})}function _filterSubjects(state,subjects,frame,flags){for(var rval={},i=0;i<subjects.length;++i){var id=subjects[i],subject=state.subjects[id];_filterSubject(subject,frame,flags)&&(rval[id]=subject)}return rval}function _filterSubject(subject,frame,flags){if("@type"in frame&&(1!==frame["@type"].length||!_isObject(frame["@type"][0]))){for(var types=frame["@type"],i=0;i<types.length;++i)if(jsonld.hasValue(subject,"@type",types[i]))return!0;return!1}var wildcard=!0,matchesSome=!1;for(var key in frame){if(_isKeyword(key)){if("@id"!==key&&"@type"!==key)continue;if(wildcard=!1,"@id"===key&&_isString(frame[key])){if(subject[key]!==frame[key])return!1;matchesSome=!0;continue}}if(wildcard=!1,key in subject){if(_isArray(frame[key])&&0===frame[key].length&&void 0!==subject[key])return!1;matchesSome=!0}else{var hasDefault=_isArray(frame[key])&&_isObject(frame[key][0])&&"@default"in frame[key][0];if(flags.requireAll&&!hasDefault)return!1}}return wildcard||matchesSome}function _removeEmbed(state,id){var embeds=state.uniqueEmbeds,embed=embeds[id],parent=embed.parent,property=embed.property,subject={"@id":id};if(_isArray(parent)){for(var i=0;i<parent.length;++i)if(jsonld.compareValues(parent[i],subject)){parent[i]=subject;break}}else{var useArray=_isArray(parent[property]);jsonld.removeValue(parent,property,subject,{propertyIsArray:useArray}),jsonld.addValue(parent,property,subject,{propertyIsArray:useArray})}var removeDependents=function(id){for(var ids=Object.keys(embeds),i=0;i<ids.length;++i){var next=ids[i];next in embeds&&_isObject(embeds[next].parent)&&embeds[next].parent["@id"]===id&&(delete embeds[next],removeDependents(next))}};removeDependents(id)}function _addFrameOutput(parent,property,output){_isObject(parent)?jsonld.addValue(parent,property,output,{propertyIsArray:!0}):parent.push(output)}function _removePreserve(ctx,input,options){if(_isArray(input)){for(var output=[],i=0;i<input.length;++i){var result=_removePreserve(ctx,input[i],options);null!==result&&output.push(result)}input=output}else if(_isObject(input)){if("@preserve"in input)return"@null"===input["@preserve"]?null:input["@preserve"];if(_isValue(input))return input;if(_isList(input))return input["@list"]=_removePreserve(ctx,input["@list"],options),input;var idAlias=_compactIri(ctx,"@id");if(idAlias in input){var id=input[idAlias];if(id in options.link){var idx=options.link[id].indexOf(input);if(-1!==idx)return options.link[id][idx];options.link[id].push(input)}else options.link[id]=[input]}for(var prop in input){var result=_removePreserve(ctx,input[prop],options),container=jsonld.getContextValue(ctx,prop,"@container");options.compactArrays&&_isArray(result)&&1===result.length&&null===container&&(result=result[0]),input[prop]=result}}return input}function _compareShortestLeast(a,b){return a.length<b.length?-1:b.length<a.length?1:a===b?0:b>a?-1:1}function _selectTerm(activeCtx,iri,value,containers,typeOrLanguage,typeOrLanguageValue){null===typeOrLanguageValue&&(typeOrLanguageValue="@null");var prefs=[];if("@id"!==typeOrLanguageValue&&"@reverse"!==typeOrLanguageValue||!_isSubjectReference(value))prefs.push(typeOrLanguageValue);else{"@reverse"===typeOrLanguageValue&&prefs.push("@reverse");var term=_compactIri(activeCtx,value["@id"],null,{vocab:!0});term in activeCtx.mappings&&activeCtx.mappings[term]&&activeCtx.mappings[term]["@id"]===value["@id"]?prefs.push.apply(prefs,["@vocab","@id"]):prefs.push.apply(prefs,["@id","@vocab"])}prefs.push("@none");for(var containerMap=activeCtx.inverse[iri],ci=0;ci<containers.length;++ci){var container=containers[ci];if(container in containerMap)for(var typeOrLanguageValueMap=containerMap[container][typeOrLanguage],pi=0;pi<prefs.length;++pi){var pref=prefs[pi];if(pref in typeOrLanguageValueMap)return typeOrLanguageValueMap[pref]}}return null}function _compactIri(activeCtx,iri,value,relativeTo,reverse){if(null===iri)return iri;_isUndefined(value)&&(value=null),_isUndefined(reverse)&&(reverse=!1),relativeTo=relativeTo||{};var inverseCtx=activeCtx.getInverse();if(_isKeyword(iri))return iri in inverseCtx?inverseCtx[iri]["@none"]["@type"]["@none"]:iri;if(relativeTo.vocab&&iri in inverseCtx){var defaultLanguage=activeCtx["@language"]||"@none",containers=[];_isObject(value)&&"@index"in value&&containers.push("@index");var typeOrLanguage="@language",typeOrLanguageValue="@null";if(reverse)typeOrLanguage="@type",typeOrLanguageValue="@reverse",containers.push("@set");else if(_isList(value)){"@index"in value||containers.push("@list");for(var list=value["@list"],commonLanguage=0===list.length?defaultLanguage:null,commonType=null,i=0;i<list.length;++i){var item=list[i],itemLanguage="@none",itemType="@none";if(_isValue(item)?"@language"in item?itemLanguage=item["@language"]:"@type"in item?itemType=item["@type"]:itemLanguage="@null":itemType="@id",null===commonLanguage?commonLanguage=itemLanguage:itemLanguage!==commonLanguage&&_isValue(item)&&(commonLanguage="@none"),null===commonType?commonType=itemType:itemType!==commonType&&(commonType="@none"),"@none"===commonLanguage&&"@none"===commonType)break}commonLanguage=commonLanguage||"@none",commonType=commonType||"@none","@none"!==commonType?(typeOrLanguage="@type",typeOrLanguageValue=commonType):typeOrLanguageValue=commonLanguage}else _isValue(value)?"@language"in value&&!("@index"in value)?(containers.push("@language"),typeOrLanguageValue=value["@language"]):"@type"in value&&(typeOrLanguage="@type",typeOrLanguageValue=value["@type"]):(typeOrLanguage="@type",typeOrLanguageValue="@id"),containers.push("@set");containers.push("@none");var term=_selectTerm(activeCtx,iri,value,containers,typeOrLanguage,typeOrLanguageValue);if(null!==term)return term}if(relativeTo.vocab&&"@vocab"in activeCtx){var vocab=activeCtx["@vocab"];if(0===iri.indexOf(vocab)&&iri!==vocab){var suffix=iri.substr(vocab.length);if(!(suffix in activeCtx.mappings))return suffix}}for(var choice=null,idx=0,partialMatches=[],iriMap=activeCtx.fastCurieMap,maxPartialLength=iri.length-1;maxPartialLength>idx&&iri[idx]in iriMap;++idx)iriMap=iriMap[iri[idx]],""in iriMap&&partialMatches.push(iriMap[""][0]);for(var i=partialMatches.length-1;i>=0;--i)for(var entry=partialMatches[i],terms=entry.terms,ti=0;ti<terms.length;++ti){var curie=terms[ti]+":"+iri.substr(entry.iri.length),isUsableCurie=!(curie in activeCtx.mappings)||null===value&&activeCtx.mappings[curie]["@id"]===iri;isUsableCurie&&(null===choice||_compareShortestLeast(curie,choice)<0)&&(choice=curie)}return null!==choice?choice:relativeTo.vocab?iri:_removeBase(activeCtx["@base"],iri)}function _compactValue(activeCtx,activeProperty,value){if(_isValue(value)){var type=jsonld.getContextValue(activeCtx,activeProperty,"@type"),language=jsonld.getContextValue(activeCtx,activeProperty,"@language"),container=jsonld.getContextValue(activeCtx,activeProperty,"@container"),preserveIndex="@index"in value&&"@index"!==container;if(!preserveIndex&&(value["@type"]===type||value["@language"]===language))return value["@value"];var keyCount=Object.keys(value).length,isValueOnlyKey=1===keyCount||2===keyCount&&"@index"in value&&!preserveIndex,hasDefaultLanguage="@language"in activeCtx,isValueString=_isString(value["@value"]),hasNullMapping=activeCtx.mappings[activeProperty]&&null===activeCtx.mappings[activeProperty]["@language"];if(isValueOnlyKey&&(!hasDefaultLanguage||!isValueString||hasNullMapping))return value["@value"];var rval={};return preserveIndex&&(rval[_compactIri(activeCtx,"@index")]=value["@index"]),"@type"in value?rval[_compactIri(activeCtx,"@type")]=_compactIri(activeCtx,value["@type"],null,{vocab:!0}):"@language"in value&&(rval[_compactIri(activeCtx,"@language")]=value["@language"]),rval[_compactIri(activeCtx,"@value")]=value["@value"],rval}var expandedProperty=_expandIri(activeCtx,activeProperty,{vocab:!0}),type=jsonld.getContextValue(activeCtx,activeProperty,"@type"),compacted=_compactIri(activeCtx,value["@id"],null,{vocab:"@vocab"===type});if("@id"===type||"@vocab"===type||"@graph"===expandedProperty)return compacted;var rval={};return rval[_compactIri(activeCtx,"@id")]=compacted,rval}function _createTermDefinition(activeCtx,localCtx,term,defined){if(term in defined){if(defined[term])return;throw new JsonLdError("Cyclical context definition detected.","jsonld.CyclicalContext",{code:"cyclic IRI mapping",context:localCtx,term:term})}if(defined[term]=!1,_isKeyword(term))throw new JsonLdError("Invalid JSON-LD syntax; keywords cannot be overridden.","jsonld.SyntaxError",{code:"keyword redefinition",context:localCtx,term:term});if(""===term)throw new JsonLdError("Invalid JSON-LD syntax; a term cannot be an empty string.","jsonld.SyntaxError",{code:"invalid term definition",context:localCtx});activeCtx.mappings[term]&&delete activeCtx.mappings[term];var value=localCtx[term];if(null===value||_isObject(value)&&null===value["@id"])return activeCtx.mappings[term]=null,void(defined[term]=!0);if(_isString(value)&&(value={"@id":value}),!_isObject(value))throw new JsonLdError("Invalid JSON-LD syntax; @context property values must be strings or objects.","jsonld.SyntaxError",{code:"invalid term definition",context:localCtx});var mapping=activeCtx.mappings[term]={};if(mapping.reverse=!1,"@reverse"in value){if("@id"in value)throw new JsonLdError("Invalid JSON-LD syntax; a @reverse term definition must not contain @id.","jsonld.SyntaxError",{code:"invalid reverse property",context:localCtx});var reverse=value["@reverse"];if(!_isString(reverse))throw new JsonLdError("Invalid JSON-LD syntax; a @context @reverse value must be a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:localCtx});var id=_expandIri(activeCtx,reverse,{vocab:!0,base:!1},localCtx,defined);if(!_isAbsoluteIri(id))throw new JsonLdError("Invalid JSON-LD syntax; a @context @reverse value must be an absolute IRI or a blank node identifier.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:localCtx});mapping["@id"]=id,mapping.reverse=!0}else if("@id"in value){var id=value["@id"];if(!_isString(id))throw new JsonLdError("Invalid JSON-LD syntax; a @context @id value must be an array of strings or a string.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:localCtx});if(id!==term){if(id=_expandIri(activeCtx,id,{vocab:!0,base:!1},localCtx,defined),!_isAbsoluteIri(id)&&!_isKeyword(id))throw new JsonLdError("Invalid JSON-LD syntax; a @context @id value must be an absolute IRI, a blank node identifier, or a keyword.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:localCtx});mapping["@id"]=id}}var colon=term.indexOf(":");if(mapping._termHasColon=-1!==colon,!("@id"in mapping))if(mapping._termHasColon){var prefix=term.substr(0,colon);if(prefix in localCtx&&_createTermDefinition(activeCtx,localCtx,prefix,defined),activeCtx.mappings[prefix]){var suffix=term.substr(colon+1);mapping["@id"]=activeCtx.mappings[prefix]["@id"]+suffix}else mapping["@id"]=term}else{if(!("@vocab"in activeCtx))throw new JsonLdError("Invalid JSON-LD syntax; @context terms must define an @id.","jsonld.SyntaxError",{code:"invalid IRI mapping",context:localCtx,term:term});mapping["@id"]=activeCtx["@vocab"]+term}if(defined[term]=!0,"@type"in value){var type=value["@type"];if(!_isString(type))throw new JsonLdError("Invalid JSON-LD syntax; an @context @type values must be a string.","jsonld.SyntaxError",{code:"invalid type mapping",context:localCtx});if("@id"!==type&&"@vocab"!==type){if(type=_expandIri(activeCtx,type,{vocab:!0,base:!1},localCtx,defined),!_isAbsoluteIri(type))throw new JsonLdError("Invalid JSON-LD syntax; an @context @type value must be an absolute IRI.","jsonld.SyntaxError",{code:"invalid type mapping",context:localCtx});if(0===type.indexOf("_:"))throw new JsonLdError("Invalid JSON-LD syntax; an @context @type values must be an IRI, not a blank node identifier.","jsonld.SyntaxError",{code:"invalid type mapping",context:localCtx})}mapping["@type"]=type}if("@container"in value){var container=value["@container"];if("@list"!==container&&"@set"!==container&&"@index"!==container&&"@language"!==container)throw new JsonLdError("Invalid JSON-LD syntax; @context @container value must be one of the following: @list, @set, @index, or @language.","jsonld.SyntaxError",{code:"invalid container mapping",context:localCtx});if(mapping.reverse&&"@index"!==container&&"@set"!==container&&null!==container)throw new JsonLdError("Invalid JSON-LD syntax; @context @container value for a @reverse type definition must be @index or @set.","jsonld.SyntaxError",{code:"invalid reverse property",context:localCtx});mapping["@container"]=container}if("@language"in value&&!("@type"in value)){var language=value["@language"];if(null!==language&&!_isString(language))throw new JsonLdError("Invalid JSON-LD syntax; @context @language value must be a string or null.","jsonld.SyntaxError",{code:"invalid language mapping",context:localCtx});null!==language&&(language=language.toLowerCase()),mapping["@language"]=language}var id=mapping["@id"];if("@context"===id||"@preserve"===id)throw new JsonLdError("Invalid JSON-LD syntax; @context and @preserve cannot be aliased.","jsonld.SyntaxError",{code:"invalid keyword alias",context:localCtx})}function _expandIri(activeCtx,value,relativeTo,localCtx,defined){if(null===value||_isKeyword(value))return value;if(value=String(value),localCtx&&value in localCtx&&defined[value]!==!0&&_createTermDefinition(activeCtx,localCtx,value,defined),relativeTo=relativeTo||{},relativeTo.vocab){var mapping=activeCtx.mappings[value];if(null===mapping)return null;if(mapping)return mapping["@id"]}var colon=value.indexOf(":");if(-1!==colon){var prefix=value.substr(0,colon),suffix=value.substr(colon+1);if("_"===prefix||0===suffix.indexOf("//"))return value;localCtx&&prefix in localCtx&&_createTermDefinition(activeCtx,localCtx,prefix,defined);var mapping=activeCtx.mappings[prefix];return mapping?mapping["@id"]+suffix:value}if(relativeTo.vocab&&"@vocab"in activeCtx)return activeCtx["@vocab"]+value;var rval=value;return relativeTo.base&&(rval=jsonld.prependBase(activeCtx["@base"],rval)),rval}function _prependBase(base,iri){if(null===base)return iri;if(-1!==iri.indexOf(":"))return iri;_isString(base)&&(base=jsonld.url.parse(base||""));var rel=jsonld.url.parse(iri),transform={protocol:base.protocol||""};if(null!==rel.authority)transform.authority=rel.authority,transform.path=rel.path,transform.query=rel.query;else if(transform.authority=base.authority,""===rel.path)transform.path=base.path,transform.query=null!==rel.query?rel.query:base.query;else{if(0===rel.path.indexOf("/"))transform.path=rel.path;else{var path=base.path;""!==rel.path&&(path=path.substr(0,path.lastIndexOf("/")+1),path.length>0&&"/"!==path.substr(-1)&&(path+="/"),path+=rel.path),transform.path=path}transform.query=rel.query}transform.path=_removeDotSegments(transform.path,!!transform.authority);var rval=transform.protocol;return null!==transform.authority&&(rval+="//"+transform.authority),rval+=transform.path,null!==transform.query&&(rval+="?"+transform.query),null!==rel.fragment&&(rval+="#"+rel.fragment),""===rval&&(rval="./"),rval}function _removeBase(base,iri){if(null===base)return iri;_isString(base)&&(base=jsonld.url.parse(base||""));var root="";if(""!==base.href?root+=(base.protocol||"")+"//"+(base.authority||""):iri.indexOf("//")&&(root+="//"),0!==iri.indexOf(root))return iri;for(var rel=jsonld.url.parse(iri.substr(root.length)),baseSegments=base.normalizedPath.split("/"),iriSegments=rel.normalizedPath.split("/"),last=rel.fragment||rel.query?0:1;baseSegments.length>0&&iriSegments.length>last&&baseSegments[0]===iriSegments[0];)baseSegments.shift(),iriSegments.shift();var rval="";if(baseSegments.length>0){baseSegments.pop();for(var i=0;i<baseSegments.length;++i)rval+="../"}return rval+=iriSegments.join("/"),null!==rel.query&&(rval+="?"+rel.query),null!==rel.fragment&&(rval+="#"+rel.fragment),""===rval&&(rval="./"),rval}function _getInitialContext(options){function _createInverseContext(){var activeCtx=this;if(activeCtx.inverse)return activeCtx.inverse;for(var inverse=activeCtx.inverse={},fastCurieMap=activeCtx.fastCurieMap={},irisToTerms={},defaultLanguage=activeCtx["@language"]||"@none",mappings=activeCtx.mappings,terms=Object.keys(mappings).sort(_compareShortestLeast),i=0;i<terms.length;++i){var term=terms[i],mapping=mappings[term];if(null!==mapping){var container=mapping["@container"]||"@none",ids=mapping["@id"];_isArray(ids)||(ids=[ids]);for(var ii=0;ii<ids.length;++ii){var iri=ids[ii],entry=inverse[iri],isKeyword=_isKeyword(iri);if(entry)isKeyword||mapping._termHasColon||irisToTerms[iri].push(term);else if(inverse[iri]=entry={},!isKeyword&&!mapping._termHasColon){irisToTerms[iri]=[term];var fastCurieEntry={iri:iri,terms:irisToTerms[iri]};iri[0]in fastCurieMap?fastCurieMap[iri[0]].push(fastCurieEntry):fastCurieMap[iri[0]]=[fastCurieEntry]}if(entry[container]||(entry[container]={"@language":{},"@type":{}}),entry=entry[container],mapping.reverse)_addPreferredTerm(mapping,term,entry["@type"],"@reverse");else if("@type"in mapping)_addPreferredTerm(mapping,term,entry["@type"],mapping["@type"]);else if("@language"in mapping){var language=mapping["@language"]||"@null";_addPreferredTerm(mapping,term,entry["@language"],language)}else _addPreferredTerm(mapping,term,entry["@language"],defaultLanguage),_addPreferredTerm(mapping,term,entry["@type"],"@none"),_addPreferredTerm(mapping,term,entry["@language"],"@none")}}}for(var key in fastCurieMap)_buildIriMap(fastCurieMap,key,1);return inverse}function _buildIriMap(iriMap,key,idx){for(var iri,letter,entries=iriMap[key],next=iriMap[key]={},i=0;i<entries.length;++i)iri=entries[i].iri,letter=idx>=iri.length?"":iri[idx],letter in next?next[letter].push(entries[i]):next[letter]=[entries[i]];for(var key in next)""!==key&&_buildIriMap(next,key,idx+1)}function _addPreferredTerm(mapping,term,entry,typeOrLanguageValue){typeOrLanguageValue in entry||(entry[typeOrLanguageValue]=term)}function _cloneActiveContext(){var child={};return child["@base"]=this["@base"],child.mappings=_clone(this.mappings),child.clone=this.clone,child.inverse=null,child.getInverse=this.getInverse,"@language"in this&&(child["@language"]=this["@language"]),"@vocab"in this&&(child["@vocab"]=this["@vocab"]),child}var base=jsonld.url.parse(options.base||"");return{"@base":base,mappings:{},inverse:null,getInverse:_createInverseContext,clone:_cloneActiveContext}}function _isKeyword(v){if(!_isString(v))return!1;switch(v){case"@base":case"@context":case"@container":case"@default":case"@embed":case"@explicit":case"@graph":case"@id":case"@index":case"@language":case"@list":case"@omitDefault":case"@preserve":case"@requireAll":case"@reverse":case"@set":case"@type":case"@value":case"@vocab":return!0}return!1}function _isObject(v){return"[object Object]"===Object.prototype.toString.call(v)}function _isEmptyObject(v){return _isObject(v)&&0===Object.keys(v).length}function _isArray(v){return Array.isArray(v)}function _validateTypeValue(v){if(!_isString(v)&&!_isEmptyObject(v)){var isValid=!1;if(_isArray(v)){isValid=!0;for(var i=0;i<v.length;++i)if(!_isString(v[i])){isValid=!1;break}}if(!isValid)throw new JsonLdError('Invalid JSON-LD syntax; "@type" value must a string, an array of strings, or an empty object.',"jsonld.SyntaxError",{code:"invalid type value",value:v})}}function _isString(v){return"string"==typeof v||"[object String]"===Object.prototype.toString.call(v)}function _isNumber(v){return"number"==typeof v||"[object Number]"===Object.prototype.toString.call(v)}function _isDouble(v){return _isNumber(v)&&-1!==String(v).indexOf(".")}function _isNumeric(v){return!isNaN(parseFloat(v))&&isFinite(v)}function _isBoolean(v){return"boolean"==typeof v||"[object Boolean]"===Object.prototype.toString.call(v)}function _isUndefined(v){return"undefined"==typeof v}function _isSubject(v){var rval=!1;if(_isObject(v)&&!("@value"in v||"@set"in v||"@list"in v)){var keyCount=Object.keys(v).length;rval=keyCount>1||!("@id"in v)}return rval}function _isSubjectReference(v){return _isObject(v)&&1===Object.keys(v).length&&"@id"in v}function _isValue(v){return _isObject(v)&&"@value"in v}function _isList(v){return _isObject(v)&&"@list"in v}function _isBlankNode(v){var rval=!1;return _isObject(v)&&(rval="@id"in v?0===v["@id"].indexOf("_:"):0===Object.keys(v).length||!("@value"in v||"@set"in v||"@list"in v)),rval}function _isAbsoluteIri(v){return _isString(v)&&-1!==v.indexOf(":")}function _clone(value){if(value&&"object"==typeof value){var rval;if(_isArray(value)){rval=[];for(var i=0;i<value.length;++i)rval[i]=_clone(value[i])}else if(_isObject(value)){rval={};for(var key in value)rval[key]=_clone(value[key])}else rval=value.toString();return rval}return value}function _findContextUrls(input,urls,replace,base){var count=Object.keys(urls).length;if(_isArray(input)){for(var i=0;i<input.length;++i)_findContextUrls(input[i],urls,replace,base);return count<Object.keys(urls).length}if(_isObject(input)){for(var key in input)if("@context"===key){var ctx=input[key];if(_isArray(ctx))for(var length=ctx.length,i=0;length>i;++i){var _ctx=ctx[i];_isString(_ctx)&&(_ctx=jsonld.prependBase(base,_ctx),replace?(_ctx=urls[_ctx],_isArray(_ctx)?(Array.prototype.splice.apply(ctx,[i,1].concat(_ctx)),i+=_ctx.length-1,length=ctx.length):ctx[i]=_ctx):_ctx in urls||(urls[_ctx]=!1))}else _isString(ctx)&&(ctx=jsonld.prependBase(base,ctx),replace?input[key]=urls[ctx]:ctx in urls||(urls[ctx]=!1))}else _findContextUrls(input[key],urls,replace,base);return count<Object.keys(urls).length}return!1}function _retrieveContextUrls(input,options,callback){var error=null,documentLoader=options.documentLoader,retrieve=function(input,cycles,documentLoader,base,callback){if(Object.keys(cycles).length>MAX_CONTEXT_URLS)return error=new JsonLdError("Maximum number of @context URLs exceeded.","jsonld.ContextUrlError",{code:"loading remote context failed",max:MAX_CONTEXT_URLS}),callback(error);var urls={},finished=function(){_findContextUrls(input,urls,!0,base),callback(null,input)};_findContextUrls(input,urls,!1,base)||finished();var queue=[];for(var url in urls)urls[url]===!1&&queue.push(url);for(var count=queue.length,i=0;i<queue.length;++i)!function(url){if(url in cycles)return error=new JsonLdError("Cyclical @context URLs detected.","jsonld.ContextUrlError",{code:"recursive context inclusion",url:url}),callback(error);var _cycles=_clone(cycles);_cycles[url]=!0;var done=function(err,remoteDoc){if(!error){var ctx=remoteDoc?remoteDoc.document:null;if(!err&&_isString(ctx))try{ctx=JSON.parse(ctx)}catch(ex){err=ex}if(err?err=new JsonLdError("Dereferencing a URL did not result in a valid JSON-LD object. Possible causes are an inaccessible URL perhaps due to a same-origin policy (ensure the server uses CORS if you are using client-side JavaScript), too many redirects, a non-JSON response, or more than one HTTP Link Header was provided for a remote context.","jsonld.InvalidUrl",{code:"loading remote context failed",url:url,cause:err}):_isObject(ctx)||(err=new JsonLdError("Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object.","jsonld.InvalidUrl",{code:"invalid remote context",url:url,cause:err})),err)return error=err,callback(error);ctx="@context"in ctx?{"@context":ctx["@context"]}:{"@context":{}},remoteDoc.contextUrl&&(_isArray(ctx["@context"])||(ctx["@context"]=[ctx["@context"]]),ctx["@context"].push(remoteDoc.contextUrl)),retrieve(ctx,_cycles,documentLoader,url,function(err,ctx){return err?callback(err):(urls[url]=ctx["@context"],count-=1,void(0===count&&finished()))})}},promise=documentLoader(url,done);promise&&"then"in promise&&promise.then(done.bind(null,null),done)}(queue[i])};retrieve(input,{},documentLoader,options.base,callback)}function _parseNQuads(input){for(var iri="(?:<([^:]+:[^>]*)>)",bnode="(_:(?:[A-Za-z0-9]+))",plain='"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"',datatype="(?:\\^\\^"+iri+")",language="(?:@([a-z]+(?:-[a-z0-9]+)*))",literal="(?:"+plain+"(?:"+datatype+"|"+language+")?)",comment="(?:#.*)?",ws="[ \\t]+",wso="[ \\t]*",eoln=/(?:\r\n)|(?:\n)|(?:\r)/g,empty=new RegExp("^"+wso+comment+"$"),subject="(?:"+iri+"|"+bnode+")"+ws,property=iri+ws,object="(?:"+iri+"|"+bnode+"|"+literal+")"+wso,graphName="(?:\\.|(?:(?:"+iri+"|"+bnode+")"+wso+"\\.))",quad=new RegExp("^"+wso+subject+property+object+graphName+wso+comment+"$"),dataset={},lines=input.split(eoln),lineNumber=0,li=0;li<lines.length;++li){var line=lines[li];if(lineNumber++,!empty.test(line)){var match=line.match(quad);if(null===match)throw new JsonLdError("Error while parsing N-Quads; invalid quad.","jsonld.ParseError",{line:lineNumber});var triple={};if(triple.subject=_isUndefined(match[1])?{type:"blank node",value:match[2]}:{type:"IRI",value:match[1]},triple.predicate={type:"IRI",value:match[3]},_isUndefined(match[4]))if(_isUndefined(match[5])){triple.object={type:"literal"},_isUndefined(match[7])?_isUndefined(match[8])?triple.object.datatype=XSD_STRING:(triple.object.datatype=RDF_LANGSTRING,triple.object.language=match[8]):triple.object.datatype=match[7];var unescaped=match[6].replace(/\\"/g,'"').replace(/\\t/g,"	").replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/\\\\/g,"\\");triple.object.value=unescaped}else triple.object={type:"blank node",value:match[5]};else triple.object={type:"IRI",value:match[4]};var name="@default";if(_isUndefined(match[9])?_isUndefined(match[10])||(name=match[10]):name=match[9],name in dataset){for(var unique=!0,triples=dataset[name],ti=0;unique&&ti<triples.length;++ti)_compareRDFTriples(triples[ti],triple)&&(unique=!1);unique&&triples.push(triple)}else dataset[name]=[triple]}}return dataset}function _toNQuads(dataset){var quads=[];for(var graphName in dataset)for(var triples=dataset[graphName],ti=0;ti<triples.length;++ti){var triple=triples[ti];"@default"===graphName&&(graphName=null),quads.push(_toNQuad(triple,graphName))}return quads.sort().join("")}function _toNQuad(triple,graphName){var s=triple.subject,p=triple.predicate,o=triple.object,g=graphName||null;"name"in triple&&triple.name&&(g=triple.name.value);var quad="";if(quad+="IRI"===s.type?"<"+s.value+">":s.value,quad+=" ",quad+="IRI"===p.type?"<"+p.value+">":p.value,quad+=" ","IRI"===o.type)quad+="<"+o.value+">";else if("blank node"===o.type)quad+=o.value;else{var escaped=o.value.replace(/\\/g,"\\\\").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\"/g,'\\"');quad+='"'+escaped+'"',o.datatype===RDF_LANGSTRING?o.language&&(quad+="@"+o.language):o.datatype!==XSD_STRING&&(quad+="^^<"+o.datatype+">")}return null!==g&&void 0!==g&&(quad+=0!==g.indexOf("_:")?" <"+g+">":" "+g),quad+=" .\n"}function _parseRdfaApiData(data){var dataset={};dataset["@default"]=[];for(var subjects=data.getSubjects(),si=0;si<subjects.length;++si){var subject=subjects[si];if(null!==subject){var triples=data.getSubjectTriples(subject);if(null!==triples){var predicates=triples.predicates;for(var predicate in predicates)for(var objects=predicates[predicate].objects,oi=0;oi<objects.length;++oi){var object=objects[oi],triple={};triple.subject=0===subject.indexOf("_:")?{type:"blank node",value:subject}:{type:"IRI",value:subject},triple.predicate=0===predicate.indexOf("_:")?{type:"blank node",value:predicate}:{type:"IRI",value:predicate};var value=object.value;if(object.type===RDF_XML_LITERAL){XMLSerializer||_defineXMLSerializer();var serializer=new XMLSerializer;value="";for(var x=0;x<object.value.length;x++)object.value[x].nodeType===Node.ELEMENT_NODE?value+=serializer.serializeToString(object.value[x]):object.value[x].nodeType===Node.TEXT_NODE&&(value+=object.value[x].nodeValue)}triple.object={},object.type===RDF_OBJECT?triple.object.type=0===object.value.indexOf("_:")?"blank node":"IRI":(triple.object.type="literal",object.type===RDF_PLAIN_LITERAL?object.language?(triple.object.datatype=RDF_LANGSTRING,triple.object.language=object.language):triple.object.datatype=XSD_STRING:triple.object.datatype=object.type),triple.object.value=value,dataset["@default"].push(triple)}}}}return dataset}function IdentifierIssuer(prefix){this.prefix=prefix,this.counter=0,this.existing={}}function _removeDotSegments(path,hasAuthority){var rval="";0===path.indexOf("/")&&(rval="/");for(var input=path.split("/"),output=[];input.length>0;)"."===input[0]||""===input[0]&&input.length>1?input.shift():".."!==input[0]?output.push(input.shift()):(input.shift(),hasAuthority||output.length>0&&".."!==output[output.length-1]?output.pop():output.push(".."));return rval+output.join("/")}jsonld.compact=function(input,ctx,options,callback){function cleanup(err,compacted,activeCtx,options){if(err)return callback(err);options.compactArrays&&!options.graph&&_isArray(compacted)?1===compacted.length?compacted=compacted[0]:0===compacted.length&&(compacted={}):options.graph&&_isObject(compacted)&&(compacted=[compacted]),_isObject(ctx)&&"@context"in ctx&&(ctx=ctx["@context"]),ctx=_clone(ctx),_isArray(ctx)||(ctx=[ctx]);var tmp=ctx;ctx=[];for(var i=0;i<tmp.length;++i)(!_isObject(tmp[i])||Object.keys(tmp[i]).length>0)&&ctx.push(tmp[i]);var hasContext=ctx.length>0;if(1===ctx.length&&(ctx=ctx[0]),_isArray(compacted)){var kwgraph=_compactIri(activeCtx,"@graph"),graph=compacted;compacted={},hasContext&&(compacted["@context"]=ctx),compacted[kwgraph]=graph}else if(_isObject(compacted)&&hasContext){var graph=compacted;compacted={"@context":ctx};for(var key in graph)compacted[key]=graph[key]}callback(null,compacted,activeCtx)}if(arguments.length<2)return jsonld.nextTick(function(){callback(new TypeError("Could not compact, too few arguments."))});if("function"==typeof options&&(callback=options,options={}),options=options||{},null===ctx)return jsonld.nextTick(function(){callback(new JsonLdError("The compaction context must not be null.","jsonld.CompactError",{code:"invalid local context"}))});if(null===input)return jsonld.nextTick(function(){callback(null,null)});"base"in options||(options.base="string"==typeof input?input:""),"compactArrays"in options||(options.compactArrays=!0),"graph"in options||(options.graph=!1),"skipExpansion"in options||(options.skipExpansion=!1),"documentLoader"in options||(options.documentLoader=jsonld.loadDocument),"link"in options||(options.link=!1),options.link&&(options.skipExpansion=!0);var expand=function(input,options,callback){return options.skipExpansion?jsonld.nextTick(function(){callback(null,input)}):void jsonld.expand(input,options,callback)};expand(input,options,function(err,expanded){if(err)return callback(new JsonLdError("Could not expand input before compaction.","jsonld.CompactError",{cause:err}));var activeCtx=_getInitialContext(options);jsonld.processContext(activeCtx,ctx,options,function(err,activeCtx){if(err)return callback(new JsonLdError("Could not process context before compaction.","jsonld.CompactError",{cause:err}));var compacted;try{compacted=(new Processor).compact(activeCtx,null,expanded,options)}catch(ex){return callback(ex)}cleanup(null,compacted,activeCtx,options)})})},jsonld.expand=function(input,options,callback){function expand(remoteDoc){"base"in options||(options.base=remoteDoc.documentUrl||"");var input={document:_clone(remoteDoc.document),remoteContext:{"@context":remoteDoc.contextUrl
  }};if("expandContext"in options){var expandContext=_clone(options.expandContext);input.expandContext="object"==typeof expandContext&&"@context"in expandContext?expandContext:{"@context":expandContext}}_retrieveContextUrls(input,options,function(err,input){if(err)return callback(err);var expanded;try{var processor=new Processor,activeCtx=_getInitialContext(options),document=input.document,remoteContext=input.remoteContext["@context"];input.expandContext&&(activeCtx=processor.processContext(activeCtx,input.expandContext["@context"],options)),remoteContext&&(activeCtx=processor.processContext(activeCtx,remoteContext,options)),expanded=processor.expand(activeCtx,null,document,options,!1),_isObject(expanded)&&"@graph"in expanded&&1===Object.keys(expanded).length?expanded=expanded["@graph"]:null===expanded&&(expanded=[]),_isArray(expanded)||(expanded=[expanded])}catch(ex){return callback(ex)}callback(null,expanded)})}return arguments.length<1?jsonld.nextTick(function(){callback(new TypeError("Could not expand, too few arguments."))}):("function"==typeof options&&(callback=options,options={}),options=options||{},"documentLoader"in options||(options.documentLoader=jsonld.loadDocument),"keepFreeFloatingNodes"in options||(options.keepFreeFloatingNodes=!1),void jsonld.nextTick(function(){if("string"==typeof input){var done=function(err,remoteDoc){if(err)return callback(err);try{if(!remoteDoc.document)throw new JsonLdError("No remote document found at the given URL.","jsonld.NullRemoteDocument");"string"==typeof remoteDoc.document&&(remoteDoc.document=JSON.parse(remoteDoc.document))}catch(ex){return callback(new JsonLdError("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed",cause:ex,remoteDoc:remoteDoc}))}expand(remoteDoc)},promise=options.documentLoader(input,done);return void(promise&&"then"in promise&&promise.then(done.bind(null,null),done))}expand({contextUrl:null,documentUrl:null,document:input})}))},jsonld.flatten=function(input,ctx,options,callback){return arguments.length<1?jsonld.nextTick(function(){callback(new TypeError("Could not flatten, too few arguments."))}):("function"==typeof options?(callback=options,options={}):"function"==typeof ctx&&(callback=ctx,ctx=null,options={}),options=options||{},"base"in options||(options.base="string"==typeof input?input:""),"documentLoader"in options||(options.documentLoader=jsonld.loadDocument),void jsonld.expand(input,options,function(err,_input){if(err)return callback(new JsonLdError("Could not expand input before flattening.","jsonld.FlattenError",{cause:err}));var flattened;try{flattened=(new Processor).flatten(_input)}catch(ex){return callback(ex)}return null===ctx?callback(null,flattened):(options.graph=!0,options.skipExpansion=!0,void jsonld.compact(flattened,ctx,options,function(err,compacted){return err?callback(new JsonLdError("Could not compact flattened output.","jsonld.FlattenError",{cause:err})):void callback(null,compacted)}))}))},jsonld.frame=function(input,frame,options,callback){function doFrame(remoteFrame){var ctx,frame=remoteFrame.document;frame?(ctx=frame["@context"],remoteFrame.contextUrl?(ctx?_isArray(ctx)?ctx.push(remoteFrame.contextUrl):ctx=[ctx,remoteFrame.contextUrl]:ctx=remoteFrame.contextUrl,frame["@context"]=ctx):ctx=ctx||{}):ctx={},jsonld.expand(input,options,function(err,expanded){if(err)return callback(new JsonLdError("Could not expand input before framing.","jsonld.FrameError",{cause:err}));var opts=_clone(options);opts.isFrame=!0,opts.keepFreeFloatingNodes=!0,jsonld.expand(frame,opts,function(err,expandedFrame){if(err)return callback(new JsonLdError("Could not expand frame before framing.","jsonld.FrameError",{cause:err}));var framed;try{framed=(new Processor).frame(expanded,expandedFrame,opts)}catch(ex){return callback(ex)}opts.graph=!0,opts.skipExpansion=!0,opts.link={},jsonld.compact(framed,ctx,opts,function(err,compacted,ctx){if(err)return callback(new JsonLdError("Could not compact framed output.","jsonld.FrameError",{cause:err}));var graph=_compactIri(ctx,"@graph");opts.link={},compacted[graph]=_removePreserve(ctx,compacted[graph],opts),callback(null,compacted)})})})}return arguments.length<2?jsonld.nextTick(function(){callback(new TypeError("Could not frame, too few arguments."))}):("function"==typeof options&&(callback=options,options={}),options=options||{},"base"in options||(options.base="string"==typeof input?input:""),"documentLoader"in options||(options.documentLoader=jsonld.loadDocument),"embed"in options||(options.embed="@last"),options.explicit=options.explicit||!1,"requireAll"in options||(options.requireAll=!0),options.omitDefault=options.omitDefault||!1,void jsonld.nextTick(function(){if("string"==typeof frame){var done=function(err,remoteDoc){if(err)return callback(err);try{if(!remoteDoc.document)throw new JsonLdError("No remote document found at the given URL.","jsonld.NullRemoteDocument");"string"==typeof remoteDoc.document&&(remoteDoc.document=JSON.parse(remoteDoc.document))}catch(ex){return callback(new JsonLdError("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed",cause:ex,remoteDoc:remoteDoc}))}doFrame(remoteDoc)},promise=options.documentLoader(frame,done);return void(promise&&"then"in promise&&promise.then(done.bind(null,null),done))}doFrame({contextUrl:null,documentUrl:null,document:frame})}))},jsonld.link=function(input,ctx,options,callback){var frame={};ctx&&(frame["@context"]=ctx),frame["@embed"]="@link",jsonld.frame(input,frame,options,callback)},jsonld.objectify=function(input,ctx,options,callback){"function"==typeof options&&(callback=options,options={}),options=options||{},"base"in options||(options.base="string"==typeof input?input:""),"documentLoader"in options||(options.documentLoader=jsonld.loadDocument),jsonld.expand(input,options,function(err,_input){if(err)return callback(new JsonLdError("Could not expand input before linking.","jsonld.LinkError",{cause:err}));var flattened;try{flattened=(new Processor).flatten(_input)}catch(ex){return callback(ex)}options.graph=!0,options.skipExpansion=!0,jsonld.compact(flattened,ctx,options,function(err,compacted,ctx){if(err)return callback(new JsonLdError("Could not compact flattened output before linking.","jsonld.LinkError",{cause:err}));var graph=_compactIri(ctx,"@graph"),top=compacted[graph][0],recurse=function(subject){if(_isObject(subject)||_isArray(subject)){if(_isObject(subject)){if(recurse.visited[subject["@id"]])return;recurse.visited[subject["@id"]]=!0}for(var k in subject){var obj=subject[k],isid="@id"===jsonld.getContextValue(ctx,k,"@type");if(_isArray(obj)||_isObject(obj)||isid)if(_isString(obj)&&isid)subject[k]=obj=top[obj],recurse(obj);else if(_isArray(obj))for(var i=0;i<obj.length;++i)_isString(obj[i])&&isid?obj[i]=top[obj[i]]:_isObject(obj[i])&&"@id"in obj[i]&&(obj[i]=top[obj[i]["@id"]]),recurse(obj[i]);else if(_isObject(obj)){var sid=obj["@id"];subject[k]=obj=top[sid],recurse(obj)}}}};recurse.visited={},recurse(top),compacted.of_type={};for(var s in top)if("@type"in top[s]){var types=top[s]["@type"];_isArray(types)||(types=[types]);for(var t=0;t<types.length;++t)types[t]in compacted.of_type||(compacted.of_type[types[t]]=[]),compacted.of_type[types[t]].push(top[s])}callback(null,compacted)})})},jsonld.normalize=function(input,options,callback){if(arguments.length<1)return jsonld.nextTick(function(){callback(new TypeError("Could not normalize, too few arguments."))});if("function"==typeof options&&(callback=options,options={}),options=options||{},"algorithm"in options||(options.algorithm="URGNA2012"),"base"in options||(options.base="string"==typeof input?input:""),"documentLoader"in options||(options.documentLoader=jsonld.loadDocument),"inputFormat"in options){if("application/nquads"!==options.inputFormat)return callback(new JsonLdError("Unknown normalization input format.","jsonld.NormalizeError"));var parsedInput=_parseNQuads(input);(new Processor).normalize(parsedInput,options,callback)}else{var opts=_clone(options);delete opts.format,opts.produceGeneralizedRdf=!1,jsonld.toRDF(input,opts,function(err,dataset){return err?callback(new JsonLdError("Could not convert input to RDF dataset before normalization.","jsonld.NormalizeError",{cause:err})):void(new Processor).normalize(dataset,options,callback)})}},jsonld.fromRDF=function(dataset,options,callback){return arguments.length<1?jsonld.nextTick(function(){callback(new TypeError("Could not convert from RDF, too few arguments."))}):("function"==typeof options&&(callback=options,options={}),options=options||{},"useRdfType"in options||(options.useRdfType=!1),"useNativeTypes"in options||(options.useNativeTypes=!1),"format"in options||!_isString(dataset)||"format"in options||(options.format="application/nquads"),void jsonld.nextTick(function(){function fromRDF(dataset,options,callback){(new Processor).fromRDF(dataset,options,callback)}var rdfParser;if(options.format){if(rdfParser=options.rdfParser||_rdfParsers[options.format],!rdfParser)return callback(new JsonLdError("Unknown input format.","jsonld.UnknownFormat",{format:options.format}))}else rdfParser=function(){return dataset};var callbackCalled=!1;try{dataset=rdfParser(dataset,function(err,dataset){return callbackCalled=!0,err?callback(err):void fromRDF(dataset,options,callback)})}catch(e){if(!callbackCalled)return callback(e);throw e}if(dataset){if("then"in dataset)return dataset.then(function(dataset){fromRDF(dataset,options,callback)},callback);fromRDF(dataset,options,callback)}}))},jsonld.toRDF=function(input,options,callback){return arguments.length<1?jsonld.nextTick(function(){callback(new TypeError("Could not convert to RDF, too few arguments."))}):("function"==typeof options&&(callback=options,options={}),options=options||{},"base"in options||(options.base="string"==typeof input?input:""),"documentLoader"in options||(options.documentLoader=jsonld.loadDocument),void jsonld.expand(input,options,function(err,expanded){if(err)return callback(new JsonLdError("Could not expand input before serialization to RDF.","jsonld.RdfError",{cause:err}));var dataset;try{if(dataset=Processor.prototype.toRDF(expanded,options),options.format){if("application/nquads"===options.format)return callback(null,_toNQuads(dataset));throw new JsonLdError("Unknown output format.","jsonld.UnknownFormat",{format:options.format})}}catch(ex){return callback(ex)}callback(null,dataset)}))},jsonld.createNodeMap=function(input,options,callback){return arguments.length<1?jsonld.nextTick(function(){callback(new TypeError("Could not create node map, too few arguments."))}):("function"==typeof options&&(callback=options,options={}),options=options||{},"base"in options||(options.base="string"==typeof input?input:""),"documentLoader"in options||(options.documentLoader=jsonld.loadDocument),void jsonld.expand(input,options,function(err,_input){if(err)return callback(new JsonLdError("Could not expand input before creating node map.","jsonld.CreateNodeMapError",{cause:err}));var nodeMap;try{nodeMap=(new Processor).createNodeMap(_input,options)}catch(ex){return callback(ex)}callback(null,nodeMap)}))},jsonld.merge=function(docs,ctx,options,callback){function expandComplete(err,_input){if(!error){if(err)return error=err,callback(new JsonLdError("Could not expand input before flattening.","jsonld.FlattenError",{cause:err}));expanded.push(_input),0===--count&&merge(expanded)}}function merge(expanded){var mergeNodes=!0;"mergeNodes"in options&&(mergeNodes=options.mergeNodes);var defaultGraph,issuer=options.namer||options.issuer||new IdentifierIssuer("_:b"),graphs={"@default":{}};try{for(var i=0;i<expanded.length;++i){var doc=expanded[i];doc=jsonld.relabelBlankNodes(doc,{issuer:new IdentifierIssuer("_:b"+i+"-")});var _graphs=mergeNodes||0===i?graphs:{"@default":{}};if(_createNodeMap(doc,_graphs,"@default",issuer),_graphs!==graphs)for(var graphName in _graphs){var _nodeMap=_graphs[graphName];if(graphName in graphs){var nodeMap=graphs[graphName];for(var key in _nodeMap)key in nodeMap||(nodeMap[key]=_nodeMap[key])}else graphs[graphName]=_nodeMap}}defaultGraph=_mergeNodeMaps(graphs)}catch(ex){return callback(ex)}for(var flattened=[],keys=Object.keys(defaultGraph).sort(),ki=0;ki<keys.length;++ki){var node=defaultGraph[keys[ki]];_isSubjectReference(node)||flattened.push(node)}return null===ctx?callback(null,flattened):(options.graph=!0,options.skipExpansion=!0,void jsonld.compact(flattened,ctx,options,function(err,compacted){return err?callback(new JsonLdError("Could not compact merged output.","jsonld.MergeError",{cause:err})):void callback(null,compacted)}))}if(arguments.length<1)return jsonld.nextTick(function(){callback(new TypeError("Could not merge, too few arguments."))});if(!_isArray(docs))return jsonld.nextTick(function(){callback(new TypeError('Could not merge, "docs" must be an array.'))});"function"==typeof options?(callback=options,options={}):"function"==typeof ctx&&(callback=ctx,ctx=null,options={}),options=options||{};for(var expanded=[],error=null,count=docs.length,i=0;i<docs.length;++i){var opts={};for(var key in options)opts[key]=options[key];jsonld.expand(docs[i],opts,expandComplete)}},jsonld.relabelBlankNodes=function(input,options){options=options||{};var issuer=options.namer||options.issuer||new IdentifierIssuer("_:b");return _labelBlankNodes(issuer,input)},jsonld.prependBase=function(base,iri){return _prependBase(base,iri)},jsonld.documentLoader=function(url,callback){var err=new JsonLdError("Could not retrieve a JSON-LD document from the URL. URL dereferencing not implemented.","jsonld.LoadDocumentError",{code:"loading document failed"});return _nodejs?callback(err,{contextUrl:null,documentUrl:url,document:null}):jsonld.promisify(function(callback){callback(err)})},jsonld.loadDocument=function(url,callback){var promise=jsonld.documentLoader(url,callback);promise&&"then"in promise&&promise.then(callback.bind(null,null),callback)},jsonld.promises=function(options){options=options||{};var slice=Array.prototype.slice,promisify=jsonld.promisify,api=options.api||{},version=options.version||"jsonld.js";"string"==typeof options.api&&(options.version||(version=options.api),api={}),api.expand=function(){if(arguments.length<1)throw new TypeError("Could not expand, too few arguments.");return promisify.apply(null,[jsonld.expand].concat(slice.call(arguments)))},api.compact=function(){if(arguments.length<2)throw new TypeError("Could not compact, too few arguments.");var compact=function(input,ctx,options,callback){jsonld.compact(input,ctx,options,function(err,compacted){callback(err,compacted)})};return promisify.apply(null,[compact].concat(slice.call(arguments)))},api.flatten=function(){if(arguments.length<1)throw new TypeError("Could not flatten, too few arguments.");return promisify.apply(null,[jsonld.flatten].concat(slice.call(arguments)))},api.frame=function(){if(arguments.length<2)throw new TypeError("Could not frame, too few arguments.");return promisify.apply(null,[jsonld.frame].concat(slice.call(arguments)))},api.fromRDF=function(){if(arguments.length<1)throw new TypeError("Could not convert from RDF, too few arguments.");return promisify.apply(null,[jsonld.fromRDF].concat(slice.call(arguments)))},api.toRDF=function(){if(arguments.length<1)throw new TypeError("Could not convert to RDF, too few arguments.");return promisify.apply(null,[jsonld.toRDF].concat(slice.call(arguments)))},api.normalize=function(){if(arguments.length<1)throw new TypeError("Could not normalize, too few arguments.");return promisify.apply(null,[jsonld.normalize].concat(slice.call(arguments)))},"jsonld.js"===version&&(api.link=function(){if(arguments.length<2)throw new TypeError("Could not link, too few arguments.");return promisify.apply(null,[jsonld.link].concat(slice.call(arguments)))},api.objectify=function(){return promisify.apply(null,[jsonld.objectify].concat(slice.call(arguments)))},api.createNodeMap=function(){return promisify.apply(null,[jsonld.createNodeMap].concat(slice.call(arguments)))},api.merge=function(){return promisify.apply(null,[jsonld.merge].concat(slice.call(arguments)))});try{jsonld.Promise=global.Promise||require("es6-promise").Promise}catch(e){var f=function(){throw new Error("Unable to find a Promise implementation.")};for(var method in api)api[method]=f}return api},jsonld.promisify=function(op){if(!jsonld.Promise)try{jsonld.Promise=global.Promise||require("es6-promise").Promise}catch(e){throw new Error("Unable to find a Promise implementation.")}var args=Array.prototype.slice.call(arguments,1);return new jsonld.Promise(function(resolve,reject){op.apply(null,args.concat(function(err,value){err?reject(err):resolve(value)}))})},jsonld.promises({api:jsonld.promises}),JsonLdProcessor.prototype=jsonld.promises({version:"json-ld-1.0"}),JsonLdProcessor.prototype.toString=function(){return this instanceof JsonLdProcessor?"[object JsonLdProcessor]":"[object JsonLdProcessorPrototype]"},jsonld.JsonLdProcessor=JsonLdProcessor;var canDefineProperty=!!Object.defineProperty;if(canDefineProperty)try{Object.defineProperty({},"x",{})}catch(e){canDefineProperty=!1}canDefineProperty&&(Object.defineProperty(JsonLdProcessor,"prototype",{writable:!1,enumerable:!1}),Object.defineProperty(JsonLdProcessor.prototype,"constructor",{writable:!0,enumerable:!1,configurable:!0,value:JsonLdProcessor})),_browser&&"undefined"==typeof global.JsonLdProcessor&&(canDefineProperty?Object.defineProperty(global,"JsonLdProcessor",{writable:!0,enumerable:!1,configurable:!0,value:JsonLdProcessor}):global.JsonLdProcessor=JsonLdProcessor);var _setImmediate="function"==typeof setImmediate&&setImmediate,_delay=_setImmediate?function(fn){_setImmediate(fn)}:function(fn){setTimeout(fn,0)};jsonld.nextTick="object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:_delay,jsonld.setImmediate=_setImmediate?_delay:jsonld.nextTick,jsonld.parseLinkHeader=function(header){for(var rval={},entries=header.match(/(?:<[^>]*?>|"[^"]*?"|[^,])+/g),rLinkHeader=/\s*<([^>]*?)>\s*(?:;\s*(.*))?/,i=0;i<entries.length;++i){var match=entries[i].match(rLinkHeader);if(match){for(var result={target:match[1]},params=match[2],rParams=/(.*?)=(?:(?:"([^"]*?)")|([^"]*?))\s*(?:(?:;\s*)|$)/g;match=rParams.exec(params);)result[match[1]]=void 0===match[2]?match[3]:match[2];var rel=result.rel||"";_isArray(rval[rel])?rval[rel].push(result):rval[rel]=rel in rval?[rval[rel],result]:result}}return rval},jsonld.RequestQueue=function(){this._requests={}},jsonld.RequestQueue.prototype.wrapLoader=function(loader){return this._loader=loader,this._usePromise=1===loader.length,this.add.bind(this)},jsonld.RequestQueue.prototype.add=function(url,callback){var self=this;if(!callback&&!self._usePromise)throw new Error("callback must be specified.");return self._usePromise?new jsonld.Promise(function(resolve,reject){var load=self._requests[url];load||(load=self._requests[url]=self._loader(url).then(function(remoteDoc){return delete self._requests[url],remoteDoc})["catch"](function(err){throw delete self._requests[url],err})),load.then(function(remoteDoc){resolve(remoteDoc)})["catch"](function(err){reject(err)})}):void(url in self._requests?self._requests[url].push(callback):(self._requests[url]=[callback],self._loader(url,function(err,remoteDoc){var callbacks=self._requests[url];delete self._requests[url];for(var i=0;i<callbacks.length;++i)callbacks[i](err,remoteDoc)})))},jsonld.DocumentCache=function(size){this.order=[],this.cache={},this.size=size||50,this.expires=3e4},jsonld.DocumentCache.prototype.get=function(url){if(url in this.cache){var entry=this.cache[url];if(entry.expires>=+new Date)return entry.ctx;delete this.cache[url],this.order.splice(this.order.indexOf(url),1)}return null},jsonld.DocumentCache.prototype.set=function(url,ctx){this.order.length===this.size&&delete this.cache[this.order.shift()],this.order.push(url),this.cache[url]={ctx:ctx,expires:+new Date+this.expires}},jsonld.ActiveContextCache=function(size){this.order=[],this.cache={},this.size=size||100},jsonld.ActiveContextCache.prototype.get=function(activeCtx,localCtx){var key1=JSON.stringify(activeCtx),key2=JSON.stringify(localCtx),level1=this.cache[key1];return level1&&key2 in level1?level1[key2]:null},jsonld.ActiveContextCache.prototype.set=function(activeCtx,localCtx,result){if(this.order.length===this.size){var entry=this.order.shift();delete this.cache[entry.activeCtx][entry.localCtx]}var key1=JSON.stringify(activeCtx),key2=JSON.stringify(localCtx);this.order.push({activeCtx:key1,localCtx:key2}),key1 in this.cache||(this.cache[key1]={}),this.cache[key1][key2]=_clone(result)},jsonld.cache={activeCtx:new jsonld.ActiveContextCache},jsonld.documentLoaders={},jsonld.documentLoaders.jquery=function($,options){function loader(url,callback){return 0!==url.indexOf("http:")&&0!==url.indexOf("https:")?callback(new JsonLdError('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:url}),{contextUrl:null,documentUrl:url,document:null}):options.secure&&0!==url.indexOf("https")?callback(new JsonLdError('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:url}),{contextUrl:null,documentUrl:url,document:null}):void $.ajax({url:url,accepts:{json:"application/ld+json, application/json"},headers:{Accept:"application/ld+json, application/json"},dataType:"json",crossDomain:!0,success:function(data,textStatus,jqXHR){var doc={contextUrl:null,documentUrl:url,document:data},contentType=jqXHR.getResponseHeader("Content-Type"),linkHeader=jqXHR.getResponseHeader("Link");if(linkHeader&&"application/ld+json"!==contentType){if(linkHeader=jsonld.parseLinkHeader(linkHeader)[LINK_HEADER_REL],_isArray(linkHeader))return callback(new JsonLdError("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:url}),doc);linkHeader&&(doc.contextUrl=linkHeader.target)}callback(null,doc)},error:function(jqXHR,textStatus,err){callback(new JsonLdError("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:url,cause:err}),{contextUrl:null,documentUrl:url,document:null})}})}options=options||{};var queue=new jsonld.RequestQueue,usePromise="usePromise"in options?options.usePromise:"undefined"!=typeof Promise;return queue.wrapLoader(usePromise?function(url){return jsonld.promisify(loader,url)}:loader)},jsonld.documentLoaders.node=function(options){function loadDocument(url,redirects,callback){function handleResponse(err,res,body){if(doc={contextUrl:null,documentUrl:url,document:body||null},err)return callback(new JsonLdError("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:url,cause:err}),doc);var statusText=http.STATUS_CODES[res.statusCode];if(res.statusCode>=400)return callback(new JsonLdError("URL could not be dereferenced: "+statusText,"jsonld.InvalidUrl",{code:"loading document failed",url:url,httpStatusCode:res.statusCode}),doc);if(res.headers.link&&"application/ld+json"!==res.headers["content-type"]){var linkHeader=jsonld.parseLinkHeader(res.headers.link)[LINK_HEADER_REL];if(_isArray(linkHeader))return callback(new JsonLdError("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:url}),doc);linkHeader&&(doc.contextUrl=linkHeader.target)}return res.statusCode>=300&&res.statusCode<400&&res.headers.location?redirects.length===maxRedirects?callback(new JsonLdError("URL could not be dereferenced; there were too many redirects.","jsonld.TooManyRedirects",{code:"loading document failed",url:url,httpStatusCode:res.statusCode,redirects:redirects}),doc):-1!==redirects.indexOf(url)?callback(new JsonLdError("URL could not be dereferenced; infinite redirection was detected.","jsonld.InfiniteRedirectDetected",{code:"recursive context inclusion",url:url,httpStatusCode:res.statusCode,redirects:redirects}),doc):(redirects.push(url),loadDocument(res.headers.location,redirects,callback)):(redirects.push(url),void callback(err,doc))}if(0!==url.indexOf("http:")&&0!==url.indexOf("https:"))return callback(new JsonLdError('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:url}),{contextUrl:null,documentUrl:url,document:null});if(options.secure&&0!==url.indexOf("https"))return callback(new JsonLdError('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:url}),{contextUrl:null,documentUrl:url,document:null});var doc=null;if(null!==doc)return callback(null,doc);var headers={Accept:acceptHeader};for(var k in options.headers)headers[k]=options.headers[k];request({url:url,headers:headers,strictSSL:strictSSL,followRedirect:!1},handleResponse)}options=options||{};var strictSSL="strictSSL"in options?options.strictSSL:!0,maxRedirects="maxRedirects"in options?options.maxRedirects:-1,request="request"in options?options.request:require("request"),acceptHeader="application/ld+json, application/json",http=require("http"),queue=new jsonld.RequestQueue;if(options.usePromise)return queue.wrapLoader(function(url){return jsonld.promisify(loadDocument,url,[])});var headers=options.headers||{};if("Accept"in headers||"accept"in headers)throw new RangeError('Accept header may not be specified as an option; only "'+acceptHeader+'" is supported.');return queue.wrapLoader(function(url,callback){loadDocument(url,[],callback)})},jsonld.documentLoaders.xhr=function(options){function loader(url,callback){if(0!==url.indexOf("http:")&&0!==url.indexOf("https:"))return callback(new JsonLdError('URL could not be dereferenced; only "http" and "https" URLs are supported.',"jsonld.InvalidUrl",{code:"loading document failed",url:url}),{contextUrl:null,documentUrl:url,document:null});if(options.secure&&0!==url.indexOf("https"))return callback(new JsonLdError('URL could not be dereferenced; secure mode is enabled and the URL\'s scheme is not "https".',"jsonld.InvalidUrl",{code:"loading document failed",url:url}),{contextUrl:null,documentUrl:url,document:null});var xhr=options.xhr||XMLHttpRequest,req=new xhr;req.onload=function(){if(req.status>=400)return callback(new JsonLdError("URL could not be dereferenced: "+req.statusText,"jsonld.LoadDocumentError",{code:"loading document failed",url:url,httpStatusCode:req.status}),{contextUrl:null,documentUrl:url,document:null});var linkHeader,doc={contextUrl:null,documentUrl:url,document:req.response},contentType=req.getResponseHeader("Content-Type");if(rlink.test(req.getAllResponseHeaders())&&(linkHeader=req.getResponseHeader("Link")),linkHeader&&"application/ld+json"!==contentType){if(linkHeader=jsonld.parseLinkHeader(linkHeader)[LINK_HEADER_REL],_isArray(linkHeader))return callback(new JsonLdError("URL could not be dereferenced, it has more than one associated HTTP Link Header.","jsonld.InvalidUrl",{code:"multiple context link headers",url:url}),doc);linkHeader&&(doc.contextUrl=linkHeader.target)}callback(null,doc)},req.onerror=function(){callback(new JsonLdError("URL could not be dereferenced, an error occurred.","jsonld.LoadDocumentError",{code:"loading document failed",url:url}),{contextUrl:null,documentUrl:url,document:null})},req.open("GET",url,!0),req.setRequestHeader("Accept","application/ld+json, application/json"),req.send()}options=options||{};var rlink=/(^|(\r\n))link:/i,queue=new jsonld.RequestQueue,usePromise="usePromise"in options?options.usePromise:"undefined"!=typeof Promise;return queue.wrapLoader(usePromise?function(url){return jsonld.promisify(loader,url)}:loader)},jsonld.useDocumentLoader=function(type){if(!(type in jsonld.documentLoaders))throw new JsonLdError('Unknown document loader type: "'+type+'"',"jsonld.UnknownDocumentLoader",{type:type});jsonld.documentLoader=jsonld.documentLoaders[type].apply(jsonld,Array.prototype.slice.call(arguments,1))},jsonld.processContext=function(activeCtx,localCtx){var options={},callbackArg=2;arguments.length>3&&(options=arguments[2]||{},callbackArg+=1);var callback=arguments[callbackArg];return"base"in options||(options.base=""),"documentLoader"in options||(options.documentLoader=jsonld.loadDocument),null===localCtx?callback(null,_getInitialContext(options)):(localCtx=_clone(localCtx),_isObject(localCtx)&&"@context"in localCtx||(localCtx={"@context":localCtx}),void _retrieveContextUrls(localCtx,options,function(err,ctx){if(err)return callback(err);try{ctx=(new Processor).processContext(activeCtx,ctx,options)}catch(ex){return callback(ex)}callback(null,ctx)}))},jsonld.hasProperty=function(subject,property){var rval=!1;if(property in subject){var value=subject[property];rval=!_isArray(value)||value.length>0}return rval},jsonld.hasValue=function(subject,property,value){var rval=!1;if(jsonld.hasProperty(subject,property)){var val=subject[property],isList=_isList(val);if(_isArray(val)||isList){isList&&(val=val["@list"]);for(var i=0;i<val.length;++i)if(jsonld.compareValues(value,val[i])){rval=!0;break}}else _isArray(value)||(rval=jsonld.compareValues(value,val))}return rval},jsonld.addValue=function(subject,property,value,options){if(options=options||{},"propertyIsArray"in options||(options.propertyIsArray=!1),"allowDuplicate"in options||(options.allowDuplicate=!0),_isArray(value)){0!==value.length||!options.propertyIsArray||property in subject||(subject[property]=[]);for(var i=0;i<value.length;++i)jsonld.addValue(subject,property,value[i],options)}else if(property in subject){var hasValue=!options.allowDuplicate&&jsonld.hasValue(subject,property,value);_isArray(subject[property])||hasValue&&!options.propertyIsArray||(subject[property]=[subject[property]]),hasValue||subject[property].push(value)}else subject[property]=options.propertyIsArray?[value]:value},jsonld.getValues=function(subject,property){var rval=subject[property]||[];return _isArray(rval)||(rval=[rval]),rval},jsonld.removeProperty=function(subject,property){delete subject[property]},jsonld.removeValue=function(subject,property,value,options){options=options||{},"propertyIsArray"in options||(options.propertyIsArray=!1);var values=jsonld.getValues(subject,property).filter(function(e){return!jsonld.compareValues(e,value)});0===values.length?jsonld.removeProperty(subject,property):subject[property]=1!==values.length||options.propertyIsArray?values:values[0]},jsonld.compareValues=function(v1,v2){return v1===v2?!0:_isValue(v1)&&_isValue(v2)&&v1["@value"]===v2["@value"]&&v1["@type"]===v2["@type"]&&v1["@language"]===v2["@language"]&&v1["@index"]===v2["@index"]?!0:_isObject(v1)&&"@id"in v1&&_isObject(v2)&&"@id"in v2?v1["@id"]===v2["@id"]:!1},jsonld.getContextValue=function(ctx,key,type){var rval=null;if(null===key)return rval;if("@language"===type&&type in ctx&&(rval=ctx[type]),ctx.mappings[key]){var entry=ctx.mappings[key];_isUndefined(type)?rval=entry:type in entry&&(rval=entry[type])}return rval};var _rdfParsers={};if(jsonld.registerRDFParser=function(contentType,parser){_rdfParsers[contentType]=parser},jsonld.unregisterRDFParser=function(contentType){delete _rdfParsers[contentType]},_nodejs){if("undefined"==typeof XMLSerializer)var XMLSerializer=null;if("undefined"==typeof Node)var Node={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12}}var XSD_BOOLEAN="http://www.w3.org/2001/XMLSchema#boolean",XSD_DOUBLE="http://www.w3.org/2001/XMLSchema#double",XSD_INTEGER="http://www.w3.org/2001/XMLSchema#integer",XSD_STRING="http://www.w3.org/2001/XMLSchema#string",RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDF_LIST=RDF+"List",RDF_FIRST=RDF+"first",RDF_REST=RDF+"rest",RDF_NIL=RDF+"nil",RDF_TYPE=RDF+"type",RDF_PLAIN_LITERAL=RDF+"PlainLiteral",RDF_XML_LITERAL=RDF+"XMLLiteral",RDF_OBJECT=RDF+"object",RDF_LANGSTRING=RDF+"langString",LINK_HEADER_REL="http://www.w3.org/ns/json-ld#context",MAX_CONTEXT_URLS=10,JsonLdError=function(msg,type,details){
  _nodejs?(Error.call(this),Error.captureStackTrace(this,this.constructor)):"undefined"!=typeof Error&&(this.stack=(new Error).stack),this.name=type||"jsonld.Error",this.message=msg||"An unspecified JSON-LD error occurred.",this.details=details||{}};_nodejs?require("util").inherits(JsonLdError,Error):"undefined"!=typeof Error&&(JsonLdError.prototype=new Error);var Processor=function(){};Processor.prototype.compact=function(activeCtx,activeProperty,element,options){if(_isArray(element)){for(var rval=[],i=0;i<element.length;++i){var compacted=this.compact(activeCtx,activeProperty,element[i],options);null!==compacted&&rval.push(compacted)}if(options.compactArrays&&1===rval.length){var container=jsonld.getContextValue(activeCtx,activeProperty,"@container");null===container&&(rval=rval[0])}return rval}if(_isObject(element)){if(options.link&&"@id"in element&&element["@id"]in options.link)for(var linked=options.link[element["@id"]],i=0;i<linked.length;++i)if(linked[i].expanded===element)return linked[i].compacted;if(_isValue(element)||_isSubjectReference(element)){var rval=_compactValue(activeCtx,activeProperty,element);return options.link&&_isSubjectReference(element)&&(element["@id"]in options.link||(options.link[element["@id"]]=[]),options.link[element["@id"]].push({expanded:element,compacted:rval})),rval}var insideReverse="@reverse"===activeProperty,rval={};options.link&&"@id"in element&&(element["@id"]in options.link||(options.link[element["@id"]]=[]),options.link[element["@id"]].push({expanded:element,compacted:rval}));for(var keys=Object.keys(element).sort(),ki=0;ki<keys.length;++ki){var expandedProperty=keys[ki],expandedValue=element[expandedProperty];if("@id"!==expandedProperty&&"@type"!==expandedProperty)if("@reverse"!==expandedProperty)if("@index"!==expandedProperty)if("@graph"!==expandedProperty&&"@list"!==expandedProperty&&_isKeyword(expandedProperty)){var alias=_compactIri(activeCtx,expandedProperty);jsonld.addValue(rval,alias,expandedValue)}else{if(0===expandedValue.length){var itemActiveProperty=_compactIri(activeCtx,expandedProperty,expandedValue,{vocab:!0},insideReverse);jsonld.addValue(rval,itemActiveProperty,expandedValue,{propertyIsArray:!0})}for(var vi=0;vi<expandedValue.length;++vi){var expandedItem=expandedValue[vi],itemActiveProperty=_compactIri(activeCtx,expandedProperty,expandedItem,{vocab:!0},insideReverse),container=jsonld.getContextValue(activeCtx,itemActiveProperty,"@container"),isList=_isList(expandedItem),list=null;isList&&(list=expandedItem["@list"]);var compactedItem=this.compact(activeCtx,itemActiveProperty,isList?list:expandedItem,options);if(isList)if(_isArray(compactedItem)||(compactedItem=[compactedItem]),"@list"!==container){var wrapper={};wrapper[_compactIri(activeCtx,"@list")]=compactedItem,compactedItem=wrapper,"@index"in expandedItem&&(compactedItem[_compactIri(activeCtx,"@index")]=expandedItem["@index"])}else if(itemActiveProperty in rval)throw new JsonLdError('JSON-LD compact error; property has a "@list" @container rule but there is more than a single @list that matches the compacted term in the document. Compaction might mix unwanted items into the list.',"jsonld.SyntaxError",{code:"compaction to list of lists"});if("@language"===container||"@index"===container){var mapObject;itemActiveProperty in rval?mapObject=rval[itemActiveProperty]:rval[itemActiveProperty]=mapObject={},"@language"===container&&_isValue(compactedItem)&&(compactedItem=compactedItem["@value"]),jsonld.addValue(mapObject,expandedItem[container],compactedItem)}else{var isArray=!options.compactArrays||"@set"===container||"@list"===container||_isArray(compactedItem)&&0===compactedItem.length||"@list"===expandedProperty||"@graph"===expandedProperty;jsonld.addValue(rval,itemActiveProperty,compactedItem,{propertyIsArray:isArray})}}}else{var container=jsonld.getContextValue(activeCtx,activeProperty,"@container");if("@index"===container)continue;var alias=_compactIri(activeCtx,expandedProperty);jsonld.addValue(rval,alias,expandedValue)}else{var compactedValue=this.compact(activeCtx,"@reverse",expandedValue,options);for(var compactedProperty in compactedValue)if(activeCtx.mappings[compactedProperty]&&activeCtx.mappings[compactedProperty].reverse){var value=compactedValue[compactedProperty],container=jsonld.getContextValue(activeCtx,compactedProperty,"@container"),useArray="@set"===container||!options.compactArrays;jsonld.addValue(rval,compactedProperty,value,{propertyIsArray:useArray}),delete compactedValue[compactedProperty]}if(Object.keys(compactedValue).length>0){var alias=_compactIri(activeCtx,expandedProperty);jsonld.addValue(rval,alias,compactedValue)}}else{var compactedValue;if(_isString(expandedValue))compactedValue=_compactIri(activeCtx,expandedValue,null,{vocab:"@type"===expandedProperty});else{compactedValue=[];for(var vi=0;vi<expandedValue.length;++vi)compactedValue.push(_compactIri(activeCtx,expandedValue[vi],null,{vocab:!0}))}var alias=_compactIri(activeCtx,expandedProperty),isArray=_isArray(compactedValue)&&0===expandedValue.length;jsonld.addValue(rval,alias,compactedValue,{propertyIsArray:isArray})}}return rval}return element},Processor.prototype.expand=function(activeCtx,activeProperty,element,options,insideList){var self=this;if(null===element||void 0===element)return null;if(!_isArray(element)&&!_isObject(element))return insideList||null!==activeProperty&&"@graph"!==_expandIri(activeCtx,activeProperty,{vocab:!0})?_expandValue(activeCtx,activeProperty,element):null;if(_isArray(element)){var rval=[],container=jsonld.getContextValue(activeCtx,activeProperty,"@container");insideList=insideList||"@list"===container;for(var i=0;i<element.length;++i){var e=self.expand(activeCtx,activeProperty,element[i],options);if(insideList&&(_isArray(e)||_isList(e)))throw new JsonLdError("Invalid JSON-LD syntax; lists of lists are not permitted.","jsonld.SyntaxError",{code:"list of lists"});null!==e&&(_isArray(e)?rval=rval.concat(e):rval.push(e))}return rval}"@context"in element&&(activeCtx=self.processContext(activeCtx,element["@context"],options));for(var expandedActiveProperty=_expandIri(activeCtx,activeProperty,{vocab:!0}),rval={},keys=Object.keys(element).sort(),ki=0;ki<keys.length;++ki){var expandedValue,key=keys[ki],value=element[key];if("@context"!==key){var expandedProperty=_expandIri(activeCtx,key,{vocab:!0});if(null!==expandedProperty&&(_isAbsoluteIri(expandedProperty)||_isKeyword(expandedProperty))){if(_isKeyword(expandedProperty)){if("@reverse"===expandedActiveProperty)throw new JsonLdError("Invalid JSON-LD syntax; a keyword cannot be used as a @reverse property.","jsonld.SyntaxError",{code:"invalid reverse property map",value:value});if(expandedProperty in rval)throw new JsonLdError("Invalid JSON-LD syntax; colliding keywords detected.","jsonld.SyntaxError",{code:"colliding keywords",keyword:expandedProperty})}if("@id"===expandedProperty&&!_isString(value)){if(!options.isFrame)throw new JsonLdError('Invalid JSON-LD syntax; "@id" value must a string.',"jsonld.SyntaxError",{code:"invalid @id value",value:value});if(!_isObject(value))throw new JsonLdError('Invalid JSON-LD syntax; "@id" value must be a string or an object.',"jsonld.SyntaxError",{code:"invalid @id value",value:value})}if("@type"===expandedProperty&&_validateTypeValue(value),"@graph"===expandedProperty&&!_isObject(value)&&!_isArray(value))throw new JsonLdError('Invalid JSON-LD syntax; "@graph" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid @graph value",value:value});if("@value"===expandedProperty&&(_isObject(value)||_isArray(value)))throw new JsonLdError('Invalid JSON-LD syntax; "@value" value must not be an object or an array.',"jsonld.SyntaxError",{code:"invalid value object value",value:value});if("@language"===expandedProperty){if(null===value)continue;if(!_isString(value))throw new JsonLdError('Invalid JSON-LD syntax; "@language" value must be a string.',"jsonld.SyntaxError",{code:"invalid language-tagged string",value:value});value=value.toLowerCase()}if("@index"===expandedProperty&&!_isString(value))throw new JsonLdError('Invalid JSON-LD syntax; "@index" value must be a string.',"jsonld.SyntaxError",{code:"invalid @index value",value:value});if("@reverse"!==expandedProperty){var container=jsonld.getContextValue(activeCtx,key,"@container");if("@language"===container&&_isObject(value))expandedValue=_expandLanguageMap(value);else if("@index"===container&&_isObject(value))expandedValue=function(activeProperty){for(var rval=[],keys=Object.keys(value).sort(),ki=0;ki<keys.length;++ki){var key=keys[ki],val=value[key];_isArray(val)||(val=[val]),val=self.expand(activeCtx,activeProperty,val,options,!1);for(var vi=0;vi<val.length;++vi){var item=val[vi];"@index"in item||(item["@index"]=key),rval.push(item)}}return rval}(key);else{var isList="@list"===expandedProperty;if(isList||"@set"===expandedProperty){var nextActiveProperty=activeProperty;if(isList&&"@graph"===expandedActiveProperty&&(nextActiveProperty=null),expandedValue=self.expand(activeCtx,nextActiveProperty,value,options,isList),isList&&_isList(expandedValue))throw new JsonLdError("Invalid JSON-LD syntax; lists of lists are not permitted.","jsonld.SyntaxError",{code:"list of lists"})}else expandedValue=self.expand(activeCtx,key,value,options,!1)}if(null!==expandedValue||"@value"===expandedProperty)if("@list"===expandedProperty||_isList(expandedValue)||"@list"!==container||(expandedValue=_isArray(expandedValue)?expandedValue:[expandedValue],expandedValue={"@list":expandedValue}),activeCtx.mappings[key]&&activeCtx.mappings[key].reverse){var reverseMap=rval["@reverse"]=rval["@reverse"]||{};_isArray(expandedValue)||(expandedValue=[expandedValue]);for(var ii=0;ii<expandedValue.length;++ii){var item=expandedValue[ii];if(_isValue(item)||_isList(item))throw new JsonLdError('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:expandedValue});jsonld.addValue(reverseMap,expandedProperty,item,{propertyIsArray:!0})}}else{var useArray=-1===["@index","@id","@type","@value","@language"].indexOf(expandedProperty);jsonld.addValue(rval,expandedProperty,expandedValue,{propertyIsArray:useArray})}}else{if(!_isObject(value))throw new JsonLdError('Invalid JSON-LD syntax; "@reverse" value must be an object.',"jsonld.SyntaxError",{code:"invalid @reverse value",value:value});if(expandedValue=self.expand(activeCtx,"@reverse",value,options),"@reverse"in expandedValue)for(var property in expandedValue["@reverse"])jsonld.addValue(rval,property,expandedValue["@reverse"][property],{propertyIsArray:!0});var reverseMap=rval["@reverse"]||null;for(var property in expandedValue)if("@reverse"!==property){null===reverseMap&&(reverseMap=rval["@reverse"]={}),jsonld.addValue(reverseMap,property,[],{propertyIsArray:!0});for(var items=expandedValue[property],ii=0;ii<items.length;++ii){var item=items[ii];if(_isValue(item)||_isList(item))throw new JsonLdError('Invalid JSON-LD syntax; "@reverse" value must not be a @value or an @list.',"jsonld.SyntaxError",{code:"invalid reverse property value",value:expandedValue});jsonld.addValue(reverseMap,property,item,{propertyIsArray:!0})}}}}}}keys=Object.keys(rval);var count=keys.length;if("@value"in rval){if("@type"in rval&&"@language"in rval)throw new JsonLdError('Invalid JSON-LD syntax; an element containing "@value" may not contain both "@type" and "@language".',"jsonld.SyntaxError",{code:"invalid value object",element:rval});var validCount=count-1;if("@type"in rval&&(validCount-=1),"@index"in rval&&(validCount-=1),"@language"in rval&&(validCount-=1),0!==validCount)throw new JsonLdError('Invalid JSON-LD syntax; an element containing "@value" may only have an "@index" property and at most one other property which can be "@type" or "@language".',"jsonld.SyntaxError",{code:"invalid value object",element:rval});if(null===rval["@value"])rval=null;else{if("@language"in rval&&!_isString(rval["@value"]))throw new JsonLdError("Invalid JSON-LD syntax; only strings may be language-tagged.","jsonld.SyntaxError",{code:"invalid language-tagged value",element:rval});if("@type"in rval&&(!_isAbsoluteIri(rval["@type"])||0===rval["@type"].indexOf("_:")))throw new JsonLdError('Invalid JSON-LD syntax; an element containing "@value" and "@type" must have an absolute IRI for the value of "@type".',"jsonld.SyntaxError",{code:"invalid typed value",element:rval})}}else if("@type"in rval&&!_isArray(rval["@type"]))rval["@type"]=[rval["@type"]];else if("@set"in rval||"@list"in rval){if(count>1&&!(2===count&&"@index"in rval))throw new JsonLdError('Invalid JSON-LD syntax; if an element has the property "@set" or "@list", then it can have at most one other property that is "@index".',"jsonld.SyntaxError",{code:"invalid set or list object",element:rval});"@set"in rval&&(rval=rval["@set"],keys=Object.keys(rval),count=keys.length)}else 1===count&&"@language"in rval&&(rval=null);return!_isObject(rval)||options.keepFreeFloatingNodes||insideList||null!==activeProperty&&"@graph"!==expandedActiveProperty||(0===count||"@value"in rval||"@list"in rval||1===count&&"@id"in rval)&&(rval=null),rval},Processor.prototype.createNodeMap=function(input,options){options=options||{};var issuer=options.namer||options.issuer||new IdentifierIssuer("_:b"),graphs={"@default":{}};return _createNodeMap(input,graphs,"@default",issuer),_mergeNodeMaps(graphs)},Processor.prototype.flatten=function(input){for(var defaultGraph=this.createNodeMap(input),flattened=[],keys=Object.keys(defaultGraph).sort(),ki=0;ki<keys.length;++ki){var node=defaultGraph[keys[ki]];_isSubjectReference(node)||flattened.push(node)}return flattened},Processor.prototype.frame=function(input,frame,options){var state={options:options,graphs:{"@default":{},"@merged":{}},subjectStack:[],link:{}},issuer=new IdentifierIssuer("_:b");_createNodeMap(input,state.graphs,"@merged",issuer),state.subjects=state.graphs["@merged"];var framed=[];return _frame(state,Object.keys(state.subjects).sort(),frame,framed,null),framed},Processor.prototype.normalize=function(dataset,options,callback){return"URDNA2015"===options.algorithm?new URDNA2015(options).main(dataset,callback):"URGNA2012"===options.algorithm?new URGNA2012(options).main(dataset,callback):void callback(new Error("Invalid RDF Dataset Normalization algorithm: "+options.algorithm))},Processor.prototype.fromRDF=function(dataset,options,callback){var defaultGraph={},graphMap={"@default":defaultGraph},referencedOnce={};for(var name in dataset){var graph=dataset[name];name in graphMap||(graphMap[name]={}),"@default"===name||name in defaultGraph||(defaultGraph[name]={"@id":name});for(var nodeMap=graphMap[name],ti=0;ti<graph.length;++ti){var triple=graph[ti],s=triple.subject.value,p=triple.predicate.value,o=triple.object;s in nodeMap||(nodeMap[s]={"@id":s});var node=nodeMap[s],objectIsId="IRI"===o.type||"blank node"===o.type;if(!objectIsId||o.value in nodeMap||(nodeMap[o.value]={"@id":o.value}),p!==RDF_TYPE||options.useRdfType||!objectIsId){var value=_RDFToObject(o,options.useNativeTypes);if(jsonld.addValue(node,p,value,{propertyIsArray:!0}),objectIsId)if(o.value===RDF_NIL){var object=nodeMap[o.value];"usages"in object||(object.usages=[]),object.usages.push({node:node,property:p,value:value})}else referencedOnce[o.value]=o.value in referencedOnce?!1:{node:node,property:p,value:value}}else jsonld.addValue(node,"@type",o.value,{propertyIsArray:!0})}}for(var name in graphMap){var graphObject=graphMap[name];if(RDF_NIL in graphObject){for(var nil=graphObject[RDF_NIL],i=0;i<nil.usages.length;++i){for(var usage=nil.usages[i],node=usage.node,property=usage.property,head=usage.value,list=[],listNodes=[],nodeKeyCount=Object.keys(node).length;property===RDF_REST&&_isObject(referencedOnce[node["@id"]])&&_isArray(node[RDF_FIRST])&&1===node[RDF_FIRST].length&&_isArray(node[RDF_REST])&&1===node[RDF_REST].length&&(3===nodeKeyCount||4===nodeKeyCount&&_isArray(node["@type"])&&1===node["@type"].length&&node["@type"][0]===RDF_LIST)&&(list.push(node[RDF_FIRST][0]),listNodes.push(node["@id"]),usage=referencedOnce[node["@id"]],node=usage.node,property=usage.property,head=usage.value,nodeKeyCount=Object.keys(node).length,0===node["@id"].indexOf("_:")););if(property===RDF_FIRST){if(node["@id"]===RDF_NIL)continue;head=graphObject[head["@id"]][RDF_REST][0],list.pop(),listNodes.pop()}delete head["@id"],head["@list"]=list.reverse();for(var j=0;j<listNodes.length;++j)delete graphObject[listNodes[j]]}delete nil.usages}}for(var result=[],subjects=Object.keys(defaultGraph).sort(),i=0;i<subjects.length;++i){var subject=subjects[i],node=defaultGraph[subject];if(subject in graphMap)for(var graph=node["@graph"]=[],graphObject=graphMap[subject],subjects_=Object.keys(graphObject).sort(),si=0;si<subjects_.length;++si){var node_=graphObject[subjects_[si]];_isSubjectReference(node_)||graph.push(node_)}_isSubjectReference(node)||result.push(node)}callback(null,result)},Processor.prototype.toRDF=function(input,options){var issuer=new IdentifierIssuer("_:b"),nodeMap={"@default":{}};_createNodeMap(input,nodeMap,"@default",issuer);for(var dataset={},graphNames=Object.keys(nodeMap).sort(),i=0;i<graphNames.length;++i){var graphName=graphNames[i];("@default"===graphName||_isAbsoluteIri(graphName))&&(dataset[graphName]=_graphToRDF(nodeMap[graphName],issuer,options))}return dataset},Processor.prototype.processContext=function(activeCtx,localCtx,options){_isObject(localCtx)&&"@context"in localCtx&&_isArray(localCtx["@context"])&&(localCtx=localCtx["@context"]);var ctxs=_isArray(localCtx)?localCtx:[localCtx];if(0===ctxs.length)return activeCtx.clone();for(var rval=activeCtx,i=0;i<ctxs.length;++i){var ctx=ctxs[i];if(null!==ctx){if(_isObject(ctx)&&"@context"in ctx&&(ctx=ctx["@context"]),!_isObject(ctx))throw new JsonLdError("Invalid JSON-LD syntax; @context must be an object.","jsonld.SyntaxError",{code:"invalid local context",context:ctx});if(jsonld.cache.activeCtx){var cached=jsonld.cache.activeCtx.get(activeCtx,ctx);if(cached){rval=activeCtx=cached;continue}}activeCtx=rval,rval=rval.clone();var defined={};if("@base"in ctx){var base=ctx["@base"];if(null===base)base=null;else{if(!_isString(base))throw new JsonLdError('Invalid JSON-LD syntax; the value of "@base" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid base IRI",context:ctx});if(""!==base&&!_isAbsoluteIri(base))throw new JsonLdError('Invalid JSON-LD syntax; the value of "@base" in a @context must be an absolute IRI or the empty string.',"jsonld.SyntaxError",{code:"invalid base IRI",context:ctx})}null!==base&&(base=jsonld.url.parse(base||"")),rval["@base"]=base,defined["@base"]=!0}if("@vocab"in ctx){var value=ctx["@vocab"];if(null===value)delete rval["@vocab"];else{if(!_isString(value))throw new JsonLdError('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:ctx});if(!_isAbsoluteIri(value))throw new JsonLdError('Invalid JSON-LD syntax; the value of "@vocab" in a @context must be an absolute IRI.',"jsonld.SyntaxError",{code:"invalid vocab mapping",context:ctx});rval["@vocab"]=value}defined["@vocab"]=!0}if("@language"in ctx){var value=ctx["@language"];if(null===value)delete rval["@language"];else{if(!_isString(value))throw new JsonLdError('Invalid JSON-LD syntax; the value of "@language" in a @context must be a string or null.',"jsonld.SyntaxError",{code:"invalid default language",context:ctx});rval["@language"]=value.toLowerCase()}defined["@language"]=!0}for(var key in ctx)_createTermDefinition(rval,ctx,key,defined);jsonld.cache.activeCtx&&jsonld.cache.activeCtx.set(activeCtx,ctx,rval)}else rval=activeCtx=_getInitialContext(options)}return rval};var URDNA2015=function(){var POSITIONS={subject:"s",object:"o",name:"g"},Normalize=function(options){options=options||{},this.name="URDNA2015",this.options=options,this.blankNodeInfo={},this.hashToBlankNodes={},this.canonicalIssuer=new IdentifierIssuer("_:c14n"),this.quads=[],this.schedule={},this.schedule.MAX_DEPTH="maxCallStackDepth"in options?options.maxCallStackDepth:500,this.schedule.MAX_TOTAL_DEPTH="maxTotalCallStackDepth"in options?options.maxCallStackDepth:4294967295,this.schedule.depth=0,this.schedule.totalDepth=0,this.schedule.timeSlice="timeSlice"in options?options.timeSlice:10};return Normalize.prototype.doWork=function(fn,callback){var schedule=this.schedule;return schedule.totalDepth>=schedule.MAX_TOTAL_DEPTH?callback(new Error("Maximum total call stack depth exceeded; normalization aborting.")):void function work(){if(schedule.depth===schedule.MAX_DEPTH)return schedule.depth=0,schedule.running=!1,jsonld.nextTick(work);var now=(new Date).getTime();return schedule.running||(schedule.start=(new Date).getTime(),schedule.deadline=schedule.start+schedule.timeSlice),now<schedule.deadline?(schedule.running=!0,schedule.depth++,schedule.totalDepth++,fn(function(err,result){schedule.depth--,schedule.totalDepth--,callback(err,result)})):(schedule.depth=0,schedule.running=!1,void jsonld.setImmediate(work))}()},Normalize.prototype.forEach=function(iterable,fn,callback){var iterator,length,self=this,idx=0;if(_isArray(iterable))length=iterable.length,iterator=function(){return idx===length?!1:(iterator.value=iterable[idx++],iterator.key=idx,!0)};else{var keys=Object.keys(iterable);length=keys.length,iterator=function(){return idx===length?!1:(iterator.key=keys[idx++],iterator.value=iterable[iterator.key],!0)}}!function iterate(err){return err?callback(err):iterator()?self.doWork(function(){fn(iterator.value,iterator.key,iterate)}):void callback()}()},Normalize.prototype.waterfall=function(fns,callback){var self=this;self.forEach(fns,function(fn,idx,callback){self.doWork(fn,callback)},callback)},Normalize.prototype.whilst=function(condition,fn,callback){var self=this;!function loop(err){return err?callback(err):condition()?void self.doWork(fn,loop):callback()}()},Normalize.prototype.main=function(dataset,callback){var self=this;self.schedule.start=(new Date).getTime();var result;if(self.options.format&&"application/nquads"!==self.options.format)return callback(new JsonLdError("Unknown output format.","jsonld.UnknownFormat",{format:self.options.format}));var nonNormalized={};self.waterfall([function(callback){self.forEach(dataset,function(triples,graphName,callback){"@default"===graphName&&(graphName=null),self.forEach(triples,function(quad,idx,callback){null!==graphName&&(quad.name=0===graphName.indexOf("_:")?{type:"blank node",value:graphName}:{type:"IRI",value:graphName}),self.quads.push(quad),self.forEachComponent(quad,function(component){if("blank node"===component.type){var id=component.value;id in self.blankNodeInfo?self.blankNodeInfo[id].quads.push(quad):(nonNormalized[id]=!0,self.blankNodeInfo[id]={quads:[quad]})}}),callback()},callback)},callback)},function(callback){var simple=!0;self.whilst(function(){return simple},function(callback){simple=!1,self.hashToBlankNodes={},self.waterfall([function(callback){self.forEach(nonNormalized,function(value,id,callback){self.hashFirstDegreeQuads(id,function(err,hash){return err?callback(err):(hash in self.hashToBlankNodes?self.hashToBlankNodes[hash].push(id):self.hashToBlankNodes[hash]=[id],void callback())})},callback)},function(callback){var hashes=Object.keys(self.hashToBlankNodes).sort();self.forEach(hashes,function(hash,i,callback){var idList=self.hashToBlankNodes[hash];if(idList.length>1)return callback();var id=idList[0];self.canonicalIssuer.getId(id),delete nonNormalized[id],delete self.hashToBlankNodes[hash],simple=!0,callback()},callback)}],callback)},callback)},function(callback){var hashes=Object.keys(self.hashToBlankNodes).sort();self.forEach(hashes,function(hash,idx,callback){var hashPathList=[],idList=self.hashToBlankNodes[hash];self.waterfall([function(callback){self.forEach(idList,function(id,idx,callback){if(self.canonicalIssuer.hasId(id))return callback();var issuer=new IdentifierIssuer("_:b");issuer.getId(id),self.hashNDegreeQuads(id,issuer,function(err,result){return err?callback(err):(hashPathList.push(result),void callback())})},callback)},function(callback){hashPathList.sort(function(a,b){return a.hash<b.hash?-1:a.hash>b.hash?1:0}),self.forEach(hashPathList,function(result,idx,callback){for(var existing in result.issuer.existing)self.canonicalIssuer.getId(existing);callback()},callback)}],callback)},callback)},function(callback){var normalized=[];self.waterfall([function(callback){self.forEach(self.quads,function(quad,idx,callback){self.forEachComponent(quad,function(component){"blank node"===component.type&&0!==component.value.indexOf(self.canonicalIssuer.prefix)&&(component.value=self.canonicalIssuer.getId(component.value))}),normalized.push(_toNQuad(quad)),callback()},callback)},function(callback){return normalized.sort(),"application/nquads"===self.options.format?(result=normalized.join(""),callback()):(result=_parseNQuads(normalized.join("")),void callback())}],callback)}],function(err){callback(err,result)})},Normalize.prototype.hashFirstDegreeQuads=function(id,callback){var self=this,info=self.blankNodeInfo[id];if("hash"in info)return callback(null,info.hash);var nquads=[],quads=info.quads;self.forEach(quads,function(quad,idx,callback){var copy={predicate:quad.predicate};self.forEachComponent(quad,function(component,key){copy[key]=self.modifyFirstDegreeComponent(id,component,key)}),nquads.push(_toNQuad(copy)),callback()},function(err){return err?callback(err):(nquads.sort(),info.hash=NormalizeHash.hashNQuads(self.name,nquads),void callback(null,info.hash))})},Normalize.prototype.modifyFirstDegreeComponent=function(id,component){return"blank node"!==component.type?component:(component=_clone(component),component.value=component.value===id?"_:a":"_:z",component)},Normalize.prototype.hashRelatedBlankNode=function(related,quad,issuer,position,callback){var id,self=this;self.waterfall([function(callback){return self.canonicalIssuer.hasId(related)?(id=self.canonicalIssuer.getId(related),callback()):issuer.hasId(related)?(id=issuer.getId(related),callback()):void self.hashFirstDegreeQuads(related,function(err,hash){return err?callback(err):(id=hash,void callback())})}],function(err){if(err)return callback(err);var md=new NormalizeHash(self.name);return md.update(position),"g"!==position&&md.update(self.getRelatedPredicate(quad)),md.update(id),callback(null,md.digest())})},Normalize.prototype.getRelatedPredicate=function(quad){return"<"+quad.predicate.value+">"},Normalize.prototype.hashNDegreeQuads=function(id,issuer,callback){var hashToRelated,self=this,md=new NormalizeHash(self.name);self.waterfall([function(callback){self.createHashToRelated(id,issuer,function(err,result){return err?callback(err):(hashToRelated=result,void callback())})},function(callback){var hashes=Object.keys(hashToRelated).sort();self.forEach(hashes,function(hash,idx,callback){md.update(hash);var chosenIssuer,chosenPath="",permutator=new Permutator(hashToRelated[hash]);self.whilst(function(){return permutator.hasNext()},function(nextPermutation){var permutation=permutator.next(),issuerCopy=issuer.clone(),path="",recursionList=[];self.waterfall([function(callback){self.forEach(permutation,function(related,idx,callback){return self.canonicalIssuer.hasId(related)?path+=self.canonicalIssuer.getId(related):(issuerCopy.hasId(related)||recursionList.push(related),path+=issuerCopy.getId(related)),0!==chosenPath.length&&path.length>=chosenPath.length&&path>chosenPath?nextPermutation():void callback()},callback)},function(callback){self.forEach(recursionList,function(related,idx,callback){self.hashNDegreeQuads(related,issuerCopy,function(err,result){return err?callback(err):(path+=issuerCopy.getId(related),path+="<"+result.hash+">",issuerCopy=result.issuer,0!==chosenPath.length&&path.length>=chosenPath.length&&path>chosenPath?nextPermutation():void callback())})},callback)},function(callback){(0===chosenPath.length||chosenPath>path)&&(chosenPath=path,chosenIssuer=issuerCopy),callback()}],nextPermutation)},function(err){return err?callback(err):(md.update(chosenPath),issuer=chosenIssuer,void callback())})},callback)}],function(err){callback(err,{hash:md.digest(),issuer:issuer})})},Normalize.prototype.createHashToRelated=function(id,issuer,callback){var self=this,hashToRelated={},quads=self.blankNodeInfo[id].quads;self.forEach(quads,function(quad,idx,callback){self.forEach(quad,function(component,key,callback){if("predicate"===key||"blank node"!==component.type||component.value===id)return callback();var related=component.value,position=POSITIONS[key];self.hashRelatedBlankNode(related,quad,issuer,position,function(err,hash){return err?callback(err):(hash in hashToRelated?hashToRelated[hash].push(related):hashToRelated[hash]=[related],void callback())})},callback)},function(err){callback(err,hashToRelated)})},Normalize.prototype.forEachComponent=function(quad,op){for(var key in quad)"predicate"!==key&&op(quad[key],key,quad)},Normalize}(),URGNA2012=function(){var Normalize=function(options){URDNA2015.call(this,options),this.name="URGNA2012"};return Normalize.prototype=new URDNA2015,Normalize.prototype.modifyFirstDegreeComponent=function(id,component,key){return"blank node"!==component.type?component:(component=_clone(component),component.value="name"===key?"_:g":component.value===id?"_:a":"_:z",component)},Normalize.prototype.getRelatedPredicate=function(quad){return quad.predicate.value},Normalize.prototype.createHashToRelated=function(id,issuer,callback){var self=this,hashToRelated={},quads=self.blankNodeInfo[id].quads;self.forEach(quads,function(quad,idx,callback){var position,related;if("blank node"===quad.subject.type&&quad.subject.value!==id)related=quad.subject.value,position="p";else{if("blank node"!==quad.object.type||quad.object.value===id)return callback();related=quad.object.value,position="r"}self.hashRelatedBlankNode(related,quad,issuer,position,function(err,hash){hash in hashToRelated?hashToRelated[hash].push(related):hashToRelated[hash]=[related],callback()})},function(err){callback(err,hashToRelated)})},Normalize}();Object.keys||(Object.keys=function(o){if(o!==Object(o))throw new TypeError("Object.keys called on non-object");var rval=[];for(var p in o)Object.prototype.hasOwnProperty.call(o,p)&&rval.push(p);return rval}),jsonld.registerRDFParser("application/nquads",_parseNQuads),jsonld.registerRDFParser("rdfa-api",_parseRdfaApiData),jsonld.IdentifierIssuer=IdentifierIssuer,jsonld.UniqueNamer=IdentifierIssuer,IdentifierIssuer.prototype.clone=function(){var copy=new IdentifierIssuer(this.prefix);return copy.counter=this.counter,copy.existing=_clone(this.existing),copy},IdentifierIssuer.prototype.getId=function(old){if(old&&old in this.existing)return this.existing[old];var identifier=this.prefix+this.counter;return this.counter+=1,old&&(this.existing[old]=identifier),identifier},IdentifierIssuer.prototype.getName=IdentifierIssuer.prototype.getName,IdentifierIssuer.prototype.hasId=function(old){return old in this.existing},IdentifierIssuer.prototype.isNamed=IdentifierIssuer.prototype.hasId;var Permutator=function(list){this.list=list.sort(),this.done=!1,this.left={};for(var i=0;i<list.length;++i)this.left[list[i]]=!0};Permutator.prototype.hasNext=function(){return!this.done},Permutator.prototype.next=function(){for(var rval=this.list.slice(),k=null,pos=0,length=this.list.length,i=0;length>i;++i){var element=this.list[i],left=this.left[element];(null===k||element>k)&&(left&&i>0&&element>this.list[i-1]||!left&&length-1>i&&element>this.list[i+1])&&(k=element,pos=i)}if(null===k)this.done=!0;else{var swap=this.left[k]?pos-1:pos+1;this.list[pos]=this.list[swap],this.list[swap]=k;for(var i=0;length>i;++i)this.list[i]>k&&(this.left[this.list[i]]=!this.left[this.list[i]])}return rval};var NormalizeHash=function(algorithm){if(!(this instanceof NormalizeHash))return new NormalizeHash(algorithm);if(-1===["URDNA2015","URGNA2012"].indexOf(algorithm))throw new Error("Invalid RDF Dataset Normalization algorithm: "+algorithm);
  
  NormalizeHash._init.call(this,algorithm)};if(NormalizeHash.hashNQuads=function(algorithm,nquads){for(var md=new NormalizeHash(algorithm),i=0;i<nquads.length;++i)md.update(nquads[i]);return md.digest()},function(_nodejs){if(_nodejs){var crypto=require("crypto");return NormalizeHash._init=function(algorithm){algorithm="URDNA2015"===algorithm?"sha256":"sha1",this.md=crypto.createHash(algorithm)},NormalizeHash.prototype.update=function(msg){return this.md.update(msg,"utf8")},void(NormalizeHash.prototype.digest=function(){return this.md.digest("hex")})}NormalizeHash._init=function(algorithm){algorithm="URDNA2015"===algorithm?new sha256.Algorithm:new sha1.Algorithm,this.md=new MessageDigest(algorithm)},NormalizeHash.prototype.update=function(msg){return this.md.update(msg)},NormalizeHash.prototype.digest=function(){return this.md.digest().toHex()};var MessageDigest=function(algorithm){if(!(this instanceof MessageDigest))return new MessageDigest(algorithm);if(this._algorithm=algorithm,!MessageDigest._padding||MessageDigest._padding.length<this._algorithm.blockSize){MessageDigest._padding=String.fromCharCode(128);for(var c=String.fromCharCode(0),n=64;n>0;)1&n&&(MessageDigest._padding+=c),n>>>=1,n>0&&(c+=c)}this.start()};MessageDigest.prototype.start=function(){this.messageLength=0,this.fullMessageLength=[];for(var int32s=this._algorithm.messageLengthSize/4,i=0;int32s>i;++i)this.fullMessageLength.push(0);return this._input=new MessageDigest.ByteBuffer,this.state=this._algorithm.start(),this},MessageDigest.prototype.update=function(msg){msg=new MessageDigest.ByteBuffer(unescape(encodeURIComponent(msg))),this.messageLength+=msg.length();var len=msg.length();len=[len/4294967296>>>0,len>>>0];for(var i=this.fullMessageLength.length-1;i>=0;--i)this.fullMessageLength[i]+=len[1],len[1]=len[0]+(this.fullMessageLength[i]/4294967296>>>0),this.fullMessageLength[i]=this.fullMessageLength[i]>>>0,len[0]=len[1]/4294967296>>>0;for(this._input.putBytes(msg.bytes());this._input.length()>=this._algorithm.blockSize;)this.state=this._algorithm.digest(this.state,this._input);return(this._input.read>2048||0===this._input.length())&&this._input.compact(),this},MessageDigest.prototype.digest=function(){var finalBlock=new MessageDigest.ByteBuffer;finalBlock.putBytes(this._input.bytes());var remaining=this.fullMessageLength[this.fullMessageLength.length-1]+this._algorithm.messageLengthSize,overflow=remaining&this._algorithm.blockSize-1;finalBlock.putBytes(MessageDigest._padding.substr(0,this._algorithm.blockSize-overflow));for(var messageLength=new MessageDigest.ByteBuffer,i=0;i<this.fullMessageLength.length;++i)messageLength.putInt32(this.fullMessageLength[i]<<3|this.fullMessageLength[i+1]>>>28);this._algorithm.writeMessageLength(finalBlock,messageLength);var state=this._algorithm.digest(this.state.copy(),finalBlock),rval=new MessageDigest.ByteBuffer;return state.write(rval),rval},MessageDigest.ByteBuffer=function(data){this.data="string"==typeof data?data:"",this.read=0},MessageDigest.ByteBuffer.prototype.putInt32=function(i){this.data+=String.fromCharCode(i>>24&255)+String.fromCharCode(i>>16&255)+String.fromCharCode(i>>8&255)+String.fromCharCode(255&i)},MessageDigest.ByteBuffer.prototype.getInt32=function(){var rval=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,rval},MessageDigest.ByteBuffer.prototype.putBytes=function(bytes){this.data+=bytes},MessageDigest.ByteBuffer.prototype.bytes=function(){return this.data.slice(this.read)},MessageDigest.ByteBuffer.prototype.length=function(){return this.data.length-this.read},MessageDigest.ByteBuffer.prototype.compact=function(){this.data=this.data.slice(this.read),this.read=0},MessageDigest.ByteBuffer.prototype.toHex=function(){for(var rval="",i=this.read;i<this.data.length;++i){var b=this.data.charCodeAt(i);16>b&&(rval+="0"),rval+=b.toString(16)}return rval};var sha1={_w:null};sha1.Algorithm=function(){this.name="sha1",this.blockSize=64,this.digestLength=20,this.messageLengthSize=8},sha1.Algorithm.prototype.start=function(){return sha1._w||(sha1._w=new Array(80)),sha1._createState()},sha1.Algorithm.prototype.writeMessageLength=function(finalBlock,messageLength){finalBlock.putBytes(messageLength.bytes())},sha1.Algorithm.prototype.digest=function(s,input){for(var t,a,b,c,d,e,f,i,len=input.length(),_w=sha1._w;len>=64;){for(a=s.h0,b=s.h1,c=s.h2,d=s.h3,e=s.h4,i=0;16>i;++i)t=input.getInt32(),_w[i]=t,f=d^b&(c^d),t=(a<<5|a>>>27)+f+e+1518500249+t,e=d,d=c,c=b<<30|b>>>2,b=a,a=t;for(;20>i;++i)t=_w[i-3]^_w[i-8]^_w[i-14]^_w[i-16],t=t<<1|t>>>31,_w[i]=t,f=d^b&(c^d),t=(a<<5|a>>>27)+f+e+1518500249+t,e=d,d=c,c=b<<30|b>>>2,b=a,a=t;for(;32>i;++i)t=_w[i-3]^_w[i-8]^_w[i-14]^_w[i-16],t=t<<1|t>>>31,_w[i]=t,f=b^c^d,t=(a<<5|a>>>27)+f+e+1859775393+t,e=d,d=c,c=b<<30|b>>>2,b=a,a=t;for(;40>i;++i)t=_w[i-6]^_w[i-16]^_w[i-28]^_w[i-32],t=t<<2|t>>>30,_w[i]=t,f=b^c^d,t=(a<<5|a>>>27)+f+e+1859775393+t,e=d,d=c,c=b<<30|b>>>2,b=a,a=t;for(;60>i;++i)t=_w[i-6]^_w[i-16]^_w[i-28]^_w[i-32],t=t<<2|t>>>30,_w[i]=t,f=b&c|d&(b^c),t=(a<<5|a>>>27)+f+e+2400959708+t,e=d,d=c,c=b<<30|b>>>2,b=a,a=t;for(;80>i;++i)t=_w[i-6]^_w[i-16]^_w[i-28]^_w[i-32],t=t<<2|t>>>30,_w[i]=t,f=b^c^d,t=(a<<5|a>>>27)+f+e+3395469782+t,e=d,d=c,c=b<<30|b>>>2,b=a,a=t;s.h0=s.h0+a|0,s.h1=s.h1+b|0,s.h2=s.h2+c|0,s.h3=s.h3+d|0,s.h4=s.h4+e|0,len-=64}return s},sha1._createState=function(){var state={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520};return state.copy=function(){var rval=sha1._createState();return rval.h0=state.h0,rval.h1=state.h1,rval.h2=state.h2,rval.h3=state.h3,rval.h4=state.h4,rval},state.write=function(buffer){buffer.putInt32(state.h0),buffer.putInt32(state.h1),buffer.putInt32(state.h2),buffer.putInt32(state.h3),buffer.putInt32(state.h4)},state};var sha256={_k:null,_w:null};sha256.Algorithm=function(){this.name="sha256",this.blockSize=64,this.digestLength=32,this.messageLengthSize=8},sha256.Algorithm.prototype.start=function(){return sha256._k||sha256._init(),sha256._createState()},sha256.Algorithm.prototype.writeMessageLength=function(finalBlock,messageLength){finalBlock.putBytes(messageLength.bytes())},sha256.Algorithm.prototype.digest=function(s,input){for(var t1,t2,s0,s1,ch,maj,i,a,b,c,d,e,f,g,h,len=input.length(),_k=sha256._k,_w=sha256._w;len>=64;){for(i=0;16>i;++i)_w[i]=input.getInt32();for(;64>i;++i)t1=_w[i-2],t1=(t1>>>17|t1<<15)^(t1>>>19|t1<<13)^t1>>>10,t2=_w[i-15],t2=(t2>>>7|t2<<25)^(t2>>>18|t2<<14)^t2>>>3,_w[i]=t1+_w[i-7]+t2+_w[i-16]|0;for(a=s.h0,b=s.h1,c=s.h2,d=s.h3,e=s.h4,f=s.h5,g=s.h6,h=s.h7,i=0;64>i;++i)s1=(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7),ch=g^e&(f^g),s0=(a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10),maj=a&b|c&(a^b),t1=h+s1+ch+_k[i]+_w[i],t2=s0+maj,h=g,g=f,f=e,e=d+t1|0,d=c,c=b,b=a,a=t1+t2|0;s.h0=s.h0+a|0,s.h1=s.h1+b|0,s.h2=s.h2+c|0,s.h3=s.h3+d|0,s.h4=s.h4+e|0,s.h5=s.h5+f|0,s.h6=s.h6+g|0,s.h7=s.h7+h|0,len-=64}return s},sha256._createState=function(){var state={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225};return state.copy=function(){var rval=sha256._createState();return rval.h0=state.h0,rval.h1=state.h1,rval.h2=state.h2,rval.h3=state.h3,rval.h4=state.h4,rval.h5=state.h5,rval.h6=state.h6,rval.h7=state.h7,rval},state.write=function(buffer){buffer.putInt32(state.h0),buffer.putInt32(state.h1),buffer.putInt32(state.h2),buffer.putInt32(state.h3),buffer.putInt32(state.h4),buffer.putInt32(state.h5),buffer.putInt32(state.h6),buffer.putInt32(state.h7)},state},sha256._init=function(){sha256._k=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],sha256._w=new Array(64)}}(_nodejs),!XMLSerializer)var _defineXMLSerializer=function(){XMLSerializer=require("xmldom").XMLSerializer};if(jsonld.url={},jsonld.url.parsers={simple:{keys:["href","scheme","authority","path","query","fragment"],regex:/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/},full:{keys:["href","protocol","scheme","authority","auth","user","password","hostname","port","path","directory","file","query","fragment"],regex:/^(([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?(?:(((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/}},jsonld.url.parse=function(str,parser){for(var parsed={},o=jsonld.url.parsers[parser||"full"],m=o.regex.exec(str),i=o.keys.length;i--;)parsed[o.keys[i]]=void 0===m[i]?null:m[i];return parsed.normalizedPath=_removeDotSegments(parsed.path,!!parsed.authority),parsed},_nodejs?jsonld.useDocumentLoader("node"):"undefined"!=typeof XMLHttpRequest&&jsonld.useDocumentLoader("xhr"),_nodejs){jsonld.use=function(extension){switch(extension){case"request":jsonld.request=require("jsonld-request");break;default:throw new JsonLdError("Unknown extension.","jsonld.UnknownExtension",{extension:extension})}};var _module={exports:{},filename:__dirname};require("pkginfo")(_module,"version"),jsonld.version=_module.exports.version}return jsonld},factory=function(){return wrapper(function(){return factory()})};return!_nodejs&&"function"==typeof define&&define.amd?define([],function(){return wrapper(factory),factory}):(wrapper(factory),"function"==typeof require&&"undefined"!=typeof module&&module.exports&&(module.exports=factory),_browser&&("undefined"==typeof jsonld?jsonld=jsonldjs=factory:jsonldjs=factory)),factory}()}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},"/node_modules/jsonld/js")},{_process:105,crypto:161,"es6-promise":163,http:161,"jsonld-request":161,pkginfo:161,request:161,util:161,xmldom:161}],163:[function(require,module){(function(process,global){(function(){"use strict";function lib$es6$promise$utils$$objectOrFunction(x){return"function"==typeof x||"object"==typeof x&&null!==x}function lib$es6$promise$utils$$isFunction(x){return"function"==typeof x}function lib$es6$promise$utils$$isMaybeThenable(x){return"object"==typeof x&&null!==x}function lib$es6$promise$asap$$setScheduler(scheduleFn){lib$es6$promise$asap$$customSchedulerFn=scheduleFn}function lib$es6$promise$asap$$setAsap(asapFn){lib$es6$promise$asap$$asap=asapFn}function lib$es6$promise$asap$$useNextTick(){var nextTick=process.nextTick,version=process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);return Array.isArray(version)&&"0"===version[1]&&"10"===version[2]&&(nextTick=setImmediate),function(){nextTick(lib$es6$promise$asap$$flush)}}function lib$es6$promise$asap$$useVertxTimer(){return function(){lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush)}}function lib$es6$promise$asap$$useMutationObserver(){var iterations=0,observer=new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush),node=document.createTextNode("");return observer.observe(node,{characterData:!0}),function(){node.data=iterations=++iterations%2}}function lib$es6$promise$asap$$useMessageChannel(){var channel=new MessageChannel;return channel.port1.onmessage=lib$es6$promise$asap$$flush,function(){channel.port2.postMessage(0)}}function lib$es6$promise$asap$$useSetTimeout(){return function(){setTimeout(lib$es6$promise$asap$$flush,1)}}function lib$es6$promise$asap$$flush(){for(var i=0;lib$es6$promise$asap$$len>i;i+=2){var callback=lib$es6$promise$asap$$queue[i],arg=lib$es6$promise$asap$$queue[i+1];callback(arg),lib$es6$promise$asap$$queue[i]=void 0,lib$es6$promise$asap$$queue[i+1]=void 0}lib$es6$promise$asap$$len=0}function lib$es6$promise$asap$$attemptVertex(){try{var r=require,vertx=r("vertx");return lib$es6$promise$asap$$vertxNext=vertx.runOnLoop||vertx.runOnContext,lib$es6$promise$asap$$useVertxTimer()}catch(e){return lib$es6$promise$asap$$useSetTimeout()}}function lib$es6$promise$$internal$$noop(){}function lib$es6$promise$$internal$$selfFullfillment(){return new TypeError("You cannot resolve a promise with itself")}function lib$es6$promise$$internal$$cannotReturnOwn(){return new TypeError("A promises callback cannot return that same promise.")}function lib$es6$promise$$internal$$getThen(promise){try{return promise.then}catch(error){return lib$es6$promise$$internal$$GET_THEN_ERROR.error=error,lib$es6$promise$$internal$$GET_THEN_ERROR}}function lib$es6$promise$$internal$$tryThen(then,value,fulfillmentHandler,rejectionHandler){try{then.call(value,fulfillmentHandler,rejectionHandler)}catch(e){return e}}function lib$es6$promise$$internal$$handleForeignThenable(promise,thenable,then){lib$es6$promise$asap$$asap(function(promise){var sealed=!1,error=lib$es6$promise$$internal$$tryThen(then,thenable,function(value){sealed||(sealed=!0,thenable!==value?lib$es6$promise$$internal$$resolve(promise,value):lib$es6$promise$$internal$$fulfill(promise,value))},function(reason){sealed||(sealed=!0,lib$es6$promise$$internal$$reject(promise,reason))},"Settle: "+(promise._label||" unknown promise"));!sealed&&error&&(sealed=!0,lib$es6$promise$$internal$$reject(promise,error))},promise)}function lib$es6$promise$$internal$$handleOwnThenable(promise,thenable){thenable._state===lib$es6$promise$$internal$$FULFILLED?lib$es6$promise$$internal$$fulfill(promise,thenable._result):thenable._state===lib$es6$promise$$internal$$REJECTED?lib$es6$promise$$internal$$reject(promise,thenable._result):lib$es6$promise$$internal$$subscribe(thenable,void 0,function(value){lib$es6$promise$$internal$$resolve(promise,value)},function(reason){lib$es6$promise$$internal$$reject(promise,reason)})}function lib$es6$promise$$internal$$handleMaybeThenable(promise,maybeThenable){if(maybeThenable.constructor===promise.constructor)lib$es6$promise$$internal$$handleOwnThenable(promise,maybeThenable);else{var then=lib$es6$promise$$internal$$getThen(maybeThenable);then===lib$es6$promise$$internal$$GET_THEN_ERROR?lib$es6$promise$$internal$$reject(promise,lib$es6$promise$$internal$$GET_THEN_ERROR.error):void 0===then?lib$es6$promise$$internal$$fulfill(promise,maybeThenable):lib$es6$promise$utils$$isFunction(then)?lib$es6$promise$$internal$$handleForeignThenable(promise,maybeThenable,then):lib$es6$promise$$internal$$fulfill(promise,maybeThenable)}}function lib$es6$promise$$internal$$resolve(promise,value){promise===value?lib$es6$promise$$internal$$reject(promise,lib$es6$promise$$internal$$selfFullfillment()):lib$es6$promise$utils$$objectOrFunction(value)?lib$es6$promise$$internal$$handleMaybeThenable(promise,value):lib$es6$promise$$internal$$fulfill(promise,value)}function lib$es6$promise$$internal$$publishRejection(promise){promise._onerror&&promise._onerror(promise._result),lib$es6$promise$$internal$$publish(promise)}function lib$es6$promise$$internal$$fulfill(promise,value){promise._state===lib$es6$promise$$internal$$PENDING&&(promise._result=value,promise._state=lib$es6$promise$$internal$$FULFILLED,0!==promise._subscribers.length&&lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish,promise))}function lib$es6$promise$$internal$$reject(promise,reason){promise._state===lib$es6$promise$$internal$$PENDING&&(promise._state=lib$es6$promise$$internal$$REJECTED,promise._result=reason,lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection,promise))}function lib$es6$promise$$internal$$subscribe(parent,child,onFulfillment,onRejection){var subscribers=parent._subscribers,length=subscribers.length;parent._onerror=null,subscribers[length]=child,subscribers[length+lib$es6$promise$$internal$$FULFILLED]=onFulfillment,subscribers[length+lib$es6$promise$$internal$$REJECTED]=onRejection,0===length&&parent._state&&lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish,parent)}function lib$es6$promise$$internal$$publish(promise){var subscribers=promise._subscribers,settled=promise._state;if(0!==subscribers.length){for(var child,callback,detail=promise._result,i=0;i<subscribers.length;i+=3)child=subscribers[i],callback=subscribers[i+settled],child?lib$es6$promise$$internal$$invokeCallback(settled,child,callback,detail):callback(detail);promise._subscribers.length=0}}function lib$es6$promise$$internal$$ErrorObject(){this.error=null}function lib$es6$promise$$internal$$tryCatch(callback,detail){try{return callback(detail)}catch(e){return lib$es6$promise$$internal$$TRY_CATCH_ERROR.error=e,lib$es6$promise$$internal$$TRY_CATCH_ERROR}}function lib$es6$promise$$internal$$invokeCallback(settled,promise,callback,detail){var value,error,succeeded,failed,hasCallback=lib$es6$promise$utils$$isFunction(callback);if(hasCallback){if(value=lib$es6$promise$$internal$$tryCatch(callback,detail),value===lib$es6$promise$$internal$$TRY_CATCH_ERROR?(failed=!0,error=value.error,value=null):succeeded=!0,promise===value)return void lib$es6$promise$$internal$$reject(promise,lib$es6$promise$$internal$$cannotReturnOwn())}else value=detail,succeeded=!0;promise._state!==lib$es6$promise$$internal$$PENDING||(hasCallback&&succeeded?lib$es6$promise$$internal$$resolve(promise,value):failed?lib$es6$promise$$internal$$reject(promise,error):settled===lib$es6$promise$$internal$$FULFILLED?lib$es6$promise$$internal$$fulfill(promise,value):settled===lib$es6$promise$$internal$$REJECTED&&lib$es6$promise$$internal$$reject(promise,value))}function lib$es6$promise$$internal$$initializePromise(promise,resolver){try{resolver(function(value){lib$es6$promise$$internal$$resolve(promise,value)},function(reason){lib$es6$promise$$internal$$reject(promise,reason)})}catch(e){lib$es6$promise$$internal$$reject(promise,e)}}function lib$es6$promise$enumerator$$Enumerator(Constructor,input){var enumerator=this;enumerator._instanceConstructor=Constructor,enumerator.promise=new Constructor(lib$es6$promise$$internal$$noop),enumerator._validateInput(input)?(enumerator._input=input,enumerator.length=input.length,enumerator._remaining=input.length,enumerator._init(),0===enumerator.length?lib$es6$promise$$internal$$fulfill(enumerator.promise,enumerator._result):(enumerator.length=enumerator.length||0,enumerator._enumerate(),0===enumerator._remaining&&lib$es6$promise$$internal$$fulfill(enumerator.promise,enumerator._result))):lib$es6$promise$$internal$$reject(enumerator.promise,enumerator._validationError())}function lib$es6$promise$promise$all$$all(entries){return new lib$es6$promise$enumerator$$default(this,entries).promise}function lib$es6$promise$promise$race$$race(entries){function onFulfillment(value){lib$es6$promise$$internal$$resolve(promise,value)}function onRejection(reason){lib$es6$promise$$internal$$reject(promise,reason)}var Constructor=this,promise=new Constructor(lib$es6$promise$$internal$$noop);if(!lib$es6$promise$utils$$isArray(entries))return lib$es6$promise$$internal$$reject(promise,new TypeError("You must pass an array to race.")),promise;for(var length=entries.length,i=0;promise._state===lib$es6$promise$$internal$$PENDING&&length>i;i++)lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]),void 0,onFulfillment,onRejection);return promise}function lib$es6$promise$promise$resolve$$resolve(object){var Constructor=this;if(object&&"object"==typeof object&&object.constructor===Constructor)return object;var promise=new Constructor(lib$es6$promise$$internal$$noop);return lib$es6$promise$$internal$$resolve(promise,object),promise}function lib$es6$promise$promise$reject$$reject(reason){var Constructor=this,promise=new Constructor(lib$es6$promise$$internal$$noop);return lib$es6$promise$$internal$$reject(promise,reason),promise}function lib$es6$promise$promise$$needsResolver(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function lib$es6$promise$promise$$needsNew(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function lib$es6$promise$promise$$Promise(resolver){this._id=lib$es6$promise$promise$$counter++,this._state=void 0,this._result=void 0,this._subscribers=[],lib$es6$promise$$internal$$noop!==resolver&&(lib$es6$promise$utils$$isFunction(resolver)||lib$es6$promise$promise$$needsResolver(),this instanceof lib$es6$promise$promise$$Promise||lib$es6$promise$promise$$needsNew(),lib$es6$promise$$internal$$initializePromise(this,resolver))}function lib$es6$promise$polyfill$$polyfill(){var local;if("undefined"!=typeof global)local=global;else if("undefined"!=typeof self)local=self;else try{local=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var P=local.Promise;(!P||"[object Promise]"!==Object.prototype.toString.call(P.resolve())||P.cast)&&(local.Promise=lib$es6$promise$promise$$default)}var lib$es6$promise$utils$$_isArray;lib$es6$promise$utils$$_isArray=Array.isArray?Array.isArray:function(x){return"[object Array]"===Object.prototype.toString.call(x)};var lib$es6$promise$asap$$vertxNext,lib$es6$promise$asap$$customSchedulerFn,lib$es6$promise$asap$$scheduleFlush,lib$es6$promise$utils$$isArray=lib$es6$promise$utils$$_isArray,lib$es6$promise$asap$$len=0,lib$es6$promise$asap$$asap=({}.toString,function(callback,arg){lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len]=callback,lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len+1]=arg,lib$es6$promise$asap$$len+=2,2===lib$es6$promise$asap$$len&&(lib$es6$promise$asap$$customSchedulerFn?lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush):lib$es6$promise$asap$$scheduleFlush())}),lib$es6$promise$asap$$browserWindow="undefined"!=typeof window?window:void 0,lib$es6$promise$asap$$browserGlobal=lib$es6$promise$asap$$browserWindow||{},lib$es6$promise$asap$$BrowserMutationObserver=lib$es6$promise$asap$$browserGlobal.MutationObserver||lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver,lib$es6$promise$asap$$isNode="undefined"!=typeof process&&"[object process]"==={}.toString.call(process),lib$es6$promise$asap$$isWorker="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,lib$es6$promise$asap$$queue=new Array(1e3);lib$es6$promise$asap$$scheduleFlush=lib$es6$promise$asap$$isNode?lib$es6$promise$asap$$useNextTick():lib$es6$promise$asap$$BrowserMutationObserver?lib$es6$promise$asap$$useMutationObserver():lib$es6$promise$asap$$isWorker?lib$es6$promise$asap$$useMessageChannel():void 0===lib$es6$promise$asap$$browserWindow&&"function"==typeof require?lib$es6$promise$asap$$attemptVertex():lib$es6$promise$asap$$useSetTimeout();var lib$es6$promise$$internal$$PENDING=void 0,lib$es6$promise$$internal$$FULFILLED=1,lib$es6$promise$$internal$$REJECTED=2,lib$es6$promise$$internal$$GET_THEN_ERROR=new lib$es6$promise$$internal$$ErrorObject,lib$es6$promise$$internal$$TRY_CATCH_ERROR=new lib$es6$promise$$internal$$ErrorObject;lib$es6$promise$enumerator$$Enumerator.prototype._validateInput=function(input){return lib$es6$promise$utils$$isArray(input)},lib$es6$promise$enumerator$$Enumerator.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},lib$es6$promise$enumerator$$Enumerator.prototype._init=function(){this._result=new Array(this.length)};var lib$es6$promise$enumerator$$default=lib$es6$promise$enumerator$$Enumerator;lib$es6$promise$enumerator$$Enumerator.prototype._enumerate=function(){for(var enumerator=this,length=enumerator.length,promise=enumerator.promise,input=enumerator._input,i=0;promise._state===lib$es6$promise$$internal$$PENDING&&length>i;i++)enumerator._eachEntry(input[i],i)},lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry=function(entry,i){var enumerator=this,c=enumerator._instanceConstructor;lib$es6$promise$utils$$isMaybeThenable(entry)?entry.constructor===c&&entry._state!==lib$es6$promise$$internal$$PENDING?(entry._onerror=null,enumerator._settledAt(entry._state,i,entry._result)):enumerator._willSettleAt(c.resolve(entry),i):(enumerator._remaining--,enumerator._result[i]=entry)},lib$es6$promise$enumerator$$Enumerator.prototype._settledAt=function(state,i,value){var enumerator=this,promise=enumerator.promise;promise._state===lib$es6$promise$$internal$$PENDING&&(enumerator._remaining--,state===lib$es6$promise$$internal$$REJECTED?lib$es6$promise$$internal$$reject(promise,value):enumerator._result[i]=value),0===enumerator._remaining&&lib$es6$promise$$internal$$fulfill(promise,enumerator._result)},lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt=function(promise,i){var enumerator=this;lib$es6$promise$$internal$$subscribe(promise,void 0,function(value){enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED,i,value)},function(reason){enumerator._settledAt(lib$es6$promise$$internal$$REJECTED,i,reason)})};var lib$es6$promise$promise$all$$default=lib$es6$promise$promise$all$$all,lib$es6$promise$promise$race$$default=lib$es6$promise$promise$race$$race,lib$es6$promise$promise$resolve$$default=lib$es6$promise$promise$resolve$$resolve,lib$es6$promise$promise$reject$$default=lib$es6$promise$promise$reject$$reject,lib$es6$promise$promise$$counter=0,lib$es6$promise$promise$$default=lib$es6$promise$promise$$Promise;lib$es6$promise$promise$$Promise.all=lib$es6$promise$promise$all$$default,lib$es6$promise$promise$$Promise.race=lib$es6$promise$promise$race$$default,lib$es6$promise$promise$$Promise.resolve=lib$es6$promise$promise$resolve$$default,lib$es6$promise$promise$$Promise.reject=lib$es6$promise$promise$reject$$default,lib$es6$promise$promise$$Promise._setScheduler=lib$es6$promise$asap$$setScheduler,lib$es6$promise$promise$$Promise._setAsap=lib$es6$promise$asap$$setAsap,lib$es6$promise$promise$$Promise._asap=lib$es6$promise$asap$$asap,lib$es6$promise$promise$$Promise.prototype={constructor:lib$es6$promise$promise$$Promise,then:function(onFulfillment,onRejection){var parent=this,state=parent._state;if(state===lib$es6$promise$$internal$$FULFILLED&&!onFulfillment||state===lib$es6$promise$$internal$$REJECTED&&!onRejection)return this;var child=new this.constructor(lib$es6$promise$$internal$$noop),result=parent._result;if(state){var callback=arguments[state-1];lib$es6$promise$asap$$asap(function(){lib$es6$promise$$internal$$invokeCallback(state,child,callback,result)})}else lib$es6$promise$$internal$$subscribe(parent,child,onFulfillment,onRejection);return child},"catch":function(onRejection){return this.then(null,onRejection)}};var lib$es6$promise$polyfill$$default=lib$es6$promise$polyfill$$polyfill,lib$es6$promise$umd$$ES6Promise={Promise:lib$es6$promise$promise$$default,polyfill:lib$es6$promise$polyfill$$default};"function"==typeof define&&define.amd?define(function(){return lib$es6$promise$umd$$ES6Promise}):"undefined"!=typeof module&&module.exports?module.exports=lib$es6$promise$umd$$ES6Promise:"undefined"!=typeof this&&(this.ES6Promise=lib$es6$promise$umd$$ES6Promise),lib$es6$promise$polyfill$$default()}).call(this)}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:105}],164:[function(require,module,exports){var globalRequire=require;require=function(){};var exports=module.exports={Lexer:require("./lib/N3Lexer"),Parser:require("./lib/N3Parser"),Writer:require("./lib/N3Writer"),Store:require("./lib/N3Store"),StreamParser:require("./lib/N3StreamParser"),StreamWriter:require("./lib/N3StreamWriter"),Util:require("./lib/N3Util")};Object.keys(exports).forEach(function(submodule){Object.defineProperty(exports,submodule,{configurable:!0,enumerable:!0,get:function(){return delete exports[submodule],exports[submodule]=globalRequire("./lib/N3"+submodule)}})})},{"./lib/N3Lexer":165,"./lib/N3Parser":166,"./lib/N3Store":167,"./lib/N3StreamParser":168,"./lib/N3StreamWriter":169,"./lib/N3Util":170,"./lib/N3Writer":171}],165:[function(require,module){function N3Lexer(options){if(!(this instanceof N3Lexer))return new N3Lexer(options);if(options&&options.lineMode){this._tripleQuotedString=this._number=this._boolean=/$0^/;var self=this;this._tokenize=this.tokenize,this.tokenize=function(input,callback){this._tokenize(input,function(error,token){!error&&/^(?:IRI|prefixed|literal|langcode|type|\.|eof)$/.test(token.type)?callback&&callback(error,token):callback&&callback(error||self._syntaxError(token.type,callback=null))})}}}var fromCharCode=String.fromCharCode,immediately="function"==typeof setImmediate?setImmediate:function(func){setTimeout(func,0)},escapeSequence=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\[uU]|\\(.)/g,escapeReplacements={"\\":"\\","'":"'",'"':'"',n:"\n",r:"\r",t:"	",f:"\f",b:"\b",_:"_","~":"~",".":".","-":"-","!":"!",$:"$","&":"&","(":"(",")":")","*":"*","+":"+",",":",",";":";","=":"=","/":"/","?":"?","#":"#","@":"@","%":"%"},illegalIriChars=/[\x00-\x20<>\\"\{\}\|\^\`]/;N3Lexer.prototype={_iri:/^<((?:[^>\\]|\\[uU])+)>/,_unescapedIri:/^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>/,_unescapedString:/^"[^"\\]+"(?=[^"\\])/,_singleQuotedString:/^"[^"\\]*(?:\\.[^"\\]*)*"(?=[^"\\])|^'[^'\\]*(?:\\.[^'\\]*)*'(?=[^'\\])/,_tripleQuotedString:/^""("[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*")""|^''('[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*')''/,_langcode:/^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9\-])/i,_prefix:/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/,_prefixed:/^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?=\.?[,;\s#()\[\]\{\}"'<])/,_blank:/^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=\.?[,;:\s#()\[\]\{\}"'<])/,_number:/^[\-+]?(?:\d+\.?\d*([eE](?:[\-\+])?\d+)|\d*\.?\d+)(?=[.,;:\s#()\[\]\{\}"'<])/,_boolean:/^(?:true|false)(?=[.,;:\s#()\[\]\{\}"'<])/,_keyword:/^@[a-z]+(?=[\s#<:])/,_sparqlKeyword:/^(?:PREFIX|BASE|GRAPH)(?=[\s#<:])/i,_shortPredicates:/^a(?=\s+|<)/,_newline:/^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,_whitespace:/^[ \t]+/,_endOfFile:/^(?:#[^\n\r]*)?$/,_tokenizeToEnd:function(callback,inputFinished){function reportSyntaxError(self){callback(self._syntaxError(/^\S*/.exec(input)[0]))}for(var input=this._input;;){for(var whiteSpaceMatch;whiteSpaceMatch=this._newline.exec(input);)input=input.substr(whiteSpaceMatch[0].length,input.length),
  this._line++;if((whiteSpaceMatch=this._whitespace.exec(input))&&(input=input.substr(whiteSpaceMatch[0].length,input.length)),this._endOfFile.test(input))return inputFinished&&callback(input=null,{line:this._line,type:"eof",value:"",prefix:""}),this._input=input;var unescaped,line=this._line,type="",value="",prefix="",firstChar=input[0],match=null,matchLength=0,inconclusive=!1;switch(firstChar){case"^":if(1===input.length)break;if("^"!==input[1])return reportSyntaxError(this);if(this._prevTokenType="^",input=input.substr(2),"<"!==input[0]){inconclusive=!0;break}case"<":if(match=this._unescapedIri.exec(input))type="IRI",value=match[1];else if(match=this._iri.exec(input)){if(unescaped=this._unescape(match[1]),null===unescaped||illegalIriChars.test(unescaped))return reportSyntaxError(this);type="IRI",value=unescaped}break;case"_":((match=this._blank.exec(input))||inputFinished&&(match=this._blank.exec(input+" ")))&&(type="prefixed",prefix="_",value=match[1]);break;case'"':case"'":if(match=this._unescapedString.exec(input))type="literal",value=match[0];else if(match=this._singleQuotedString.exec(input)){if(unescaped=this._unescape(match[0]),null===unescaped)return reportSyntaxError(this);type="literal",value=unescaped.replace(/^'|'$/g,'"')}else if(match=this._tripleQuotedString.exec(input)){if(unescaped=match[1]||match[2],this._line+=unescaped.split(/\r\n|\r|\n/).length-1,unescaped=this._unescape(unescaped),null===unescaped)return reportSyntaxError(this);type="literal",value=unescaped.replace(/^'|'$/g,'"')}break;case"@":"literal"===this._prevTokenType&&(match=this._langcode.exec(input))?(type="langcode",value=match[1]):(match=this._keyword.exec(input))&&(type=match[0]);break;case".":if(1===input.length?inputFinished:input[1]<"0"||input[1]>"9"){type=".",matchLength=1;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"+":case"-":(match=this._number.exec(input))&&(type="literal",value='"'+match[0]+'"^^http://www.w3.org/2001/XMLSchema#'+(match[1]?"double":/^[+\-]?\d+$/.test(match[0])?"integer":"decimal"));break;case"B":case"b":case"p":case"P":case"G":case"g":(match=this._sparqlKeyword.exec(input))?type=match[0].toUpperCase():inconclusive=!0;break;case"f":case"t":(match=this._boolean.exec(input))?(type="literal",value='"'+match[0]+'"^^http://www.w3.org/2001/XMLSchema#boolean'):inconclusive=!0;break;case"a":(match=this._shortPredicates.exec(input))?(type="abbreviation",value="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"):inconclusive=!0;break;case",":case";":case"[":case"]":case"(":case")":case"{":case"}":matchLength=1,type=firstChar;break;default:inconclusive=!0}if(inconclusive&&("@prefix"!==this._prevTokenType&&"PREFIX"!==this._prevTokenType||!(match=this._prefix.exec(input))?((match=this._prefixed.exec(input))||inputFinished&&(match=this._prefixed.exec(input+" ")))&&(type="prefixed",prefix=match[1]||"",value=this._unescape(match[2])):(type="prefix",value=match[1]||"")),"^"===this._prevTokenType&&(type="IRI"===type||"prefixed"===type?"type":""),!type)return inputFinished||!/^'''|^"""/.test(input)&&/\n|\r/.test(input)?reportSyntaxError(this):this._input=input;callback(null,{line:line,type:type,value:value,prefix:prefix}),this._prevTokenType=type,input=input.substr(matchLength||match[0].length,input.length)}},_unescape:function(item){try{return item.replace(escapeSequence,function(sequence,unicode4,unicode8,escapedChar){var charCode;if(unicode4){if(charCode=parseInt(unicode4,16),isNaN(charCode))throw new Error;return fromCharCode(charCode)}if(unicode8){if(charCode=parseInt(unicode8,16),isNaN(charCode))throw new Error;return 65535>=charCode?fromCharCode(charCode):fromCharCode(55296+(charCode-=65536)/1024,56320+(1023&charCode))}var replacement=escapeReplacements[escapedChar];if(!replacement)throw new Error;return replacement})}catch(error){return null}},_syntaxError:function(issue){return this._input=null,new Error('Syntax error: unexpected "'+issue+'" on line '+this._line+".")},tokenize:function(input,callback){function addChunk(data){null!==self._input&&(self._input+=data,self._tokenizeToEnd(callback,!1))}function end(){null!==self._input&&self._tokenizeToEnd(callback,!0)}var self=this;this._line=1,"string"==typeof input?(this._input=input,immediately(function(){self._tokenizeToEnd(callback,!0)})):(this._input="",input&&"function"!=typeof input?("function"==typeof input.setEncoding&&input.setEncoding("utf8"),input.on("data",addChunk),input.on("end",end)):(this.addChunk=addChunk,this.end=end,callback||(callback=input)))}},module.exports=N3Lexer},{}],166:[function(require,module){function N3Parser(options){if(!(this instanceof N3Parser))return new N3Parser(options);this._tripleStack=[],this._graph=null,options=options||{},this._setBase(options.documentIRI);var format="string"==typeof options.format&&options.format.match(/\w*$/)[0].toLowerCase(),isTurtle="turtle"===format,isTriG="trig"===format,isNTriples=/triple/.test(format),isNQuads=/quad/.test(format),isLineMode=isNTriples||isNQuads;(this._supportsNamedGraphs=!isTurtle)||(this._readPredicateOrNamedGraph=this._readPredicate),this._supportsQuads=!(isTurtle||isTriG||isNTriples),isLineMode&&(this._base="",this._resolveIRI=function(token){return this._error("Disallowed relative IRI",token),this._callback=noop,this._subject=null}),this._blankNodePrefix="string"!=typeof options.blankNodePrefix?"":"_:"+options.blankNodePrefix.replace(/^_:/,""),this._lexer=options.lexer||new N3Lexer({lineMode:isLineMode})}function noop(){}var N3Lexer=require("./N3Lexer"),RDF_PREFIX="http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDF_NIL=RDF_PREFIX+"nil",RDF_FIRST=RDF_PREFIX+"first",RDF_REST=RDF_PREFIX+"rest",absoluteIRI=/^[a-z][a-z0-9+.-]*:/i,schemeAuthority=/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i,dotSegments=/(?:^|\/)\.\.?(?:$|[\/#?])/,blankNodePrefix=0,blankNodeCount=0;N3Parser._resetBlankNodeIds=function(){blankNodePrefix=blankNodeCount=0},N3Parser.prototype={_setBase:function(baseIRI){if(baseIRI){if(baseIRI.indexOf("#")>=0)throw new Error("Invalid base IRI "+baseIRI)}else baseIRI=null;(this._base=baseIRI)&&(this._basePath=baseIRI.replace(/[^\/?]*(?:\?.*)?$/,""),baseIRI=baseIRI.match(schemeAuthority),this._baseRoot=baseIRI[0],this._baseScheme=baseIRI[1])},_readInTopContext:function(token){switch(token.type){case"eof":return null!==this._graph?this._error("Unclosed graph",token):(delete this._prefixes._,this._callback(null,null,this._prefixes));case"@prefix":return this._sparqlStyle=!1,this._readPrefix;case"PREFIX":return this._sparqlStyle=!0,this._readPrefix;case"@base":return this._sparqlStyle=!1,this._readBaseIRI;case"BASE":return this._sparqlStyle=!0,this._readBaseIRI;case"{":if(this._supportsNamedGraphs)return this._graph="",this._subject=null,this._readSubject;case"GRAPH":if(this._supportsNamedGraphs)return this._readNamedGraphLabel;default:return this._readSubject(token)}},_readSubject:function(token){switch(this._predicate=null,token.type){case"IRI":this._subject=null===this._base||absoluteIRI.test(token.value)?token.value:this._resolveIRI(token);break;case"prefixed":var prefix=this._prefixes[token.prefix];if(void 0===prefix)return this._error('Undefined prefix "'+token.prefix+':"',token);this._subject=prefix+token.value;break;case"[":return this._subject="_:b"+blankNodeCount++,this._tripleStack.push({subject:this._subject,predicate:null,object:null,type:"blank"}),this._readBlankNodeHead;case"(":return this._tripleStack.push({subject:RDF_NIL,predicate:null,object:null,type:"list"}),this._subject=null,this._readListItem;case"}":return this._readPunctuation(token);default:return this._error("Expected subject but got "+token.type,token)}return this._readPredicateOrNamedGraph},_readPredicate:function(token){var type=token.type;switch(type){case"IRI":case"abbreviation":this._predicate=null===this._base||absoluteIRI.test(token.value)?token.value:this._resolveIRI(token);break;case"prefixed":if("_"===token.prefix)return this._error("Disallowed blank node as predicate",token);var prefix=this._prefixes[token.prefix];if(void 0===prefix)return this._error('Undefined prefix "'+token.prefix+':"',token);this._predicate=prefix+token.value;break;case".":case"]":case"}":return null===this._predicate?this._error("Unexpected "+type,token):(this._subject=null,"]"===type?this._readBlankNodeTail(token):this._readPunctuation(token));case";":return this._readPredicate;default:return this._error('Expected predicate to follow "'+this._subject+'"',token)}return this._readObject},_readObject:function(token){switch(token.type){case"IRI":this._object=null===this._base||absoluteIRI.test(token.value)?token.value:this._resolveIRI(token);break;case"prefixed":var prefix=this._prefixes[token.prefix];if(void 0===prefix)return this._error('Undefined prefix "'+token.prefix+':"',token);this._object=prefix+token.value;break;case"literal":return this._object=token.value,this._readDataTypeOrLang;case"[":var blank="_:b"+blankNodeCount++;return this._tripleStack.push({subject:this._subject,predicate:this._predicate,object:blank,type:"blank"}),this._subject=blank,this._readBlankNodeHead;case"(":return this._tripleStack.push({subject:this._subject,predicate:this._predicate,object:RDF_NIL,type:"list"}),this._subject=null,this._readListItem;default:return this._error('Expected object to follow "'+this._predicate+'"',token)}return this._getTripleEndReader()},_readPredicateOrNamedGraph:function(token){return"{"===token.type?this._readGraph(token):this._readPredicate(token)},_readGraph:function(token){return"{"!==token.type?this._error("Expected graph but got "+token.type,token):(this._graph=this._subject,this._subject=null,this._readSubject)},_readBlankNodeHead:function(token){return"]"===token.type?(this._subject=null,this._readBlankNodeTail(token)):(this._predicate=null,this._readPredicate(token))},_readBlankNodeTail:function(token){if("]"!==token.type)return this._readBlankNodePunctuation(token);null!==this._subject&&this._callback(null,{subject:this._subject,predicate:this._predicate,object:this._object,graph:this._graph||""});var triple=this._tripleStack.pop();return this._subject=triple.subject,null!==triple.object?(this._predicate=triple.predicate,this._object=triple.object,this._getTripleEndReader()):null!==this._predicate?this._readPredicate:this._readPredicateOrNamedGraph},_readDataTypeOrLang:function(token){switch(token.type){case"type":var value;if(""===token.prefix)value=null===this._base||absoluteIRI.test(token.value)?token.value:this._resolveIRI(token);else{var prefix=this._prefixes[token.prefix];if(void 0===prefix)return this._error('Undefined prefix "'+token.prefix+':"',token);value=prefix+token.value}return this._object+="^^"+value,this._getTripleEndReader();case"langcode":return this._object+="@"+token.value.toLowerCase(),this._getTripleEndReader();default:return this._getTripleEndReader().call(this,token)}},_readListItem:function(token){var item=null,itemHead=null,prevItemHead=this._subject,stack=this._tripleStack,parentTriple=stack[stack.length-1],next=this._readListItem;switch(token.type){case"IRI":item=null===this._base||absoluteIRI.test(token.value)?token.value:this._resolveIRI(token);break;case"prefixed":var prefix=this._prefixes[token.prefix];if(void 0===prefix)return this._error('Undefined prefix "'+token.prefix+':"',token);item=prefix+token.value;break;case"literal":item=token.value,next=this._readDataTypeOrLang;break;case"[":itemHead="_:b"+blankNodeCount++,item="_:b"+blankNodeCount++,stack.push({subject:itemHead,predicate:RDF_FIRST,object:item,type:"blank"}),this._subject=item,next=this._readBlankNodeHead;break;case"(":itemHead="_:b"+blankNodeCount++,stack.push({subject:itemHead,predicate:RDF_FIRST,object:RDF_NIL,type:"list"}),this._subject=null,next=this._readListItem;break;case")":if(stack.pop(),0!==stack.length&&"list"===stack[stack.length-1].type&&this._callback(null,{subject:parentTriple.subject,predicate:parentTriple.predicate,object:parentTriple.object,graph:this._graph||""}),this._subject=parentTriple.subject,null===parentTriple.predicate){if(next=this._readPredicate,parentTriple.subject===RDF_NIL)return next}else if(this._predicate=parentTriple.predicate,this._object=parentTriple.object,next=this._getTripleEndReader(),parentTriple.object===RDF_NIL)return next;itemHead=RDF_NIL;break;default:return this._error('Expected list item instead of "'+token.type+'"',token)}return null===itemHead&&(this._subject=itemHead="_:b"+blankNodeCount++),null===prevItemHead?parentTriple.object===RDF_NIL?parentTriple.object=itemHead:parentTriple.subject=itemHead:this._callback(null,{subject:prevItemHead,predicate:RDF_REST,object:itemHead,graph:this._graph||""}),null!==item&&this._callback(null,{subject:itemHead,predicate:RDF_FIRST,object:item,graph:this._graph||""}),next},_readPunctuation:function(token){var next,subject=this._subject,graph=this._graph;switch(token.type){case"}":if(null===this._graph)return this._error("Unexpected graph closing",token);this._graph=null;case".":this._subject=null,next=this._readInTopContext;break;case";":next=this._readPredicate;break;case",":next=this._readObject;break;case"IRI":if(this._supportsQuads&&null===this._graph){graph=null===this._base||absoluteIRI.test(token.value)?token.value:this._resolveIRI(token),subject=this._subject,next=this._readQuadPunctuation;break}case"prefixed":if(this._supportsQuads&&null===this._graph){var prefix=this._prefixes[token.prefix];if(void 0===prefix)return this._error('Undefined prefix "'+token.prefix+':"',token);graph=prefix+token.value,next=this._readQuadPunctuation;break}default:return this._error('Expected punctuation to follow "'+this._object+'"',token)}return null!==subject&&this._callback(null,{subject:subject,predicate:this._predicate,object:this._object,graph:graph||""}),next},_readBlankNodePunctuation:function(token){var next;switch(token.type){case";":next=this._readPredicate;break;case",":next=this._readObject;break;default:return this._error('Expected punctuation to follow "'+this._object+'"',token)}return this._callback(null,{subject:this._subject,predicate:this._predicate,object:this._object,graph:this._graph||""}),next},_readQuadPunctuation:function(token){return"."!==token.type?this._error("Expected dot to follow quad",token):this._readInTopContext},_readPrefix:function(token){return"prefix"!==token.type?this._error("Expected prefix to follow @prefix",token):(this._prefix=token.value,this._readPrefixIRI)},_readPrefixIRI:function(token){if("IRI"!==token.type)return this._error('Expected IRI to follow prefix "'+this._prefix+':"',token);var prefixIRI;return prefixIRI=null===this._base||absoluteIRI.test(token.value)?token.value:this._resolveIRI(token),this._prefixes[this._prefix]=prefixIRI,this._prefixCallback(this._prefix,prefixIRI),this._readDeclarationPunctuation},_readBaseIRI:function(token){if("IRI"!==token.type)return this._error("Expected IRI to follow base declaration",token);try{this._setBase(null===this._base||absoluteIRI.test(token.value)?token.value:this._resolveIRI(token))}catch(error){this._error(error.message,token)}return this._readDeclarationPunctuation},_readNamedGraphLabel:function(token){switch(token.type){case"IRI":case"prefixed":return this._readSubject(token),this._readGraph;case"[":return this._readNamedGraphBlankLabel;default:return this._error("Invalid graph label",token)}},_readNamedGraphBlankLabel:function(token){return"]"!==token.type?this._error("Invalid graph label",token):(this._subject="_:b"+blankNodeCount++,this._readGraph)},_readDeclarationPunctuation:function(token){return this._sparqlStyle?this._readInTopContext(token):"."!==token.type?this._error("Expected declaration to end with a dot",token):this._readInTopContext},_getTripleEndReader:function(){var stack=this._tripleStack;if(0===stack.length)return this._readPunctuation;switch(stack[stack.length-1].type){case"blank":return this._readBlankNodeTail;case"list":return this._readListItem}},_error:function(message,token){this._callback(new Error(message+" at line "+token.line+"."))},_resolveIRI:function(token){var iri=token.value;switch(iri[0]){case void 0:return this._base;case"#":return this._base+iri;case"?":return this._base.replace(/(?:\?.*)?$/,iri);case"/":return("/"===iri[1]?this._baseScheme:this._baseRoot)+this._removeDotSegments(iri);default:return this._removeDotSegments(this._basePath+iri)}},_removeDotSegments:function(iri){if(!dotSegments.test(iri))return iri;for(var result="",length=iri.length,i=-1,pathStart=-1,segmentStart=0,next="/";length>i;){switch(next){case":":if(0>pathStart&&"/"===iri[++i]&&"/"===iri[++i])for(;(pathStart=i+1)<length&&"/"!==iri[pathStart];)i=pathStart;break;case"?":case"#":i=length;break;case"/":if("."===iri[i+1])switch(next=iri[++i+1]){case"/":result+=iri.substring(segmentStart,i-1),segmentStart=i+1;break;case void 0:case"?":case"#":return result+iri.substring(segmentStart,i)+iri.substr(i+1);case".":if(next=iri[++i+1],void 0===next||"/"===next||"?"===next||"#"===next){if(result+=iri.substring(segmentStart,i-2),(segmentStart=result.lastIndexOf("/"))>=pathStart&&(result=result.substr(0,segmentStart)),"/"!==next)return result+"/"+iri.substr(i+1);segmentStart=i+1}}}next=iri[++i]}return result+iri.substring(segmentStart)},parse:function(input,tripleCallback,prefixCallback){this._readCallback=this._readInTopContext,this._prefixes=Object.create(null),this._prefixes._=this._blankNodePrefix||"_:b"+blankNodePrefix++ +"_","function"==typeof input&&(prefixCallback=tripleCallback,tripleCallback=input,input=null),this._callback=tripleCallback||noop,this._prefixCallback=prefixCallback||noop;var self=this;this._lexer.tokenize(input,function(error,token){null!==error?(self._callback(error),self._callback=noop):void 0!==self._readCallback&&(self._readCallback=self._readCallback(token))}),input||(this.addChunk=this._lexer.addChunk,this.end=this._lexer.end)}},module.exports=N3Parser},{"./N3Lexer":165}],167:[function(require,module){function N3Store(triples,options){return this instanceof N3Store?(this._size=0,this._graphs=Object.create(null),this._entities=Object.create(null),this._entities["><"]=0,this._entityCount=0,this._blankNodeIndex=0,options||!triples||triples[0]||(options=triples,triples=null),this._prefixes=Object.create(null),options&&options.prefixes&&this.addPrefixes(options.prefixes),void(triples&&this.addTriples(triples))):new N3Store(triples,options)}var expandPrefixedName=require("./N3Util").expandPrefixedName;N3Store.prototype={get size(){var size=this._size;if(null!==size)return size;var subjects,subject,graphs=this._graphs;for(var graphKey in graphs)for(var subjectKey in subjects=graphs[graphKey].subjects)for(var predicateKey in subject=subjects[subjectKey])size+=Object.keys(subject[predicateKey]).length;return this._size=size},_addToIndex:function(index0,key0,key1,key2){var index1=index0[key0]||(index0[key0]={}),index2=index1[key1]||(index1[key1]={});index2[key2]=null},_removeFromIndex:function(index0,key0,key1,key2){var key,index1=index0[key0],index2=index1[key1];delete index2[key2];for(key in index2)return;delete index1[key1];for(key in index1)return;delete index0[key0]},_findInIndex:function(index0,key0,key1,key2,name0,name1,name2,graph){var tmp,index1,index2,results=[],entityKeys=Object.keys(this._entities);key0&&((tmp=index0,index0={})[key0]=tmp[key0]);for(var value0 in index0){var entity0=entityKeys[value0];if(index1=index0[value0]){key1&&((tmp=index1,index1={})[key1]=tmp[key1]);for(var value1 in index1){var entity1=entityKeys[value1];if(index2=index1[value1])for(var values=(key2?key2 in index2?[key2]:[]:Object.keys(index2)),l=values.length-1;l>=0;l--){var result={subject:"",predicate:"",object:"",graph:graph};result[name0]=entity0,result[name1]=entity1,result[name2]=entityKeys[values[l]],results.push(result)}}}}return results},_countInIndex:function(index0,key0,key1,key2){var tmp,index1,index2,count=0;key0&&((tmp=index0,index0={})[key0]=tmp[key0]);for(var value0 in index0)if(index1=index0[value0]){key1&&((tmp=index1,index1={})[key1]=tmp[key1]);for(var value1 in index1)(index2=index1[value1])&&(key2?key2 in index2&&count++:count+=Object.keys(index2).length)}return count},addTriple:function(subject,predicate,object,graph){predicate||(graph=subject.graph,object=subject.object,predicate=subject.predicate,subject=subject.subject),graph=graph||"";var graphItem=this._graphs[graph];graphItem||(graphItem=this._graphs[graph]={subjects:{},predicates:{},objects:{}},Object.freeze(graphItem));var entities=this._entities;subject=entities[subject]||(entities[subject]=++this._entityCount),predicate=entities[predicate]||(entities[predicate]=++this._entityCount),object=entities[object]||(entities[object]=++this._entityCount),this._addToIndex(graphItem.subjects,subject,predicate,object),this._addToIndex(graphItem.predicates,predicate,object,subject),this._addToIndex(graphItem.objects,object,subject,predicate),this._size=null},addTriples:function(triples){for(var i=triples.length-1;i>=0;i--)this.addTriple(triples[i])},addPrefix:function(prefix,iri){this._prefixes[prefix]=iri},addPrefixes:function(prefixes){for(var prefix in prefixes)this.addPrefix(prefix,prefixes[prefix])},removeTriple:function(subject,predicate,object,graph){predicate||(graph=subject.graph,object=subject.object,predicate=subject.predicate,subject=subject.subject),graph=graph||"";var graphItem,entities=this._entities,graphs=this._graphs;if((subject=entities[subject])&&(predicate=entities[predicate])&&(object=entities[object])&&(graphItem=graphs[graph])){var subjects,predicates;if((subjects=graphItem.subjects[subject])&&(predicates=subjects[predicate])&&object in predicates){this._removeFromIndex(graphItem.subjects,subject,predicate,object),this._removeFromIndex(graphItem.predicates,predicate,object,subject),this._removeFromIndex(graphItem.objects,object,subject,predicate),null!==this._size&&this._size--;for(subject in graphItem.subjects)return;delete graphs[graph]}}},removeTriples:function(triples){for(var i=triples.length-1;i>=0;i--)this.removeTriple(triples[i])},find:function(subject,predicate,object,graph){var prefixes=this._prefixes;return this.findByIRI(expandPrefixedName(subject,prefixes),expandPrefixedName(predicate,prefixes),expandPrefixedName(object,prefixes),expandPrefixedName(graph,prefixes))},findByIRI:function(subject,predicate,object,graph){graph=graph||"";var graphItem=this._graphs[graph],entities=this._entities;return graphItem?subject&&!(subject=entities[subject])?[]:predicate&&!(predicate=entities[predicate])?[]:object&&!(object=entities[object])?[]:subject?object?this._findInIndex(graphItem.objects,object,subject,predicate,"object","subject","predicate",graph):this._findInIndex(graphItem.subjects,subject,predicate,null,"subject","predicate","object",graph):predicate?this._findInIndex(graphItem.predicates,predicate,object,null,"predicate","object","subject",graph):object?this._findInIndex(graphItem.objects,object,null,null,"object","subject","predicate",graph):this._findInIndex(graphItem.subjects,null,null,null,"subject","predicate","object",graph):[]},count:function(subject,predicate,object,graph){var prefixes=this._prefixes;return this.countByIRI(expandPrefixedName(subject,prefixes),expandPrefixedName(predicate,prefixes),expandPrefixedName(object,prefixes),expandPrefixedName(graph,prefixes))},countByIRI:function(subject,predicate,object,graph){graph=graph||"";var graphItem=this._graphs[graph],entities=this._entities;return graphItem?subject&&!(subject=entities[subject])?0:predicate&&!(predicate=entities[predicate])?0:object&&!(object=entities[object])?0:subject?object?this._countInIndex(graphItem.objects,object,subject,predicate):this._countInIndex(graphItem.subjects,subject,predicate,object):predicate?this._countInIndex(graphItem.predicates,predicate,object,subject):this._countInIndex(graphItem.objects,object,subject,predicate):0},createBlankNode:function(suggestedName){var name,index;if(suggestedName)for(name=suggestedName="_:"+suggestedName,index=1;this._entities[name];)name=suggestedName+index++;else do name="_:b"+this._blankNodeIndex++;while(this._entities[name]);return this._entities[name]=++this._entityCount,name}},module.exports=N3Store},{"./N3Util":170}],168:[function(require,module){function N3StreamParser(options){if(!(this instanceof N3StreamParser))return new N3StreamParser(options);Transform.call(this,{decodeStrings:!0}),this._readableState.objectMode=!0;var self=this,parser=new N3Parser(options);parser.parse(function(error,triple){triple&&self.push(triple)||error&&self.emit("error",error)},this.emit.bind(this,"prefix")),this._transform=function(chunk,encoding,done){parser.addChunk(chunk),done()},this._flush=function(done){parser.end(),done()}}var Transform=require("stream").Transform,util=require("util"),N3Parser=require("./N3Parser.js");util.inherits(N3StreamParser,Transform),module.exports=N3StreamParser},{"./N3Parser.js":166,stream:137,util:149}],169:[function(require,module){function N3StreamWriter(options){if(!(this instanceof N3StreamWriter))return new N3StreamWriter(options);Transform.call(this,{encoding:"utf8"}),this._writableState.objectMode=!0;var self=this,writer=new N3Writer({write:function(chunk,encoding,callback){self.push(chunk),callback&&callback()},end:function(callback){self.push(null),callback&&callback()}},options);this._transform=function(triple,encoding,done){writer.addTriple(triple,done)},this._flush=function(done){writer.end(done)}}var Transform=require("stream").Transform,util=require("util"),N3Writer=require("./N3Writer.js");util.inherits(N3StreamWriter,Transform),module.exports=N3StreamWriter},{"./N3Writer.js":171,stream:137,util:149}],170:[function(require,module){function addN3Util(parent,toPrototype){for(var name in N3Util)toPrototype?parent.prototype[name]=applyToThis(N3Util[name]):parent[name]=N3Util[name];return parent}function applyToThis(f){return function(a){return f(this,a)}}var Xsd="http://www.w3.org/2001/XMLSchema#",XsdString=Xsd+"string",XsdInteger=Xsd+"integer",XsdDecimal=Xsd+"decimal",XsdBoolean=Xsd+"boolean",RdfLangString="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",N3Util={isIRI:function(entity){if(!entity)return entity;var firstChar=entity[0];return'"'!==firstChar&&"_"!==firstChar},isLiteral:function(entity){return entity&&'"'===entity[0]},isBlank:function(entity){return entity&&"_:"===entity.substr(0,2)},getLiteralValue:function(literal){var match=/^"([^]*)"/.exec(literal);if(!match)throw new Error(literal+" is not a literal");return match[1]},getLiteralType:function(literal){var match=/^"[^]*"(?:\^\^([^"]+)|(@)[^@"]+)?$/.exec(literal);if(!match)throw new Error(literal+" is not a literal");return match[1]||(match[2]?RdfLangString:XsdString)},getLiteralLanguage:function(literal){var match=/^"[^]*"(?:@([^@"]+)|\^\^[^"]+)?$/.exec(literal);if(!match)throw new Error(literal+" is not a literal");return match[1]?match[1].toLowerCase():""},isPrefixedName:function(entity){return entity&&/^[^:\/"']*:[^:\/"']+$/.test(entity)},expandPrefixedName:function(prefixedName,prefixes){var prefix,base,index,match=/(?:^|"\^\^)([^:\/#"'\^_]*):[^\/]*$/.exec(prefixedName);return match&&(prefix=match[1],base=prefixes[prefix],index=match.index),void 0===base?prefixedName:0===index?base+prefixedName.substr(prefix.length+1):prefixedName.substr(0,index+3)+base+prefixedName.substr(index+prefix.length+4)},createIRI:function(iri){return iri&&'"'===iri[0]?N3Util.getLiteralValue(iri):iri},createLiteral:function(value,modifier){if(!modifier)switch(typeof value){case"boolean":modifier=XsdBoolean;break;case"number":if(isFinite(value)){modifier=value%1===0?XsdInteger:XsdDecimal;break}default:return'"'+value+'"'}return'"'+value+(/^[a-z]+(-[a-z0-9]+)*$/i.test(modifier)?'"@'+modifier.toLowerCase():'"^^'+modifier)}};module.exports=addN3Util(addN3Util)},{}],171:[function(require,module){function N3Writer(outputStream,options){if(!(this instanceof N3Writer))return new N3Writer(outputStream,options);if(outputStream&&"function"!=typeof outputStream.write&&(options=outputStream,outputStream=null),options=options||{},outputStream)this._outputStream=outputStream,this._endStream=void 0===options.end?!0:!!options.end;else{var output="";this._outputStream={write:function(chunk,encoding,done){output+=chunk,done&&done()},end:function(done){done&&done(null,output)}},this._endStream=!0}this._subject=null,/triple|quad/i.test(options.format)?this._writeTriple=this._writeTripleLine:(this._graph="",this._prefixIRIs=Object.create(null),options.prefixes&&this.addPrefixes(options.prefixes))}function characterReplacer(character){var result=escapeReplacements[character];return void 0===result&&(1===character.length?(result=character.charCodeAt(0).toString(16),result="\\u0000".substr(0,6-result.length)+result):(result=(1024*(character.charCodeAt(0)-55296)+character.charCodeAt(1)+9216).toString(16),result="\\U00000000".substr(0,10-result.length)+result)),result}var N3LiteralMatcher=/^"([^]*)"(?:\^\^(.+)|@([\-a-z]+))?$/i,RDF_PREFIX="http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDF_TYPE=RDF_PREFIX+"type",escape=/["\\\t\n\r\b\f\u0000-\u0019\ud800-\udbff]/,escapeAll=/["\\\t\n\r\b\f\u0000-\u0019]|[\ud800-\udbff][\udc00-\udfff]/g,escapeReplacements={"\\":"\\\\",'"':'\\"',"	":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};N3Writer.prototype={_write:function(string,callback){this._outputStream.write(string,"utf8",callback)},_writeTriple:function(subject,predicate,object,graph,done){try{this._graph!==graph&&(this._write((null===this._subject?"":this._graph?"\n}\n":".\n")+(graph?this._encodeIriOrBlankNode(graph)+" {\n":"")),this._subject=null,this._graph="["!==graph[0]?graph:"]"),this._subject===subject?this._predicate===predicate?this._write(", "+this._encodeObject(object),done):this._write(";\n    "+this._encodePredicate(this._predicate=predicate)+" "+this._encodeObject(object),done):this._write((null===this._subject?"":".\n")+this._encodeSubject(this._subject=subject)+" "+this._encodePredicate(this._predicate=predicate)+" "+this._encodeObject(object),done)}catch(error){done&&done(error)}},_writeTripleLine:function(subject,predicate,object,graph,done){delete this._prefixMatch;try{this._write(this._encodeIriOrBlankNode(subject)+" "+this._encodeIriOrBlankNode(predicate)+" "+this._encodeObject(object)+(graph?" "+this._encodeIriOrBlankNode(graph)+".\n":".\n"),done)}catch(error){done&&done(error)}},_encodeIriOrBlankNode:function(entity){var firstChar=entity[0];if("["===firstChar||"("===firstChar||"_"===firstChar&&":"===entity[1])return entity;escape.test(entity)&&(entity=entity.replace(escapeAll,characterReplacer));var prefixMatch=this._prefixRegex.exec(entity);return prefixMatch?prefixMatch[1]?this._prefixIRIs[prefixMatch[1]]+prefixMatch[2]:entity:"<"+entity+">"},_encodeLiteral:function(value,type,language){return escape.test(value)&&(value=value.replace(escapeAll,characterReplacer)),language?'"'+value+'"@'+language:type?'"'+value+'"^^'+this._encodeIriOrBlankNode(type):'"'+value+'"'},_encodeSubject:function(subject){if('"'===subject[0])throw new Error("A literal as subject is not allowed: "+subject);return"["===subject[0]&&(this._subject="]"),this._encodeIriOrBlankNode(subject)},_encodePredicate:function(predicate){if('"'===predicate[0])throw new Error("A literal as predicate is not allowed: "+predicate);return predicate===RDF_TYPE?"a":this._encodeIriOrBlankNode(predicate)},_encodeObject:function(object){if('"'!==object[0])return this._encodeIriOrBlankNode(object);var match=N3LiteralMatcher.exec(object);if(!match)throw new Error("Invalid literal: "+object);return this._encodeLiteral(match[1],match[2],match[3])},_blockedWrite:function(){throw new Error("Cannot write because the writer has been closed.")},addTriple:function(subject,predicate,object,graph,done){void 0===object?this._writeTriple(subject.subject,subject.predicate,subject.object,subject.graph||"",predicate):"string"!=typeof graph?this._writeTriple(subject,predicate,object,"",graph):this._writeTriple(subject,predicate,object,graph,done)},addTriples:function(triples){for(var i=0;i<triples.length;i++)this.addTriple(triples[i]);
  
  },addPrefix:function(prefix,iri,done){var prefixes={};prefixes[prefix]=iri,this.addPrefixes(prefixes,done)},addPrefixes:function(prefixes,done){var prefixIRIs=this._prefixIRIs,hasPrefixes=!1;for(var prefix in prefixes){var iri=prefixes[prefix];/[#\/]$/.test(iri)&&prefixIRIs[iri]!==(prefix+=":")&&(hasPrefixes=!0,prefixIRIs[iri]=prefix,null!==this._subject&&(this._write(this._graph?"\n}\n":".\n"),this._subject=null,this._graph=""),this._write("@prefix "+prefix+" <"+iri+">.\n"))}if(hasPrefixes){var IRIlist="",prefixList="";for(var prefixIRI in prefixIRIs)IRIlist+=IRIlist?"|"+prefixIRI:prefixIRI,prefixList+=(prefixList?"|":"")+prefixIRIs[prefixIRI];IRIlist=IRIlist.replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&"),this._prefixRegex=new RegExp("^(?:"+prefixList+")[^/]*$|^("+IRIlist+")([a-zA-Z][\\-_a-zA-Z0-9]*)$")}this._write(hasPrefixes?"\n":"",done)},blank:function(predicate,object){var child,length,children=predicate;switch(void 0===predicate?children=[]:"string"==typeof predicate?children=[{predicate:predicate,object:object}]:"length"in predicate||(children=[predicate]),length=children.length){case 0:return"[]";case 1:if(child=children[0],"["!==child.object[0])return"[ "+this._encodePredicate(child.predicate)+" "+this._encodeObject(child.object)+" ]";default:for(var contents="[",i=0;length>i;i++)child=children[i],child.predicate===predicate?contents+=", "+this._encodeObject(child.object):(contents+=(i?";\n  ":"\n  ")+this._encodePredicate(child.predicate)+" "+this._encodeObject(child.object),predicate=child.predicate);return contents+"\n]"}},list:function(elements){for(var length=elements&&elements.length||0,contents=new Array(length),i=0;length>i;i++)contents[i]=this._encodeObject(elements[i]);return"("+contents.join(" ")+")"},_prefixRegex:/$0^/,end:function(done){null!==this._subject&&(this._write(this._graph?"\n}\n":".\n"),this._subject=null),this._write=this._blockedWrite;var singleDone=done&&function(error,result){singleDone=null,done(error,result)};if(this._endStream)try{return this._outputStream.end(singleDone)}catch(error){}singleDone&&singleDone()}},module.exports=N3Writer},{}],172:[function(require,module,exports){arguments[4][104][0].apply(exports,arguments)},{_process:105,dup:104}],173:[function(require,module){function mixin(rdf){rdf.PrefixMap=function(prefixes){this.addAll(prefixes)},rdf.PrefixMap.prototype.addAll=function(prefixes){for(var prefix in prefixes)this[prefix]=prefixes[prefix]},rdf.PrefixMap.prototype.resolve=function(curie){if(-1!==curie.indexOf("://"))throw new Error("string looks like an IRI");var separator=curie.indexOf(":");if(-1===separator)throw new Error("separator not found");var prefix=curie.substr(0,separator).toLowerCase();if(!(prefix in this))throw new Error("prefix is not defined");return this[prefix].concat(curie.substr(separator+1))},rdf.PrefixMap.prototype.setDefault=function(namespace){this[""]=namespace},rdf.PrefixMap.prototype.shrink=function(iri){var reserved=["addAll","resolve","setDefault","shrink"];for(var prefix in this)if(-1===reserved.indexOf(prefix)){var namespace=this[prefix];if(iri.substr(0,namespace.length)===namespace)return prefix+":"+iri.substr(namespace.length)}return iri},rdf.TermMap=function(i){return Object.defineProperties({},{resolve:{writable:!1,configurable:!1,enumerable:!0,value:function(term){return this[term]?this[term]:this[""]?this[""].concat(term):null}},shrink:{writable:!1,configurable:!1,enumerable:!0,value:function(iri){for(var t in this)if(this[t]===iri)return t;return iri}},setDefault:{writable:!1,configurable:!1,enumerable:!0,value:function(iri){this[""]=iri}},addAll:{writable:!1,configurable:!1,enumerable:!0,value:function(terms,override){for(var t in terms)(!this[t]||override)&&(this[t]=terms[t]);return this}}}).addAll(i)},rdf.Profile=function(i){return Object.defineProperties({},{prefixes:{writable:!1,configurable:!1,enumerable:!0,value:new rdf.PrefixMap},terms:{writable:!1,configurable:!1,enumerable:!0,value:new rdf.TermMap},resolve:{writable:!1,configurable:!1,enumerable:!0,value:function(tp){return tp.indexOf(":")>=0?this.prefixes.resolve(tp):this.terms.resolve(tp)}},setDefaultVocabulary:{writable:!1,configurable:!1,enumerable:!0,value:function(iri){this.terms.setDefault(iri)}},setDefaultPrefix:{writable:!1,configurable:!1,enumerable:!0,value:function(iri){this.prefixes.setDefault(iri)}},setTerm:{writable:!1,configurable:!1,enumerable:!0,value:function(term,iri){this.terms[term]=iri}},setPrefix:{writable:!1,configurable:!1,enumerable:!0,value:function(prefix,iri){this.prefixes[prefix]=iri}},importProfile:{writable:!1,configurable:!1,enumerable:!0,value:function(profile,override){return profile?(this.prefixes.addAll(profile.prefixes,override),this.terms.addAll(profile.terms,override),this):this}}}).importProfile(i)},rdf.RDFEnvironment=function(){var rp={terms:{},prefixes:{owl:"http://www.w3.org/2002/07/owl#",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",rdfa:"http://www.w3.org/ns/rdfa#",xhv:"http://www.w3.org/1999/xhtml/vocab#",xml:"http://www.w3.org/XML/1998/namespace",xsd:"http://www.w3.org/2001/XMLSchema#"}},xsd={},x=["string","boolean","dateTime","date","time","int","double","float","decimal","integer","nonPositiveInteger","negativeInteger","long","int","short","byte","nonNegativeInteger","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger"];for(var v in x)xsd[x[v]]=rp.prefixes.xsd.concat(x[v]);return Object.defineProperties(new rdf.Profile(rp),{createBlankNode:{writable:!1,configurable:!1,enumerable:!0,value:function(){return new rdf.BlankNode}},createNamedNode:{writable:!1,configurable:!1,enumerable:!0,value:function(iri){return new rdf.NamedNode(iri)}},createLiteral:{writable:!1,configurable:!1,enumerable:!0,value:function(value,language,datatype){return new rdf.Literal(value,language,datatype)}},createTriple:{writable:!1,configurable:!1,enumerable:!0,value:function(s,p,o){return new rdf.Triple(s,p,o)}},createGraph:{writable:!1,configurable:!0,enumerable:!0,value:function(a){return new rdf.Graph(a)}},createAction:{writable:!1,configurable:!1,enumerable:!0,value:function(t,a){return new rdf.TripleAction(t,a)}},createProfile:{writable:!1,configurable:!1,enumerable:!0,value:function(empty){return new rdf.Profile(empty?null:this)}},createTermMap:{writable:!1,configurable:!1,enumerable:!0,value:function(empty){return new rdf.TermMap(empty?null:this.terms)}},createPrefixMap:{writable:!1,configurable:!1,enumerable:!0,value:function(empty){return new rdf.PrefixMap(empty?null:this.prefixes)}}})};var singleton=new rdf.RDFEnvironment;Object.keys(singleton).forEach(function(property){rdf[property]=singleton[property]})}module.exports=mixin},{}],174:[function(require,module){function Parsers(parsers){var self=this;parsers&&Object.keys(parsers).forEach(function(mediaType){self[mediaType]=parsers[mediaType]})}Parsers.prototype.list=function(){var propertyBlackList=["list","findParsers","parse","process","stream"];return Object.keys(this).filter(function(property){return-1===propertyBlackList.indexOf(property)})},Parsers.prototype.findParsers=function(mediaType){if(!(mediaType in this))return null;var parsers=this[mediaType];return Array.isArray(parsers)||(parsers=[parsers]),parsers},Parsers.prototype.parse=function(mediaType,data,callback,base,filter,graph){var parsers=this.findParsers(mediaType);return parsers?parsers.shift().parse(data,callback,base,filter,graph):Promise.reject("no parser for mime type: "+mediaType+" found")},Parsers.prototype.process=function(mediaType,data,callback,base,filter,done){var parsers=this.findParsers(mediaType);return parsers?parsers.shift().process(data,callback,base,filter,done):Promise.reject("no parser for mime type: "+mediaType+" found")},Parsers.prototype.stream=function(mediaType,inputStream,base,filter){var parsers=this.findParsers(mediaType);return parsers?parsers.shift().stream(inputStream,base,filter):null},module.exports=Parsers},{}],175:[function(require,module){function Serializers(serializers){var self=this;serializers&&Object.keys(serializers).forEach(function(mediaType){self[mediaType]=serializers[mediaType]})}Serializers.prototype.list=function(){var propertyBlackList=["list","findSerializer","serialize","stream"];return Object.keys(this).filter(function(property){return-1===propertyBlackList.indexOf(property)})},Serializers.prototype.findSerializer=function(mediaType){return mediaType in this?this[mediaType]:null},Serializers.prototype.serialize=function(mediaType,graph,callback){var serializer=this.findSerializer(mediaType);return serializer?serializer.serialize(graph,callback):Promise.reject("no serializer for mime type: "+mediaType+" found")},Serializers.prototype.stream=function(mediaType,inputStream,base,filter){var serializer=this.findSerializer(mediaType);return serializer?serializer.stream(inputStream,base,filter):null},module.exports=Serializers},{}],176:[function(require,module){var utils={};utils.defaultRequest=function(method,requestUrl,headers,content,callback){return"object"==typeof method&&(callback=requestUrl,requestUrl=method.url,headers=method.headers,content=method.body,method=method.method),new Promise(function(resolve){callback=callback||function(){};var xhr=new XMLHttpRequest;xhr.onreadystatechange=function(){if(xhr.readyState===xhr.DONE){for(var headerLines=xhr.getAllResponseHeaders().split("\r\n"),resHeaders={},i=0;i<headerLines.length;i++){var headerLine=headerLines[i].split(": ",2);resHeaders[headerLine[0].toLowerCase()]=headerLine[1]}callback(xhr.status,resHeaders,xhr.responseText),resolve({statusCode:xhr.status,headers:resHeaders,content:xhr.responseText})}},xhr.open(method,requestUrl,!0);for(var header in headers)xhr.setRequestHeader(header,headers[header]);xhr.send(content)})},utils.corsProxyRequest=function(proxyUrl,method,requestUrl,headers,content,callback){var url=proxyUrl+"?url="+encodeURIComponent(requestUrl);return utils.defaultRequest(method,url,headers,content,callback)},utils.mixin=function(rdf){rdf.defaultRequest=utils.defaultRequest,rdf.corsProxyRequest=utils.corsProxyRequest},module.exports=utils.mixin},{}],177:[function(require,module){var http=require("http"),https=require("https"),url=require("url"),utils={};utils.defaultRequest=function(method,requestUrl,headers,content,callback){return"object"==typeof method&&(callback=requestUrl,requestUrl=method.url,headers=method.headers,content=method.body,method=method.method),new Promise(function(resolve,reject){callback=callback||function(){};var options=url.parse(requestUrl),client=http;options.hash=null,options.method=method,options.headers=headers,"https:"===options.protocol&&(client=https);var req=client.request(options,function(res){var resContent="";res.setEncoding("utf8"),res.on("data",function(chunk){resContent+=chunk}),res.on("end",function(){callback(res.statusCode,res.headers,resContent),resolve({statusCode:res.statusCode,headers:res.headers,content:resContent})})});req.on("error",function(error){callback(null,null,null,error),reject(error)}),content&&req.write(content),req.end()})},utils.mixin=function(rdf){rdf.defaultRequest=utils.defaultRequest},module.exports=utils.mixin},{http:138,https:90,url:144}],178:[function(require,module){var utils={};utils.filter={},utils.filter.namedNode=function(node){return"NamedNode"===node.interfaceName},utils.filter.blankNode=function(node){return"BlankNode"===node.interfaceName},utils.filter.literal=function(node){return"Literal"===node.interfaceName},utils.filter.namedNodeSubject=function(subject){return function(triple){return"NamedNode"!==triple.subject.interfaceName||triple.subject.equals(subject)}},utils.list={},utils.list.tripleParts=function(graph,part,filter){var nodes={};return filter=filter||function(){return!0},graph.forEach(function(triple){nodes[triple[part].toString()]=triple[part]}),nodes=Object.keys(nodes).map(function(key){return nodes[key]}).filter(function(node){return filter(node)})},utils.list.subjects=function(graph,filter){return utils.list.tripleParts(graph,"subject",filter)},utils.list.predicates=function(graph,filter){return utils.list.tripleParts(graph,"predicate",filter)},utils.list.objects=function(graph,filter){return utils.list.tripleParts(graph,"object",filter)},utils.createSubGraph=function(rdf,graph,entry,filter){var processedEntries={},subGraph=rdf.createGraph(),processSubject=function(entries){if(0!==entries.length){var newEntries=[],matches=rdf.createGraph();entries.forEach(function(entry){matches.addAll(graph.match(entry))}),filter&&(matches=matches.filter(filter)),matches.forEach(function(match){var key=match.object.toString();key in processedEntries||(newEntries.push(match.object),processedEntries[key]=!0)}),subGraph.addAll(matches),processSubject(newEntries)}};return processSubject([entry]),subGraph},utils.createSubGraphByNamedNodeSubject=function(rdf,graph,subject){return rdf.utils.createSubGraph(graph,subject,utils.filter.namedNodeSubject(subject))},utils.splitGraphByNamedNodeSubject=function(rdf,graph,store){store=store||rdf.createStore();var adds=[];return utils.list.subjects(graph,utils.filter.namedNode).forEach(function(subject){adds.push(store.add(subject,utils.createSubGraphByNamedNodeSubject(rdf,graph,subject)))}),Promise.all(adds).then(function(){return store})},utils.mapNamespaceNode=function(rdf,node,search,replace){return"NamedNode"!==node.interfaceName?node:0!==node.nominalValue.toString().indexOf(search)?node:rdf.createNamedNode(replace+node.nominalValue.toString().substr(search.length))},utils.mapNamespaceTriple=function(rdf,triple,search,replace){return rdf.createTriple(utils.mapNamespaceNode(rdf,triple.subject,search,replace),utils.mapNamespaceNode(rdf,triple.predicate,search,replace),utils.mapNamespaceNode(rdf,triple.object,search,replace))},utils.mapNamespaceGraph=function(rdf,graph,search,replace){var mappedGraph=rdf.createGraph();return graph.forEach(function(triple){mappedGraph.add(utils.mapNamespaceTriple(rdf,triple,search,replace))}),mappedGraph},utils.mixin=function(rdf){rdf.utils={},rdf.utils.filter=utils.filter,rdf.utils.list=utils.list,rdf.utils.createSubGraph=utils.createSubGraph.bind(null,rdf),rdf.utils.createSubGraphByNamedNodeSubject=utils.createSubGraphByNamedNodeSubject.bind(null,rdf),rdf.utils.splitGraphByNamedNodeSubject=utils.splitGraphByNamedNodeSubject.bind(null,rdf),rdf.utils.mapNamespaceNode=utils.mapNamespaceNode.bind(null,rdf),rdf.utils.mapNamespaceTriple=utils.mapNamespaceTriple.bind(null,rdf),rdf.utils.mapNamespaceGraph=utils.mapNamespaceGraph.bind(null,rdf),rdf.utils.mimeTypeParserMap=utils.mimeTypeParserMap,rdf.utils.mimeTypeSerializerMap=utils.mimeTypeSerializerMap,rdf.utils.parse=utils.parse,rdf.utils.serialize=utils.serialize},module.exports=utils.mixin},{}],179:[function(require,module){(function(process){var rdf=require("rdf-graph-array"),InMemoryStore=require("rdf-store-inmemory"),Parsers=require("./lib/parsers"),Serializers=require("./lib/serializers"),mixin=function(rdf,options){return options=options||{},require("./lib/environment")(rdf),"undefined"!=typeof window&&(window.rdf=rdf),rdf.defaultRequest=null,rdf.corsProxyRequest=null,require("./lib/utils")(rdf),"undefined"!=typeof process&&process.versions&&process.versions.node?require("./lib/utils-node")(rdf):require("./lib/utils-browser")(rdf),rdf.createBlankNode=function(){return new rdf.BlankNode},rdf.createNamedNode=function(iri){return new rdf.NamedNode(iri)},rdf.createLiteral=function(value,language,datatype){return new rdf.Literal(value,language,datatype)},rdf.createTriple=function(subject,predicate,object){return new rdf.Triple(subject,predicate,object)},rdf.createQuad=function(subject,predicate,object,graph){return new rdf.Quad(subject,predicate,object,graph)},rdf.createGraph=function(triples){return new rdf.Graph(triples)},rdf.createStore=function(options){return options=options||{},options.rdf=options.rdf||rdf,new InMemoryStore(options)},rdf.Parsers=Parsers,rdf.parsers=new Parsers,rdf.Serializers=Serializers,rdf.serializers=new Serializers,rdf};mixin(rdf),module.exports=rdf}).call(this,require("_process"))},{"./lib/environment":173,"./lib/parsers":174,"./lib/serializers":175,"./lib/utils":178,"./lib/utils-browser":176,"./lib/utils-node":177,_process:105,"rdf-graph-array":182,"rdf-store-inmemory":201}],180:[function(require,module){function register(handler,format,instance){format in handler||(handler[format]=instance)}function mixin(object){return object=object||{},object.parsers=object.parsers||new rdf.Parsers,object.serializers=object.serializers||new rdf.Serializers,register(object.parsers,"application/ld+json",JsonLdParser),register(object.parsers,"application/n-triples",N3Parser),register(object.parsers,"application/rdf+xml",RdfXmlParser),register(object.parsers,"application/xhtml+xml",MicrodataParser),register(object.parsers,"text/html",MicrodataParser),register(object.parsers,"text/n3",N3Parser),register(object.parsers,"text/turtle",N3Parser),register(object.serializers,"application/ld+json",new JsonLdSerializer({outputString:!0})),register(object.serializers,"application/n-triples",NTriplesSerializer),register(object.serializers,"application/sparql-update",SparqlUpdateSerializer),register(object.serializers,"text/n3",N3Serializer),register(object.serializers,"text/turtle",N3Serializer),object}var rdf=require("rdf-ext"),JsonLdParser=require("rdf-parser-jsonld"),MicrodataParser=require("rdf-parser-microdata"),N3Parser=require("rdf-parser-n3"),RdfXmlParser=require("rdf-parser-rdfxml"),JsonLdSerializer=require("rdf-serializer-jsonld"),N3Serializer=require("rdf-serializer-n3"),NTriplesSerializer=require("rdf-serializer-ntriples"),SparqlUpdateSerializer=require("rdf-serializer-sparql-update");module.exports=mixin},{"rdf-ext":179,"rdf-parser-jsonld":189,"rdf-parser-microdata":190,"rdf-parser-n3":192,"rdf-parser-rdfxml":194,"rdf-serializer-jsonld":196,"rdf-serializer-n3":197,"rdf-serializer-ntriples":198,"rdf-serializer-sparql-update":199}],181:[function(require,module){var normalize=require("rdf-normalize"),rdf={};rdf.encodeString=function(s){for(var out="",skip=!1,_g1=0,_g=s.length;_g>_g1;){var i=_g1++;if(skip)skip=!skip;else{var code=s.charCodeAt(i);if(code>=55296&&56319>=code){var low=s.charCodeAt(i+1);code=1024*(code-55296)+(low-56320)+65536,skip=!0}if(code>1114111)throw new Error("Char out of range");var hex="00000000".concat(Number(code).toString(16).toUpperCase());if(code>=65536)out+="\\"+hex.slice(-8);else if(code>=127||31>=code)switch(code){case 9:out+="\\t";break;case 10:out+="\\n";break;case 13:out+="\\r";break;default:out+="\\u"+hex.slice(-4)}else switch(code){case 34:out+='\\"';break;case 92:out+="\\\\";break;default:out+=s.charAt(i)}}}return out},rdf.AbstractGraph=function(constructor,other){this.constructor=constructor,Object.defineProperty(this,"length",{get:function(){return this.toArray().length}}),other&&this.addAll(other)},rdf.AbstractGraph.prototype.addAll=function(other){var self=this;return other.forEach(function(quad){self.add(quad)}),this},rdf.AbstractGraph.prototype.clone=function(){return new this.constructor(this)},rdf.AbstractGraph.prototype.difference=function(other){var difference=new this.constructor;return this.forEach(function(quad){other.includes(quad)||difference.add(quad)}),difference},rdf.AbstractGraph.prototype.equals=function(other){return normalize(this)===normalize(other)},rdf.AbstractGraph.prototype.every=function(callback){return this.toArray().every(callback)},rdf.AbstractGraph.prototype.filter=function(callback){return new this.constructor(this.toArray().filter(callback))},rdf.AbstractGraph.prototype.forEach=function(callback){var self=this;self.toArray().forEach(function(quad){callback(quad,self)})},rdf.AbstractGraph.prototype.includes=function(quad){return 1===this.match(quad.subject,quad.predicate,quad.object,quad.graph).length},rdf.AbstractGraph.prototype.intersection=function(other){var intersection=new this.constructor;return this.forEach(function(quad){other.includes(quad)&&intersection.add(quad)}),intersection},rdf.AbstractGraph.prototype.map=function(callback){var self=this;return self.toArray().map(function(quad){return callback(quad,self)})},rdf.AbstractGraph.prototype.match=function(subject,predicate,object,graph){return new rdf.Graph(this.toArray().filter(function(quad){return!graph||quad.graph&&quad.graph.equals(graph)?subject&&!quad.subject.equals(subject)?!1:predicate&&!quad.predicate.equals(predicate)?!1:object&&!quad.object.equals(object)?!1:!0:!1}))},rdf.AbstractGraph.prototype.merge=function(other){return this.clone().addAll(other)},rdf.AbstractGraph.prototype.removeMatches=function(subject,predicate,object,graph){var self=this,matches=self.match(subject,predicate,object,graph);return matches.forEach(function(quad){self.remove(quad)}),self},rdf.AbstractGraph.prototype.some=function(callback){return this.toArray().some(callback)},rdf.AbstractGraph.prototype.toString=function(){return this.toArray().map(function(quad){return quad.toString()}).join("\n")},module.exports=rdf},{"rdf-normalize":183}],182:[function(require,module){var rdf=require("rdf-graph-abstract"),util=require("util");rdf.NamedNode=function(iri){this.interfaceName="NamedNode",this.nominalValue=iri},rdf.NamedNode.prototype.equals=function(other){if("string"==typeof other)return this.nominalValue===other;if("object"==typeof other){if("RegExp"===other.constructor.name)return other.test(this.nominalValue);if(other.interfaceName===this.interfaceName)return this.nominalValue===other.nominalValue}return!1},rdf.NamedNode.prototype.toNT=function(){return"<"+rdf.encodeString(this.nominalValue)+">"},rdf.NamedNode.prototype.toString=function(){return this.nominalValue},rdf.NamedNode.prototype.valueOf=function(){return this.nominalValue},rdf.BlankNode=function(){this.interfaceName="BlankNode",this.nominalValue="b"+ ++rdf.BlankNode.nextId},rdf.BlankNode.prototype.equals=function(other){if("string"==typeof other)return this.nominalValue===other;if("object"==typeof other){if("RegExp"===other.constructor.name)return other.test(this.nominalValue);if(other.interfaceName===this.interfaceName)return this.nominalValue===other.nominalValue}return!1},rdf.BlankNode.prototype.toNT=function(){return"_:"+rdf.encodeString(this.nominalValue)},rdf.BlankNode.prototype.toString=function(){return"_:"+this.nominalValue},rdf.BlankNode.prototype.valueOf=function(){return this.nominalValue},rdf.BlankNode.nextId=0,rdf.Literal=function(value,language,datatype,native){this.interfaceName="Literal",this.nominalValue=value,language?(this.language=language,this.datatype=rdf.Literal.langString):(this.language=null,this.datatype=datatype?new rdf.NamedNode(datatype.toString()):rdf.Literal.string),this["native"]=native},rdf.Literal.prototype.equals=function(other){if("string"==typeof other)return this.nominalValue===other;if("object"==typeof other){if("RegExp"===other.constructor.name)return other.test(this.nominalValue);if(other.interfaceName===this.interfaceName)return this.nominalValue.toString()!==other.nominalValue.toString()?!1:this.language!==other.language?!1:this.datatype&&!this.datatype.equals(other.datatype)?!1:!0}return!1},rdf.Literal.prototype.toNT=function(){var string='"'+rdf.encodeString(this.nominalValue.toString())+'"';return this.language&&(string+="@"+this.language),!this.datatype||rdf.Literal.string.equals(this.datatype)||rdf.Literal.langString.equals(this.datatype)||(string+="^^"+this.datatype.toNT()),string},rdf.Literal.prototype.toString=function(){return this.nominalValue},rdf.Literal.langString=new rdf.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),rdf.Literal.string=new rdf.NamedNode("http://www.w3.org/2001/XMLSchema#string"),rdf.Triple=function(subject,predicate,object){this.subject=subject,this.predicate=predicate,this.object=object},rdf.Triple.prototype.equals=function(other){return this.subject.equals(other.subject)&&this.predicate.equals(other.predicate)&&this.object.equals(other.object)},rdf.Triple.prototype.toNT=function(){return this.toString()},rdf.Triple.prototype.toQuad=function(graph){return new rdf.Quad(this.subject,this.predicate,this.object,graph)},rdf.Triple.prototype.toString=function(){return this.subject.toNT()+" "+this.predicate.toNT()+" "+this.object.toNT()+" ."},rdf.Quad=function(subject,predicate,object,graph){this.subject=subject,this.predicate=predicate,this.object=object,this.graph=graph},rdf.Quad.prototype.equals=function(other){return this.subject.equals(other.subject)&&this.predicate.equals(other.predicate)&&this.object.equals(other.object)&&this.graph.equals(other.graph)},rdf.Quad.prototype.toNT=function(){return this.toString()},rdf.Quad.prototype.toString=function(){return this.subject.toNT()+" "+this.predicate.toNT()+" "+this.object.toNT()+" "+this.graph.toNT()+" ."},rdf.Quad.prototype.toTriple=function(){return new rdf.Triple(this.subject,this.predicate,this.object)},rdf.Graph=function(other){this.actions=[],this._graph=[],this._gspo={},rdf.AbstractGraph.call(this,rdf.Graph,other)},util.inherits(rdf.Graph,rdf.AbstractGraph),rdf.Graph.prototype.add=function(quad){var i=rdf.Graph.index(quad);return this._gspo[i.g]=this._gspo[i.g]||{},this._gspo[i.g][i.s]=this._gspo[i.g][i.s]||{},this._gspo[i.g][i.s][i.p]=this._gspo[i.g][i.s][i.p]||{},this._gspo[i.g][i.s][i.p][i.o]||(this._gspo[i.g][i.s][i.p][i.o]=quad,this._graph.push(quad),this.actions.forEach(function(action){action.run(quad)})),this},rdf.Graph.prototype.addAction=function(){},rdf.Graph.prototype.remove=function(quad){var i=rdf.Graph.index(quad);this._gspo[i.g][i.s][i.p][i.o]&&(delete this._gspo[i.g][i.s][i.p][i.o],this._graph.splice(this._graph.indexOf(quad),1))},rdf.Graph.prototype.toArray=function(){return this._graph.slice(0)},rdf.Graph.index=function(quad){return{g:quad.graph?quad.graph.toString():null,s:quad.subject.toString(),p:quad.predicate.toString(),o:quad.object.toString()}},module.exports=rdf},{"rdf-graph-abstract":181,util:149}],183:[function(require,module){function createPlainNode(node){if(!node)return null;var plain={};return"NamedNode"===node.interfaceName?(plain.type="IRI",plain.value=node.nominalValue):"BlankNode"===node.interfaceName?(plain.type="blank node",plain.value=node.toString()):"Literal"===node.interfaceName&&(plain.type="literal",plain.value=node.nominalValue,plain.datatype=node.datatype.nominalValue,plain.language=node.language),plain}function createPlainTriple(triple){return{subject:createPlainNode(triple.subject),predicate:createPlainNode(triple.predicate),object:createPlainNode(triple.object)}}function createPlainDataset(graph){var dataset={};return graph.forEach(function(quad){var name="@default";"graph"in quad&&quad.graph.nominalValue&&(name=quad.graph.nominalValue),name in dataset||(dataset[name]=[]),dataset[name].push(createPlainTriple(quad))}),dataset}function normalize(graph){return jsonldNormalize(createPlainDataset(graph))}var jsonldNormalize=require("./jsonld-normalize");module.exports=normalize},{"./jsonld-normalize":184}],184:[function(require,module){function _hashQuads(id,bnodes){if("hash"in bnodes[id])return bnodes[id].hash;for(var quads=bnodes[id].quads,nquads=[],i=0;i<quads.length;++i)nquads.push(_toNQuad(quads[i],quads[i].name?quads[i].name.value:null,id));nquads.sort();var hash=bnodes[id].hash=sha1.hash(nquads);return hash}function _hashPaths(id,bnodes,namer,pathNamer,callback){function groupNodes(i){if(i===quads.length)return groupHashes=Object.keys(groups).sort(),hashGroup(0);var quad=quads[i],bnode=_getAdjacentBlankNodeName(quad.subject,id),direction=null;if(null!==bnode?direction="p":(bnode=_getAdjacentBlankNodeName(quad.object,id),null!==bnode&&(direction="r")),null!==bnode){var name;name=namer.isNamed(bnode)?namer.getName(bnode):pathNamer.isNamed(bnode)?pathNamer.getName(bnode):_hashQuads(bnode,bnodes);var md=sha1.create();md.update(direction),md.update(quad.predicate.value),md.update(name);var groupHash=md.digest();groupHash in groups?groups[groupHash].push(bnode):groups[groupHash]=[bnode]}return groupNodes(i+1)}function hashGroup(i){function permutate(){function nextRecursion(n){if(n===recurse.length)return nextPermutation(!1);var bnode=recurse[n];return _hashPaths(bnode,bnodes,namer,pathNamerCopy,function(err,result){return err?callback(err):(path+=pathNamerCopy.getName(bnode)+"<"+result.hash+">",pathNamerCopy=result.pathNamer,null!==chosenPath&&path.length>=chosenPath.length&&path>chosenPath?nextPermutation(!0):nextRecursion(n+1))})}function nextPermutation(skipped){return!skipped&&(null===chosenPath||chosenPath>path)&&(chosenPath=path,chosenNamer=pathNamerCopy),permutator.hasNext()?permutate():(md.update(chosenPath),pathNamer=chosenNamer,hashGroup(i+1))}var permutation=permutator.next(),pathNamerCopy=pathNamer.clone(),path="",recurse=[];for(var n in permutation){var bnode=permutation[n];if(namer.isNamed(bnode)?path+=namer.getName(bnode):(pathNamerCopy.isNamed(bnode)||recurse.push(bnode),path+=pathNamerCopy.getName(bnode)),null!==chosenPath&&path.length>=chosenPath.length&&path>chosenPath)return nextPermutation(!0)}return nextRecursion(0)}if(i===groupHashes.length)return callback(null,{hash:md.digest(),pathNamer:pathNamer});var groupHash=groupHashes[i];md.update(groupHash);var chosenPath=null,chosenNamer=null,permutator=new Permutator(groups[groupHash]);return permutate()}var groupHashes,md=sha1.create(),groups={},quads=bnodes[id].quads;return groupNodes(0)}function _getAdjacentBlankNodeName(node,id){return"blank node"===node.type&&node.value!==id?node.value:null}function _clone(value){if(value&&"object"==typeof value){var rval;if(Array.isArray(value)){rval=[];for(var i=0;i<value.length;++i)rval[i]=_clone(value[i])}else if("object"==typeof value){rval={};for(var key in value)rval[key]=_clone(value[key])}else rval=value.toString();return rval}return value}function _toNQuad(triple,graphName,bnode){var s=triple.subject,p=triple.predicate,o=triple.object,g=graphName,quad="";if(quad+="IRI"===s.type?"<"+s.value+">":bnode?s.value===bnode?"_:a":"_:z":s.value,quad+=" ",quad+="IRI"===p.type?"<"+p.value+">":bnode?"_:p":p.value,quad+=" ","IRI"===o.type)quad+="<"+o.value+">";else if("blank node"===o.type)quad+=bnode?o.value===bnode?"_:a":"_:z":o.value;else{var escaped=o.value.replace(/\\/g,"\\\\").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\"/g,'\\"');quad+='"'+escaped+'"',o.datatype===RDF_LANGSTRING?o.language&&(quad+="@"+o.language):o.datatype!==XSD_STRING&&(quad+="^^<"+o.datatype+">")}return null!==g&&(quad+=0!==g.indexOf("_:")?" <"+g+">":bnode?" _:g":" "+g),quad+=" .\n"}function UniqueNamer(prefix){this.prefix=prefix,this.counter=0,this.existing={}}function normalize(dataset){var processor=new Processor;return processor.normalize(dataset)}var XSD_STRING="http://www.w3.org/2001/XMLSchema#string",RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDF_LANGSTRING=RDF+"langString",Processor=function(){};Processor.prototype.normalize=function(dataset,options,callback){function hashBlankNodes(unnamed){function hashUnnamed(i){if(i===unnamed.length)return nameBlankNodes(unique,duplicates,nextUnnamed);var bnode=unnamed[i],hash=_hashQuads(bnode,bnodes);return hash in duplicates?(duplicates[hash].push(bnode),nextUnnamed.push(bnode)):hash in unique?(duplicates[hash]=[unique[hash],bnode],nextUnnamed.push(unique[hash]),nextUnnamed.push(bnode),delete unique[hash]):unique[hash]=bnode,hashUnnamed(i+1)}var nextUnnamed=[],duplicates={},unique={};return hashUnnamed(0)}function nameBlankNodes(unique,duplicates,unnamed){for(var named=!1,hashes=Object.keys(unique).sort(),i=0;i<hashes.length;++i){var bnode=unique[hashes[i]];namer.getName(bnode),named=!0}return named?hashBlankNodes(unnamed):nameDuplicates(duplicates)}function nameDuplicates(duplicates){function processGroup(i){function nameGroupMember(group,n){if(n===group.length){results.sort(function(a,b){return a=a.hash,b=b.hash,b>a?-1:a>b?1:0});for(var r=0;r<results.length;++r)for(var key in results[r].pathNamer.existing)namer.getName(key);return processGroup(i+1)}var bnode=group[n];
  
  if(namer.isNamed(bnode))return nameGroupMember(group,n+1);var pathNamer=new UniqueNamer("_:b");return pathNamer.getName(bnode),_hashPaths(bnode,bnodes,namer,pathNamer,function(err,result){return err?callback(err):(results.push(result),nameGroupMember(group,n+1))})}if(i===hashes.length)return createArray();var group=duplicates[hashes[i]],results=[];return nameGroupMember(group,0)}var hashes=Object.keys(duplicates).sort();return processGroup(0)}function createArray(){for(var normalized=[],i=0;i<quads.length;++i){for(var quad=quads[i],attrs=["subject","object","name"],ai=0;ai<attrs.length;++ai){var attr=attrs[ai];quad[attr]&&"blank node"===quad[attr].type&&0!==quad[attr].value.indexOf("_:c14n")&&(quad[attr].value=namer.getName(quad[attr].value))}normalized.push(_toNQuad(quad,quad.name?quad.name.value:null))}return normalized.sort().join("")}var quads=[],bnodes={};for(var graphName in dataset){var triples=dataset[graphName];"@default"===graphName&&(graphName=null);for(var ti=0;ti<triples.length;++ti){var quad=triples[ti];null!==graphName&&(quad.name=0===graphName.indexOf("_:")?{type:"blank node",value:graphName}:{type:"IRI",value:graphName}),quads.push(quad);for(var attrs=["subject","object","name"],ai=0;ai<attrs.length;++ai){var attr=attrs[ai];if(quad[attr]&&"blank node"===quad[attr].type){var id=quad[attr].value;id in bnodes?bnodes[id].quads.push(quad):bnodes[id]={quads:[quad]}}}}}var namer=new UniqueNamer("_:c14n");return hashBlankNodes(Object.keys(bnodes))},UniqueNamer.prototype.clone=function(){var copy=new UniqueNamer(this.prefix);return copy.counter=this.counter,copy.existing=_clone(this.existing),copy},UniqueNamer.prototype.getName=function(oldName){if(oldName&&oldName in this.existing)return this.existing[oldName];var name=this.prefix+this.counter;return this.counter+=1,oldName&&(this.existing[oldName]=name),name},UniqueNamer.prototype.isNamed=function(oldName){return oldName in this.existing};var Permutator=function(list){this.list=list.sort(),this.done=!1,this.left={};for(var i=0;i<list.length;++i)this.left[list[i]]=!0};Permutator.prototype.hasNext=function(){return!this.done},Permutator.prototype.next=function(){for(var rval=this.list.slice(),k=null,pos=0,length=this.list.length,i=0;length>i;++i){var element=this.list[i],left=this.left[element];(null===k||element>k)&&(left&&i>0&&element>this.list[i-1]||!left&&length-1>i&&element>this.list[i+1])&&(k=element,pos=i)}if(null===k)this.done=!0;else{var swap=this.left[k]?pos-1:pos+1;this.list[pos]=this.list[swap],this.list[swap]=k;for(var i=0;length>i;++i)this.list[i]>k&&(this.left[this.list[i]]=!this.left[this.list[i]])}return rval};var sha1={},crypto=require("crypto");sha1.create=function(){var md=crypto.createHash("sha1");return{update:function(data){md.update(data,"utf8")},digest:function(){return md.digest("hex")}}},sha1.hash=function(nquads){for(var md=sha1.create(),i=0;i<nquads.length;++i)md.update(nquads[i]);return md.digest()},module.exports=normalize},{crypto:54}],185:[function(require,module){(function(process){function AbstractParser(rdf){this.rdf=rdf}var concatStream=require("concat-stream"),inherits=require("inherits"),Readable=require("stream").Readable;AbstractParser.prototype.parse=function(data,callback,base,filter,graph){var self=this;graph=graph||self.rdf.createGraph();var pushTriple=function(triple){graph.add(triple)};return new Promise(function(resolve,reject){self.process(data,pushTriple,base,filter,function(error){callback&&process.nextTick(function(){error?callback(error):callback(null,graph)}),error?reject(error):resolve(graph)})})},AbstractParser.prototype.stream=function(inputStream,base,filter){var self=this,outputStream=new AbstractParser.TripleReadStream;return AbstractParser.streamToData(inputStream).then(function(data){self.process(data,function(triple){outputStream.push(triple)},base,filter,function(error){error?outputStream.emit("error",error):outputStream.emit("end")})})["catch"](function(error){outputStream.emit("error",error)}),outputStream},AbstractParser.streamToData=function(stream){return new Promise(function(resolve,reject){return"object"!=typeof stream||"function"!=typeof stream.read?resolve(stream):(stream.on("error",function(error){reject(error)}),void stream.pipe(concatStream(function(data){resolve(data)})))})},AbstractParser.TripleReadStream=function(){Readable.call(this,{objectMode:!0}),this._read=function(){return 0}},inherits(AbstractParser.TripleReadStream,Readable),module.exports=AbstractParser}).call(this,require("_process"))},{_process:105,"concat-stream":154,inherits:159,stream:137}],186:[function(require,module){function DomParser(rdf){AbstractParser.call(this,rdf)}var util=require("util"),AbstractParser=require("rdf-parser-abstract");util.inherits(DomParser,AbstractParser),DomParser.prototype.parseHtmlDom=function(toparse){var parser=new DOMParser;return parser.parseFromString(toparse,"text/html")},DomParser.prototype.parseXmlDom=function(toparse){var parser=new DOMParser;return parser.parseFromString(toparse,"application/xml")},module.exports=DomParser},{"rdf-parser-abstract":185,util:149}],187:[function(require,module){(function(process){module.exports=require(process.browser?"./browser":"./node")}).call(this,require("_process"))},{"./browser":186,"./node":188,_process:105}],188:[function(require,module){function DomParser(rdf){AbstractParser.call(this,rdf)}var util=require("util"),xmldom=require("xmldom"),AbstractParser=require("rdf-parser-abstract");util.inherits(DomParser,AbstractParser),DomParser.prototype.parseHtmlDom=function(toparse){var parser=new xmldom.DOMParser;return parser.options.errorHandler={warning:function(){},error:function(){},fatalError:function(){}},parser.parseFromString(toparse,"text/html")},DomParser.prototype.parseXmlDom=function(toparse){var parser=new xmldom.DOMParser;return parser.options.errorHandler={warning:function(){},error:function(){},fatalError:function(){}},parser.parseFromString(toparse,"application/xml")},module.exports=DomParser},{"rdf-parser-abstract":185,util:149,xmldom:219}],189:[function(require,module){var jsonld=require("jsonld"),rdf=require("rdf-ext"),inherits=require("inherits"),AbstractParser=require("rdf-parser-abstract"),JsonLdParser=function(options){AbstractParser.call(this,rdf),options=options||{},"importPrefixMap"in options||(options.importPrefixMap=!0);var expandAndFlatten=function(data,base,callback){jsonld.expand(data,{base:base},function(error,expanded){return error?callback(error):void jsonld.flatten(expanded,{},function(error,flattened){return error?callback(error):"@graph"in flattened?void callback(null,flattened["@graph"]):callback(new Error("no @graph property in flattened JSON-LD"))})})},toArray=function(object){return object=object||[],Array.isArray(object)?object:[object]};this.process=function(data,callback,base,filter,done){return new Promise(function(resolve,reject){"string"==typeof data&&(data=JSON.parse(data)),base=base||"",filter=filter||function(){return!0},done=done||function(){};var getLiteral=function(jsonNode){var type=null,lang=null;return"@type"in jsonNode&&(type=getNode(jsonNode["@type"])),"@language"in jsonNode&&(lang=jsonNode["@language"]),rdf.createLiteral(jsonNode["@value"],lang,type)},nodeCache={},getNode=function(jsonNode){return jsonNode in nodeCache?nodeCache[jsonNode]:jsonNode?nodeCache[jsonNode]=0===jsonNode.indexOf("_:")?rdf.createBlankNode():rdf.createNamedNode(jsonNode):rdf.createBlankNode()},pushTriple=function(subject,predicate,object){var triple=rdf.createTriple(subject,predicate,object);filter(triple)&&callback(triple)},processSubject=function(jsonSubject){var subject=jsonSubject["@id"],types=toArray(jsonSubject["@type"]);types.forEach(function(type){pushTriple(getNode(subject),getNode(rdf.resolve("rdf:type")),getNode(type))});for(var predicate in jsonSubject)0!==predicate.indexOf("@")&&processPredicate(subject,predicate,toArray(jsonSubject[predicate]))},processPredicate=function(subject,predicate,jsonObjects){jsonObjects.forEach(function(jsonObject){pushTriple(getNode(subject),getNode(predicate),processObject(jsonObject))})},processObject=function(jsonObject){return"object"!=typeof jsonObject?"boolean"==typeof jsonObject?rdf.createLiteral(jsonObject,null,rdf.createNamedNode("http://www.w3.org/2001/XMLSchema#boolean")):"number"==typeof jsonObject?-1!==String(jsonObject).indexOf(".")?rdf.createLiteral(jsonObject.toString(),null,rdf.createNamedNode("http://www.w3.org/2001/XMLSchema#double")):rdf.createLiteral(jsonObject.toString(),null,rdf.createNamedNode("http://www.w3.org/2001/XMLSchema#integer")):rdf.createLiteral(jsonObject.toString()):"@id"in jsonObject?getNode(jsonObject["@id"]):"@list"in jsonObject?processList(jsonObject["@list"]):getLiteral(jsonObject)},processList=function(jsonList){var rest,entry=getNode(),subject=entry;return jsonList.forEach(function(jItem,index){rest=index!==jsonList.length-1?getNode():getNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"),pushTriple(subject,getNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#first"),getNode(jItem["@id"])),pushTriple(subject,getNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"),rest),subject=rest}),entry};if(options.importPrefixMap&&"@context"in data&&"object"==typeof data["@context"]){var context=data["@context"];Object.keys(context).forEach(function(key){"@"!==key.slice(0,1)&&"string"==typeof context[key]&&(rdf.prefixes[key]=context[key])})}expandAndFlatten(data,base,function(error,jsonGraph){return error?(done&&done(error),reject(error)):(jsonGraph&&jsonGraph.forEach(function(jsonSubject){jsonSubject["@graph"]&&(jsonSubject=jsonSubject["@graph"].shift()),processSubject(jsonSubject)}),done&&done(),void resolve())})})}};inherits(JsonLdParser,AbstractParser);var instance=new JsonLdParser;for(var property in instance)JsonLdParser[property]=instance[property];module.exports=JsonLdParser},{inherits:159,jsonld:162,"rdf-ext":179,"rdf-parser-abstract":185}],190:[function(require,module){var rdf=require("rdf-ext"),util=require("util"),DomParser=require("rdf-parser-dom"),URIResolver=require("./uri-resolver"),MicrodataProcessor=function(){this.blankCounter=0,this.vocabularies=[{namespaceURI:"http://schema.org/",isMember:function(uri){return 0===uri.indexOf(this.namespaceURI)},getProperty:function(name){return this.namespaceURI+name}}]};MicrodataProcessor.prototype=new URIResolver,MicrodataProcessor.prototype.constructor=MicrodataProcessor,MicrodataProcessor.typeNode=rdf.createNamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),MicrodataProcessor.integerNode=rdf.createNamedNode("http://www.w3.org/2001/XMLSchema#integer"),MicrodataProcessor.doubleNode=rdf.createNamedNode("http://www.w3.org/2001/XMLSchema#double"),MicrodataProcessor.timeNode=rdf.createNamedNode("http://www.w3.org/2001/XMLSchema#time"),MicrodataProcessor.dateTimeNode=rdf.createNamedNode("http://www.w3.org/2001/XMLSchema#dateTime"),MicrodataProcessor.durationNode=rdf.createNamedNode("http://www.w3.org/2001/XMLSchema#duration"),MicrodataProcessor.absoluteURIRE=/[\w\_\-]+:\S+/,MicrodataProcessor.prototype.resolve=function(uri){return uri},MicrodataProcessor.trim=function(str){return str=str||"",str.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},MicrodataProcessor.tokenize=function(str){return MicrodataProcessor.trim(str).split(/\s+/).reduce(function(tokens,token){return token&&tokens.push(token),tokens},[])},MicrodataProcessor.prototype.getVocabulary=function(uri){for(var i=0;i<this.vocabularies.length;i++)if(this.vocabularies[i].isMember(uri))return this.vocabularies[i];var makeVocab=function(ns){return{namespaceURI:ns,getProperty:function(name){return this.namespaceURI+name}}},hash=uri.indexOf("#");if(hash>=0)return makeVocab(uri.substring(0,hash+1));var lastSlash=uri.lastIndexOf("/");return makeVocab(lastSlash>=0?uri.substring(0,lastSlash+1):uri)},MicrodataProcessor.prototype.getProperty=function(value,vocabulary){return MicrodataProcessor.absoluteURIRE.exec(value)?value:vocabulary?vocabulary.getProperty(value):base.resolve("#"+value)},MicrodataProcessor.valueMappings={link:function(node,base){return rdf.createNamedNode(base.resolve(node.getAttribute("href")))},media:function(node,base){return rdf.createNamedNode(base.resolve(node.getAttribute("src")))},meta:function(node){var value=node.getAttribute("content"),lang=node.getAttribute("lang");return rdf.createLiteral(value,lang?lang:null)},number:function(node){var value=node.getAttribute("value");return value===parseInt(value).toString()?rdf.createLiteral(value,null,MicrodataProcessor.integerNode):value===parseFloat(value).toString()?rdf.createLiteral(value,null,MicrodataProcessor.doubleNode):rdf.createLiteral(value)},object:function(node,base){return rdf.createNamedNode(base.resolve(node.getAttribute("data")))},time:function(node){var value=node.getAttribute("datetime"),lang=node.getAttribute("lang");return 9===value.length?rdf.createLiteral(value,null,MicrodataProcessor.timeNode):20===value.length?rdf.createLiteral(value,null,MicrodataProcessor.dateTimeNode):"P"===value.substr(0,1)?rdf.createLiteral(value,null,MicrodataProcessor.durationNode):rdf.createLiteral(value,lang?lang:null)}},MicrodataProcessor.valueMappings.a=MicrodataProcessor.valueMappings.link,MicrodataProcessor.valueMappings.area=MicrodataProcessor.valueMappings.a,MicrodataProcessor.valueMappings.audio=MicrodataProcessor.valueMappings.media,MicrodataProcessor.valueMappings.data=MicrodataProcessor.valueMappings.number,MicrodataProcessor.valueMappings.embed=MicrodataProcessor.valueMappings.media,MicrodataProcessor.valueMappings.iframe=MicrodataProcessor.valueMappings.media,MicrodataProcessor.valueMappings.img=MicrodataProcessor.valueMappings.media,MicrodataProcessor.valueMappings.meter=MicrodataProcessor.valueMappings.number,MicrodataProcessor.valueMappings.source=MicrodataProcessor.valueMappings.media,MicrodataProcessor.valueMappings.track=MicrodataProcessor.valueMappings.media,MicrodataProcessor.valueMappings.video=MicrodataProcessor.valueMappings.media,MicrodataProcessor.prototype.getValue=function(node,base){var converter=MicrodataProcessor.valueMappings[node.localName];return converter?converter(node,base):rdf.createLiteral(node.textContent)},MicrodataProcessor.prototype.process=function(node,callback,base){var self=this;node.nodeType===node.DOCUMENT_NODE&&(node=node.documentElement),base=self.parseURI(base);var createContext=function(memory,subject,type,vocabulary){return{memory:memory?memory:{},subject:subject,type:type,vocabulary:vocabulary}},processChildren=function(current,type){for(var context,itemProp,itemScope,predicate,subject,value,child=current.item.firstChild;child;child=child.nextSibling)child.nodeType===child.ELEMENT_NODE&&(itemProp=child.getAttribute("itemprop"),itemScope=child.hasAttribute("itemscope"),context=createContext(current.context.memory,current.context.subject,type,current.context.vocabulary),subject=generateTriple({item:child,context:context}),itemProp&&MicrodataProcessor.tokenize(itemProp).forEach(function(token){predicate=rdf.createNamedNode(MicrodataProcessor.absoluteURIRE.test(token)?token:context.vocabulary?context.vocabulary+token:base.resolve("#"+token)),value=self.getValue(child,base),itemScope&&(value=subject),callback(rdf.createTriple(current.context.subject,predicate,value))}))},processSubject=function(current){var type,vocab,itemType=current.item.getAttribute("itemtype");MicrodataProcessor.tokenize(itemType).forEach(function(token){MicrodataProcessor.absoluteURIRE.test(token)&&(type||(type=token),callback(rdf.createTriple(current.context.subject,MicrodataProcessor.typeNode,rdf.createNamedNode(base.resolve(token)))))}),type||(type=current.context.type),type&&(vocab=self.getVocabulary(type),vocab=vocab?vocab.namespaceURI:null),vocab&&(current.context.vocabulary=vocab),processChildren(current,type)},generateTriple=function(current){var id=current.item.getAttribute("id"),itemId=current.item.getAttribute("itemid"),itemRef=current.item.getAttribute("itemref"),itemScope=current.item.hasAttribute("itemscope");return id in current.context.memory?current.context.memory[id].forEach(function(context){processSubject({item:current.item,context:context})}):(itemScope&&(current.context.subject=itemId?rdf.createNamedNode(base.resolve(itemId)):rdf.createBlankNode(),MicrodataProcessor.tokenize(itemRef).forEach(function(token){token in current.context.memory||(current.context.memory[token]=[]),current.context.memory[token].push(current.context)})),processSubject(current)),current.context.subject};generateTriple({item:node,context:createContext(null,null,null,null)})};var MicrodataParser=function(){DomParser.call(this,rdf);var self=this,processor=new MicrodataProcessor;this.process=function(data,callback,base,filter,done){return new Promise(function(resolve,reject){base=base||"http://localhost/",filter=filter||function(){return!0},done=done||function(){};try{processor.process(self.parseHtmlDom(data,base),function(triple){filter(triple)&&callback(triple)},base)}catch(error){done(error),reject(error)}done(),resolve()})}};util.inherits(MicrodataParser,DomParser);var instance=new MicrodataParser;for(var property in instance)MicrodataParser[property]=instance[property];module.exports=MicrodataParser},{"./uri-resolver":191,"rdf-ext":179,"rdf-parser-dom":187,util:149}],191:[function(require,module){"use strict";var URIResolver=function(){};URIResolver.SCHEME=/^[A-Za-z][A-Za-z0-9\+\-\.]*\:/,URIResolver.prototype.parseURI=function(uri){var match=URIResolver.SCHEME.exec(uri);if(!match)throw"Bad URI value, no scheme: "+uri;var parsed={spec:uri};return parsed.scheme=match[0].substring(0,match[0].length-1),parsed.schemeSpecificPart=parsed.spec.substring(match[0].length),"/"==parsed.schemeSpecificPart.charAt(0)&&"/"==parsed.schemeSpecificPart.charAt(1)?this.parseGeneric(parsed):parsed.isGeneric=!1,parsed.normalize=function(){if(this.isGeneric&&0!=this.segments.length){if(this.path.length>1&&"/."==this.path.substring(this.path.length-2))return this.path=this.path.substring(0,this.path.length-1),this.segments.splice(this.segments.length-1,1),this.schemeSpecificPart="//"+this.authority+this.path,"undefined"!=typeof this.query&&(this.schemeSpecificPart+="?"+this.query),"undefined"!=typeof this.fragment&&(this.schemeSpecificPart+="#"+this.fragment),void(this.spec=this.scheme+":"+this.schemeSpecificPart);var end=this.path.charAt(this.path.length-1);"/"!=end&&(end="");for(var i=0;i<this.segments.length;i++)i>0&&".."==this.segments[i]&&(this.segments.splice(i-1,2),i-=2),"."==this.segments[i]&&(this.segments.splice(i,1),i--);this.path=0==this.segments.length?"/":"/"+this.segments.join("/")+end,this.schemeSpecificPart="//"+this.authority+this.path,"undefined"!=typeof this.query&&(this.schemeSpecificPart+="?"+this.query),"undefined"!=typeof this.fragment&&(this.schemeSpecificPart+="#"+this.fragment),this.spec=this.scheme+":"+this.schemeSpecificPart}},parsed.resolve=function(href){if(!href)return this.spec;if("#"==href.charAt(0)){var lastHash=this.spec.lastIndexOf("#");return 0>lastHash?this.spec+href:this.spec.substring(0,lastHash)+href}if(!this.isGeneric)throw"Cannot resolve uri against non-generic URI: "+this.spec;href.indexOf(":");if("/"==href.charAt(0))return this.scheme+"://"+this.authority+href;if("."==href.charAt(0)&&"/"==href.charAt(1)){if("/"==this.path.charAt(this.path.length-1))return this.scheme+"://"+this.authority+this.path+href.substring(2);var last=this.path.lastIndexOf("/");return this.scheme+"://"+this.authority+this.path.substring(0,last)+href.substring(1)}if(URIResolver.SCHEME.test(href))return href;if("?"==href.charAt(0))return this.scheme+"://"+this.authority+this.path+href;if("/"==this.path.charAt(this.path.length-1))return this.scheme+"://"+this.authority+this.path+href;var last=this.path.lastIndexOf("/");return this.scheme+"://"+this.authority+this.path.substring(0,last+1)+href},parsed.relativeTo=function(otherURI){if(otherURI.scheme!=this.scheme)return this.spec;if(!this.isGeneric)throw"A non generic URI cannot be made relative: "+this.spec;if(!otherURI.isGeneric)throw"Cannot make a relative URI against a non-generic URI: "+otherURI.spec;if(otherURI.authority!=this.authority)return this.spec;for(var i=0;i<this.segments.length&&i<otherURI.segments.length;i++)if(this.segments[i]!=otherURI.segments[i]){for(var relative="",j=i;j<otherURI.segments.length;j++)relative+="../";for(var j=i;j<this.segments.length;j++)relative+=this.segments[j],j+1<this.segments.length&&(relative+="/");return"/"==this.path.charAt(this.path.length-1)&&(relative+="/"),relative}if(this.segments.length==otherURI.segments.length)return this.hash?this.hash:this.query?this.query:"";if(i<this.segments.length){for(var relative="",j=i;j<this.segments.length;j++)relative+=this.segments[j],j+1<this.segments.length&&(relative+="/");return"/"==this.path.charAt(this.path.length-1)&&(relative+="/"),relative}throw"Cannot calculate a relative URI for "+this.spec+" against "+otherURI.spec},parsed},URIResolver.prototype.parseGeneric=function(parsed){if("/"!=parsed.schemeSpecificPart.charAt(0)||"/"!=parsed.schemeSpecificPart.charAt(1))throw"Generic URI values should start with '//':"+parsed.spec;var work=parsed.schemeSpecificPart.substring(2),pathStart=work.indexOf("/");parsed.authority=0>pathStart?work:work.substring(0,pathStart),parsed.path=0>pathStart?"":work.substring(pathStart);var hash=parsed.path.indexOf("#");hash>=0&&(parsed.fragment=parsed.path.substring(hash+1),parsed.path=parsed.path.substring(0,hash));var questionMark=parsed.path.indexOf("?");if(questionMark>=0&&(parsed.query=parsed.path.substring(questionMark+1),parsed.path=parsed.path.substring(0,questionMark)),"/"==parsed.path||""==parsed.path)parsed.segments=[];else{parsed.segments=parsed.path.split(/\//),parsed.segments.length>0&&""==parsed.segments[0]&&parsed.path.length>1&&"/"!=parsed.path.charAt(1)&&parsed.segments.shift(),parsed.segments.length>0&&parsed.path.length>0&&"/"==parsed.path.charAt(parsed.path.length-1)&&""==parsed.segments[parsed.segments.length-1]&&parsed.path.length>1&&"/"!=parsed.path.charAt(parsed.path.length-2)&&parsed.segments.pop();for(var i=0;i<parsed.segments.length;i++)for(var check=parsed.segments[i].split(/%[A-Za-z0-9][A-Za-z0-9]|[\ud800-\udfff][\ud800-\udfff]|[A-Za-z0-9\-\._~!$&'()*+,;=@:\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/),j=0;j<check.length;j++)if(check[j].length>0)throw"Unecaped character "+check[j].charAt(0)+" ("+check[j].charCodeAt(0)+") in URI "+parsed.spec}parsed.isGeneric=!0},module.exports=URIResolver},{}],192:[function(require,module){function N3Parser(options){AbstractParser.call(this,rdf),this.options=options||{},"importPrefixMap"in this.options||(this.options.importPrefixMap=!0)}var rdf=require("rdf-ext"),util=require("util"),AbstractParser=require("rdf-parser-abstract"),N3=require("n3");util.inherits(N3Parser,AbstractParser),N3Parser.prototype.process=function(data,callback,base,filter,done){var self=this;return new Promise(function(resolve,reject){filter=filter||function(){return!0};var parser=N3.Parser({documentIRI:base}),blankNodes={};parser.parse(data,function(error,n3Triple,n3Prefixes){if(error)return done&&done(error),reject(error);if(self.options.importPrefixMap&&n3Prefixes)for(var prefix in n3Prefixes)self.rdf.prefixes[prefix]=n3Prefixes[prefix];if(!n3Triple)return done&&done(),resolve();var toRdfNode=function(n3Node){if(N3.Util.isIRI(n3Node))return self.rdf.createNamedNode(n3Node);if(N3.Util.isBlank(n3Node))return n3Node in blankNodes?blankNodes[n3Node]:blankNodes[n3Node]=self.rdf.createBlankNode();var lang=N3.Util.getLiteralLanguage(n3Node),type=N3.Util.getLiteralType(n3Node);return""===lang&&(lang=null),"http://www.w3.org/2001/XMLSchema#string"===type&&(type=null),self.rdf.createLiteral(N3.Util.getLiteralValue(n3Node),lang,type?self.rdf.createNamedNode(type):null)},pushTriple=function(n3Triple){var triple=self.rdf.createTriple(toRdfNode(n3Triple.subject),toRdfNode(n3Triple.predicate),toRdfNode(n3Triple.object));filter(triple)&&callback(triple)};pushTriple(n3Triple)})})};var instance=new N3Parser;for(var property in instance)N3Parser[property]=instance[property];module.exports=N3Parser},{n3:164,"rdf-ext":179,"rdf-parser-abstract":185,util:149}],193:[function(require,module){var rdf=require("rdf-ext"),inherits=require("inherits"),DomParser=require("rdf-parser-dom"),RDFaProcessor=require("green-turtle").RDFaProcessor,RdfaParser=function(){DomParser.call(this,rdf)};inherits(RdfaParser,DomParser),RdfaParser.prototype.process=function(data,callback,base,filter,done){var self=this;return new Promise(function(resolve,reject){base=base||"http://localhost/",filter=filter||function(){return!0},done=done||function(){};try{var blankNodeMap={},createNode=function(value){if(!value)return null;if("string"==typeof value)return"_:"===value.substring(0,2)?(value in blankNodeMap||(blankNodeMap[value]=rdf.createBlankNode()),blankNodeMap[value]):rdf.createNamedNode(value);if("http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML"===value.type)return 0===value.value.length?rdf.createLiteral("",null,rdf.createNamedNode(value.type)):rdf.createLiteral(value.value[0].parentNode.textContent,value.language,rdf.createNamedNode(value.type));if("http://www.w3.org/1999/02/22-rdf-syntax-ns#object"===value.type)return createNode(value.value);var datatype=createNode(value.type);return rdf.createLiteral(value.value,value.language,datatype)},processor=new RDFaProcessor;processor.finishedHandlers.push(function(){done(),resolve()}),processor.addTriple=function(greenOrigin,greenSubject,greenPredicate,greenObject){var subject=createNode(greenSubject),predicate=createNode(greenPredicate),object=createNode(greenObject);if(subject&&predicate&&object){var triple=rdf.createTriple(subject,predicate,object);filter(triple)&&callback(triple)}},"string"==typeof data&&(data=self.parseHtmlDom(data,base)),processor.process(data,{baseURI:base})}catch(error){done(error),reject(error)}})};var instance=new RdfaParser;for(var property in instance)RdfaParser[property]=instance[property];module.exports=RdfaParser},{"green-turtle":158,inherits:159,"rdf-ext":179,"rdf-parser-dom":187}],194:[function(require,module){var RdfLibParser=function(store){var RDFParser={};RDFParser.ns={RDF:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",RDFS:"http://www.w3.org/2000/01/rdf-schema#"},RDFParser.nodeType={ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12},this.frameFactory=function(parser,parent,element){return{NODE:1,ARC:2,parent:parent,parser:parser,store:parser.store,element:element,lastChild:0,base:null,lang:null,node:null,nodeType:null,listIndex:1,rdfid:null,datatype:null,collection:!1,terminateFrame:function(){this.collection&&this.node.close()},addSymbol:function(type,uri){uri=uriJoin(uri,this.base),this.node=this.store.sym(uri),this.nodeType=type},loadTriple:function(){if(this.parent.parent.collection?this.parent.parent.node.append(this.node):this.store.add(this.parent.parent.node,this.parent.node,this.node,this.parser.why),null!=this.parent.rdfid){var triple=this.store.sym(uriJoin("#"+this.parent.rdfid,this.base));this.store.add(triple,this.store.sym(RDFParser.ns.RDF+"type"),this.store.sym(RDFParser.ns.RDF+"Statement"),this.parser.why),this.store.add(triple,this.store.sym(RDFParser.ns.RDF+"subject"),this.parent.parent.node,this.parser.why),this.store.add(triple,this.store.sym(RDFParser.ns.RDF+"predicate"),this.parent.node,this.parser.why),this.store.add(triple,this.store.sym(RDFParser.ns.RDF+"object"),this.node,this.parser.why)}},isTripleToLoad:function(){return null!=this.parent&&null!=this.parent.parent&&this.nodeType===this.NODE&&this.parent.nodeType===this.ARC&&this.parent.parent.nodeType===this.NODE},addNode:function(uri){this.addSymbol(this.NODE,uri),this.isTripleToLoad()&&this.loadTriple()},addCollection:function(){this.nodeType=this.NODE,this.node=this.store.collection(),this.collection=!0,this.isTripleToLoad()&&this.loadTriple()},addCollectionArc:function(){this.nodeType=this.ARC},addBNode:function(id){this.node=null!=id?null!=this.parser.bnodes[id]?this.parser.bnodes[id]:this.parser.bnodes[id]=this.store.bnode():this.store.bnode(),this.nodeType=this.NODE,this.isTripleToLoad()&&this.loadTriple()},addArc:function(uri){uri===RDFParser.ns.RDF+"li"&&(uri=RDFParser.ns.RDF+"_"+this.parent.listIndex,this.parent.listIndex++),this.addSymbol(this.ARC,uri)},addLiteral:function(value){this.node=this.parent.datatype?this.store.literal(value,"",this.store.sym(this.parent.datatype)):this.store.literal(value,this.lang),this.nodeType=this.NODE,this.isTripleToLoad()&&this.loadTriple()}}},this.getAttributeNodeNS=function(node,uri,name){var attributeNode=null;if(node.getAttributeNodeNS)attributeNode=node.getAttributeNodeNS(uri,name);else for(var potentialNode,fullName,attributes=node.attributes,i=0;i<attributes.length;++i)if(potentialNode=attributes[i],potentialNode.namespaceURI===uri&&(fullName=potentialNode.prefix?potentialNode.prefix+":"+name:name,fullName===potentialNode.nodeName)){attributeNode=potentialNode;break}return attributeNode},this.store=store,this.bnodes={},this.why=null,this.reify=!1,this.parse=function(document,base,why){var children=document.childNodes;this.cleanParser();var root;if(document.nodeType===RDFParser.nodeType.DOCUMENT){for(var c=0;c<children.length;c++)if(children[c].nodeType===RDFParser.nodeType.ELEMENT){root=children[c];break}}else{if(document.nodeType!==RDFParser.nodeType.ELEMENT)throw new Error("RDFParser: can't find root in "+base+". Halting. ");root=document}this.why=why;var f=this.frameFactory(this);return this.base=base,f.base=base,f.lang="",this.parseDOM(this.buildFrame(f,root)),!0},this.parseDOM=function(frame){for(var rdfid,elementURI=function(el){var result="";if(null==el.namespaceURI)throw new Error("RDF/XML syntax error: No namespace for "+el.localName+" in "+this.base);return el.namespaceURI&&(result+=el.namespaceURI),el.localName?result+=el.localName:el.nodeName&&(result+=el.nodeName.indexOf(":")>=0?el.nodeName.split(":")[1]:el.nodeName),result}.bind(this),dig=!0;frame.parent;){var dom=frame.element,attrs=dom.attributes;if(dom.nodeType===RDFParser.nodeType.TEXT||dom.nodeType===RDFParser.nodeType.CDATA_SECTION)frame.parent.nodeType==frame.NODE&&(frame.addArc(RDFParser.ns.RDF+"value"),frame=this.buildFrame(frame)),frame.addLiteral(dom.nodeValue);else if(elementURI(dom)!==RDFParser.ns.RDF+"RDF")if(frame.parent&&frame.parent.collection&&(frame.addCollectionArc(),frame=this.buildFrame(frame,frame.element),frame.parent.element=null),frame.parent&&frame.parent.nodeType&&frame.parent.nodeType!==frame.ARC){frame.addArc(elementURI(dom)),this.reify&&(rdfid=this.getAttributeNodeNS(dom,RDFParser.ns.RDF,"ID"),rdfid&&(frame.rdfid=rdfid.nodeValue,dom.removeAttributeNode(rdfid)));var parsetype=this.getAttributeNodeNS(dom,RDFParser.ns.RDF,"parseType"),datatype=this.getAttributeNodeNS(dom,RDFParser.ns.RDF,"datatype");if(datatype&&(frame.datatype=datatype.nodeValue,dom.removeAttributeNode(datatype)),parsetype){var nv=parsetype.nodeValue;"Literal"===nv?(frame.datatype=RDFParser.ns.RDF+"XMLLiteral",frame=this.buildFrame(frame),frame.addLiteral(dom),dig=!1):"Resource"===nv?(frame=this.buildFrame(frame,frame.element),frame.parent.element=null,frame.addBNode()):"Collection"===nv&&(frame=this.buildFrame(frame,frame.element),frame.parent.element=null,frame.addCollection()),dom.removeAttributeNode(parsetype)}if(0!==attrs.length){var resource=this.getAttributeNodeNS(dom,RDFParser.ns.RDF,"resource"),bnid2=this.getAttributeNodeNS(dom,RDFParser.ns.RDF,"nodeID");frame=this.buildFrame(frame),resource?(frame.addNode(resource.nodeValue),dom.removeAttributeNode(resource)):bnid2?(frame.addBNode(bnid2.nodeValue),dom.removeAttributeNode(bnid2)):frame.addBNode();for(var x1=attrs.length-1;x1>=0;x1--){var f=this.buildFrame(frame);f.addArc(elementURI(attrs[x1])),elementURI(attrs[x1])===RDFParser.ns.RDF+"type"?this.buildFrame(f).addNode(attrs[x1].nodeValue):this.buildFrame(f).addLiteral(attrs[x1].nodeValue);
  
  }}else 0===dom.childNodes.length&&this.buildFrame(frame).addLiteral("")}else{var about=this.getAttributeNodeNS(dom,RDFParser.ns.RDF,"about")||this.getAttributeNodeNS(dom,null,"about");if(rdfid=this.getAttributeNodeNS(dom,RDFParser.ns.RDF,"ID"),about&&rdfid)throw new Error("RDFParser: "+dom.nodeName+" has both rdf:id and rdf:about. Halting. Only one of these properties may be specified on a node.");if(!about&&rdfid)frame.addNode("#"+rdfid.nodeValue),dom.removeAttributeNode(rdfid);else if(null==about&&null==rdfid){var bnid=this.getAttributeNodeNS(dom,RDFParser.ns.RDF,"nodeID");bnid?(frame.addBNode(bnid.nodeValue),dom.removeAttributeNode(bnid)):frame.addBNode()}else frame.addNode(about.nodeValue),dom.removeAttributeNode(about);var rdftype=this.getAttributeNodeNS(dom,RDFParser.ns.RDF,"type");RDFParser.ns.RDF+"Description"!==elementURI(dom)&&(rdftype={nodeValue:elementURI(dom)}),null!=rdftype&&(this.store.add(frame.node,this.store.sym(RDFParser.ns.RDF+"type"),this.store.sym(uriJoin(rdftype.nodeValue,frame.base)),this.why),rdftype.nodeName&&dom.removeAttributeNode(rdftype));for(var x=attrs.length-1;x>=0;x--)this.store.add(frame.node,this.store.sym(elementURI(attrs[x])),this.store.literal(attrs[x].nodeValue,frame.lang),this.why)}for(dom=frame.element;frame.parent;){for(var pframe=frame;null==dom;)frame=frame.parent,dom=frame.element;var candidate=dom.childNodes&&dom.childNodes[frame.lastChild];if(candidate&&dig){if((candidate.nodeType===RDFParser.nodeType.ELEMENT||candidate.nodeType===RDFParser.nodeType.TEXT||candidate.nodeType===RDFParser.nodeType.CDATA_SECTION)&&(candidate.nodeType!==RDFParser.nodeType.TEXT&&candidate.nodeType!==RDFParser.nodeType.CDATA_SECTION||1===dom.childNodes.length)){frame.lastChild++,frame=this.buildFrame(pframe,dom.childNodes[frame.lastChild-1]);break}frame.lastChild++}else{if(frame.terminateFrame(),!(frame=frame.parent))break;dom=frame.element,dig=!0}}}},this.cleanParser=function(){this.bnodes={},this.why=null},this.buildFrame=function(parent,element){var frame=this.frameFactory(this,parent,element);if(parent&&(frame.base=parent.base,frame.lang=parent.lang),!element||element.nodeType===RDFParser.nodeType.TEXT||element.nodeType===RDFParser.nodeType.CDATA_SECTION)return frame;var attrs=element.attributes,base=element.getAttributeNode("xml:base");null!=base&&(frame.base=base.nodeValue,element.removeAttribute("xml:base"));var lang=element.getAttributeNode("xml:lang");null!=lang&&(frame.lang=lang.nodeValue,element.removeAttribute("xml:lang"));for(var x=attrs.length-1;x>=0;x--)if("xml"===attrs[x].nodeName.substr(0,3)){if("xmlns:"===attrs[x].name.slice(0,6)){var uri=attrs[x].nodeValue;this.base&&(uri=uriJoin(uri,this.base)),this.store.setPrefixForURI(attrs[x].name.slice(6),uri)}element.removeAttributeNode(attrs[x])}return frame}},uriJoin=function(given,base){var baseColon,baseHash,baseScheme,baseSingle,colon,lastSlash,path;if(baseHash=base.indexOf("#"),baseHash>0&&(base=base.slice(0,baseHash)),0===given.length)return base;if(0===given.indexOf("#"))return base+given;if(colon=given.indexOf(":"),colon>=0)return given;if(baseColon=base.indexOf(":"),0===base.length)return given;if(0>baseColon)return alert("Invalid base: "+base+" in join with given: "+given),given;if(baseScheme=base.slice(0,+baseColon+1||9e9),0===given.indexOf("//"))return baseScheme+given;if(base.indexOf("//",baseColon)===baseColon+1){if(baseSingle=base.indexOf("/",baseColon+3),0>baseSingle)return base.length-baseColon-3>0?base+"/"+given:baseScheme+given}else if(baseSingle=base.indexOf("/",baseColon+1),0>baseSingle)return base.length-baseColon-1>0?base+"/"+given:baseScheme+given;if(0===given.indexOf("/"))return base.slice(0,baseSingle)+given;if(path=base.slice(baseSingle),lastSlash=path.lastIndexOf("/"),0>lastSlash)return baseScheme+given;for(lastSlash>=0&&lastSlash<path.length-1&&(path=path.slice(0,+lastSlash+1||9e9)),path+=given;path.match(/[^\/]*\/\.\.\//);)path=path.replace(/[^\/]*\/\.\.\//,"");return path=path.replace(/\.\//g,""),path=path.replace(/\/\.$/,"/"),base.slice(0,baseSingle)+path},rdf=require("rdf-ext"),util=require("util"),DomParser=require("rdf-parser-dom"),RdfXmlParser=function(){DomParser.call(this,rdf)};util.inherits(RdfXmlParser,DomParser),RdfXmlParser.prototype.process=function(toparse,callback,base,filter,done){var self=this;return new Promise(function(resolve,reject){base=base||"",filter=filter||function(){return!0},done=done||function(){};var domNodesToString=function(nodes){for(var xmlString="",i=0;i<nodes.length;i++)xmlString+=nodes[i].toString();return xmlString},store={};store.add=function(s,p,o){var triple=self.rdf.createTriple(s,p,o);filter(triple)&&callback(triple)},store.bnode=function(){return self.rdf.createBlankNode()},store.literal=function(value,language,type){return type&&"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral"===type.toString()&&(value=domNodesToString(value.childNodes)),self.rdf.createLiteral(value,language,type)},store.setPrefixForURI=function(){},store.sym=function(iri){return self.rdf.createNamedNode(iri)};try{"string"==typeof toparse&&(toparse=self.parseXmlDom(toparse)),new RdfLibParser(store).parse(toparse,base)}catch(error){done(error),reject(error)}done(),resolve()})};var instance=new RdfXmlParser;for(var property in instance)RdfXmlParser[property]=instance[property];module.exports=RdfXmlParser},{"rdf-ext":179,"rdf-parser-dom":187,util:149}],195:[function(require,module){function AbstractSerializer(rdf){this.rdf=rdf}var util=require("util"),Readable=require("stream").Readable;AbstractSerializer.prototype.stream=function(inputStream){var self=this,outputStream=new AbstractSerializer.DataReadStream;return AbstractSerializer.streamToGraph(inputStream,this.rdf.createGraph()).then(function(graph){self.serialize(graph,function(error,data){error?outputStream.emit("error",error):(outputStream.push(data),outputStream.emit("end"))})})["catch"](function(error){outputStream.emit("error",error)}),outputStream},AbstractSerializer.streamToGraph=function(stream,graph){return new Promise(function(resolve,reject){return"object"!=typeof stream||"function"!=typeof stream.read?resolve(stream):(stream.on("data",function(triple){graph.add(triple)}),stream.on("end",function(){resolve(graph)}),void stream.on("error",function(error){reject(error)}))})},AbstractSerializer.DataReadStream=function(){Readable.call(this,{objectMode:!0}),this._read=function(){return 0}},util.inherits(AbstractSerializer.DataReadStream,Readable),module.exports=AbstractSerializer},{stream:137,util:149}],196:[function(require,module){function JsonLdSerializer(options){this.options=options||{},AbstractSerializer.call(this,rdf)}var rdf=require("rdf-ext"),util=require("util"),AbstractSerializer=require("rdf-serializer-abstract");util.inherits(JsonLdSerializer,AbstractSerializer),JsonLdSerializer.prototype.serialize=function(graph,done){var self=this;return new Promise(function(resolve){done=done||function(){};var jsonGraph=[],subjects={},subjectIndex=function(subject){var value=subject.nominalValue;return"undefined"==typeof subjects[value]&&(jsonGraph.push("BlankNode"===subject.interfaceName?{"@id":"_:"+value}:{"@id":value}),subjects[value]=jsonGraph.length-1),subjects[value]},objectValue=function(object){var value=object.nominalValue;return"NamedNode"===object.interfaceName?{"@id":value}:"BlankNode"===object.interfaceName?{"@id":"_:"+value}:object.language?{"@language":object.language,"@value":value}:object.datatype&&!object.datatype.equals("http://www.w3.org/2001/XMLSchema#string")?{"@type":object.datatype.nominalValue,"@value":value}:value};graph.forEach(function(triple){var index=subjectIndex(triple.subject),predicateValue=triple.predicate.nominalValue;"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"===predicateValue?("undefined"==typeof jsonGraph[index]["@type"]&&(jsonGraph[index]["@type"]=[]),jsonGraph[index]["@type"].push(triple.object.nominalValue)):"undefined"==typeof jsonGraph[index][predicateValue]?jsonGraph[index][predicateValue]=objectValue(triple.object):(Array.isArray(jsonGraph[index][predicateValue])||(jsonGraph[index][predicateValue]=[jsonGraph[index][predicateValue]]),jsonGraph[index][predicateValue].push(objectValue(triple.object)))}),self.options.outputString&&(jsonGraph=JSON.stringify(jsonGraph)),done(null,jsonGraph),resolve(jsonGraph)})};var instance=new JsonLdSerializer;for(var property in instance)JsonLdSerializer[property]=instance[property];module.exports=JsonLdSerializer},{"rdf-ext":179,"rdf-serializer-abstract":195,util:149}],197:[function(require,module){function N3Serializer(options){this.options=options||{},this.options.usePrefixMap="usePrefixMap"in this.options?this.options.usePrefixMap:!0,AbstractSerializer.call(this,rdf)}var rdf=require("rdf-ext"),util=require("util"),AbstractSerializer=require("rdf-serializer-abstract"),N3=require("n3");util.inherits(N3Serializer,AbstractSerializer),N3Serializer.prototype.serialize=function(graph,done){var self=this;return new Promise(function(resolve,reject){done=done||function(){};var writer,writerOptions={};self.options.usePrefixMap&&(writerOptions.prefixes={},Object.keys(rdf.prefixes).forEach(function(prefix){"string"==typeof rdf.prefixes[prefix]&&(writerOptions.prefixes[prefix]=rdf.prefixes[prefix])})),writer=N3.Writer(writerOptions);var createN3Node=function(node){return"NamedNode"===node.interfaceName.toString()?node.nominalValue:"BlankNode"===node.interfaceName.toString()?"_:"+node.nominalValue:node.language?'"'+node.nominalValue+'"@'+node.language:node.datatype&&!node.datatype.equals("http://www.w3.org/2001/XMLSchema#string")?'"'+node.nominalValue+'"^^'+node.datatype.nominalValue:'"'+node.nominalValue+'"'};graph.forEach(function(triple){writer.addTriple(createN3Node(triple.subject),createN3Node(triple.predicate),createN3Node(triple.object))}),writer.end(function(error,result){error?(done(error),reject(error)):(done(null,result),resolve(result))})})};var instance=new N3Serializer;for(var property in instance)N3Serializer[property]=instance[property];module.exports=N3Serializer},{n3:164,"rdf-ext":179,"rdf-serializer-abstract":195,util:149}],198:[function(require,module){function NTriplesSerializer(){AbstractSerializer.call(this,rdf)}var rdf=require("rdf-ext"),util=require("util"),AbstractSerializer=require("rdf-serializer-abstract");util.inherits(NTriplesSerializer,AbstractSerializer),NTriplesSerializer.prototype.serialize=function(graph,done){return new Promise(function(resolve){done=done||function(){};var nTriples="";graph.forEach(function(triple){nTriples+=triple.toString()+"\n"}),done(null,nTriples),resolve(nTriples)})};var instance=new NTriplesSerializer;for(var property in instance)NTriplesSerializer[property]=instance[property];module.exports=NTriplesSerializer},{"rdf-ext":179,"rdf-serializer-abstract":195,util:149}],199:[function(require,module){function SparqlUpdateSerializer(){AbstractSerializer.call(this,rdf)}var rdf=require("rdf-ext"),util=require("util"),AbstractSerializer=require("rdf-serializer-abstract");util.inherits(SparqlUpdateSerializer,AbstractSerializer),SparqlUpdateSerializer.prototype.serialize=function(graph,done){return new Promise(function(resolve){done=done||function(){};var nTriples="INSERT DATA { ";graph.forEach(function(triple){nTriples+=triple.toString()+"\n"}),nTriples+=" }",done(null,nTriples),resolve(nTriples)})};var instance=new SparqlUpdateSerializer;for(var property in instance)SparqlUpdateSerializer[property]=instance[property];module.exports=SparqlUpdateSerializer},{"rdf-ext":179,"rdf-serializer-abstract":195,util:149}],200:[function(require,module){function AbstractStore(){}AbstractStore.prototype.add=function(){throw new Error("not implemented")},AbstractStore.prototype["delete"]=function(){throw new Error("not implemented")},AbstractStore.prototype.graph=function(){throw new Error("not implemented")},AbstractStore.prototype.match=function(subject,predicate,object,iri,callback,limit){var self=this;return callback=callback||function(){},self.graph(iri).then(function(graph){return graph&&(graph=graph.match(subject,predicate,object,limit)),callback(null,graph),graph})},AbstractStore.prototype.merge=function(iri,graph,callback){var self=this;return callback=callback||function(){},self.graph(iri).then(function(existing){return existing?existing.addAll(graph):existing=graph,self.add(iri,existing,callback)}).then(function(){return graph})},AbstractStore.prototype.remove=function(iri,graph,callback){var self=this;return callback=callback||function(){},self.graph(iri).then(function(existing){return existing?self.add(iri,existing.difference(graph)):void 0}).then(callback)},AbstractStore.prototype.removeMatches=function(subject,predicate,object,iri,callback){var self=this;return callback=callback||function(){},self.graph(iri).then(function(existing){return existing?self.add(iri,existing.removeMatches(subject,predicate,object)):void 0}).then(callback)},module.exports=AbstractStore},{}],201:[function(require,module){function iriToKey(iri){return iri===!0?iri:iri?iri.toString():null}function InMemoryStore(options){options=options||{},this.rdf=options.rdf||require("rdf-ext"),this.graphs={},AbstractStore.call(this)}var util=require("util"),AbstractStore=require("rdf-store-abstract");util.inherits(InMemoryStore,AbstractStore),InMemoryStore.prototype.add=function(iri,graph,callback){var self=this;return iri=iriToKey(iri),callback=callback||function(){},new Promise(function(resolve){self.graphs[iri]=self.rdf.createGraph(),self.graphs[iri].addAll(graph),callback(null,graph),resolve(graph)})},InMemoryStore.prototype["delete"]=function(iri,callback){var self=this;return iri=iriToKey(iri),callback=callback||function(){},new Promise(function(resolve){iri in self.graphs&&delete self.graphs[iri],callback(),resolve()})},InMemoryStore.prototype.graph=function(iri,callback){var self=this;return iri=iriToKey(iri),callback=callback||function(){},new Promise(function(resolve){var graph=null;iri?graph=self.graphs[iri]:(graph=self.rdf.createGraph(),Object.keys(self.graphs).forEach(function(iri){graph.addAll(self.graphs[iri])})),callback(null,graph),resolve(graph)})},module.exports=InMemoryStore},{"rdf-ext":179,"rdf-store-abstract":200,util:149}],202:[function(require,module){var rdf=require("rdf-ext");require("rdf-formats-common")(rdf),module.exports=require("./lite")},{"./lite":203,"rdf-ext":179,"rdf-formats-common":180}],203:[function(require,module){function httpSuccess(statusCode){return statusCode>=200&&300>statusCode}function LdpStore(options){options=options||{},this.parsers=options.parsers?new rdf.Parsers(options.parsers):rdf.parsers,this.serializers=options.serializers?new rdf.Serializers(options.serializers):rdf.serializers,this.defaultParser=options.defaultParser||"text/turtle",this.defaultSerializer=options.defaultSerializer||"text/turtle",this.defaultPatchSerializer=options.defaultPatchSerializer||options.defaultSerializer||"text/turtle",this.request=options.request||rdf.defaultRequest}var rdf=require("rdf-ext"),inherits=require("inherits"),AbstractStore=require("rdf-store-abstract");inherits(LdpStore,AbstractStore),LdpStore.prototype.add=function(iri,graph,callback,options){var self=this;return new Promise(function(resolve,reject){callback=callback||function(){},options=options||{};var method="PUT",contentType=self.defaultSerializer,headers={};headers["Content-Type"]=contentType,options.method&&(method=options.method),options.etag&&(headers["If-Match"]=options.etag),options.useEtag&&graph.etag&&(headers["If-Match"]=graph.etag),self.serializers.serialize(contentType,graph).then(function(data){return self.request(method,iri,headers,data,null,options).then(function(res){return httpSuccess(res.statusCode)?(callback(null,graph),void resolve(graph)):(callback("status code error: "+res.statusCode),Promise.reject("status code error: "+res.statusCode))})})["catch"](function(error){callback(error),reject(error)})})},LdpStore.prototype["delete"]=function(iri,callback,options){var self=this;return new Promise(function(resolve,reject){callback=callback||function(){},self.request("DELETE",iri,{},null,null,options).then(function(res){return httpSuccess(res.statusCode)?(callback(),void resolve()):(callback("status code error: "+res.statusCode),Promise.reject("status code error: "+res.statusCode))})["catch"](function(error){callback(error),reject(error)})})},LdpStore.prototype.graph=function(iri,callback,options){var self=this;return new Promise(function(resolve,reject){callback=callback||function(){},options=options||{},self.request("GET",iri,{Accept:self.parsers.list().join(", ")},null,null,options).then(function(res){if(!httpSuccess(res.statusCode)&&0!==res.statusCode)return callback("status code error: "+res.statusCode),Promise.reject("status code error: "+res.statusCode);var contentType;return options.contentType?contentType=options.contentType:("content-type"in res.headers&&(contentType=res.headers["content-type"].split(";")[0]),contentType&&contentType in self.parsers||(contentType=self.defaultParser)),self.parsers.parse(contentType,res.content,null,iri).then(function(graph){options.useEtag&&"etag"in res.headers&&(graph.etag=res.headers.etag),callback(null,graph),resolve(graph)})})["catch"](function(error){callback(error),reject(error)})})},LdpStore.prototype.merge=function(iri,graph,callback,options){var self=this;return new Promise(function(resolve,reject){var contentType=self.defaultPatchSerializer,headers={};callback=callback||function(){},options=options||{},headers["Content-Type"]=contentType,"etag"in options&&(headers["If-Match"]=options.etag),"useEtag"in options&&options.useEtag&&"etag"in graph&&(headers["If-Match"]=graph.etag),self.serializers.serialize(contentType,graph).then(function(data){return self.request("PATCH",iri,headers,data,null,options).then(function(res){return httpSuccess(res.statusCode)?(callback(null,graph),void resolve(graph)):(callback("status code error: "+res.statusCode),Promise.reject("status code error: "+res.statusCode))})})["catch"](function(error){callback(error),reject(error)})})},module.exports=LdpStore},{inherits:159,"rdf-ext":179,"rdf-store-abstract":200}],204:[function(require,module,exports){arguments[4][118][0].apply(exports,arguments)},{"./_stream_readable":206,"./_stream_writable":208,"core-util-is":155,dup:118,inherits:159,"process-nextick-args":172}],205:[function(require,module,exports){arguments[4][119][0].apply(exports,arguments)},{"./_stream_transform":207,"core-util-is":155,dup:119,inherits:159}],206:[function(require,module,exports){arguments[4][120][0].apply(exports,arguments)},{"./_stream_duplex":204,"./internal/streams/BufferList":209,_process:105,buffer:45,"buffer-shims":153,"core-util-is":155,dup:120,events:82,inherits:159,isarray:160,"process-nextick-args":172,"string_decoder/":216,util:18}],207:[function(require,module,exports){arguments[4][121][0].apply(exports,arguments)},{"./_stream_duplex":204,"core-util-is":155,dup:121,inherits:159}],208:[function(require,module,exports){arguments[4][122][0].apply(exports,arguments)},{"./_stream_duplex":204,_process:105,buffer:45,"buffer-shims":153,"core-util-is":155,dup:122,events:82,inherits:159,"process-nextick-args":172,"util-deprecate":218}],209:[function(require,module,exports){arguments[4][123][0].apply(exports,arguments)},{buffer:45,"buffer-shims":153,dup:123}],210:[function(require,module,exports){arguments[4][125][0].apply(exports,arguments)},{"./lib/_stream_duplex.js":204,"./lib/_stream_passthrough.js":205,"./lib/_stream_readable.js":206,"./lib/_stream_transform.js":207,"./lib/_stream_writable.js":208,_process:105,dup:125}],211:[function(require,module){function Parser(parsers){return this instanceof Parser?void(this.parsers=parsers):new Parser(parsers)}module.exports=Parser,Parser.prototype.parse=function(data,contentType,subjectUri){return this.parsers[contentType].parse(data,null,subjectUri)}},{}],212:[function(require,module){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),LdpStore=require("rdf-store-ldp"),lite=require("./lite"),SimpleRDF=function(_lite$SimpleRDF){function SimpleRDF(context,iri,graph,store){_classCallCheck(this,SimpleRDF);var _this=_possibleConstructorReturn(this,Object.getPrototypeOf(SimpleRDF).call(this,context,iri,graph));return _this._store=store||new LdpStore,_this}return _inherits(SimpleRDF,_lite$SimpleRDF),_createClass(SimpleRDF,[{key:"child",value:function(iri){return new SimpleRDF(this._context,iri,this._graph,this._store)}},{key:"get",value:function(iri,options){var _this2=this;return"string"!=typeof iri&&(options=iri,iri=null),iri&&this.iri(iri),this._store.graph(this._iri.toString(),null,options).then(function(graph){return _this2.graph(graph),_this2})}},{key:"save",value:function(iri,options){var _this3=this;return"string"!=typeof iri&&(options=iri,iri=null),iri&&this.iri(iri),this._store.add(this._iri.toString(),this._graph,null,options).then(function(){return _this3})}}]),SimpleRDF}(lite.SimpleRDF);module.exports=function(context,iri,graph,store){return new SimpleRDF(context,iri,graph,store)},module.exports.isArray=lite.isArray,module.exports.SimpleRDF=SimpleRDF},{"./lite":215,"rdf-store-ldp":202}],213:[function(require,module){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),SimpleArray=function(){function SimpleArray(addValue,getValue,removeValue,array){_classCallCheck(this,SimpleArray),this._addValue=addValue,this._getValue=getValue,this._removeValue=removeValue,this._array=array||[]}return _createClass(SimpleArray,[{key:"at",value:function(index,value){return void 0!==value&&(void 0!==this._array[index]&&this._removeValue(this._array[index]),this._addValue(this._array[index]=value)),this._array[index]}},{key:"indexOf",value:function(searchElement,fromIndex){return this._array.indexOf(searchElement,fromIndex)}},{key:"forEach",value:function(callback,thisArg){return this._array.forEach(callback,thisArg)}},{key:"map",value:function(callback,thisArg){return this._array.map(callback,thisArg)}},{key:"reduce",value:function(callback,initialValue){return this._array.reduce(callback,initialValue)}},{key:"reduceRight",value:function(callback,initialValue){return this._array.reduceRight(callback,initialValue)}},{key:"push",value:function(value){var index=this._array.push(value);return this._addValue(value),index}},{key:"pop",value:function(){var popped=this._array.pop();return this._removeValue(popped),popped}}]),SimpleArray}();module.exports=SimpleArray},{}],214:[function(require,module){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Context=function(){function Context(json){_classCallCheck(this,Context),this._json=json}return _createClass(Context,[{key:"description",value:function description(property){if(!(property in this._json))return null;var json=this._json[property],description={};return description.property=property,description.options={array:!1,namedNode:!1},"string"==typeof json?description.predicate=json:(description.predicate=json["@id"],description.options.array="@container"in json&&"@set"===json["@container"]||"@array"in json&&json["@array"],description.options.namedNode="@type"in json&&"@id"===json["@type"]),description}},{key:"descriptions",value:function(){var _this=this;return this.properties().map(function(property){return _this.description(property)})}},{key:"properties",value:function(){return Object.keys(this._json)}}]),Context}();module.exports=Context},{}],215:[function(require,module){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function buildIri(iri){return"string"==typeof iri?rdf.createNamedNode(iri):iri||rdf.createBlankNode()}function updateSubject(graph,oldSubject,newSubject){graph.match(oldSubject).forEach(function(triple){graph.remove(triple),graph.add(rdf.createTriple(newSubject,triple.predicate,triple.object))})}function updateObject(graph,oldObject,newObject){graph.match(null,null,oldObject).forEach(function(triple){graph.remove(triple),graph.add(rdf.createTriple(triple.subject,triple.predicate,newObject))})}function addValues(self,predicate,options,values){Array.isArray(values)||(values=[values]),values.forEach(function(value){"string"==typeof value?self._graph.add(options.namedNode?rdf.createTriple(self._iri,predicate,rdf.createNamedNode(value)):rdf.createTriple(self._iri,predicate,rdf.createLiteral(value))):"object"===("undefined"==typeof value?"undefined":_typeof(value))?value.interfaceName?self._graph.add(rdf.createTriple(self._iri,predicate,value)):(self._graph.add(rdf.createTriple(self._iri,predicate,value._iri)),options.array||(self._objects[predicate]=value)):"boolean"==typeof value?self._graph.add(rdf.createTriple(self._iri,predicate,rdf.createLiteral(value,null,"http://www.w3.org/2001/XMLSchema#boolean"))):"number"==typeof value?self._graph.add(rdf.createTriple(self._iri,predicate,rdf.createLiteral(value,null,rdf.createNamedNode("http://www.w3.org/2001/XMLSchema#double")))):console.warn("unsupported type: "+("undefined"==typeof value?"undefined":_typeof(value)))})}function getValuesArray(self,predicate,options){return self._graph.match(self._iri,predicate).map(function(triple){return"Literal"!==triple.object.interfaceName?options.namedNode?triple.object.toString():self.child(triple.object):triple.object.toString()})}function getValues(self,predicate,options){if(predicate in self._objects)return self._objects[predicate];var values=getValuesArray(self,predicate,options);return values=options.array?self._objects[predicate]=new SimpleArray(addValues.bind(null,self,predicate,options),getValues.bind(null,self,predicate,options),removeValues.bind(null,self,predicate,options),getValuesArray(self,predicate,options)):values.shift()}function removeValues(self,predicate){self._graph.removeMatches(self._iri,predicate)}function addProperty(property,predicate,options){var _this3=this;options=options||{},predicate=rdf.createNamedNode(predicate.toString()),Object.defineProperty(this,property,{configurable:!0,get:function(){return getValues(_this3,predicate,options)},set:function(values){removeValues(_this3,predicate,options),addValues(_this3,predicate,options,values)}})}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj},_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),rdf=require("rdf-ext"),SimpleArray=require("./lib/array"),SimpleContext=require("./lib/context"),SimpleRDF=function(){function SimpleRDF(context,iri,graph){_classCallCheck(this,SimpleRDF),this._iri=buildIri(iri),this._objects={},this.context(context),this.graph(graph||rdf.createGraph())}return _createClass(SimpleRDF,[{key:"toString",value:function(){return this._graph.toString()}},{key:"context",value:function(_context){var _this=this;return _context&&(this._context=_context instanceof SimpleContext?_context:new SimpleContext(_context),this._context.descriptions().forEach(function(description){addProperty.call(_this,description.predicate,description.predicate,description.options),addProperty.call(_this,description.property,description.predicate,description.options)})),this._context}},{key:"iri",value:function(_iri){return _iri&&(_iri=buildIri(_iri),updateSubject(this._graph,this._iri,_iri),updateObject(this._graph,this._iri,_iri),this._iri=_iri),this._iri}},{key:"graph",value:function(_graph){var _this2=this;return _graph&&(this._graph=_graph,this._graph.match(this._iri).forEach(function(triple){var predicate=triple.predicate.toString(),descriptor=Object.getOwnPropertyDescriptor(_this2,predicate);descriptor||addProperty.call(_this2,triple.predicate.toString(),predicate)})),this._graph}},{key:"child",value:function(iri){return new SimpleRDF(this._context,iri,this._graph)}}]),SimpleRDF}();module.exports=function(context,iri,graph,store){return new SimpleRDF(context,iri,graph,store)},module.exports.isArray=function(obj){return obj instanceof SimpleArray},module.exports.SimpleRDF=SimpleRDF},{"./lib/array":213,"./lib/context":214,"rdf-ext":179}],216:[function(require,module,exports){arguments[4][142][0].apply(exports,arguments)},{buffer:45,dup:142}],217:[function(require,module,exports){function configureProperties(obj){if(getOwnPropNames&&defineProp){var i,props=getOwnPropNames(obj);for(i=0;i<props.length;i+=1)defineProp(obj,props[i],{value:obj[props[i]],writable:!1,enumerable:!1,configurable:!1})}}function makeArrayAccessors(obj){function makeArrayAccessor(index){defineProp(obj,index,{get:function(){return obj._getter(index)},set:function(v){obj._setter(index,v)},enumerable:!0,configurable:!1})}if(defineProp){if(obj.length>MAX_ARRAY_LENGTH)throw new RangeError("Array too large for polyfill");var i;for(i=0;i<obj.length;i+=1)makeArrayAccessor(i)}}function as_signed(value,bits){var s=32-bits;return value<<s>>s}function as_unsigned(value,bits){var s=32-bits;return value<<s>>>s}function packI8(n){return[255&n]}function unpackI8(bytes){return as_signed(bytes[0],8)}function packU8(n){return[255&n]}function unpackU8(bytes){return as_unsigned(bytes[0],8)}function packU8Clamped(n){return n=round(Number(n)),
  [0>n?0:n>255?255:255&n]}function packI16(n){return[n>>8&255,255&n]}function unpackI16(bytes){return as_signed(bytes[0]<<8|bytes[1],16)}function packU16(n){return[n>>8&255,255&n]}function unpackU16(bytes){return as_unsigned(bytes[0]<<8|bytes[1],16)}function packI32(n){return[n>>24&255,n>>16&255,n>>8&255,255&n]}function unpackI32(bytes){return as_signed(bytes[0]<<24|bytes[1]<<16|bytes[2]<<8|bytes[3],32)}function packU32(n){return[n>>24&255,n>>16&255,n>>8&255,255&n]}function unpackU32(bytes){return as_unsigned(bytes[0]<<24|bytes[1]<<16|bytes[2]<<8|bytes[3],32)}function packIEEE754(v,ebits,fbits){function roundToEven(n){var w=floor(n),f=n-w;return.5>f?w:f>.5?w+1:w%2?w+1:w}var s,e,f,i,bits,str,bytes,bias=(1<<ebits-1)-1;for(v!==v?(e=(1<<ebits)-1,f=pow(2,fbits-1),s=0):v===1/0||v===-(1/0)?(e=(1<<ebits)-1,f=0,s=0>v?1:0):0===v?(e=0,f=0,s=1/v===-(1/0)?1:0):(s=0>v,v=abs(v),v>=pow(2,1-bias)?(e=min(floor(log(v)/LN2),1023),f=roundToEven(v/pow(2,e)*pow(2,fbits)),f/pow(2,fbits)>=2&&(e+=1,f=1),e>bias?(e=(1<<ebits)-1,f=0):(e+=bias,f-=pow(2,fbits))):(e=0,f=roundToEven(v/pow(2,1-bias-fbits)))),bits=[],i=fbits;i;i-=1)bits.push(f%2?1:0),f=floor(f/2);for(i=ebits;i;i-=1)bits.push(e%2?1:0),e=floor(e/2);for(bits.push(s?1:0),bits.reverse(),str=bits.join(""),bytes=[];str.length;)bytes.push(parseInt(str.substring(0,8),2)),str=str.substring(8);return bytes}function unpackIEEE754(bytes,ebits,fbits){var i,j,b,str,bias,s,e,f,bits=[];for(i=bytes.length;i;i-=1)for(b=bytes[i-1],j=8;j;j-=1)bits.push(b%2?1:0),b>>=1;return bits.reverse(),str=bits.join(""),bias=(1<<ebits-1)-1,s=parseInt(str.substring(0,1),2)?-1:1,e=parseInt(str.substring(1,1+ebits),2),f=parseInt(str.substring(1+ebits),2),e===(1<<ebits)-1?0!==f?0/0:s*(1/0):e>0?s*pow(2,e-bias)*(1+f/pow(2,fbits)):0!==f?s*pow(2,-(bias-1))*(f/pow(2,fbits)):0>s?-0:0}function unpackF64(b){return unpackIEEE754(b,11,52)}function packF64(v){return packIEEE754(v,11,52)}function unpackF32(b){return unpackIEEE754(b,8,23)}function packF32(v){return packIEEE754(v,8,23)}var defineProp,undefined=void 0,MAX_ARRAY_LENGTH=1e5,ECMAScript=function(){var opts=Object.prototype.toString,ophop=Object.prototype.hasOwnProperty;return{Class:function(v){return opts.call(v).replace(/^\[object *|\]$/g,"")},HasProperty:function(o,p){return p in o},HasOwnProperty:function(o,p){return ophop.call(o,p)},IsCallable:function(o){return"function"==typeof o},ToInt32:function(v){return v>>0},ToUint32:function(v){return v>>>0}}}(),LN2=Math.LN2,abs=Math.abs,floor=Math.floor,log=Math.log,min=Math.min,pow=Math.pow,round=Math.round;defineProp=Object.defineProperty&&function(){try{return Object.defineProperty({},"x",{}),!0}catch(e){return!1}}()?Object.defineProperty:function(o,p,desc){if(!o===Object(o))throw new TypeError("Object.defineProperty called on non-object");return ECMAScript.HasProperty(desc,"get")&&Object.prototype.__defineGetter__&&Object.prototype.__defineGetter__.call(o,p,desc.get),ECMAScript.HasProperty(desc,"set")&&Object.prototype.__defineSetter__&&Object.prototype.__defineSetter__.call(o,p,desc.set),ECMAScript.HasProperty(desc,"value")&&(o[p]=desc.value),o};var getOwnPropNames=Object.getOwnPropertyNames||function(o){if(o!==Object(o))throw new TypeError("Object.getOwnPropertyNames called on non-object");var p,props=[];for(p in o)ECMAScript.HasOwnProperty(o,p)&&props.push(p);return props};!function(){function makeConstructor(bytesPerElement,pack,unpack){var ctor;return ctor=function(buffer,byteOffset,length){var array,sequence,i,s;if(arguments.length&&"number"!=typeof arguments[0])if("object"==typeof arguments[0]&&arguments[0].constructor===ctor)for(array=arguments[0],this.length=array.length,this.byteLength=this.length*this.BYTES_PER_ELEMENT,this.buffer=new ArrayBuffer(this.byteLength),this.byteOffset=0,i=0;i<this.length;i+=1)this._setter(i,array._getter(i));else if("object"!=typeof arguments[0]||(arguments[0]instanceof ArrayBuffer||"ArrayBuffer"===ECMAScript.Class(arguments[0]))){if("object"!=typeof arguments[0]||!(arguments[0]instanceof ArrayBuffer||"ArrayBuffer"===ECMAScript.Class(arguments[0])))throw new TypeError("Unexpected argument type(s)");if(this.buffer=buffer,this.byteOffset=ECMAScript.ToUint32(byteOffset),this.byteOffset>this.buffer.byteLength)throw new RangeError("byteOffset out of range");if(this.byteOffset%this.BYTES_PER_ELEMENT)throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.");if(arguments.length<3){if(this.byteLength=this.buffer.byteLength-this.byteOffset,this.byteLength%this.BYTES_PER_ELEMENT)throw new RangeError("length of buffer minus byteOffset not a multiple of the element size");this.length=this.byteLength/this.BYTES_PER_ELEMENT}else this.length=ECMAScript.ToUint32(length),this.byteLength=this.length*this.BYTES_PER_ELEMENT;if(this.byteOffset+this.byteLength>this.buffer.byteLength)throw new RangeError("byteOffset and length reference an area beyond the end of the buffer")}else for(sequence=arguments[0],this.length=ECMAScript.ToUint32(sequence.length),this.byteLength=this.length*this.BYTES_PER_ELEMENT,this.buffer=new ArrayBuffer(this.byteLength),this.byteOffset=0,i=0;i<this.length;i+=1)s=sequence[i],this._setter(i,Number(s));else{if(this.length=ECMAScript.ToInt32(arguments[0]),0>length)throw new RangeError("ArrayBufferView size is not a small enough positive integer");this.byteLength=this.length*this.BYTES_PER_ELEMENT,this.buffer=new ArrayBuffer(this.byteLength),this.byteOffset=0}this.constructor=ctor,configureProperties(this),makeArrayAccessors(this)},ctor.prototype=new ArrayBufferView,ctor.prototype.BYTES_PER_ELEMENT=bytesPerElement,ctor.prototype._pack=pack,ctor.prototype._unpack=unpack,ctor.BYTES_PER_ELEMENT=bytesPerElement,ctor.prototype._getter=function(index){if(arguments.length<1)throw new SyntaxError("Not enough arguments");if(index=ECMAScript.ToUint32(index),index>=this.length)return undefined;var i,o,bytes=[];for(i=0,o=this.byteOffset+index*this.BYTES_PER_ELEMENT;i<this.BYTES_PER_ELEMENT;i+=1,o+=1)bytes.push(this.buffer._bytes[o]);return this._unpack(bytes)},ctor.prototype.get=ctor.prototype._getter,ctor.prototype._setter=function(index,value){if(arguments.length<2)throw new SyntaxError("Not enough arguments");if(index=ECMAScript.ToUint32(index),index>=this.length)return undefined;var i,o,bytes=this._pack(value);for(i=0,o=this.byteOffset+index*this.BYTES_PER_ELEMENT;i<this.BYTES_PER_ELEMENT;i+=1,o+=1)this.buffer._bytes[o]=bytes[i]},ctor.prototype.set=function(){if(arguments.length<1)throw new SyntaxError("Not enough arguments");var array,sequence,offset,len,i,s,d,byteOffset,byteLength,tmp;if("object"==typeof arguments[0]&&arguments[0].constructor===this.constructor){if(array=arguments[0],offset=ECMAScript.ToUint32(arguments[1]),offset+array.length>this.length)throw new RangeError("Offset plus length of array is out of range");if(byteOffset=this.byteOffset+offset*this.BYTES_PER_ELEMENT,byteLength=array.length*this.BYTES_PER_ELEMENT,array.buffer===this.buffer){for(tmp=[],i=0,s=array.byteOffset;byteLength>i;i+=1,s+=1)tmp[i]=array.buffer._bytes[s];for(i=0,d=byteOffset;byteLength>i;i+=1,d+=1)this.buffer._bytes[d]=tmp[i]}else for(i=0,s=array.byteOffset,d=byteOffset;byteLength>i;i+=1,s+=1,d+=1)this.buffer._bytes[d]=array.buffer._bytes[s]}else{if("object"!=typeof arguments[0]||"undefined"==typeof arguments[0].length)throw new TypeError("Unexpected argument type(s)");if(sequence=arguments[0],len=ECMAScript.ToUint32(sequence.length),offset=ECMAScript.ToUint32(arguments[1]),offset+len>this.length)throw new RangeError("Offset plus length of array is out of range");for(i=0;len>i;i+=1)s=sequence[i],this._setter(offset+i,Number(s))}},ctor.prototype.subarray=function(start,end){function clamp(v,min,max){return min>v?min:v>max?max:v}start=ECMAScript.ToInt32(start),end=ECMAScript.ToInt32(end),arguments.length<1&&(start=0),arguments.length<2&&(end=this.length),0>start&&(start=this.length+start),0>end&&(end=this.length+end),start=clamp(start,0,this.length),end=clamp(end,0,this.length);var len=end-start;return 0>len&&(len=0),new this.constructor(this.buffer,this.byteOffset+start*this.BYTES_PER_ELEMENT,len)},ctor}var ArrayBuffer=function(length){if(length=ECMAScript.ToInt32(length),0>length)throw new RangeError("ArrayBuffer size is not a small enough positive integer");this.byteLength=length,this._bytes=[],this._bytes.length=length;var i;for(i=0;i<this.byteLength;i+=1)this._bytes[i]=0;configureProperties(this)};exports.ArrayBuffer=exports.ArrayBuffer||ArrayBuffer;var ArrayBufferView=function(){},Int8Array=makeConstructor(1,packI8,unpackI8),Uint8Array=makeConstructor(1,packU8,unpackU8),Uint8ClampedArray=makeConstructor(1,packU8Clamped,unpackU8),Int16Array=makeConstructor(2,packI16,unpackI16),Uint16Array=makeConstructor(2,packU16,unpackU16),Int32Array=makeConstructor(4,packI32,unpackI32),Uint32Array=makeConstructor(4,packU32,unpackU32),Float32Array=makeConstructor(4,packF32,unpackF32),Float64Array=makeConstructor(8,packF64,unpackF64);exports.Int8Array=exports.Int8Array||Int8Array,exports.Uint8Array=exports.Uint8Array||Uint8Array,exports.Uint8ClampedArray=exports.Uint8ClampedArray||Uint8ClampedArray,exports.Int16Array=exports.Int16Array||Int16Array,exports.Uint16Array=exports.Uint16Array||Uint16Array,exports.Int32Array=exports.Int32Array||Int32Array,exports.Uint32Array=exports.Uint32Array||Uint32Array,exports.Float32Array=exports.Float32Array||Float32Array,exports.Float64Array=exports.Float64Array||Float64Array}(),function(){function r(array,index){return ECMAScript.IsCallable(array.get)?array.get(index):array[index]}function makeGetter(arrayType){return function(byteOffset,littleEndian){if(byteOffset=ECMAScript.ToUint32(byteOffset),byteOffset+arrayType.BYTES_PER_ELEMENT>this.byteLength)throw new RangeError("Array index out of range");byteOffset+=this.byteOffset;var i,uint8Array=new exports.Uint8Array(this.buffer,byteOffset,arrayType.BYTES_PER_ELEMENT),bytes=[];for(i=0;i<arrayType.BYTES_PER_ELEMENT;i+=1)bytes.push(r(uint8Array,i));return Boolean(littleEndian)===Boolean(IS_BIG_ENDIAN)&&bytes.reverse(),r(new arrayType(new exports.Uint8Array(bytes).buffer),0)}}function makeSetter(arrayType){return function(byteOffset,value,littleEndian){if(byteOffset=ECMAScript.ToUint32(byteOffset),byteOffset+arrayType.BYTES_PER_ELEMENT>this.byteLength)throw new RangeError("Array index out of range");var i,byteView,typeArray=new arrayType([value]),byteArray=new exports.Uint8Array(typeArray.buffer),bytes=[];for(i=0;i<arrayType.BYTES_PER_ELEMENT;i+=1)bytes.push(r(byteArray,i));Boolean(littleEndian)===Boolean(IS_BIG_ENDIAN)&&bytes.reverse(),byteView=new exports.Uint8Array(this.buffer,byteOffset,arrayType.BYTES_PER_ELEMENT),byteView.set(bytes)}}var IS_BIG_ENDIAN=function(){var u16array=new exports.Uint16Array([4660]),u8array=new exports.Uint8Array(u16array.buffer);return 18===r(u8array,0)}(),DataView=function(buffer,byteOffset,byteLength){if(0===arguments.length)buffer=new exports.ArrayBuffer(0);else if(!(buffer instanceof exports.ArrayBuffer||"ArrayBuffer"===ECMAScript.Class(buffer)))throw new TypeError("TypeError");if(this.buffer=buffer||new exports.ArrayBuffer(0),this.byteOffset=ECMAScript.ToUint32(byteOffset),this.byteOffset>this.buffer.byteLength)throw new RangeError("byteOffset out of range");if(this.byteLength=arguments.length<3?this.buffer.byteLength-this.byteOffset:ECMAScript.ToUint32(byteLength),this.byteOffset+this.byteLength>this.buffer.byteLength)throw new RangeError("byteOffset and length reference an area beyond the end of the buffer");configureProperties(this)};DataView.prototype.getUint8=makeGetter(exports.Uint8Array),DataView.prototype.getInt8=makeGetter(exports.Int8Array),DataView.prototype.getUint16=makeGetter(exports.Uint16Array),DataView.prototype.getInt16=makeGetter(exports.Int16Array),DataView.prototype.getUint32=makeGetter(exports.Uint32Array),DataView.prototype.getInt32=makeGetter(exports.Int32Array),DataView.prototype.getFloat32=makeGetter(exports.Float32Array),DataView.prototype.getFloat64=makeGetter(exports.Float64Array),DataView.prototype.setUint8=makeSetter(exports.Uint8Array),DataView.prototype.setInt8=makeSetter(exports.Int8Array),DataView.prototype.setUint16=makeSetter(exports.Uint16Array),DataView.prototype.setInt16=makeSetter(exports.Int16Array),DataView.prototype.setUint32=makeSetter(exports.Uint32Array),DataView.prototype.setInt32=makeSetter(exports.Int32Array),DataView.prototype.setFloat32=makeSetter(exports.Float32Array),DataView.prototype.setFloat64=makeSetter(exports.Float64Array),exports.DataView=exports.DataView||DataView}()},{}],218:[function(require,module,exports){arguments[4][146][0].apply(exports,arguments)},{dup:146}],219:[function(require,module,exports){function DOMParser(options){this.options=options||{locator:{}}}function buildErrorHandler(errorImpl,domBuilder,locator){function build(key){var fn=errorImpl[key];!fn&&isCallback&&(fn=2==errorImpl.length?function(msg){errorImpl(key,msg)}:errorImpl),errorHandler[key]=fn&&function(msg){fn("[xmldom "+key+"]	"+msg+_locator(locator))}||function(){}}if(!errorImpl){if(domBuilder instanceof DOMHandler)return domBuilder;errorImpl=domBuilder}var errorHandler={},isCallback=errorImpl instanceof Function;return locator=locator||{},build("warning"),build("error"),build("fatalError"),errorHandler}function DOMHandler(){this.cdata=!1}function position(locator,node){node.lineNumber=locator.lineNumber,node.columnNumber=locator.columnNumber}function _locator(l){return l?"\n@"+(l.systemId||"")+"#[line:"+l.lineNumber+",col:"+l.columnNumber+"]":void 0}function _toString(chars,start,length){return"string"==typeof chars?chars.substr(start,length):chars.length>=start+length||start?new java.lang.String(chars,start,length)+"":chars}function appendElement(hander,node){hander.currentElement?hander.currentElement.appendChild(node):hander.doc.appendChild(node)}DOMParser.prototype.parseFromString=function(source,mimeType){var options=this.options,sax=new XMLReader,domBuilder=options.domBuilder||new DOMHandler,errorHandler=options.errorHandler,locator=options.locator,defaultNSMap=options.xmlns||{},entityMap={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return locator&&domBuilder.setDocumentLocator(locator),sax.errorHandler=buildErrorHandler(errorHandler,domBuilder,locator),sax.domBuilder=options.domBuilder||domBuilder,/\/x?html?$/.test(mimeType)&&(entityMap.nbsp=" ",entityMap.copy="©",defaultNSMap[""]="http://www.w3.org/1999/xhtml"),defaultNSMap.xml=defaultNSMap.xml||"http://www.w3.org/XML/1998/namespace",source?sax.parse(source,defaultNSMap,entityMap):sax.errorHandler.error("invalid doc source"),domBuilder.doc},DOMHandler.prototype={startDocument:function(){this.doc=(new DOMImplementation).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(namespaceURI,localName,qName,attrs){var doc=this.doc,el=doc.createElementNS(namespaceURI,qName||localName),len=attrs.length;appendElement(this,el),this.currentElement=el,this.locator&&position(this.locator,el);for(var i=0;len>i;i++){var namespaceURI=attrs.getURI(i),value=attrs.getValue(i),qName=attrs.getQName(i),attr=doc.createAttributeNS(namespaceURI,qName);this.locator&&position(attrs.getLocator(i),attr),attr.value=attr.nodeValue=value,el.setAttributeNode(attr)}},endElement:function(){{var current=this.currentElement;current.tagName}this.currentElement=current.parentNode},startPrefixMapping:function(){},endPrefixMapping:function(){},processingInstruction:function(target,data){var ins=this.doc.createProcessingInstruction(target,data);this.locator&&position(this.locator,ins),appendElement(this,ins)},ignorableWhitespace:function(){},characters:function(chars){if(chars=_toString.apply(this,arguments)){if(this.cdata)var charNode=this.doc.createCDATASection(chars);else var charNode=this.doc.createTextNode(chars);this.currentElement?this.currentElement.appendChild(charNode):/^\s*$/.test(chars)&&this.doc.appendChild(charNode),this.locator&&position(this.locator,charNode)}},skippedEntity:function(){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(locator){(this.locator=locator)&&(locator.lineNumber=0)},comment:function(chars){chars=_toString.apply(this,arguments);var comm=this.doc.createComment(chars);this.locator&&position(this.locator,comm),appendElement(this,comm)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(name,publicId,systemId){var impl=this.doc.implementation;if(impl&&impl.createDocumentType){var dt=impl.createDocumentType(name,publicId,systemId);this.locator&&position(this.locator,dt),appendElement(this,dt)}},warning:function(error){console.warn("[xmldom warning]	"+error,_locator(this.locator))},error:function(error){console.error("[xmldom error]	"+error,_locator(this.locator))},fatalError:function(error){throw console.error("[xmldom fatalError]	"+error,_locator(this.locator)),error}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){DOMHandler.prototype[key]=function(){return null}});var XMLReader=require("./sax").XMLReader,DOMImplementation=exports.DOMImplementation=require("./dom").DOMImplementation;exports.XMLSerializer=require("./dom").XMLSerializer,exports.DOMParser=DOMParser},{"./dom":220,"./sax":221}],220:[function(require,module,exports){function copy(src,dest){for(var p in src)dest[p]=src[p]}function _extends(Class,Super){function t(){}var pt=Class.prototype;if(Object.create){var ppt=Object.create(Super.prototype);pt.__proto__=ppt}pt instanceof Super||(t.prototype=Super.prototype,t=new t,copy(pt,t),Class.prototype=pt=t),pt.constructor!=Class&&("function"!=typeof Class&&console.error("unknow Class:"+Class),pt.constructor=Class)}function DOMException(code,message){if(message instanceof Error)var error=message;else error=this,Error.call(this,ExceptionMessage[code]),this.message=ExceptionMessage[code],Error.captureStackTrace&&Error.captureStackTrace(this,DOMException);return error.code=code,message&&(this.message=this.message+": "+message),error}function NodeList(){}function LiveNodeList(node,refresh){this._node=node,this._refresh=refresh,_updateLiveList(this)}function _updateLiveList(list){var inc=list._node._inc||list._node.ownerDocument._inc;if(list._inc!=inc){var ls=list._refresh(list._node);__set__(list,"length",ls.length),copy(ls,list),list._inc=inc}}function NamedNodeMap(){}function _findNodeIndex(list,node){for(var i=list.length;i--;)if(list[i]===node)return i}function _addNamedNode(el,list,newAttr,oldAttr){if(oldAttr?list[_findNodeIndex(list,oldAttr)]=newAttr:list[list.length++]=newAttr,el){newAttr.ownerElement=el;var doc=el.ownerDocument;doc&&(oldAttr&&_onRemoveAttribute(doc,el,oldAttr),_onAddAttribute(doc,el,newAttr))}}function _removeNamedNode(el,list,attr){var i=_findNodeIndex(list,attr);if(!(i>=0))throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+"@"+attr));for(var lastIndex=list.length-1;lastIndex>i;)list[i]=list[++i];if(list.length=lastIndex,el){var doc=el.ownerDocument;doc&&(_onRemoveAttribute(doc,el,attr),attr.ownerElement=null)}}function DOMImplementation(features){if(this._features={},features)for(var feature in features)this._features=features[feature]}function Node(){}function _xmlEncoder(c){return"<"==c&&"&lt;"||">"==c&&"&gt;"||"&"==c&&"&amp;"||'"'==c&&"&quot;"||"&#"+c.charCodeAt()+";"}function _visitNode(node,callback){if(callback(node))return!0;if(node=node.firstChild)do if(_visitNode(node,callback))return!0;while(node=node.nextSibling)}function Document(){}function _onAddAttribute(doc,el,newAttr){doc&&doc._inc++;var ns=newAttr.namespaceURI;"http://www.w3.org/2000/xmlns/"==ns&&(el._nsMap[newAttr.prefix?newAttr.localName:""]=newAttr.value)}function _onRemoveAttribute(doc,el,newAttr){doc&&doc._inc++;var ns=newAttr.namespaceURI;"http://www.w3.org/2000/xmlns/"==ns&&delete el._nsMap[newAttr.prefix?newAttr.localName:""]}function _onUpdateChild(doc,el,newChild){if(doc&&doc._inc){doc._inc++;var cs=el.childNodes;if(newChild)cs[cs.length++]=newChild;else{for(var child=el.firstChild,i=0;child;)cs[i++]=child,child=child.nextSibling;cs.length=i}}}function _removeChild(parentNode,child){var previous=child.previousSibling,next=child.nextSibling;return previous?previous.nextSibling=next:parentNode.firstChild=next,next?next.previousSibling=previous:parentNode.lastChild=previous,_onUpdateChild(parentNode.ownerDocument,parentNode),child}function _insertBefore(parentNode,newChild,nextChild){var cp=newChild.parentNode;if(cp&&cp.removeChild(newChild),newChild.nodeType===DOCUMENT_FRAGMENT_NODE){var newFirst=newChild.firstChild;if(null==newFirst)return newChild;var newLast=newChild.lastChild}else newFirst=newLast=newChild;var pre=nextChild?nextChild.previousSibling:parentNode.lastChild;newFirst.previousSibling=pre,newLast.nextSibling=nextChild,pre?pre.nextSibling=newFirst:parentNode.firstChild=newFirst,null==nextChild?parentNode.lastChild=newLast:nextChild.previousSibling=newLast;do newFirst.parentNode=parentNode;while(newFirst!==newLast&&(newFirst=newFirst.nextSibling));return _onUpdateChild(parentNode.ownerDocument||parentNode,parentNode),newChild.nodeType==DOCUMENT_FRAGMENT_NODE&&(newChild.firstChild=newChild.lastChild=null),newChild}function _appendSingleChild(parentNode,newChild){var cp=newChild.parentNode;if(cp){var pre=parentNode.lastChild;cp.removeChild(newChild);var pre=parentNode.lastChild}var pre=parentNode.lastChild;return newChild.parentNode=parentNode,newChild.previousSibling=pre,newChild.nextSibling=null,pre?pre.nextSibling=newChild:parentNode.firstChild=newChild,parentNode.lastChild=newChild,_onUpdateChild(parentNode.ownerDocument,parentNode,newChild),newChild}function Element(){this._nsMap={}}function Attr(){}function CharacterData(){}function Text(){}function Comment(){}function CDATASection(){}function DocumentType(){}function Notation(){}function Entity(){}function EntityReference(){}function DocumentFragment(){}function ProcessingInstruction(){}function XMLSerializer(){}function nodeSerializeToString(isHtml,nodeFilter){var buf=[],refNode=9==this.nodeType?this.documentElement:this,prefix=refNode.prefix,uri=refNode.namespaceURI;if(uri&&null==prefix){var prefix=refNode.lookupPrefix(uri);if(null==prefix)var visibleNamespaces=[{namespace:uri,prefix:null}]}return serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces),buf.join("")}function needNamespaceDefine(node,isHTML,visibleNamespaces){var prefix=node.prefix||"",uri=node.namespaceURI;if(!prefix&&!uri)return!1;if("xml"===prefix&&"http://www.w3.org/XML/1998/namespace"===uri||"http://www.w3.org/2000/xmlns/"==uri)return!1;for(var i=visibleNamespaces.length;i--;){var ns=visibleNamespaces[i];if(ns.prefix==prefix)return ns.namespace!=uri}return!0}function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){if(nodeFilter){if(node=nodeFilter(node),!node)return;if("string"==typeof node)return void buf.push(node)}switch(node.nodeType){case ELEMENT_NODE:visibleNamespaces||(visibleNamespaces=[]);var attrs=(visibleNamespaces.length,node.attributes),len=attrs.length,child=node.firstChild,nodeName=node.tagName;isHTML=htmlns===node.namespaceURI||isHTML,buf.push("<",nodeName);for(var i=0;len>i;i++){var attr=attrs.item(i);"xmlns"==attr.prefix?visibleNamespaces.push({prefix:attr.localName,namespace:attr.value}):"xmlns"==attr.nodeName&&visibleNamespaces.push({prefix:"",namespace:attr.value})}for(var i=0;len>i;i++){var attr=attrs.item(i);if(needNamespaceDefine(attr,isHTML,visibleNamespaces)){var prefix=attr.prefix||"",uri=attr.namespaceURI,ns=prefix?" xmlns:"+prefix:" xmlns";buf.push(ns,'="',uri,'"'),visibleNamespaces.push({prefix:prefix,namespace:uri})}serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces)}if(needNamespaceDefine(node,isHTML,visibleNamespaces)){var prefix=node.prefix||"",uri=node.namespaceURI,ns=prefix?" xmlns:"+prefix:" xmlns";buf.push(ns,'="',uri,'"'),visibleNamespaces.push({prefix:prefix,namespace:uri})}if(child||isHTML&&!/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){if(buf.push(">"),isHTML&&/^script$/i.test(nodeName))for(;child;)child.data?buf.push(child.data):serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces),child=child.nextSibling;else for(;child;)serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces),child=child.nextSibling;buf.push("</",nodeName,">")}else buf.push("/>");return;case DOCUMENT_NODE:case DOCUMENT_FRAGMENT_NODE:for(var child=node.firstChild;child;)serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces),child=child.nextSibling;return;case ATTRIBUTE_NODE:return buf.push(" ",node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"');case TEXT_NODE:return buf.push(node.data.replace(/[<&]/g,_xmlEncoder));case CDATA_SECTION_NODE:return buf.push("<![CDATA[",node.data,"]]>");case COMMENT_NODE:return buf.push("<!--",node.data,"-->");case DOCUMENT_TYPE_NODE:var pubid=node.publicId,sysid=node.systemId;if(buf.push("<!DOCTYPE ",node.name),pubid)buf.push(' PUBLIC "',pubid),sysid&&"."!=sysid&&buf.push('" "',sysid),buf.push('">');else if(sysid&&"."!=sysid)buf.push(' SYSTEM "',sysid,'">');else{var sub=node.internalSubset;sub&&buf.push(" [",sub,"]"),buf.push(">")}return;case PROCESSING_INSTRUCTION_NODE:return buf.push("<?",node.target," ",node.data,"?>");case ENTITY_REFERENCE_NODE:return buf.push("&",node.nodeName,";");default:buf.push("??",node.nodeName)}}function importNode(doc,node,deep){var node2;switch(node.nodeType){case ELEMENT_NODE:node2=node.cloneNode(!1),node2.ownerDocument=doc;case DOCUMENT_FRAGMENT_NODE:break;case ATTRIBUTE_NODE:deep=!0}if(node2||(node2=node.cloneNode(!1)),node2.ownerDocument=doc,node2.parentNode=null,deep)for(var child=node.firstChild;child;)node2.appendChild(importNode(doc,child,deep)),child=child.nextSibling;return node2}function cloneNode(doc,node,deep){var node2=new node.constructor;for(var n in node){var v=node[n];"object"!=typeof v&&v!=node2[n]&&(node2[n]=v)}switch(node.childNodes&&(node2.childNodes=new NodeList),node2.ownerDocument=doc,node2.nodeType){case ELEMENT_NODE:var attrs=node.attributes,attrs2=node2.attributes=new NamedNodeMap,len=attrs.length;attrs2._ownerElement=node2;for(var i=0;len>i;i++)node2.setAttributeNode(cloneNode(doc,attrs.item(i),!0));break;case ATTRIBUTE_NODE:deep=!0}if(deep)for(var child=node.firstChild;child;)node2.appendChild(cloneNode(doc,child,deep)),child=child.nextSibling;return node2}function __set__(object,key,value){object[key]=value}function getTextContent(node){switch(node.nodeType){case ELEMENT_NODE:case DOCUMENT_FRAGMENT_NODE:var buf=[];for(node=node.firstChild;node;)7!==node.nodeType&&8!==node.nodeType&&buf.push(getTextContent(node)),node=node.nextSibling;return buf.join("");default:return node.nodeValue}}{var htmlns="http://www.w3.org/1999/xhtml",NodeType={},ELEMENT_NODE=NodeType.ELEMENT_NODE=1,ATTRIBUTE_NODE=NodeType.ATTRIBUTE_NODE=2,TEXT_NODE=NodeType.TEXT_NODE=3,CDATA_SECTION_NODE=NodeType.CDATA_SECTION_NODE=4,ENTITY_REFERENCE_NODE=NodeType.ENTITY_REFERENCE_NODE=5,ENTITY_NODE=NodeType.ENTITY_NODE=6,PROCESSING_INSTRUCTION_NODE=NodeType.PROCESSING_INSTRUCTION_NODE=7,COMMENT_NODE=NodeType.COMMENT_NODE=8,DOCUMENT_NODE=NodeType.DOCUMENT_NODE=9,DOCUMENT_TYPE_NODE=NodeType.DOCUMENT_TYPE_NODE=10,DOCUMENT_FRAGMENT_NODE=NodeType.DOCUMENT_FRAGMENT_NODE=11,NOTATION_NODE=NodeType.NOTATION_NODE=12,ExceptionCode={},ExceptionMessage={},HIERARCHY_REQUEST_ERR=(ExceptionCode.INDEX_SIZE_ERR=(ExceptionMessage[1]="Index size error",1),ExceptionCode.DOMSTRING_SIZE_ERR=(ExceptionMessage[2]="DOMString size error",2),ExceptionCode.HIERARCHY_REQUEST_ERR=(ExceptionMessage[3]="Hierarchy request error",3)),NOT_FOUND_ERR=(ExceptionCode.WRONG_DOCUMENT_ERR=(ExceptionMessage[4]="Wrong document",4),ExceptionCode.INVALID_CHARACTER_ERR=(ExceptionMessage[5]="Invalid character",5),ExceptionCode.NO_DATA_ALLOWED_ERR=(ExceptionMessage[6]="No data allowed",6),ExceptionCode.NO_MODIFICATION_ALLOWED_ERR=(ExceptionMessage[7]="No modification allowed",7),ExceptionCode.NOT_FOUND_ERR=(ExceptionMessage[8]="Not found",8)),INUSE_ATTRIBUTE_ERR=(ExceptionCode.NOT_SUPPORTED_ERR=(ExceptionMessage[9]="Not supported",9),ExceptionCode.INUSE_ATTRIBUTE_ERR=(ExceptionMessage[10]="Attribute in use",10));ExceptionCode.INVALID_STATE_ERR=(ExceptionMessage[11]="Invalid state",11),ExceptionCode.SYNTAX_ERR=(ExceptionMessage[12]="Syntax error",12),ExceptionCode.INVALID_MODIFICATION_ERR=(ExceptionMessage[13]="Invalid modification",13),ExceptionCode.NAMESPACE_ERR=(ExceptionMessage[14]="Invalid namespace",14),ExceptionCode.INVALID_ACCESS_ERR=(ExceptionMessage[15]="Invalid access",15)}DOMException.prototype=Error.prototype,copy(ExceptionCode,DOMException),NodeList.prototype={length:0,item:function(index){return this[index]||null},toString:function(isHTML,nodeFilter){for(var buf=[],i=0;i<this.length;i++)serializeToString(this[i],buf,isHTML,nodeFilter);return buf.join("")}},LiveNodeList.prototype.item=function(i){return _updateLiveList(this),this[i]},_extends(LiveNodeList,NodeList),NamedNodeMap.prototype={length:0,item:NodeList.prototype.item,getNamedItem:function(key){for(var i=this.length;i--;){var attr=this[i];if(attr.nodeName==key)return attr}},setNamedItem:function(attr){var el=attr.ownerElement;if(el&&el!=this._ownerElement)throw new DOMException(INUSE_ATTRIBUTE_ERR);var oldAttr=this.getNamedItem(attr.nodeName);return _addNamedNode(this._ownerElement,this,attr,oldAttr),oldAttr},setNamedItemNS:function(attr){var oldAttr,el=attr.ownerElement;if(el&&el!=this._ownerElement)throw new DOMException(INUSE_ATTRIBUTE_ERR);return oldAttr=this.getNamedItemNS(attr.namespaceURI,attr.localName),_addNamedNode(this._ownerElement,this,attr,oldAttr),oldAttr},removeNamedItem:function(key){var attr=this.getNamedItem(key);return _removeNamedNode(this._ownerElement,this,attr),attr},removeNamedItemNS:function(namespaceURI,localName){var attr=this.getNamedItemNS(namespaceURI,localName);return _removeNamedNode(this._ownerElement,this,attr),attr},getNamedItemNS:function(namespaceURI,localName){for(var i=this.length;i--;){var node=this[i];if(node.localName==localName&&node.namespaceURI==namespaceURI)return node}return null}},DOMImplementation.prototype={hasFeature:function(feature,version){var versions=this._features[feature.toLowerCase()];return versions&&(!version||version in versions)?!0:!1},createDocument:function(namespaceURI,qualifiedName,doctype){var doc=new Document;if(doc.implementation=this,doc.childNodes=new NodeList,doc.doctype=doctype,doctype&&doc.appendChild(doctype),qualifiedName){var root=doc.createElementNS(namespaceURI,qualifiedName);doc.appendChild(root)}return doc},createDocumentType:function(qualifiedName,publicId,systemId){var node=new DocumentType;return node.name=qualifiedName,node.nodeName=qualifiedName,node.publicId=publicId,node.systemId=systemId,node}},Node.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(newChild,refChild){return _insertBefore(this,newChild,refChild)},replaceChild:function(newChild,oldChild){this.insertBefore(newChild,oldChild),oldChild&&this.removeChild(oldChild)},removeChild:function(oldChild){return _removeChild(this,oldChild)},appendChild:function(newChild){return this.insertBefore(newChild,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(deep){return cloneNode(this.ownerDocument||this,this,deep)},normalize:function(){for(var child=this.firstChild;child;){var next=child.nextSibling;next&&next.nodeType==TEXT_NODE&&child.nodeType==TEXT_NODE?(this.removeChild(next),child.appendData(next.data)):(child.normalize(),child=next)}},isSupported:function(feature,version){return this.ownerDocument.implementation.hasFeature(feature,version)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(namespaceURI){for(var el=this;el;){var map=el._nsMap;if(map)for(var n in map)if(map[n]==namespaceURI)return n;el=el.nodeType==ATTRIBUTE_NODE?el.ownerDocument:el.parentNode;
  
  }return null},lookupNamespaceURI:function(prefix){for(var el=this;el;){var map=el._nsMap;if(map&&prefix in map)return map[prefix];el=el.nodeType==ATTRIBUTE_NODE?el.ownerDocument:el.parentNode}return null},isDefaultNamespace:function(namespaceURI){var prefix=this.lookupPrefix(namespaceURI);return null==prefix}},copy(NodeType,Node),copy(NodeType,Node.prototype),Document.prototype={nodeName:"#document",nodeType:DOCUMENT_NODE,doctype:null,documentElement:null,_inc:1,insertBefore:function(newChild,refChild){if(newChild.nodeType==DOCUMENT_FRAGMENT_NODE){for(var child=newChild.firstChild;child;){var next=child.nextSibling;this.insertBefore(child,refChild),child=next}return newChild}return null==this.documentElement&&newChild.nodeType==ELEMENT_NODE&&(this.documentElement=newChild),_insertBefore(this,newChild,refChild),newChild.ownerDocument=this,newChild},removeChild:function(oldChild){return this.documentElement==oldChild&&(this.documentElement=null),_removeChild(this,oldChild)},importNode:function(importedNode,deep){return importNode(this,importedNode,deep)},getElementById:function(id){var rtv=null;return _visitNode(this.documentElement,function(node){return node.nodeType==ELEMENT_NODE&&node.getAttribute("id")==id?(rtv=node,!0):void 0}),rtv},createElement:function(tagName){var node=new Element;node.ownerDocument=this,node.nodeName=tagName,node.tagName=tagName,node.childNodes=new NodeList;var attrs=node.attributes=new NamedNodeMap;return attrs._ownerElement=node,node},createDocumentFragment:function(){var node=new DocumentFragment;return node.ownerDocument=this,node.childNodes=new NodeList,node},createTextNode:function(data){var node=new Text;return node.ownerDocument=this,node.appendData(data),node},createComment:function(data){var node=new Comment;return node.ownerDocument=this,node.appendData(data),node},createCDATASection:function(data){var node=new CDATASection;return node.ownerDocument=this,node.appendData(data),node},createProcessingInstruction:function(target,data){var node=new ProcessingInstruction;return node.ownerDocument=this,node.tagName=node.target=target,node.nodeValue=node.data=data,node},createAttribute:function(name){var node=new Attr;return node.ownerDocument=this,node.name=name,node.nodeName=name,node.localName=name,node.specified=!0,node},createEntityReference:function(name){var node=new EntityReference;return node.ownerDocument=this,node.nodeName=name,node},createElementNS:function(namespaceURI,qualifiedName){var node=new Element,pl=qualifiedName.split(":"),attrs=node.attributes=new NamedNodeMap;return node.childNodes=new NodeList,node.ownerDocument=this,node.nodeName=qualifiedName,node.tagName=qualifiedName,node.namespaceURI=namespaceURI,2==pl.length?(node.prefix=pl[0],node.localName=pl[1]):node.localName=qualifiedName,attrs._ownerElement=node,node},createAttributeNS:function(namespaceURI,qualifiedName){var node=new Attr,pl=qualifiedName.split(":");return node.ownerDocument=this,node.nodeName=qualifiedName,node.name=qualifiedName,node.namespaceURI=namespaceURI,node.specified=!0,2==pl.length?(node.prefix=pl[0],node.localName=pl[1]):node.localName=qualifiedName,node}},_extends(Document,Node),Element.prototype={nodeType:ELEMENT_NODE,hasAttribute:function(name){return null!=this.getAttributeNode(name)},getAttribute:function(name){var attr=this.getAttributeNode(name);return attr&&attr.value||""},getAttributeNode:function(name){return this.attributes.getNamedItem(name)},setAttribute:function(name,value){var attr=this.ownerDocument.createAttribute(name);attr.value=attr.nodeValue=""+value,this.setAttributeNode(attr)},removeAttribute:function(name){var attr=this.getAttributeNode(name);attr&&this.removeAttributeNode(attr)},appendChild:function(newChild){return newChild.nodeType===DOCUMENT_FRAGMENT_NODE?this.insertBefore(newChild,null):_appendSingleChild(this,newChild)},setAttributeNode:function(newAttr){return this.attributes.setNamedItem(newAttr)},setAttributeNodeNS:function(newAttr){return this.attributes.setNamedItemNS(newAttr)},removeAttributeNode:function(oldAttr){return this.attributes.removeNamedItem(oldAttr.nodeName)},removeAttributeNS:function(namespaceURI,localName){var old=this.getAttributeNodeNS(namespaceURI,localName);old&&this.removeAttributeNode(old)},hasAttributeNS:function(namespaceURI,localName){return null!=this.getAttributeNodeNS(namespaceURI,localName)},getAttributeNS:function(namespaceURI,localName){var attr=this.getAttributeNodeNS(namespaceURI,localName);return attr&&attr.value||""},setAttributeNS:function(namespaceURI,qualifiedName,value){var attr=this.ownerDocument.createAttributeNS(namespaceURI,qualifiedName);attr.value=attr.nodeValue=""+value,this.setAttributeNode(attr)},getAttributeNodeNS:function(namespaceURI,localName){return this.attributes.getNamedItemNS(namespaceURI,localName)},getElementsByTagName:function(tagName){return new LiveNodeList(this,function(base){var ls=[];return _visitNode(base,function(node){node===base||node.nodeType!=ELEMENT_NODE||"*"!==tagName&&node.tagName!=tagName||ls.push(node)}),ls})},getElementsByTagNameNS:function(namespaceURI,localName){return new LiveNodeList(this,function(base){var ls=[];return _visitNode(base,function(node){node===base||node.nodeType!==ELEMENT_NODE||"*"!==namespaceURI&&node.namespaceURI!==namespaceURI||"*"!==localName&&node.localName!=localName||ls.push(node)}),ls})}},Document.prototype.getElementsByTagName=Element.prototype.getElementsByTagName,Document.prototype.getElementsByTagNameNS=Element.prototype.getElementsByTagNameNS,_extends(Element,Node),Attr.prototype.nodeType=ATTRIBUTE_NODE,_extends(Attr,Node),CharacterData.prototype={data:"",substringData:function(offset,count){return this.data.substring(offset,offset+count)},appendData:function(text){text=this.data+text,this.nodeValue=this.data=text,this.length=text.length},insertData:function(offset,text){this.replaceData(offset,0,text)},appendChild:function(){throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])},deleteData:function(offset,count){this.replaceData(offset,count,"")},replaceData:function(offset,count,text){var start=this.data.substring(0,offset),end=this.data.substring(offset+count);text=start+text+end,this.nodeValue=this.data=text,this.length=text.length}},_extends(CharacterData,Node),Text.prototype={nodeName:"#text",nodeType:TEXT_NODE,splitText:function(offset){var text=this.data,newText=text.substring(offset);text=text.substring(0,offset),this.data=this.nodeValue=text,this.length=text.length;var newNode=this.ownerDocument.createTextNode(newText);return this.parentNode&&this.parentNode.insertBefore(newNode,this.nextSibling),newNode}},_extends(Text,CharacterData),Comment.prototype={nodeName:"#comment",nodeType:COMMENT_NODE},_extends(Comment,CharacterData),CDATASection.prototype={nodeName:"#cdata-section",nodeType:CDATA_SECTION_NODE},_extends(CDATASection,CharacterData),DocumentType.prototype.nodeType=DOCUMENT_TYPE_NODE,_extends(DocumentType,Node),Notation.prototype.nodeType=NOTATION_NODE,_extends(Notation,Node),Entity.prototype.nodeType=ENTITY_NODE,_extends(Entity,Node),EntityReference.prototype.nodeType=ENTITY_REFERENCE_NODE,_extends(EntityReference,Node),DocumentFragment.prototype.nodeName="#document-fragment",DocumentFragment.prototype.nodeType=DOCUMENT_FRAGMENT_NODE,_extends(DocumentFragment,Node),ProcessingInstruction.prototype.nodeType=PROCESSING_INSTRUCTION_NODE,_extends(ProcessingInstruction,Node),XMLSerializer.prototype.serializeToString=function(node,isHtml,nodeFilter){return nodeSerializeToString.call(node,isHtml,nodeFilter)},Node.prototype.toString=nodeSerializeToString;try{Object.defineProperty&&(Object.defineProperty(LiveNodeList.prototype,"length",{get:function(){return _updateLiveList(this),this.$$length}}),Object.defineProperty(Node.prototype,"textContent",{get:function(){return getTextContent(this)},set:function(data){switch(this.nodeType){case ELEMENT_NODE:case DOCUMENT_FRAGMENT_NODE:for(;this.firstChild;)this.removeChild(this.firstChild);(data||String(data))&&this.appendChild(this.ownerDocument.createTextNode(data));break;default:this.data=data,this.value=data,this.nodeValue=data}}}),__set__=function(object,key,value){object["$$"+key]=value})}catch(e){}exports.DOMImplementation=DOMImplementation,exports.XMLSerializer=XMLSerializer},{}],221:[function(require,module,exports){function XMLReader(){}function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){function fixedFromCharCode(code){if(code>65535){code-=65536;var surrogate1=55296+(code>>10),surrogate2=56320+(1023&code);return String.fromCharCode(surrogate1,surrogate2)}return String.fromCharCode(code)}function entityReplacer(a){var k=a.slice(1,-1);return k in entityMap?entityMap[k]:"#"===k.charAt(0)?fixedFromCharCode(parseInt(k.substr(1).replace("x","0x"))):(errorHandler.error("entity not found:"+a),a)}function appendText(end){if(end>start){var xt=source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);locator&&position(start),domBuilder.characters(xt,0,end-start),start=end}}function position(p,m){for(;p>=lineEnd&&(m=linePattern.exec(source));)lineStart=m.index,lineEnd=lineStart+m[0].length,locator.lineNumber++;locator.columnNumber=p-lineStart+1}for(var lineStart=0,lineEnd=0,linePattern=/.*(?:\r\n?|\n)|.*$/g,locator=domBuilder.locator,parseStack=[{currentNSMap:defaultNSMapCopy}],closeMap={},start=0;;){try{var tagStart=source.indexOf("<",start);if(0>tagStart){if(!source.substr(start).match(/^\s*$/)){var doc=domBuilder.doc,text=doc.createTextNode(source.substr(start));doc.appendChild(text),domBuilder.currentElement=text}return}switch(tagStart>start&&appendText(tagStart),source.charAt(tagStart+1)){case"/":var end=source.indexOf(">",tagStart+3),tagName=source.substring(tagStart+2,end),config=parseStack.pop();0>end?(tagName=source.substring(tagStart+2).replace(/[\s<].*/,""),errorHandler.error("end tag name: "+tagName+" is not complete:"+config.tagName),end=tagStart+1+tagName.length):tagName.match(/\s</)&&(tagName=tagName.replace(/[\s<].*/,""),errorHandler.error("end tag name: "+tagName+" maybe not complete"),end=tagStart+1+tagName.length);var localNSMap=config.localNSMap,endMatch=config.tagName==tagName,endIgnoreCaseMach=endMatch||config.tagName&&config.tagName.toLowerCase()==tagName.toLowerCase();if(endIgnoreCaseMach){if(domBuilder.endElement(config.uri,config.localName,tagName),localNSMap)for(var prefix in localNSMap)domBuilder.endPrefixMapping(prefix);endMatch||errorHandler.fatalError("end tag name: "+tagName+" is not match the current start tagName:"+config.tagName)}else parseStack.push(config);end++;break;case"?":locator&&position(tagStart),end=parseInstruction(source,tagStart,domBuilder);break;case"!":locator&&position(tagStart),end=parseDCC(source,tagStart,domBuilder,errorHandler);break;default:locator&&position(tagStart);var el=new ElementAttributes,currentNSMap=parseStack[parseStack.length-1].currentNSMap,end=parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler),len=el.length;if(!el.closed&&fixSelfClosed(source,end,el.tagName,closeMap)&&(el.closed=!0,entityMap.nbsp||errorHandler.warning("unclosed xml attribute")),locator&&len){for(var locator2=copyLocator(locator,{}),i=0;len>i;i++){var a=el[i];position(a.offset),a.locator=copyLocator(locator,{})}domBuilder.locator=locator2,appendElement(el,domBuilder,currentNSMap)&&parseStack.push(el),domBuilder.locator=locator}else appendElement(el,domBuilder,currentNSMap)&&parseStack.push(el);"http://www.w3.org/1999/xhtml"!==el.uri||el.closed?end++:end=parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)}}catch(e){errorHandler.error("element parse error: "+e),end=-1}end>start?start=end:appendText(Math.max(tagStart,start)+1)}}function copyLocator(f,t){return t.lineNumber=f.lineNumber,t.columnNumber=f.columnNumber,t}function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){for(var attrName,value,p=++start,s=S_TAG;;){var c=source.charAt(p);switch(c){case"=":if(s===S_ATTR)attrName=source.slice(start,p),s=S_EQ;else{if(s!==S_ATTR_SPACE)throw new Error("attribute equal must after attrName");s=S_EQ}break;case"'":case'"':if(s===S_EQ||s===S_ATTR){if(s===S_ATTR&&(errorHandler.warning('attribute value must after "="'),attrName=source.slice(start,p)),start=p+1,p=source.indexOf(c,start),!(p>0))throw new Error("attribute value no end '"+c+"' match");value=source.slice(start,p).replace(/&#?\w+;/g,entityReplacer),el.add(attrName,value,start-1),s=S_ATTR_END}else{if(s!=S_ATTR_NOQUOT_VALUE)throw new Error('attribute value must after "="');value=source.slice(start,p).replace(/&#?\w+;/g,entityReplacer),el.add(attrName,value,start),errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+")!!"),start=p+1,s=S_ATTR_END}break;case"/":switch(s){case S_TAG:el.setTagName(source.slice(start,p));case S_ATTR_END:case S_TAG_SPACE:case S_TAG_CLOSE:s=S_TAG_CLOSE,el.closed=!0;case S_ATTR_NOQUOT_VALUE:case S_ATTR:case S_ATTR_SPACE:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return errorHandler.error("unexpected end of input"),s==S_TAG&&el.setTagName(source.slice(start,p)),p;case">":switch(s){case S_TAG:el.setTagName(source.slice(start,p));case S_ATTR_END:case S_TAG_SPACE:case S_TAG_CLOSE:break;case S_ATTR_NOQUOT_VALUE:case S_ATTR:value=source.slice(start,p),"/"===value.slice(-1)&&(el.closed=!0,value=value.slice(0,-1));case S_ATTR_SPACE:s===S_ATTR_SPACE&&(value=attrName),s==S_ATTR_NOQUOT_VALUE?(errorHandler.warning('attribute "'+value+'" missed quot(")!!'),el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start)):("http://www.w3.org/1999/xhtml"===currentNSMap[""]&&value.match(/^(?:disabled|checked|selected)$/i)||errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!'),el.add(value,value,start));break;case S_EQ:throw new Error("attribute value missed!!")}return p;case"":c=" ";default:if(" ">=c)switch(s){case S_TAG:el.setTagName(source.slice(start,p)),s=S_TAG_SPACE;break;case S_ATTR:attrName=source.slice(start,p),s=S_ATTR_SPACE;break;case S_ATTR_NOQUOT_VALUE:var value=source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);errorHandler.warning('attribute "'+value+'" missed quot(")!!'),el.add(attrName,value,start);case S_ATTR_END:s=S_TAG_SPACE}else switch(s){case S_ATTR_SPACE:{el.tagName}"http://www.w3.org/1999/xhtml"===currentNSMap[""]&&attrName.match(/^(?:disabled|checked|selected)$/i)||errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!'),el.add(attrName,attrName,start),start=p,s=S_ATTR;break;case S_ATTR_END:errorHandler.warning('attribute space is required"'+attrName+'"!!');case S_TAG_SPACE:s=S_ATTR,start=p;break;case S_EQ:s=S_ATTR_NOQUOT_VALUE,start=p;break;case S_TAG_CLOSE:throw new Error("elements closed character '/' and '>' must be connected to")}}p++}}function appendElement(el,domBuilder,currentNSMap){for(var tagName=el.tagName,localNSMap=null,i=el.length;i--;){var a=el[i],qName=a.qName,value=a.value,nsp=qName.indexOf(":");if(nsp>0)var prefix=a.prefix=qName.slice(0,nsp),localName=qName.slice(nsp+1),nsPrefix="xmlns"===prefix&&localName;else localName=qName,prefix=null,nsPrefix="xmlns"===qName&&"";a.localName=localName,nsPrefix!==!1&&(null==localNSMap&&(localNSMap={},_copy(currentNSMap,currentNSMap={})),currentNSMap[nsPrefix]=localNSMap[nsPrefix]=value,a.uri="http://www.w3.org/2000/xmlns/",domBuilder.startPrefixMapping(nsPrefix,value))}for(var i=el.length;i--;){a=el[i];var prefix=a.prefix;prefix&&("xml"===prefix&&(a.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==prefix&&(a.uri=currentNSMap[prefix||""]))}var nsp=tagName.indexOf(":");nsp>0?(prefix=el.prefix=tagName.slice(0,nsp),localName=el.localName=tagName.slice(nsp+1)):(prefix=null,localName=el.localName=tagName);var ns=el.uri=currentNSMap[prefix||""];if(domBuilder.startElement(ns,localName,tagName,el),!el.closed)return el.currentNSMap=currentNSMap,el.localNSMap=localNSMap,!0;if(domBuilder.endElement(ns,localName,tagName),localNSMap)for(prefix in localNSMap)domBuilder.endPrefixMapping(prefix)}function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){if(/^(?:script|textarea)$/i.test(tagName)){var elEndStart=source.indexOf("</"+tagName+">",elStartEnd),text=source.substring(elStartEnd+1,elEndStart);if(/[&<]/.test(text))return/^script$/i.test(tagName)?(domBuilder.characters(text,0,text.length),elEndStart):(text=text.replace(/&#?\w+;/g,entityReplacer),domBuilder.characters(text,0,text.length),elEndStart)}return elStartEnd+1}function fixSelfClosed(source,elStartEnd,tagName,closeMap){var pos=closeMap[tagName];return null==pos&&(pos=source.lastIndexOf("</"+tagName+">"),elStartEnd>pos&&(pos=source.lastIndexOf("</"+tagName)),closeMap[tagName]=pos),elStartEnd>pos}function _copy(source,target){for(var n in source)target[n]=source[n]}function parseDCC(source,start,domBuilder,errorHandler){var next=source.charAt(start+2);switch(next){case"-":if("-"===source.charAt(start+3)){var end=source.indexOf("-->",start+4);return end>start?(domBuilder.comment(source,start+4,end-start-4),end+3):(errorHandler.error("Unclosed comment"),-1)}return-1;default:if("CDATA["==source.substr(start+3,6)){var end=source.indexOf("]]>",start+9);return domBuilder.startCDATA(),domBuilder.characters(source,start+9,end-start-9),domBuilder.endCDATA(),end+3}var matchs=split(source,start),len=matchs.length;if(len>1&&/!doctype/i.test(matchs[0][0])){var name=matchs[1][0],pubid=len>3&&/^public$/i.test(matchs[2][0])&&matchs[3][0],sysid=len>4&&matchs[4][0],lastMatch=matchs[len-1];return domBuilder.startDTD(name,pubid&&pubid.replace(/^(['"])(.*?)\1$/,"$2"),sysid&&sysid.replace(/^(['"])(.*?)\1$/,"$2")),domBuilder.endDTD(),lastMatch.index+lastMatch[0].length}}return-1}function parseInstruction(source,start,domBuilder){var end=source.indexOf("?>",start);if(end){var match=source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(match){{match[0].length}return domBuilder.processingInstruction(match[1],match[2]),end+2}return-1}return-1}function ElementAttributes(){}function _set_proto_(thiz,parent){return thiz.__proto__=parent,thiz}function split(source,start){var match,buf=[],reg=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;for(reg.lastIndex=start,reg.exec(source);match=reg.exec(source);)if(buf.push(match),match[1])return buf}var nameStartChar=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,nameChar=new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),tagNamePattern=new RegExp("^"+nameStartChar.source+nameChar.source+"*(?::"+nameStartChar.source+nameChar.source+"*)?$"),S_TAG=0,S_ATTR=1,S_ATTR_SPACE=2,S_EQ=3,S_ATTR_NOQUOT_VALUE=4,S_ATTR_END=5,S_TAG_SPACE=6,S_TAG_CLOSE=7;XMLReader.prototype={parse:function(source,defaultNSMap,entityMap){var domBuilder=this.domBuilder;domBuilder.startDocument(),_copy(defaultNSMap,defaultNSMap={}),parse(source,defaultNSMap,entityMap,domBuilder,this.errorHandler),domBuilder.endDocument()}},ElementAttributes.prototype={setTagName:function(tagName){if(!tagNamePattern.test(tagName))throw new Error("invalid tagName:"+tagName);this.tagName=tagName},add:function(qName,value,offset){if(!tagNamePattern.test(qName))throw new Error("invalid attribute:"+qName);this[this.length++]={qName:qName,value:value,offset:offset}},length:0,getLocalName:function(i){return this[i].localName},getLocator:function(i){return this[i].locator},getQName:function(i){return this[i].qName},getURI:function(i){return this[i].uri},getValue:function(i){return this[i].value}},_set_proto_({},_set_proto_.prototype)instanceof _set_proto_||(_set_proto_=function(thiz,parent){function p(){}p.prototype=parent,p=new p;for(parent in thiz)p[parent]=thiz[parent];return p}),exports.XMLReader=XMLReader},{}]},{},[152])(152)});