UNPKG

prismic.io

Version:

JavaScript development kit for prismic.io

6 lines 168 kB
!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){(function(global){"use strict";function Api(url,options){var opts=options||{};return this.accessToken=opts.accessToken,this.url=url+(this.accessToken?(url.indexOf("?")>-1?"&":"?")+"access_token="+this.accessToken:""),this.req=opts.req,this.apiCache=opts.apiCache||globalCache(),this.requestHandler=opts.requestHandler||Requests.request,this.apiCacheKey=this.url+(this.accessToken?"#"+this.accessToken:""),this.apiDataTTL=opts.apiDataTTL||5,this}function Form(name,fields,form_method,rel,enctype,action){this.name=name,this.fields=fields,this.form_method=form_method,this.rel=rel,this.enctype=enctype,this.action=action}function SearchForm(api,form,data){this.api=api,this.form=form,this.data=data||{};for(var field in form.fields)form.fields[field].default&&(this.data[field]=[form.fields[field].default])}function Response(page,results_per_page,results_size,total_results_size,total_pages,next_page,prev_page,results){this.page=page,this.results_per_page=results_per_page,this.results_size=results_size,this.total_results_size=total_results_size,this.total_pages=total_pages,this.next_page=next_page,this.prev_page=prev_page,this.results=results}function Ref(ref,label,isMaster,scheduledAt,id){this.ref=ref,this.label=label,this.isMaster=isMaster,this.scheduledAt=scheduledAt,this.id=id}function globalCache(){var g;return g="object"==("undefined"==typeof global?"undefined":_typeof(global))?global:window,g.prismicCache||(g.prismicCache=new ApiCache),g.prismicCache}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},Requests=require("./requests"),Cookies=require("./cookies"),documents=require("./documents"),ApiCache=require("./cache"),Predicates=require("./predicates"),experiments=require("./experiments"),Experiments=experiments.Experiments,Document=documents.Document,experimentCookie="io.prismic.experiment",previewCookie="io.prismic.preview";Api.prototype={AT:"at",ANY:"any",SIMILAR:"similar",FULLTEXT:"fulltext",NUMBER:{GT:"number.gt",LT:"number.lt"},DATE:{AFTER:"date.after",BEFORE:"date.before",BETWEEN:"date.between"},DOCUMENT:{ID:"document.id",TYPE:"document.type",TAGS:"document.tags"},data:null,get:function(callback){var self=this,cacheKey=this.apiCacheKey;return new Promise(function(resolve,reject){var cb=function(err,value,xhr,ttl){callback&&callback(err,value,xhr,ttl),value&&resolve(value),err&&reject(err)};self.apiCache.get(cacheKey,function(err,value){return err||value?void cb(err,value):void self.requestHandler(self.url,function(err,data,xhr,ttl){if(err)return void cb(err,null,xhr,ttl);var parsed=self.parse(data);ttl=ttl||self.apiDataTTL,self.apiCache.set(cacheKey,parsed,ttl,function(err){cb(err,parsed,xhr,ttl)})})})})},refresh:function(callback){var self=this,cacheKey=this.apiCacheKey;return new Promise(function(resolve,reject){var cb=function(err,value,xhr){callback&&callback(err,value,xhr),value&&resolve(value),err&&reject(err)};self.apiCache.remove(cacheKey,function(err){return err?void cb(err):void self.get(function(err,data){return err?void cb(err):(self.data=data,self.bookmarks=data.bookmarks,self.experiments=new Experiments(data.experiments),void cb())})})})},parse:function(data){var refs,master,form,types,tags,f,i,forms={};for(i in data.forms)data.forms.hasOwnProperty(i)&&(f=data.forms[i],this.accessToken&&(f.fields.access_token={},f.fields.access_token.type="string",f.fields.access_token.default=this.accessToken),form=new Form(f.name,f.fields,f.form_method,f.rel,f.enctype,f.action),forms[i]=form);if(refs=data.refs.map(function(r){return new Ref(r.ref,r.label,r.isMasterRef,r.scheduledAt,r.id)})||[],master=refs.filter(function(r){return r.isMaster===!0}),types=data.types,tags=data.tags,0===master.length)throw"No master ref.";return{bookmarks:data.bookmarks||{},refs:refs,forms:forms,master:master[0],types:types,tags:tags,experiments:data.experiments,oauthInitiate:data.oauth_initiate,oauthToken:data.oauth_token}},forms:function(formId){return this.form(formId)},form:function form(formId){var form=this.data.forms[formId];return form?new SearchForm(this,form,{}):null},master:function(){return this.data.master.ref},ref:function(label){for(var i=0;i<this.data.refs.length;i++)if(this.data.refs[i].label==label)return this.data.refs[i].ref;return null},currentExperiment:function(){return this.experiments.current()},query:function(q,options,callback){var opts=options||{},form=this.form("everything");for(var key in opts)form=form.set(key,options[key]);if(!opts.ref){var cookieString="";this.req?cookieString=this.req.headers.cookie||"":"undefined"!=typeof window&&(cookieString=window.document.cookie||"");var cookies=Cookies.parse(cookieString),previewRef=cookies[previewCookie],experimentRef=cookies[experimentCookie];form=form.ref(previewRef||experimentRef||this.master())}return form.query(q).submit(callback)},getByID:function(id,options,callback){return this.query(Predicates.at("document.id",id),options,function(err,response){if(callback){var result=response.results.length>0?response.results[0]:null;callback(err,result)}}).then(function(response){return response&&response.results&&response.results[0]})},getByIDs:function(ids,options,callback){return this.query(["in","document.id",ids],options,callback)},getByUID:function(type,uid,options,callback){"function"==typeof options&&(callback=options,options={});var self=this;return new Promise(function(resolve,reject){var cb=function(err,value,xhr){callback&&callback(err,value,xhr),err?reject(err):resolve(value)};self.query(Predicates.at("my."+type+".uid",uid),options,function(err,response){var result=response&&response.results&&response.results.length>0?response.results[0]:null;cb(err,result)})})},getSingle:function(type,options,callback){"function"==typeof options&&(callback=options,options={});var self=this;return new Promise(function(resolve,reject){var cb=function(err,value,xhr){callback&&callback(err,value,xhr),err?reject(err):resolve(value)};self.query(Predicates.at("document.type",type),options,function(err,response){var result=response&&response.results&&response.results.length>0?response.results[0]:null;cb(err,result)})})},getBookmark:function(bookmark,options,callback){return new Promise(function(resolve,reject){var id=this.bookmarks[bookmark];if(id)resolve(id);else{var err=new Error("Error retrieving bookmarked id");callback&&callback(err),reject(err)}}).then(function(id){return this.getByID(id,options,callback)})},previewSession:function(token,linkResolver,defaultUrl,callback){var api=this;return new Promise(function(resolve,reject){var cb=function(err,value,xhr){callback&&callback(err,value,xhr),err?reject(err):resolve(value)};api.requestHandler(token,function(err,result,xhr){if(err)return void cb(err,defaultUrl,xhr);try{var mainDocumentId=result.mainDocument;mainDocumentId?api.form("everything").query(Predicates.at("document.id",mainDocumentId)).ref(token).submit(function(err,response){err&&cb(err);try{0===response.results.length?cb(null,defaultUrl,xhr):cb(null,linkResolver(response.results[0]),xhr)}catch(e){cb(e)}}):cb(null,defaultUrl,xhr)}catch(e){cb(e,defaultUrl,xhr)}})})},request:function(url,callback){var api=this,cacheKey=url+(this.accessToken?"#"+this.accessToken:""),cache=this.apiCache;cache.get(cacheKey,function(err,value){return err||value?void callback(err,api.response(value)):void api.requestHandler(url,function(err,documents,xhr,ttl){return err?void callback(err,null,xhr):void(ttl?cache.set(cacheKey,documents,ttl,function(err){callback(err,api.response(documents))}):callback(null,api.response(documents)))})})},response:function(documents){var results=documents.results.map(parseDoc);return new Response(documents.page,documents.results_per_page,documents.results_size,documents.total_results_size,documents.total_pages,documents.next_page,documents.prev_page,results||[])}},Form.prototype={};var parseDoc=function(json){var fragments={};for(var field in json.data[json.type])fragments[json.type+"."+field]=json.data[json.type][field];var slugs=[];if(void 0!==json.slugs)for(var i=0;i<json.slugs.length;i++)slugs.push(decodeURIComponent(json.slugs[i]));return new Document(json.id,json.uid||null,json.type,json.href,json.tags,slugs,json.first_publication_date,json.last_publication_date,fragments)};SearchForm.prototype={set:function(field,value){var fieldDesc=this.form.fields[field];if(!fieldDesc)throw new Error("Unknown field "+field);var values=this.data[field]||[];return""!==value&&void 0!==value||(value=null),fieldDesc.multiple?value&&values.push(value):values=value&&[value],this.data[field]=values,this},ref:function(_ref){return this.set("ref",_ref)},query:function(_query){if("string"==typeof _query)return this.set("q",_query);var predicates;predicates=_query.constructor===Array&&_query.length>0&&_query[0].constructor===Array?_query:[].slice.apply(arguments);var stringQueries=[];return predicates.forEach(function(predicate){stringQueries.push(Predicates.toQuery(predicate))}),this.query("["+stringQueries.join("")+"]")},pageSize:function(size){return this.set("pageSize",size)},fetch:function(fields){return fields instanceof Array&&(fields=fields.join(",")),this.set("fetch",fields)},fetchLinks:function(fields){return fields instanceof Array&&(fields=fields.join(",")),this.set("fetchLinks",fields)},page:function(p){return this.set("page",p)},orderings:function(_orderings){return"string"==typeof _orderings?this.set("orderings",_orderings):_orderings?this.set("orderings","["+_orderings.join(",")+"]"):this},submit:function(callback){var self=this,url=this.form.action;if(this.data){var sep=url.indexOf("?")>-1?"&":"?";for(var key in this.data)if(this.data.hasOwnProperty(key)){var values=this.data[key];if(values)for(var i=0;i<values.length;i++)url+=sep+key+"="+encodeURIComponent(values[i]),sep="&"}}return new Promise(function(resolve,reject){self.api.request(url,function(err,value,xhr){callback&&callback(err,value,xhr),err&&reject(err),value&&resolve(value)})})}},Ref.prototype={},module.exports={experimentCookie:experimentCookie,previewCookie:previewCookie,Api:Api,Form:Form,SearchForm:SearchForm,Ref:Ref,parseDoc:parseDoc}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./cache":3,"./cookies":4,"./documents":5,"./experiments":6,"./predicates":9,"./requests":11}],2:[function(require,module,exports){"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj};require("es6-promise").polyfill(),"function"!=typeof Object.create&&(Object.create=function(){var Object=function(){};return function(prototype){if(arguments.length>1)throw Error("Second argument not supported");if("object"!=("undefined"==typeof prototype?"undefined":_typeof(prototype)))throw TypeError("Argument must be an object");Object.prototype=prototype;var result={};return Object.prototype=null,result}}()),window.Prismic=require("./prismic")},{"./prismic":10,"es6-promise":48}],3:[function(require,module,exports){"use strict";function ApiCache(limit){this.lru=new LRUCache(limit)}var LRUCache=require("./lru");ApiCache.prototype={get:function(key,cb){var maybeEntry=this.lru.get(key);return maybeEntry&&!this.isExpired(key)?cb(null,maybeEntry.data):cb()},set:function(key,value,ttl,cb){return this.lru.remove(key),this.lru.put(key,{data:value,expiredIn:ttl?Date.now()+1e3*ttl:0}),cb()},isExpired:function(key){var entry=this.lru.get(key);return!!entry&&(0!==entry.expiredIn&&entry.expiredIn<Date.now())},remove:function(key,cb){return this.lru.remove(key),cb()},clear:function(cb){return this.lru.removeAll(),cb()}},module.exports=ApiCache},{"./lru":8}],4:[function(require,module,exports){"use strict";function tryDecode(str,decode){try{return decode(str)}catch(e){return str}}function parse(str,options){if("string"!=typeof str)throw new TypeError("argument str must be a string");var obj={},opt=options||{},pairs=str.split(/; */),dec=opt.decode||decode;return pairs.forEach(function(pair){var eq_idx=pair.indexOf("=");if(!(eq_idx<0)){var key=pair.substr(0,eq_idx).trim(),val=pair.substr(++eq_idx,pair.length).trim();'"'==val[0]&&(val=val.slice(1,-1)),void 0==obj[key]&&(obj[key]=tryDecode(val,dec))}}),obj}var decode=decodeURIComponent;module.exports={parse:parse}},{}],5:[function(require,module,exports){"use strict";function WithFragments(){}function Document(id,uid,type,href,tags,slugs,firstPublicationDate,lastPublicationDate,data){this.id=id,this.uid=uid,this.type=type,this.href=href,this.tags=tags,this.slug=slugs?slugs[0]:"-",this.slugs=slugs,this.data=data,this.firstPublicationDate=firstPublicationDate?new Date(firstPublicationDate):null,this.lastPublicationDate=lastPublicationDate?new Date(lastPublicationDate):null,this.fragments=require("./fragments").parseFragments(data)}function GroupDoc(data){this.data=data,this.fragments=require("./fragments").parseFragments(data)}function isFunction(f){var getType={};return f&&"[object Function]"===getType.toString.call(f)}WithFragments.prototype={get:function(name){var frags=this._getFragments(name);return frags.length?frags[0]:null},getAll:function(name){return this._getFragments(name)},getImage:function(fragment){var Fragments=require("./fragments"),img=this.get(fragment);return img instanceof Fragments.Image?img:img instanceof Fragments.StructuredText?img:null},getAllImages:function(fragment){var Fragments=require("./fragments"),images=this.getAll(fragment);return images.map(function(image){if(image instanceof Fragments.Image)return image;if(image instanceof Fragments.StructuredText)throw new Error("Not done.");return null})},getFirstImage:function(){var Fragments=require("./fragments"),fragments=this.fragments,firstImage=Object.keys(fragments).reduce(function(image,key){if(image)return image;var element=fragments[key];return"function"==typeof element.getFirstImage?element.getFirstImage():element instanceof Fragments.Image?element:null},null);return firstImage},getFirstTitle:function(){var Fragments=require("./fragments"),fragments=this.fragments,firstTitle=Object.keys(fragments).reduce(function(st,key){if(st)return st;var element=fragments[key];return"function"==typeof element.getFirstTitle?element.getFirstTitle():element instanceof Fragments.StructuredText?element.getTitle():null},null);return firstTitle},getFirstParagraph:function(){var fragments=this.fragments,firstParagraph=Object.keys(fragments).reduce(function(st,key){if(st)return st;var element=fragments[key];return"function"==typeof element.getFirstParagraph?element.getFirstParagraph():null},null);return firstParagraph},getImageView:function(name,view){var Fragments=require("./fragments"),fragment=this.get(name);if(fragment instanceof Fragments.Image)return fragment.getView(view);if(fragment instanceof Fragments.StructuredText)for(var i=0;i<fragment.blocks.length;i++)if("image"==fragment.blocks[i].type)return fragment.blocks[i];return null},getAllImageViews:function(name,view){return this.getAllImages(name).map(function(image){return image.getView(view)})},getTimestamp:function(name){var Fragments=require("./fragments"),fragment=this.get(name);return fragment instanceof Fragments.Timestamp?fragment.value:null},getDate:function(name){var Fragments=require("./fragments"),fragment=this.get(name);return fragment instanceof Fragments.Date?fragment.value:null},getBoolean:function(name){var fragment=this.get(name);return fragment.value&&("yes"==fragment.value.toLowerCase()||"on"==fragment.value.toLowerCase()||"true"==fragment.value.toLowerCase())},getText:function(name,after){var Fragments=require("./fragments"),fragment=this.get(name);return fragment instanceof Fragments.StructuredText?fragment.blocks.map(function(block){return block.text?block.text+(after?after:""):""}).join("\n"):fragment instanceof Fragments.Text&&fragment.value?fragment.value+(after?after:""):fragment instanceof Fragments.Number&&fragment.value?fragment.value+(after?after:""):fragment instanceof Fragments.Select&&fragment.value?fragment.value+(after?after:""):fragment instanceof Fragments.Color&&fragment.value?fragment.value+(after?after:""):null},getStructuredText:function(name){var fragment=this.get(name);return fragment instanceof require("./fragments").StructuredText?fragment:null},getLink:function(name){var Fragments=require("./fragments"),fragment=this.get(name);return fragment instanceof Fragments.WebLink||fragment instanceof Fragments.DocumentLink||fragment instanceof Fragments.FileLink||fragment instanceof Fragments.ImageLink?fragment:null},getNumber:function(name){var Fragments=require("./fragments"),fragment=this.get(name);return fragment instanceof Fragments.Number?fragment.value:null},getColor:function(name){var Fragments=require("./fragments"),fragment=this.get(name);return fragment instanceof Fragments.Color?fragment.value:null},getGeoPoint:function(name){var Fragments=require("./fragments"),fragment=this.get(name);return fragment instanceof Fragments.GeoPoint?fragment:null},getGroup:function(name){var fragment=this.get(name);return fragment instanceof require("./fragments").Group?fragment:null},getHtml:function(name,linkResolver){if(!isFunction(linkResolver)){var ctx=linkResolver;linkResolver=function(doc,isBroken){return ctx.linkResolver(ctx,doc,isBroken)}}var fragment=this.get(name);return fragment&&fragment.asHtml?fragment.asHtml(linkResolver):null},asHtml:function(linkResolver){if(!isFunction(linkResolver)){var ctx=linkResolver;linkResolver=function(doc,isBroken){return ctx.linkResolver(ctx,doc,isBroken)}}var htmls=[];for(var field in this.fragments){var fragment=this.get(field);htmls.push(fragment&&fragment.asHtml?'<section data-field="'+field+'">'+fragment.asHtml(linkResolver)+"</section>":"")}return htmls.join("")},asText:function(linkResolver){if(!isFunction(linkResolver)){var ctx=linkResolver;linkResolver=function(doc,isBroken){return ctx.linkResolver(ctx,doc,isBroken)}}var texts=[];for(var field in this.fragments){var fragment=this.get(field);texts.push(fragment&&fragment.asText?fragment.asText(linkResolver):"")}return texts.join("")},linkedDocuments:function(){var i,j,link,result=[],Fragments=require("./fragments");for(var field in this.data){var fragment=this.get(field);if(fragment instanceof Fragments.DocumentLink&&result.push(fragment),fragment instanceof Fragments.StructuredText)for(i=0;i<fragment.blocks.length;i++){var block=fragment.blocks[i];"image"==block.type&&block.linkTo&&(link=Fragments.initField(block.linkTo),link instanceof Fragments.DocumentLink&&result.push(link));var spans=block.spans||[];for(j=0;j<spans.length;j++){var span=spans[j];"hyperlink"==span.type&&(link=Fragments.initField(span.data),link instanceof Fragments.DocumentLink&&result.push(link))}}if(fragment instanceof Fragments.Group)for(i=0;i<fragment.value.length;i++)result=result.concat(fragment.value[i].linkedDocuments());if(fragment instanceof Fragments.SliceZone)for(i=0;i<fragment.value.length;i++){var slice=fragment.value[i];slice.value instanceof Fragments.DocumentLink&&result.push(slice.value)}}return result},_getFragments:function(name){return this.fragments&&this.fragments[name]?Array.isArray(this.fragments[name])?this.fragments[name]:[this.fragments[name]]:[]}},Document.prototype=Object.create(WithFragments.prototype),Document.prototype.getSliceZone=function(name){var fragment=this.get(name);return fragment instanceof require("./fragments").SliceZone?fragment:null},GroupDoc.prototype=Object.create(WithFragments.prototype),module.exports={WithFragments:WithFragments,Document:Document,GroupDoc:GroupDoc}},{"./fragments":7}],6:[function(require,module,exports){"use strict";function Experiments(data){var drafts=[],running=[];data&&(data.drafts&&data.drafts.forEach(function(exp){drafts.push(new Experiment(exp))}),data.running&&data.running.forEach(function(exp){running.push(new Experiment(exp))})),this.drafts=drafts,this.running=running}function Experiment(data){this.data=data;var variations=[];data.variations&&data.variations.forEach(function(v){variations.push(new Variation(v))}),this.variations=variations}function Variation(data){this.data=data}Experiments.prototype.current=function(){return this.running.length>0?this.running[0]:null},Experiments.prototype.refFromCookie=function(cookie){if(!cookie||""===cookie.trim())return null;var splitted=cookie.trim().split(" ");if(splitted.length<2)return null;var expId=splitted[0],varIndex=parseInt(splitted[1],10),exp=this.running.filter(function(exp){return exp.googleId()==expId&&exp.variations.length>varIndex})[0];return exp?exp.variations[varIndex].ref():null},Experiment.prototype.id=function(){return this.data.id},Experiment.prototype.googleId=function(){return this.data.googleId},Experiment.prototype.name=function(){return this.data.name},Variation.prototype.id=function(){return this.data.id},Variation.prototype.ref=function(){return this.data.ref},Variation.prototype.label=function(){return this.data.label},module.exports={Experiments:Experiments,Variation:Variation}},{}],7:[function(require,module,exports){"use strict";function Text(data){this.value=data}function DocumentLink(data){this.value=data,this.document=data.document,this.id=data.document.id,this.uid=data.document.uid,this.tags=data.document.tags,this.slug=data.document.slug,this.type=data.document.type;var fragmentsData={};if(data.document.data)for(var field in data.document.data[data.document.type])fragmentsData[data.document.type+"."+field]=data.document.data[data.document.type][field];this.fragments=parseFragments(fragmentsData),this.isBroken=data.isBroken}function WebLink(data){this.value=data}function FileLink(data){this.value=data}function ImageLink(data){this.value=data}function Select(data){this.value=data}function Color(data){this.value=data}function GeoPoint(data){this.latitude=data.latitude,this.longitude=data.longitude}function Num(data){this.value=data}function DateFragment(data){this.value=new Date(data)}function Timestamp(data){var correctIso8601Date=24==data.length?data.substring(0,22)+":"+data.substring(22,24):data;this.value=new Date(correctIso8601Date)}function Embed(data){this.value=data}function ImageEl(main,views){this.main=main,this.url=main.url,this.views=views||{}}function ImageView(url,width,height,alt){this.url=url,this.width=width,this.height=height,this.alt=alt}function Separator(){}function Group(data){this.value=[];for(var i=0;i<data.length;i++)this.value.push(new GroupDoc(data[i]))}function StructuredText(blocks){this.blocks=blocks}function htmlEscape(input){return input&&input.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")}function insertSpans(text,spans,linkResolver,htmlSerializer){if(!spans||!spans.length)return htmlEscape(text);var tagsStart={},tagsEnd={};spans.forEach(function(span){tagsStart[span.start]||(tagsStart[span.start]=[]),tagsEnd[span.end]||(tagsEnd[span.end]=[]),tagsStart[span.start].push(span),tagsEnd[span.end].unshift(span)});for(var c,html="",stack=[],pos=0,len=text.length+1;pos<len;pos++)tagsEnd[pos]&&tagsEnd[pos].forEach(function(){var tag=stack.pop();if("undefined"!=typeof tag){var innerHtml=serialize(tag.span,tag.text,htmlSerializer);0===stack.length?html+=innerHtml:stack[stack.length-1].text+=innerHtml}}),tagsStart[pos]&&(tagsStart[pos].sort(function(a,b){return b.end-b.start-(a.end-a.start)}),tagsStart[pos].forEach(function(span){var url=null;if("hyperlink"==span.type){var fragment=initField(span.data);if(!fragment)return void(console&&console.error&&console.error("Impossible to convert span.data as a Fragment",span));url=fragment.url(linkResolver),span.url=url}var elt={span:span,text:""};stack.push(elt)})),pos<text.length&&(c=text[pos],0===stack.length?html+=htmlEscape(c):stack[stack.length-1].text+=htmlEscape(c));return html}function Slice(sliceType,label,value){this.sliceType=sliceType,this.label=label,this.value=value}function SliceZone(data){this.value=[];for(var i=0;i<data.length;i++){var sliceType=data[i].slice_type,fragment=initField(data[i].value),label=data[i].slice_label||null;sliceType&&fragment&&this.value.push(new Slice(sliceType,label,fragment))}this.slices=this.value}function initField(field){var classForType={Color:Color,Number:Num,Date:DateFragment,Timestamp:Timestamp,Text:Text,Embed:Embed,GeoPoint:GeoPoint,Select:Select,StructuredText:StructuredText,"Link.document":DocumentLink,"Link.web":WebLink,"Link.file":FileLink,"Link.image":ImageLink,Separator:Separator,Group:Group,SliceZone:SliceZone};if(classForType[field.type])return new classForType[field.type](field.value);if("Image"===field.type){var img=field.value.main,output=new ImageEl(new ImageView(img.url,img.dimensions.width,img.dimensions.height,img.alt),{});for(var name in field.value.views)img=field.value.views[name],output.views[name]=new ImageView(img.url,img.dimensions.width,img.dimensions.height,img.alt);return output}return console&&console.log&&console.log("Fragment type not supported: ",field.type),null}function parseFragments(json){var result={};for(var key in json)json.hasOwnProperty(key)&&(Array.isArray(json[key])?result[key]=json[key].map(function(fragment){return initField(fragment)}):result[key]=initField(json[key]));return result}function isFunction(f){var getType={};return f&&"[object Function]"===getType.toString.call(f)}function serialize(element,content,htmlSerializer){if(htmlSerializer){var custom=htmlSerializer(element,content);if(custom)return custom}var TAG_NAMES={heading1:"h1",heading2:"h2",heading3:"h3",heading4:"h4",heading5:"h5",heading6:"h6",paragraph:"p",preformatted:"pre","list-item":"li","o-list-item":"li","group-list-item":"ul","group-o-list-item":"ol",strong:"strong",em:"em"};if(TAG_NAMES[element.type]){var name=TAG_NAMES[element.type],classCode=element.label?' class="'+element.label+'"':"";return"<"+name+classCode+">"+content+"</"+name+">"}if("image"==element.type){var label=element.label?" "+element.label:"",imgTag='<img src="'+element.url+'" alt="'+(element.alt||"")+'">';return'<p class="block-img'+label+'">'+(element.linkUrl?'<a href="'+element.linkUrl+'">'+imgTag+"</a>":imgTag)+"</p>"}return"embed"==element.type?'<div data-oembed="'+element.embed_url+'" data-oembed-type="'+element.type+'" data-oembed-provider="'+element.provider_name+(element.label?'" class="'+element.label:"")+'">'+element.oembed.html+"</div>":"hyperlink"===element.type?'<a href="'+element.url+'">'+content+"</a>":"label"===element.type?'<span class="'+element.data.label+'">'+content+"</span>":"<!-- Warning: "+element.type+" not implemented. Upgrade the Developer Kit. -->"+content}var documents=require("./documents"),WithFragments=documents.WithFragments,GroupDoc=documents.GroupDoc;Text.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},DocumentLink.prototype=Object.create(WithFragments.prototype),DocumentLink.prototype.asHtml=function(ctx){return'<a href="'+this.url(ctx)+'">'+this.url(ctx)+"</a>"},DocumentLink.prototype.url=function(linkResolver){return linkResolver(this,this.isBroken)},DocumentLink.prototype.asText=function(linkResolver){return this.url(linkResolver)},WebLink.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.url()+"</a>"},url:function(){return this.value.url},asText:function(){return this.url()}},FileLink.prototype={asHtml:function(){return'<a href="'+this.url()+'">'+this.value.file.name+"</a>"},url:function(){return this.value.file.url},asText:function(){return this.url()}},ImageLink.prototype={asHtml:function(){return'<a href="'+this.url()+'"><img src="'+this.url()+'" alt="'+(this.alt||"")+'"></a>'},url:function(){return this.value.image.url},asText:function(){return this.url()}},Select.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},Color.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return this.value}},GeoPoint.prototype={asHtml:function(){return'<div class="geopoint"><span class="latitude">'+this.latitude+'</span><span class="longitude">'+this.longitude+"</span></div>"},asText:function(){return"("+this.latitude+","+this.longitude+")"}},Num.prototype={asHtml:function(){return"<span>"+this.value+"</span>"},asText:function(){return null===this.value?null:this.value.toString()}},DateFragment.prototype={asHtml:function(){return"<time>"+this.value+"</time>"},asText:function(){return null===this.value?null:this.value.toString()}},Timestamp.prototype={asHtml:function(){return"<time>"+this.value+"</time>"},asText:function(){return null===this.value?null:this.value.toString()}},Embed.prototype={asHtml:function(){return this.value.oembed.html},asText:function(){return""}},ImageEl.prototype={getView:function(name){return"main"===name?this.main:this.views[name]},asHtml:function(){return this.main.asHtml()},asText:function(){return""}},ImageView.prototype={ratio:function(){return this.width/this.height},asHtml:function(){return'<img src="'+this.url+'" width="'+this.width+'" height="'+this.height+'" alt="'+(this.alt||"")+'">'},asText:function(){return""}},Separator.prototype={asHtml:function(){return"<hr/>"},asText:function(){return"----"}},Group.prototype={asHtml:function(linkResolver){for(var output="",i=0;i<this.value.length;i++)output+=this.value[i].asHtml(linkResolver);return output},toArray:function(){return this.value},asText:function(linkResolver){for(var output="",i=0;i<this.value.length;i++)output+=this.value[i].asText(linkResolver)+"\n";return output},getFirstImage:function(){return this.toArray().reduce(function(image,fragment){return image?image:fragment.getFirstImage()},null)},getFirstTitle:function(){return this.toArray().reduce(function(st,fragment){return st?st:fragment.getFirstTitle()},null)},getFirstParagraph:function(){return this.toArray().reduce(function(st,fragment){return st?st:fragment.getFirstParagraph()},null)}},StructuredText.prototype={getTitle:function(){for(var i=0;i<this.blocks.length;i++){var block=this.blocks[i];if(0===block.type.indexOf("heading"))return block}return null},getFirstParagraph:function(){for(var i=0;i<this.blocks.length;i++){var block=this.blocks[i];if("paragraph"==block.type)return block}return null},getParagraphs:function(){for(var paragraphs=[],i=0;i<this.blocks.length;i++){var block=this.blocks[i];"paragraph"==block.type&&paragraphs.push(block)}return paragraphs},getParagraph:function(n){return this.getParagraphs()[n]},getFirstImage:function(){for(var i=0;i<this.blocks.length;i++){var block=this.blocks[i];if("image"==block.type)return new ImageView(block.url,block.dimensions.width,block.dimensions.height,block.alt)}return null},asHtml:function(linkResolver,htmlSerializer){var blockGroup,block,blockGroups=[],html=[];if(!isFunction(linkResolver)){var ctx=linkResolver;linkResolver=function(doc,isBroken){return ctx.linkResolver(ctx,doc,isBroken)}}if(Array.isArray(this.blocks)){for(var i=0;i<this.blocks.length;i++){if(block=this.blocks[i],"image"==block.type&&block.linkTo){var link=initField(block.linkTo);block.linkUrl=link.url(linkResolver)}"list-item"!==block.type&&"o-list-item"!==block.type?(blockGroups.push(block),blockGroup=null):blockGroup&&blockGroup.type=="group-"+block.type?blockGroup.blocks.push(block):(blockGroup={type:"group-"+block.type,blocks:[block]},blockGroups.push(blockGroup))}var blockContent=function blockContent(block){var content="";
return block.blocks?block.blocks.forEach(function(block2){content+=serialize(block2,blockContent(block2),htmlSerializer)}):content=insertSpans(block.text,block.spans,linkResolver,htmlSerializer),content};blockGroups.forEach(function(blockGroup){html.push(serialize(blockGroup,blockContent(blockGroup),htmlSerializer))})}return html.join("")},asText:function(){for(var output=[],i=0;i<this.blocks.length;i++){var block=this.blocks[i];block.text&&output.push(block.text)}return output.join(" ")}},Slice.prototype={asHtml:function(linkResolver){var classes=["slice"];return this.label&&classes.push(this.label),'<div data-slicetype="'+this.sliceType+'" class="'+classes.join(" ")+'">'+this.value.asHtml(linkResolver)+"</div>"},asText:function(linkResolver){return this.value.asText(linkResolver)},getFirstImage:function(){var fragment=this.value;return"function"==typeof fragment.getFirstImage?fragment.getFirstImage():fragment instanceof ImageEl?fragment:null},getFirstTitle:function(){var fragment=this.value;return"function"==typeof fragment.getFirstTitle?fragment.getFirstTitle():fragment instanceof StructuredText?fragment.getTitle():null},getFirstParagraph:function(){var fragment=this.value;return"function"==typeof fragment.getFirstParagraph?fragment.getFirstParagraph():null}},SliceZone.prototype={asHtml:function(linkResolver){for(var output="",i=0;i<this.value.length;i++)output+=this.value[i].asHtml(linkResolver);return output},asText:function(linkResolver){for(var output="",i=0;i<this.value.length;i++)output+=this.value[i].asText(linkResolver)+"\n";return output},getFirstImage:function(){return this.value.reduce(function(image,slice){return image?image:slice.getFirstImage()},null)},getFirstTitle:function(){return this.value.reduce(function(text,slice){return text?text:slice.getFirstTitle()},null)},getFirstParagraph:function(){return this.value.reduce(function(paragraph,slice){return paragraph?paragraph:slice.getFirstParagraph()},null)}},module.exports={Embed:Embed,Image:ImageEl,ImageView:ImageView,Text:Text,Number:Num,Date:DateFragment,Timestamp:Timestamp,Select:Select,Color:Color,StructuredText:StructuredText,WebLink:WebLink,DocumentLink:DocumentLink,ImageLink:ImageLink,FileLink:FileLink,Separator:Separator,Group:Group,GeoPoint:GeoPoint,Slice:Slice,SliceZone:SliceZone,initField:initField,parseFragments:parseFragments,insertSpans:insertSpans}},{"./documents":5}],8:[function(require,module,exports){"use strict";function LRUCache(limit){this.size=0,this.limit=limit,this._keymap={}}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj};LRUCache.prototype.put=function(key,value){var entry={key:key,value:value};return this._keymap[key]=entry,this.tail?(this.tail.newer=entry,entry.older=this.tail):this.head=entry,this.tail=entry,this.size===this.limit?this.shift():(this.size++,null)},LRUCache.prototype.shift=function(){var entry=this.head;return entry&&(this.head.newer?(this.head=this.head.newer,this.head.older=void 0):this.head=void 0,entry.newer=entry.older=void 0,delete this._keymap[entry.key]),entry},LRUCache.prototype.get=function(key,returnEntry){var entry=this._keymap[key];return void 0===entry?null:entry===this.tail?returnEntry?entry:entry.value:(entry.newer&&(entry===this.head&&(this.head=entry.newer),entry.newer.older=entry.older),entry.older&&(entry.older.newer=entry.newer),entry.newer=void 0,entry.older=this.tail,this.tail&&(this.tail.newer=entry),this.tail=entry,returnEntry?entry:entry.value)},LRUCache.prototype.find=function(key){return this._keymap[key]},LRUCache.prototype.set=function(key,value){var oldvalue,entry=this.get(key,!0);return entry?(oldvalue=entry.value,entry.value=value):(oldvalue=this.put(key,value),oldvalue&&(oldvalue=oldvalue.value)),oldvalue},LRUCache.prototype.remove=function(key){var entry=this._keymap[key];return entry?(delete this._keymap[entry.key],entry.newer&&entry.older?(entry.older.newer=entry.newer,entry.newer.older=entry.older):entry.newer?(entry.newer.older=void 0,this.head=entry.newer):entry.older?(entry.older.newer=void 0,this.tail=entry.older):this.head=this.tail=void 0,this.size--,entry.value):null},LRUCache.prototype.removeAll=function(){this.head=this.tail=void 0,this.size=0,this._keymap={}},"function"==typeof Object.keys?LRUCache.prototype.keys=function(){return Object.keys(this._keymap)}:LRUCache.prototype.keys=function(){var keys=[];for(var k in this._keymap)keys.push(k);return keys},LRUCache.prototype.forEach=function(fun,context,desc){var entry;if(context===!0?(desc=!0,context=void 0):"object"!==("undefined"==typeof context?"undefined":_typeof(context))&&(context=this),desc)for(entry=this.tail;entry;)fun.call(context,entry.key,entry.value,this),entry=entry.older;else for(entry=this.head;entry;)fun.call(context,entry.key,entry.value,this),entry=entry.newer},LRUCache.prototype.toJSON=function(){for(var s=[],entry=this.head;entry;)s.push({key:entry.key.toJSON(),value:entry.value.toJSON()}),entry=entry.newer;return s},LRUCache.prototype.toString=function(){for(var s="",entry=this.head;entry;)s+=String(entry.key)+":"+entry.value,entry=entry.newer,entry&&(s+=" < ");return s},module.exports=LRUCache},{}],9:[function(require,module,exports){"use strict";function clean(s){return s.replace(/"/g,"")}module.exports={toQuery:function(predicate){var pred=clean(predicate[0]),first=clean(predicate[1]),firstArg=0===first.indexOf("my.")||0===first.indexOf("document")?first:'"'+first+'"';return"[:d = "+pred+"("+firstArg+(predicate.length>2?", ":"")+function(){return predicate.slice(2).map(function(p){return"string"==typeof p?'"'+clean(p)+'"':Array.isArray(p)?"["+p.map(function(e){return'"'+clean(e)+'"'}).join(",")+"]":p instanceof Date?p.getTime():p}).join(",")}()+")]"},at:function(fragment,value){return["at",fragment,value]},not:function(fragment,value){return["not",fragment,value]},missing:function(fragment){return["missing",fragment]},has:function(fragment){return["has",fragment]},any:function(fragment,values){return["any",fragment,values]},in:function(fragment,values){return["in",fragment,values]},fulltext:function(fragment,value){return["fulltext",fragment,value]},similar:function(documentId,maxResults){return["similar",documentId,maxResults]},gt:function(fragment,value){return["number.gt",fragment,value]},lt:function(fragment,value){return["number.lt",fragment,value]},inRange:function(fragment,before,after){return["number.inRange",fragment,before,after]},dateBefore:function(fragment,before){return["date.before",fragment,before]},dateAfter:function(fragment,after){return["date.after",fragment,after]},dateBetween:function(fragment,before,after){return["date.between",fragment,before,after]},dayOfMonth:function(fragment,day){return["date.day-of-month",fragment,day]},dayOfMonthAfter:function(fragment,day){return["date.day-of-month-after",fragment,day]},dayOfMonthBefore:function(fragment,day){return["date.day-of-month-before",fragment,day]},dayOfWeek:function(fragment,day){return["date.day-of-week",fragment,day]},dayOfWeekAfter:function(fragment,day){return["date.day-of-week-after",fragment,day]},dayOfWeekBefore:function(fragment,day){return["date.day-of-week-before",fragment,day]},month:function(fragment,_month){return["date.month",fragment,_month]},monthBefore:function(fragment,month){return["date.month-before",fragment,month]},monthAfter:function(fragment,month){return["date.month-after",fragment,month]},year:function(fragment,_year){return["date.year",fragment,_year]},hour:function(fragment,_hour){return["date.hour",fragment,_hour]},hourBefore:function(fragment,hour){return["date.hour-before",fragment,hour]},hourAfter:function(fragment,hour){return["date.hour-after",fragment,hour]},near:function(fragment,latitude,longitude,radius){return["geopoint.near",fragment,latitude,longitude,radius]}}},{}],10:[function(require,module,exports){"use strict";function getApi(url,options){options=options||{},"function"==typeof arguments[1]?options={complete:arguments[1],accessToken:arguments[2],requestHandler:arguments[3],apiCache:arguments[4],apiDataTTL:arguments[5]}:"string"==typeof arguments[1]&&(options={accessToken:arguments[1],requestHandler:arguments[2],apiCache:arguments[3],apiDataTTL:arguments[4]});var api=new Api(url,options||{});return new Promise(function(resolve,reject){var cb=function(err,value,xhr){options.complete&&options.complete(err,value,xhr),err?reject(err):resolve(value)};return api.get(function(err,data){!err&&data&&(api.data=data,api.bookmarks=data.bookmarks,api.experiments=new Experiments(data.experiments)),cb(err,api)}),api})}var experiments=require("./experiments"),Predicates=require("./predicates"),api=require("./api"),Fragments=require("./fragments"),documents=require("./documents"),Api=api.Api,Experiments=experiments.Experiments;module.exports={experimentCookie:api.experimentCookie,previewCookie:api.previewCookie,Document:documents.Document,SearchForm:api.SearchForm,Form:api.Form,Experiments:Experiments,Predicates:Predicates,Fragments:Fragments,api:getApi,Api:getApi,parseDoc:api.parseDoc},module.exports.Prismic=module.exports},{"./api":1,"./documents":5,"./experiments":6,"./fragments":7,"./predicates":9}],11:[function(require,module,exports){(function(process){"use strict";var createError=function(status,message){var err=new Error(message);return err.status=status,err},ajaxRequest=function(){return"undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest?function(url,callback){var xhr=new XMLHttpRequest,resolve=function(){var ttl,cacheControl=/max-age\s*=\s*(\d+)/.exec(xhr.getResponseHeader("Cache-Control"));cacheControl&&cacheControl.length>1&&(ttl=parseInt(cacheControl[1],10)),callback(null,JSON.parse(xhr.responseText),xhr,ttl)},reject=function(){var status=xhr.status;callback(createError(status,"Unexpected status code ["+status+"] on URL "+url),null,xhr)};xhr.onreadystatechange=function(){4===xhr.readyState&&(xhr.status&&200==xhr.status?resolve():reject())},xhr.open("GET",url,!0),xhr.setRequestHeader("Accept","application/json"),xhr.send()}:null},xdomainRequest=function(){return"undefined"!=typeof XDomainRequest?function(url,callback){var xdr=new XDomainRequest,resolve=function(){callback(null,JSON.parse(xdr.responseText),xdr,0)},reject=function(msg){callback(new Error(msg),null,xdr)};xdr.onload=function(){resolve(xdr)},xdr.onerror=function(){reject("Unexpected status code on URL "+url)},xdr.open("GET",url,!0),xdr.ontimeout=function(){reject("Request timeout")},xdr.onprogress=function(){},xdr.send()}:null},fetchRequest=function(){if("function"==typeof fetch){var pjson=require("../package.json");return function(requestUrl,callback){fetch(requestUrl,{headers:{Accept:"application/json","User-Agent":"Prismic-javascript-kit/"+pjson.version+" NodeJS/"+process.version}}).then(function(response){if(~~(response.status/100!=2))throw new createError(response.status,"Unexpected status code ["+response.status+"] on URL "+requestUrl);return response.json().then(function(json){return{response:response,json:json}})}).then(function(next){var response=next.response,json=next.json,cacheControl=response.headers["cache-control"],ttl=cacheControl&&/max-age=(\d+)/.test(cacheControl)?parseInt(/max-age=(\d+)/.exec(cacheControl)[1],10):void 0;callback(null,json,response,ttl)}).catch(function(error){callback(error)})}}return null},nodeJSRequest=function(){if("function"==typeof require&&require("http")){var http=require("http"),https=require("https"),url=require("url"),pjson=require("../package.json");return function(requestUrl,callback){var parsed=url.parse(requestUrl),h="https:"==parsed.protocol?https:http,options={hostname:parsed.hostname,path:parsed.path,query:parsed.query,headers:{Accept:"application/json","User-Agent":"Prismic-javascript-kit/"+pjson.version+" NodeJS/"+process.version}};if(!requestUrl){var e=new Error("dummy"),stack=e.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@").split("\n");console.log(stack)}var request=h.get(options,function(response){if(response.statusCode&&200==response.statusCode){var jsonStr="";response.setEncoding("utf8"),response.on("data",function(chunk){jsonStr+=chunk}),response.on("end",function(){var json;try{json=JSON.parse(jsonStr)}catch(ex){console.log("Failed to parse json: "+jsonStr,ex)}var cacheControl=response.headers["cache-control"],ttl=cacheControl&&/max-age=(\d+)/.test(cacheControl)?parseInt(/max-age=(\d+)/.exec(cacheControl)[1],10):void 0;callback(null,json,response,ttl)})}else callback(createError(response.statusCode,"Unexpected status code ["+response.statusCode+"] on URL "+requestUrl),null,response)});request.on("error",function(err){callback(new Error("Unexpected error on URL "+requestUrl),null,err)})}}return null},MAX_CONNECTIONS=20,running=0,queue=[],processQueue=function processQueue(){if(!(0===queue.length||running>=MAX_CONNECTIONS)){running++;var next=queue.shift(),fn=ajaxRequest()||xdomainRequest()||fetchRequest()||nodeJSRequest()||function(){throw new Error("No request handler available (tried XMLHttpRequest, fetch & NodeJS)")}();fn.call(this,next.url,function(error,result,xhr,ttl){running--,next.callback(error,result,xhr,ttl),processQueue()})}},request=function(url,callback){queue.push({url:url,callback:callback}),processQueue()};module.exports={MAX_CONNECTIONS:MAX_CONNECTIONS,request:request}}).call(this,require("_process"))},{"../package.json":49,_process:21,http:38,https:18,url:45}],12:[function(require,module,exports){},{}],13:[function(require,module,exports){(function(global){"use strict";function typedArraySupport(){function Bar(){}try{var arr=new Uint8Array(1);return arr.foo=function(){return 42},arr.constructor=Bar,42===arr.foo()&&arr.constructor===Bar&&"function"==typeof arr.subarray&&0===arr.subarray(1,1).byteLength}catch(e){return!1}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Buffer(arg){return this instanceof Buffer?(Buffer.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof arg?fromNumber(this,arg):"string"==typeof arg?fromString(this,arg,arguments.length>1?arguments[1]:"utf8"):fromObject(this,arg)):arguments.length>1?new Buffer(arg,arguments[1]):new Buffer(arg)}function fromNumber(that,length){if(that=allocate(that,length<0?0:0|checked(length)),!Buffer.TYPED_ARRAY_SUPPORT)for(var i=0;i<length;i++)that[i]=0;return that}function fromString(that,string,encoding){"string"==typeof encoding&&""!==encoding||(encoding="utf8");var length=0|byteLength(string,encoding);return that=allocate(that,length),that.write(string,encoding),that}function fromObject(that,object){if(Buffer.isBuffer(object))return fromBuffer(that,object);if(isArray(object))return fromArray(that,object);if(null==object)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(object.buffer instanceof ArrayBuffer)return fromTypedArray(that,object);if(object instanceof ArrayBuffer)return fromArrayBuffer(that,object)}return object.length?fromArrayLike(that,object):fromJsonObject(that,object)}function fromBuffer(that,buffer){var length=0|checked(buffer.length);return that=allocate(that,length),buffer.copy(that,0,0,length),that}function fromArray(that,array){var length=0|checked(array.length);that=allocate(that,length);for(var i=0;i<length;i+=1)that[i]=255&array[i];return that}function fromTypedArray(that,array){var length=0|checked(array.length);that=allocate(that,length);for(var i=0;i<length;i+=1)that[i]=255&array[i];return that}function fromArrayBuffer(that,array){return Buffer.TYPED_ARRAY_SUPPORT?(array.byteLength,that=Buffer._augment(new Uint8Array(array))):that=fromTypedArray(that,new Uint8Array(array)),that}function fromArrayLike(that,array){var length=0|checked(array.length);that=allocate(that,length);for(var i=0;i<length;i+=1)that[i]=255&array[i];return that}function fromJsonObject(that,object){var array,length=0;"Buffer"===object.type&&isArray(object.data)&&(array=object.data,length=0|checked(array.length)),that=allocate(that,length);for(var i=0;i<length;i+=1)that[i]=255&array[i];return that}function allocate(that,length){Buffer.TYPED_ARRAY_SUPPORT?(that=Buffer._augment(new Uint8Array(length)),that.__proto__=Buffer.prototype):(that.length=length,that._isBuffer=!0);var fromPool=0!==length&&length<=Buffer.poolSize>>>1;return fromPool&&(that.parent=rootParent),that}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(subject,encoding){if(!(this instanceof SlowBuffer))return new SlowBuffer(subject,encoding);var buf=new Buffer(subject,encoding);return delete buf.parent,buf}function byteLength(string,encoding){"string"!=typeof string&&(string=""+string);var len=string.length;if(0===len)return 0;for(var loweredCase=!1;;)switch(encoding){case"ascii":case"binary":case"raw":case"raws":return len;case"utf8":case"utf-8":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(start=0|start,end=void 0===end||end===1/0?this.length:0|end,encoding||(encoding="utf8"),start<0&&(start=0),end>this.length&&(end=this.length),end<=start)return"";for(;;)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"binary":return binarySlice(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 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 Error("Invalid hex string");length>strLen/2&&(length=strLen/2);for(var i=0;i<length;i++){var parsed=parseInt(string.substr(2*i,2),16);if(isNaN(parsed))throw new Error("Invalid hex string");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 binaryWrite(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 0===start&&end===buf.length?base64.fromByteArray(buf):base64.fromByteArray(buf.slice(start,end))}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);for(var res=[],i=start;i<end;){var firstByte=buf[i],codePoint=null,bytesPerSequence=firstByte>239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:firstByte<128&&(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&&(tempCodePoint<55296||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&&tempCodePoint<1114112&&(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(len<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,codePoints);for(var res="",i=0;i<len;)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;i<end;i++)ret+=String.fromCharCode(127&buf[i]);return ret}function binarySlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++)ret+=String.fromCharCode(buf[i]);return ret}function hexSlice(buf,start,end){var len=buf.length;(!start||start<0)&&(start=0),(!end||end<0||end>len)&&(end=len);for(var out="",i=start;i<end;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||offset<0)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 must be a Buffer instance");if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range")}function objectWriteUInt16(buf,value,offset,littleEndian){value<0&&(value=65535+value+1);for(var i=0,j=Math.min(buf.length-offset,2);i<j;i++)buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>8*(littleEndian?i:1-i)}function objectWriteUInt32(buf,value,offset,littleEndian){value<0&&(value=4294967295+value+1);for(var i=0,j=Math.min(buf.length-offset,4);i<j;i++)buf[offset+i]=value>>>8*(littleEndian?i:3-i)&255}function checkIEEE754(buf,value,offset,ext,max,min){if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range");if(offset<0)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 n<16?"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;i<length;i++){if(codePoint=string.charCodeAt(i),codePoint>55295&&codePoint<57344){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(codePoint<56320){(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,codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,63&codePoint|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,63&codePoint|128)}else{if(!(codePoint<1114112))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;i<length&&!(i+offset>=dst.length||i>=src.length);i++)dst[i+offset]=src[i];return i}var base64=require("base64-js"),ieee754=require("ieee754"),isArray=require("isarray");exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50,Buffer.poolSize=8192;var rootParent={};Buffer.TYPED_ARRAY_SUPPORT=void 0!==global.TYPED_ARRAY_SUPPORT?global.TYPED_ARRAY_SUPPORT:typedArraySupport(),Buffer.TYPED_ARRAY_SUPPORT?(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array):(Buffer.prototype.length=void 0,Buffer.prototype.parent=void 0),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);i<len&&a[i]===b[i];)++i;return i!==len&&(x=a[i],y=b[i]),x<y?-1:y<x?1:0},Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":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 new Buffer(0);var i;if(void 0===length)for(length=0,i=0;i<list.length;i++)length+=list[i].length;var buf=new Buffer(length),pos=0;for(i=0;i<list.length;i++){var item=list[i];item.copy(buf,pos),pos+=item.length}return buf},Buffer.byteLength=byteLength,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===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(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b?0:Buffer.compare(this,b)},Buffer.prototype.indexOf=function(val,byteOffset){function arrayIndexOf(arr,val,byteOffset){for(var foundIndex=-1,i=0;byteOffset+i<arr.length;i++)if(arr[byteOffset+i]===val[foundIndex===-1?0:i-foundIndex]){if(foundIndex===-1&&(foundIndex=i),i-foundIndex+1===val.length)return byteOffset+foundIndex}else foundIndex=-1;return-1}if(byteOffset>2147483647?byteOffset=2147483647:byteOffset<-2147483648&&(byteOffset=-2147483648),byteOffset>>=0,0===this.length)return-1;if(byteOffset>=this.length)return-1;if(byteOffset<0&&(byteOffset=Math.max(this.length+byteOffset,0)),"string"==typeof val)return 0===val.length?-1:String.prototype.indexOf.call(this,val,byteOffset);if(Buffer.isBuffer(val))return arrayIndexOf(this,val,byteOffset);if("number"==typeof val)return Buffer.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,val,byteOffset):arrayIndexOf(this,[val],byteOffset);throw new TypeError("val must be string, number or Buffer")},Buffer.prototype.get=function(offset){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(offset)},Buffer.prototype.set=function(v,offset){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(v,offset)},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))offset=0|offset,isFinite(length)?(length=0|length,void 0===encoding&&(encoding="utf8")):(encoding=length,length=void 0);else{var swap=encoding;encoding=offset,offset=0|length,length=swap}var remaining=this.length-offset;if((void 0===length||length>remaining)&&(length=remaining),string.length>0&&(length<0||offset<0)||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"binary":return binaryWrite(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,start<0?(start+=len,start<0&&(start=0)):start>len&&(start=len),end<0?(end+=len,end<0&&(end=0)):end>len&&(end=len),end<start&&(end=start);var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT)newBuf=Buffer._augment(this.subarray(start,end));else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,void 0);for(var i=0;i<sliceLen;i++)newBuf[i]=this[i+start]}return newBuf.length&&(newBuf.parent=this.parent||this),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]?(255-this[offset]+1)*-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){value=+value,offset=0|offset,byteLength=0|byteLength,noAssert||checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),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){value=+value,offset=0|offset,byteLength=0|byteLength,noAssert||checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),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=value<0?1:0;for(this[offset]=255&value;++i<byteLength&&(mul*=256);)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=value<0?1:0;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)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)),value<0&&(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),value<0&&(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&&end<start&&(end=start),end===start)return 0;if(0===target.length||0===this.length)return 0;if(targetStart<0)throw new RangeError("targetStart out of bounds");if(start<0||start>=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)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&&start<targetStart&&targetStart<end)for(i=len-1;i>=0;i--)target[i+targetStart]=this[i+start];else if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(i=0;i<len;i++)target[i+targetStart]=this[i+start];else target._set(this.subarray(start,start+len),targetStart);return len},Buffer.prototype.fill=function(value,start,end){if(value||(value=0),start||(start=0),end||(end=this.length),end<start)throw new RangeError("end < start");if(end!==start&&0!==this.length){if(start<0||start>=this.length)throw new RangeError("start out of bounds");if(end<0||end>this.length)throw new RangeError("end out of bounds");var i;if("number"==typeof value)for(i=start;i<end;i++)this[i]=value;else{var bytes=utf8ToBytes(value.toString()),len=bytes.length;for(i=start;i<end;i++)this[i]=bytes[i%len]}return this}},Buffer.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(Buffer.TYPED_ARRAY_SUPPORT)return new Buffer(this).buffer;for(var buf=new Uint8Array(this.length),i=0,len=buf.length;i<len;i+=1)buf[i]=this[i];return buf.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var BP=Buffer.prototype;Buffer._augment=function(arr){return arr.constructor=Buffer,arr._isBuffer=!0,arr._set=arr.set,arr.get=BP.get,arr.set=BP.set,arr.write=BP.write,arr.toString=BP.toString,arr.toLocaleString=BP.toString,arr.toJSON=BP.toJSON,arr.equals=BP.equals,arr.compare=BP.compare,arr.indexOf=BP.indexOf,arr.copy=BP.copy,arr.slice=BP.slice,arr.readUIntLE=BP.readUIntLE,arr.readUIntBE=BP.readUIntBE,arr.readUInt8=BP.readUInt8,arr.readUInt16LE=BP.readUInt16LE,arr.readUInt16BE=BP.readUInt16BE,arr.readUInt32LE=BP.readUInt32LE,arr.readUInt32BE=BP.readUInt32BE,arr.readIntLE=BP.readIntLE,arr.readIntBE=BP.readIntBE,arr.readInt8=BP.readInt8,arr.readInt16LE=BP.readInt16LE,arr.readInt16BE=BP.readInt16BE,arr.readInt32LE=BP.readInt32LE,arr.readInt32BE=BP.readInt32BE,arr.readFloatLE=BP.readFloatLE,arr.readFloatBE=BP.readFloatBE,arr.readDoubleLE=BP.readDoubleLE,arr.readDoubleBE=BP.readDoubleBE,arr.writeUInt8=BP.writeUInt8,arr.writeUIntLE=BP.writeUIntLE,arr.writeUIntBE=BP.writeUIntBE,arr.writeUInt16LE=BP.writeUInt16LE,arr.writeUInt16BE=BP.writeUInt16BE,arr.writeUInt32LE=BP.writeUInt32LE,arr.writeUInt32BE=BP.writeUInt32BE,arr.writeIntLE=BP.writeIntLE,arr.writeIntBE=BP.writeIntBE,arr.writeInt8=BP.writeInt8,arr.writeInt16LE=BP.writeInt16LE,arr.writeInt16BE=BP.writeInt16BE,arr.writeInt32LE=BP.writeInt32LE,arr.writeInt32BE=BP.writeInt32BE,arr.writeFloatLE=BP.writeFloatLE,arr.writeFloatBE=BP.writeFloatBE,arr.writeDoubleLE=BP.writeDoubleLE,arr.writeDoubleBE=BP.writeDoubleBE,arr.fill=BP.fill,arr.inspect=BP.inspect,arr.toArrayBuffer=BP.toArrayBuffer,arr};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":14,ieee754:15,isarray:16}],14:[function(require,module,exports){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(exports){"use strict";function decode(elt){var code=elt.charCodeAt(0);return code===PLUS||code===PLUS_URL_SAFE?62:code===SLASH||code===SLASH_URL_SAFE?63:code<NUMBER?-1:code<NUMBER+10?code-NUMBER+26+26:code<UPPER+26?code-UPPER:code<LOWER+26?code-LOWER+26:void 0}function b64ToByteArray(b64){function push(v){arr[L++]=v}var i,j,l,tmp,placeHolders,arr;if(b64.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0,arr=new Arr(3*b64.length/4-placeHolders),l=placeHolders>0?b64.length-4:b64.length;var L=0;for(i=0,j=0;i<l;i+=4,j+=3)tmp=decode(b64.charAt(i))<<18|decode(b64.charAt(i+1))<<12|decode(b64.charAt(i+2))<<6|decode(b64.charAt(i+3)),push((16711680&tmp)>>16),push((65280&tmp)>>8),push(255&tmp);return 2===placeHolders?(tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4,push(255&tmp)):1===placeHolders&&(tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2,push(tmp>>8&255),push(255&tmp)),arr}function uint8ToBase64(uint8){function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(63&num)}var i,temp,length,extraBytes=uint8.length%3,output="";for(i=0,length=uint8.length-extraBytes;i<length;i+=3)temp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2],output+=tripletToBase64(temp);switch(extraBytes){case 1:temp=uint8[uint8.length-1],output+=encode(temp>>2),output+=encode(temp<<4&63),output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1],output+=encode(temp>>10),output+=encode(temp>>4&63),output+=encode(temp<<2&63),output+="="}return output}var Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,PLUS="+".charCodeAt(0),SLASH="/".charCodeAt(0),NUMBER="0".charCodeAt(0),LOWER="a".charCodeAt(0),UPPER="A".charCodeAt(0),PLUS_URL_SAFE="-".charCodeAt(0),SLASH_URL_SAFE="_".charCodeAt(0);exports.toByteArray=b64ToByteArray,exports.fromByteArray=uint8ToBase64}("undefined"==typeof exports?this.base64js={}:exports)},{}],15:[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?NaN:(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=value<0||0===value&&1/value<0?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}},{}],16:[function(require,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return"[object Array]"==toString.call(arr)}},{}],17:[function(require,module,exports){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)||n<0||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;i<len;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(position<0)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)}},{}],18:[function(require,module,exports){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:38}],19:[function(require,module,exports){"function"==typeof Object.create?module.exports=function(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}},{}],20:[function(require,module,exports){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)}},{}],21:[function(require,module,exports){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(name){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(dir){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}},{}],22:[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;counter<length;)value=string.charCodeAt(counter++),value>=55296&&value<=56319&&counter<length?(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 codePoint-48<10?codePoint-22:codePoint-65<26?codePoint-65:codePoint-97<26?codePoint-97:base}function digitToBasic(digit,flag){return digit+22+75*(digit<26)-((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),basic<0&&(basic=0),j=0;j<basic;++j)input.charCodeAt(j)>=128&&error("not-basic"),output.push(input.charCodeAt(j));for(index=basic>0?basic+1:0;index<inputLength;){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=k<=bias?tMin:k>=bias+tMax?tMax:k-bias,!(digit<t);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;j<inputLength;++j)currentValue=input[j],currentValue<128&&output.push(stringFromCharCode(currentValue));for(handledCPCount=basicLength=output.length,basicLength&&output.push(delimiter);handledCPCount<inputLength;){for(m=maxInt,j=0;j<inputLength;++j)currentValue=input[j],currentValue>=n&&currentValue<m&&(m=currentValue);for(handledCPCountPlusOne=handledCPCount+1,m-n>floor((maxInt-delta)/handledCPCountPlusOne)&&error("overflow"),delta+=(m-n)*handledCPCountPlusOne,n=m,j=0;j<inputLength;++j)if(currentValue=input[j],currentValue<n&&++delta>maxInt&&error("overflow"),currentValue==n){for(q=delta,k=base;t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias,!(q<t);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:{})},{}],23:[function(require,module,exports){"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;i<len;++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)}},{}],24:[function(require,module,exports){"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}},{}],25:[function(require,module,exports){"use strict";exports.decode=exports.parse=require("./decode"),exports.encode=exports.stringify=require("./encode")},{"./decode":23,"./encode":24}],26:[function(require,module,exports){"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":28,"./_stream_writable":30,"core-util-is":33,inherits:19,"process-nextick-args":35}],27:[function(require,module,exports){"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":29,"core-util-is":33,inherits:19}],28:[function(require,module,exports){(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 n<=0||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,p.next?list.head=p.next:list.head=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,p.next?list.head=p.next:list.head=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;i<l;i++)f(xs[i],i)}function indexOf(xs,x){for(var i=0,l=xs.length;i<l;i++)if(xs[i]===x)return i;return-1}module.exports=Readable;var 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);var Duplex,Duplex;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(n){this.emit("error",new Error("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&&indexOf(state.pipes,dest)!==-1)&&!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;_i<len;_i++)dests[_i].emit("unpipe",this);return this}var i=indexOf(state.pipes,dest);return i===-1?this:(state.pipes.splice(i,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":26,"./internal/streams/BufferList":31,_process:21,buffer:13,"buffer-shims":32,"core-util-is":33,events:17,inherits:19,isarray:34,"process-nextick-args":35,"string_decoder/":44,util:12}],29:[function(require,module,exports){"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){done(stream,er)}):done(stream)})}function done(stream,er){if(er)return stream.emit("error",er);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(chunk,encoding,cb){throw new Error("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(n){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":26,"core-util-is":33,inherits:19}],30:[function(require,module,exports){(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"),this instanceof Writable||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 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);var Duplex;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 Duplex;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("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":26,_process:21,buffer:13,"buffer-shims":32,"core-util-is":33,events:17,inherits:19,"process-nextick-args":35,"util-deprecate":36}],31:[function(require,module,exports){"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 1===this.length?this.head=this.tail=null:this.head=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:13,"buffer-shims":32}],32:[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:13}],33:[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("../../../../insert-module-globals/node_modules/is-buffer/index.js")})},{"../../../../insert-module-globals/node_modules/is-buffer/index.js":20}],34:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{dup:16}],35:[function(require,module,exports){(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)})}}!process.version||0===process.version.indexOf("v0.")||0===process.version.indexOf("v1.")&&0!==process.version.indexOf("v1.8.")?module.exports=nextTick:module.exports=process.nextTick}).call(this,require("_process"))},{_process:21}],36:[function(require,module,exports){(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&&"true"===String(val).toLowerCase()}module.exports=deprecate}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[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":26,"./lib/_stream_passthrough.js":27,"./lib/_stream_readable.js":28,"./lib/_stream_transform.js":29,"./lib/_stream_writable.js":30,_process:21}],38:[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=global.location.protocol.search(/^https?:$/)===-1?"http:":"",protocol=opts.protocol||defaultProtocol,host=opts.hostname||opts.host,port=opts.port,path=opts.path||"/";
host&&host.indexOf(":")!==-1&&(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":40,"builtin-status-codes":42,url:45,xtend:47}],39:[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.location.host?"/":"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:{})},{}],40:[function(require,module,exports){(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();unsafeHeaders.indexOf(lowerName)===-1&&(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||(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":39,"./response":41,_process:21,buffer:13,inherits:19,"readable-stream":37,"to-arraybuffer":43}],41:[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;for(var header,_i,_it=response.headers[Symbol.iterator]();header=(_i=_it.next()).value,!_i.done;)self.headers[header[0].toLowerCase()]=header[1],self.rawHeaders.push(header[0],header[1]);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":39,_process:21,buffer:13,inherits:19,"readable-stream":37}],42:[function(require,module,exports){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"}},{}],43:[function(require,module,exports){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;i<len;i++)arrayCopy[i]=buf[i];return arrayCopy.buffer}throw new Error("Argument must be a Buffer")}},{buffer:13}],44:[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&&charCode<=56319)){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&&charCode<=56319){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(i<=2&&c>>4==14){this.charLength=3;break}if(i<=3&&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:13}],45:[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","\t"],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=queryIndex!==-1&&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],parseQueryString?this.query=querystring.parse(this.search.substr(1)):this.query=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]);hec!==-1&&(hostEnd===-1||hec<hostEnd)&&(hostEnd=hec)}var auth,atSign;atSign=hostEnd===-1?rest.lastIndexOf("@"):rest.lastIndexOf("@",hostEnd),atSign!==-1&&(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]);hec!==-1&&(hostEnd===-1||hec<hostEnd)&&(hostEnd=hec)}hostEnd===-1&&(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;i<l;i++){var part=hostparts[i];if(part&&!part.match(hostnamePartPattern)){for(var newpart="",j=0,k=part.length;j<k;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.length>hostnameMaxLen?this.hostname="":this.hostname=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;i<l;i++){var ae=autoEscape[i];if(rest.indexOf(ae)!==-1){var esc=encodeURIComponent(ae);esc===ae&&(esc=escape(ae)),rest=rest.split(ae).join(esc)}}var hash=rest.indexOf("#");hash!==-1&&(this.hash=rest.substr(hash),rest=rest.slice(0,hash));var qm=rest.indexOf("?");if(qm!==-1?(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+(this.hostname.indexOf(":")===-1?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("@");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.search?result.path="/"+result.search:result.path=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("@");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":46,punycode:22,querystring:25}],46:[function(require,module,exports){"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}}},{}],47:[function(require,module,exports){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},{}],48:[function(require,module,exports){(function(process,global){!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):global.ES6Promise=factory()}(this,function(){"use strict";function objectOrFunction(x){return"function"==typeof x||"object"==typeof x&&null!==x}function isFunction(x){return"function"==typeof x}function setScheduler(scheduleFn){customSchedulerFn=scheduleFn}function setAsap(asapFn){asap=asapFn}function useNextTick(){return function(){return process.nextTick(flush)}}function useVertxTimer(){return function(){vertxNext(flush)}}function useMutationObserver(){var iterations=0,observer=new BrowserMutationObserver(flush),node=document.createTextNode("");return observer.observe(node,{characterData:!0}),function(){node.data=iterations=++iterations%2}}function useMessageChannel(){var channel=new MessageChannel;return channel.port1.onmessage=flush,function(){return channel.port2.postMessage(0)}}function useSetTimeout(){var globalSetTimeout=setTimeout;return function(){return globalSetTimeout(flush,1)}}function flush(){for(var i=0;i<len;i+=2){var callback=queue[i],arg=queue[i+1];callback(arg),queue[i]=void 0,queue[i+1]=void 0}len=0}function attemptVertx(){try{var r=require,vertx=r("vertx");return vertxNext=vertx.runOnLoop||vertx.runOnContext,useVertxTimer()}catch(e){return useSetTimeout()}}function then(onFulfillment,onRejection){var _arguments=arguments,parent=this,child=new this.constructor(noop);void 0===child[PROMISE_ID]&&makePromise(child);var _state=parent._state;return _state?!function(){var callback=_arguments[_state-1];asap(function(){return invokeCallback(_state,child,callback,parent._result)})}():subscribe(parent,child,onFulfillment,onRejection),child}function resolve(object){var Constructor=this;if(object&&"object"==typeof object&&object.constructor===Constructor)return object;var promise=new Constructor(noop);return _resolve(promise,object),promise}function noop(){}function selfFulfillment(){return new TypeError("You cannot resolve a promise with itself")}function cannotReturnOwn(){return new TypeError("A promises callback cannot return that same promise.")}function getThen(promise){try{return promise.then}catch(error){return GET_THEN_ERROR.error=error,GET_THEN_ERROR}}function tryThen(then,value,fulfillmentHandler,rejectionHandler){try{then.call(value,fulfillmentHandler,rejectionHandler)}catch(e){return e}}function handleForeignThenable(promise,thenable,then){asap(function(promise){var sealed=!1,error=tryThen(then,thenable,function(value){sealed||(sealed=!0,thenable!==value?_resolve(promise,value):fulfill(promise,value))},function(reason){sealed||(sealed=!0,_reject(promise,reason))},"Settle: "+(promise._label||" unknown promise"));!sealed&&error&&(sealed=!0,_reject(promise,error))},promise)}function handleOwnThenable(promise,thenable){thenable._state===FULFILLED?fulfill(promise,thenable._result):thenable._state===REJECTED?_reject(promise,thenable._result):subscribe(thenable,void 0,function(value){return _resolve(promise,value)},function(reason){return _reject(promise,reason)})}function handleMaybeThenable(promise,maybeThenable,then$$){maybeThenable.constructor===promise.constructor&&then$$===then&&maybeThenable.constructor.resolve===resolve?handleOwnThenable(promise,maybeThenable):then$$===GET_THEN_ERROR?_reject(promise,GET_THEN_ERROR.error):void 0===then$$?fulfill(promise,maybeThenable):isFunction(then$$)?handleForeignThenable(promise,maybeThenable,then$$):fulfill(promise,maybeThenable)}function _resolve(promise,value){promise===value?_reject(promise,selfFulfillment()):objectOrFunction(value)?handleMaybeThenable(promise,value,getThen(value)):fulfill(promise,value)}function publishRejection(promise){promise._onerror&&promise._onerror(promise._result),publish(promise)}function fulfill(promise,value){promise._state===PENDING&&(promise._result=value,promise._state=FULFILLED,0!==promise._subscribers.length&&asap(publish,promise))}function _reject(promise,reason){promise._state===PENDING&&(promise._state=REJECTED,promise._result=reason,asap(publishRejection,promise))}function subscribe(parent,child,onFulfillment,onRejection){var _subscribers=parent._subscribers,length=_subscribers.length;
parent._onerror=null,_subscribers[length]=child,_subscribers[length+FULFILLED]=onFulfillment,_subscribers[length+REJECTED]=onRejection,0===length&&parent._state&&asap(publish,parent)}function publish(promise){var subscribers=promise._subscribers,settled=promise._state;if(0!==subscribers.length){for(var child=void 0,callback=void 0,detail=promise._result,i=0;i<subscribers.length;i+=3)child=subscribers[i],callback=subscribers[i+settled],child?invokeCallback(settled,child,callback,detail):callback(detail);promise._subscribers.length=0}}function ErrorObject(){this.error=null}function tryCatch(callback,detail){try{return callback(detail)}catch(e){return TRY_CATCH_ERROR.error=e,TRY_CATCH_ERROR}}function invokeCallback(settled,promise,callback,detail){var hasCallback=isFunction(callback),value=void 0,error=void 0,succeeded=void 0,failed=void 0;if(hasCallback){if(value=tryCatch(callback,detail),value===TRY_CATCH_ERROR?(failed=!0,error=value.error,value=null):succeeded=!0,promise===value)return void _reject(promise,cannotReturnOwn())}else value=detail,succeeded=!0;promise._state!==PENDING||(hasCallback&&succeeded?_resolve(promise,value):failed?_reject(promise,error):settled===FULFILLED?fulfill(promise,value):settled===REJECTED&&_reject(promise,value))}function initializePromise(promise,resolver){try{resolver(function(value){_resolve(promise,value)},function(reason){_reject(promise,reason)})}catch(e){_reject(promise,e)}}function nextId(){return id++}function makePromise(promise){promise[PROMISE_ID]=id++,promise._state=void 0,promise._result=void 0,promise._subscribers=[]}function Enumerator(Constructor,input){this._instanceConstructor=Constructor,this.promise=new Constructor(noop),this.promise[PROMISE_ID]||makePromise(this.promise),isArray(input)?(this._input=input,this.length=input.length,this._remaining=input.length,this._result=new Array(this.length),0===this.length?fulfill(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&fulfill(this.promise,this._result))):_reject(this.promise,validationError())}function validationError(){return new Error("Array Methods must be provided an Array")}function all(entries){return new Enumerator(this,entries).promise}function race(entries){var Constructor=this;return new Constructor(isArray(entries)?function(resolve,reject){for(var length=entries.length,i=0;i<length;i++)Constructor.resolve(entries[i]).then(resolve,reject)}:function(_,reject){return reject(new TypeError("You must pass an array to race."))})}function reject(reason){var Constructor=this,promise=new Constructor(noop);return _reject(promise,reason),promise}function needsResolver(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function needsNew(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function Promise(resolver){this[PROMISE_ID]=nextId(),this._result=this._state=void 0,this._subscribers=[],noop!==resolver&&("function"!=typeof resolver&&needsResolver(),this instanceof Promise?initializePromise(this,resolver):needsNew())}function polyfill(){var local=void 0;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;if(P){var promiseToString=null;try{promiseToString=Object.prototype.toString.call(P.resolve())}catch(e){}if("[object Promise]"===promiseToString&&!P.cast)return}local.Promise=Promise}var _isArray=void 0;_isArray=Array.isArray?Array.isArray:function(x){return"[object Array]"===Object.prototype.toString.call(x)};var isArray=_isArray,len=0,vertxNext=void 0,customSchedulerFn=void 0,asap=function(callback,arg){queue[len]=callback,queue[len+1]=arg,len+=2,2===len&&(customSchedulerFn?customSchedulerFn(flush):scheduleFlush())},browserWindow="undefined"!=typeof window?window:void 0,browserGlobal=browserWindow||{},BrowserMutationObserver=browserGlobal.MutationObserver||browserGlobal.WebKitMutationObserver,isNode="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),isWorker="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,queue=new Array(1e3),scheduleFlush=void 0;scheduleFlush=isNode?useNextTick():BrowserMutationObserver?useMutationObserver():isWorker?useMessageChannel():void 0===browserWindow&&"function"==typeof require?attemptVertx():useSetTimeout();var PROMISE_ID=Math.random().toString(36).substring(16),PENDING=void 0,FULFILLED=1,REJECTED=2,GET_THEN_ERROR=new ErrorObject,TRY_CATCH_ERROR=new ErrorObject,id=0;return Enumerator.prototype._enumerate=function(){for(var length=this.length,_input=this._input,i=0;this._state===PENDING&&i<length;i++)this._eachEntry(_input[i],i)},Enumerator.prototype._eachEntry=function(entry,i){var c=this._instanceConstructor,resolve$$=c.resolve;if(resolve$$===resolve){var _then=getThen(entry);if(_then===then&&entry._state!==PENDING)this._settledAt(entry._state,i,entry._result);else if("function"!=typeof _then)this._remaining--,this._result[i]=entry;else if(c===Promise){var promise=new c(noop);handleMaybeThenable(promise,entry,_then),this._willSettleAt(promise,i)}else this._willSettleAt(new c(function(resolve$$){return resolve$$(entry)}),i)}else this._willSettleAt(resolve$$(entry),i)},Enumerator.prototype._settledAt=function(state,i,value){var promise=this.promise;promise._state===PENDING&&(this._remaining--,state===REJECTED?_reject(promise,value):this._result[i]=value),0===this._remaining&&fulfill(promise,this._result)},Enumerator.prototype._willSettleAt=function(promise,i){var enumerator=this;subscribe(promise,void 0,function(value){return enumerator._settledAt(FULFILLED,i,value)},function(reason){return enumerator._settledAt(REJECTED,i,reason)})},Promise.all=all,Promise.race=race,Promise.resolve=resolve,Promise.reject=reject,Promise._setScheduler=setScheduler,Promise._setAsap=setAsap,Promise._asap=asap,Promise.prototype={constructor:Promise,then:then,catch:function(onRejection){return this.then(null,onRejection)}},polyfill(),Promise.polyfill=polyfill,Promise.Promise=Promise,Promise})}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:21}],49:[function(require,module,exports){module.exports={name:"prismic.io",description:"JavaScript development kit for prismic.io",license:"Apache-2.0",url:"https://github.com/prismicio/javascript-kit",keywords:["prismic","prismic.io","cms","content","api"],version:"3.2.0",devDependencies:{"babel-preset-es2015":"^6.3.13",babelify:"^7.2.0",browserify:"^12.0.1",chai:"*","codeclimate-test-reporter":"0.0.4","es6-promise":"^3.2.1",eslint:"^2.12.0",istanbul:"^0.4.4",jsdoc:"^3.4.0",mocha:"*",rimraf:"^2.5.4","uglify-js":"^2.6.1","vinyl-buffer":"^1.0.0","vinyl-source-stream":"^1.1.0"},repository:{type:"git",url:"http://github.com/prismicio/javascript-kit.git"},main:"lib/prismic.js",scripts:{build:"scripts/browser.js",postbuild:"npm run docs",uglify:"uglifyjs -c -o=dist/prismic.io.min.js dist/prismic.io.js",preuglify:"npm run build",prepublish:"npm run uglify",lint:"eslint lib",test:"istanbul cover _mocha test/",posttest:"eslint lib",predocs:"rimraf ./docs",docs:"jsdoc dist/prismic.io.js README.md -d docs"}}},{}]},{},[2]);