diff --git a/LICENSE b/LICENSE index 3b49e068..d838e1e1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Eric Martindale +Copyright (c) 2016 Eric Martindale Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index be393126..3ef721ef 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ Maki ============== [![Build Status](https://img.shields.io/travis/martindale/maki.svg?branch=master&style=flat-square)](https://travis-ci.org/martindale/maki) [![Coverage Status](https://img.shields.io/coveralls/martindale/maki.svg?style=flat-square)](https://coveralls.io/r/martindale/maki) -[![Community](https://community.ericmartindale.com/badge.svg)](https://community.ericmartindale.com/) +![Project Status](https://img.shields.io/badge/status-alpha-red.svg?style=flat-square) +[![Community](https://chat.maki.io/badge.svg)](https://chat.maki.io/) The complete stack for building extensible apps, faster than ever. Hand-roll your application by telling Maki what your application does, and it takes care of the rest – without getting in your way if you want to customize it. diff --git a/components/404.jade b/components/404.jade new file mode 100644 index 00000000..78d5f02a --- /dev/null +++ b/components/404.jade @@ -0,0 +1,17 @@ +dom-module#maki-undefined + template + .ui.text.container + h1 Nothing known. + p We're sorry, but we don't know anything about that. Here are some alternative resources you might be interested in. + + .ui.horizontal.segments + .ui.segment + p One + .ui.segment + p Two + .ui.segment + p Two + script. + Polymer({ + is: 'maki-undefined' + }); diff --git a/components/application.jade b/components/application.jade new file mode 100644 index 00000000..0c95a7be --- /dev/null +++ b/components/application.jade @@ -0,0 +1,169 @@ +dom-module#maki-application + style. + #navigation { + width: 100%; + } + + template + maki-datastore(name="#{config.service.namespace}") + maki-channel(autoconnect, reconnect="true") + + .pusher + .ui.inverted.vertical.center.aligned.segment + .ui.container + maki-navbar + + .content(for="viewport") + maki-index + + .ui.inverted.vertical.footer.segment + .ui.container + .ui.stackable.inverted.divided.equal.height.stackable.grid + .six.wide.column + h4.ui.inverted.header About + p This website is powered by Maki, a full-stack framework that implements strong-typing at the network level. You can see and engage with the auto-generated API to learn more. + p Maki is a labor of love, a result of several years of iterations and re-architectures in pursuit of a clean, hand-rolled framework for building clean, useful applications. We hope you like it. + //-.ui.inverted.link.list + a.item(href="#") Protocol + a.item(href="#") Whitepaper + a.item(href="#") Roadmap + a.item(href="#") Contact Us + .seven.wide.column + h4.ui.inverted.header Copyleft + p #{config.service.name} has not supplied a LICENSE file in config/index.json. + p Maki is copyleft, and encourages you to copy, clone, and create. After all, without a rich public domain, how else can we innovate? Much to our chagrin, the software itself is more formally MIT licensed, while our content is licensed under CC-BY. + .three.wide.column + h4.ui.inverted.header Elsewhere + .ui.inverted.link.list + a.item(href="https://github.com/martindale/maki", rel="me") + i.icon.github + | GitHub + a.item(href="https://twitter.com/martindale", rel="me") + i.icon.twitter + | Twitter + a.item(href="https://facebook.com/eric.martindale", rel="me") + i.icon.facebook + | Facebook + //-a.item(href="#", rel="me") + i.icon.medium + | Medium + + script(src="/js/page.min.js", async) + script(src="/js/jquery.js", async) + script. + window.maki = Polymer({ + is: 'maki-application', + properties: { + src: { + type: String + }, + for: { + type: String + }, + route: { + type: String + }, + routes: { + type: Object, + value: {} + }, + components: { + type: Object, + value: {} + }, + resources: { + type: Object, + observer: '_resourcesUpdated' + }, + datastore: { + type: Object + }, + identity: { + type: Object + }, + worker: { type: Object } + }, + _route: function(ctx) { + var self = this; + + var component = 'maki-undefined'; + for (var route in self.routes) { + var regex = self.routes[route]; + var viewport = document.querySelectorAll('[for=viewport]')[0]; + + console.log('[MAKI:APPLICATION]', 'testing', regex, 'against', ctx.path); + + if (regex.test(ctx.path)) { + console.log('[MAKI:APPLICATION]', 'picking', route, 'from', ctx.path); + component = self.components[route]; + view = document.createElement(component); + view.type = self.resourceMap[route]; + view.type.route = route; + break; + } + } + + console.log('[MAKI:APPLICATION]', 'settled on rendering:', view.type.route, view); + //console.log('[MAKI:APPLICATION]', 'type.static:', view.type.static); + //console.log('[MAKI:APPLICATION]', 'setting and appending...'); + + view.setAttribute('src', ctx.path); + + while (viewport.hasChildNodes()) { + viewport.removeChild(viewport.lastChild); + } + viewport.appendChild(view); + }, + _resourcesUpdated: function(resources) { + var self = this; + var _route = self._route.bind(self); + + self.resourceMap = {}; + + console.log('[MAKI:APPLICATION]', '_resourcesUpdated', resources); + + var order = ['Person', 'Post', 'Index']; + Object.keys(resources).forEach(function(name) { + var resource = resources[name]; + console.log('[MAKI:APPLICATION]', 'initializing', name); + ['get', 'query'].forEach(function(action) { + console.log('[MAKI:APPLICATION]', 'looking for', action, 'in', resource.routes); + var route = resource.routes[action]; + if (!route) return; + + console.log('[MAKI:APPLICATION]', 'components are:', resource.components); + + self.routes[route] = new RegExp(eval(resource.paths[action])); + self.components[route] = resource.components[action]; + self.resourceMap[route] = resource; + page(route, _route); + }); + }); + + self.routes['/'] = new RegExp(/^\/$/); + self.components['/'] = (resources.Index && resources.Index.components) ? resources.Index.components.query : 'maki-index'; + + page('/', _route); + page('*', _route); + + page(); + }, + created: function() { + var self = this; + + self.route = window.location.pathname; + //self.worker = new Worker('/worker.js'); + + $.ajax({ + type: 'OPTIONS', + url: '/', + headers: { + 'Accept': 'application/json' + }, + success: function(data) { + self.config = data.config; + self.resources = data.resources; + } + }); + } + }); diff --git a/components/channel.jade b/components/channel.jade new file mode 100644 index 00000000..8b302c22 --- /dev/null +++ b/components/channel.jade @@ -0,0 +1,127 @@ +dom-module#maki-channel + script(src="/js/uuid.js", async) + script(src="/js/jsonrpc.js", async) + script. + Polymer({ + is: 'maki-channel', + properties: { + namespace: { + type: String + }, + autoconnect: { + type: Boolean + }, + reconnect: { + type: Boolean + }, + subscriptions: { + type: Array + }, + ws: { + type: Object + }, + src: { + type: String + }, + }, + _send: function(method, params) { + var self = this; + self.ws.send(JSON.stringify({ + 'jsonrpc': '2.0', + 'method': method, + 'params': params, + 'id': uuid.v4() // TODO: sequence? + })); + }, + _subscribe: function(path) { + console.log('[MAKI:CHANNEL]', 'subscribing to:', path); + var self = this; + self._send('subscribe', { + channel: path + }); + }, + _consume: function() { + var self = this; + var elements = document.querySelectorAll('[src]'); + + console.log('[MAKI:CHANNEL]', '_consume', elements); + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + self._subscribe(element.src); + } + }, + _handleMessage: function(msg) { + var self = this; + console.log('[MAKI:CHANNEL]', '_handleMessage', msg); + + try { + var data = JSON.parse( msg.data ); + } catch (e) { + var data = {}; + } + + console.log('[MAKI:CHANNEL]', '_handleMessage', 'resulting data:', data); + + // experimental JSON-RPC implementation + if (data.jsonrpc === '2.0') { + console.log('[MAKI:CHANNEL]', '_handleMessage', 'valid jsonrpc!'); + + switch (data.method) { + case 'ping': + console.log('[MAKI:CHANNEL]', 'received ping. playing pong...'); + self.ws.send(JSON.stringify({ + 'jsonrpc': '2.0', + 'result': 'pong', + 'id': data.id + })); + break; + case 'patch': + // TODO: update in-memory data (two-way binding); + console.log('[MAKI:CHANNEL]', 'received `patch` event:', data.params.channel , data ); + var channel = data.params.channel; + var ops = data.params.ops; + var datastore = document.querySelector('maki-datastore[name='+self.namespace+']'); + var manager = document.querySelector('maki-peer-manager'); + + datastore._patch(channel, ops); + manager._relay(data); + + break; + default: + console.error('[MAKI:CHANNEL]', 'unhandled jsonrpc method ' , data.method); + break; + } + } else { + + } + }, + _connect: function() { + var self = this; + var maki = document.querySelector('maki-application'); + var protocol = (document.location.protocol === 'http:') ? 'ws://' : 'wss://'; + var path = protocol + document.location.host; // + self.src; + + console.log('[MAKI:CHANNEL]', 'websocket connecting to: ', path); + + self.ws = new WebSocket(path); + self.ws.onclose = function onClose() { + if (self.reconnect === true) { + setTimeout(function() { + self._connect(); + }, 500); + } + } + self.ws.onmessage = self._handleMessage.bind(self); + self.ws.onopen = function onOpen() { + console.log('[MAKI:CHANNEL]', 'websocket open.'); + } + }, + ready: function() { + var self = this; + console.log('[MAKI:CHANNEL]', 'ready'); + if (self.autoconnect === true) { + self._connect(); + } + }, + }); diff --git a/components/collection.jade b/components/collection.jade new file mode 100644 index 00000000..efdb6067 --- /dev/null +++ b/components/collection.jade @@ -0,0 +1,91 @@ +dom-module#maki-collection + template + .ui.vertical.segment + .ui.container + h2 + //-template(if$="{{type.options.icon}}") + i(class$="ui icon {{type.options.icon}}") + a(href="/{{type.names.query}}") {{type.plural}} + p {{type.description}} + code + pre {{resource}} + + .ui.five.cards + template(is="dom-repeat", items="{{items}}") + .ui.card + template(if="{{item.image}}") + .image + img(src="/img/maki-logo.png") + .content + a.header(href="/{{type.names.query}}/{{item.slug}}") {{item.name}} {{item.username}} + p.description {{item.description}} + template(if="{{item.action}}") + a.ui.bottom.attached.button(if="{{item.action}}", href="{{item.action.href}}") {{item.action.text}} + //-maki-item(src="/people/{{item.id}}", item="{{item}}") + + script. + Polymer({ + is: 'maki-collection', + listeners: { + 'datastore:query': '_handleQuery', + 'state:change': '_applyState' + }, + properties: { + src: { + type: String, + observer: '_sourceChanged' + }, + type: { + type: Object + }, + items: { + type: Array, + notify: true + }, + }, + _handleQuery: function(e, key) { + var self = this; + var datastore = document.querySelectorAll('maki-datastore')[0]; + console.log('[MAKI:COLLECTION]','_handleQuery:', e, key); + datastore._retrieve(key, function(err, data) { + if (!data) self.fire('datastore:miss', key); + if (err) { + console.error('_handleQuery error:', err); + data = []; + } + self.fire('state:change', data); + }); + }, + _applyState: function(e) { + var self = this; + var state = e.detail; + + if (!(state instanceof Array)) { + state = [state]; + } + + self.items = state; + }, + _sourceChanged: function(source) { + var self = this; + var maki = document.querySelectorAll('maki-application')[0]; + console.log('[MAKI:COLLECTION]', 'collection sourceChanged:', source); + //self.resource = maki.resourceMap[source]; + self.fire('datastore:query', source); + }, + _sync: function() { + var self = this; + console.log('[MAKI:COLLECTION]', '_sync'); + self.fire('datastore:query', self.src); + }, + ready: function() { + var self = this; + console.log('[MAKI:COLLECTION]', 'ready'); + }, + attached: function() { + var self = this; + var channel = document.querySelectorAll('maki-channel')[0]; + console.log('[MAKI:COLLECTION]', 'collection is attached:', self.src); + channel._subscribe(self.src); + } + }); diff --git a/components/content-store.jade b/components/content-store.jade new file mode 100644 index 00000000..3781ecc6 --- /dev/null +++ b/components/content-store.jade @@ -0,0 +1,25 @@ +dom-module#maki-content-store + template + maki-crypto-worker + //- TODO: replace this with maki-peer-manager + maki-key-value(name="fabric") + script. + Polymer({ + is: 'maki-content-store', + _get: function(key, cb) { + var db = document.querySelector('maki-key-value[name=fabric]'); + db._retrieve(key, cb); + }, + _store: function(doc, cb) { + var db = document.querySelector('maki-key-value[name=fabric]'); + var worker = document.querySelector('maki-crypto-worker'); + if (typeof doc !== 'string') { + doc = JSON.stringify(doc); + } + worker._digest(doc, function(err, hash) { + db._store(hash, doc, function(err) { + cb(err, hash); + }); + }); + } + }); diff --git a/components/datastore.jade b/components/datastore.jade new file mode 100644 index 00000000..f200d8e5 --- /dev/null +++ b/components/datastore.jade @@ -0,0 +1,397 @@ +//- maki-datastore +//- is a top-level manager of data +//- maps /path to +dom-module#maki-datastore + template + maki-crypto-worker(name="datastore") + maki-key-value(name="tips", for$="{{name}}") + maki-key-value(name$="{{name}}") + script(src="/js/json-patch-duplex.min.js") + script. + Polymer({ + is: 'maki-datastore', + properties: { + name: { + type: String + }, + for: { + type: String + }, + db: { + type: Object + }, + fabric: { + type: Object + }, + tips: { + type: Object + }, + private: { + type: Boolean + }, + resources: { + type: Object, + value: {} + } + }, + listeners: { + 'datastore:miss': '_handleMiss', + 'datastore:change': '_handleChange', + 'datastore:patch': '_handlePatch', + }, + _query: function(path, query, opts, cb) { + var self = this; + var name = self.name; + if (typeof opts === 'function') { + cb = opts; + opts = {}; + } + + console.log('[MAKI:DATASTORE]', name, '_query', 'incoming:', path, query, opts); + + // TODO: not do this + var application = document.querySelector(self.for + '-application'); + var resource = application._pathToResource(path); + console.log('[MAKI:DATASTORE]', name, '_query', 'dat path', path, resource); + resource.store.find(query, function(err, docs) { + console.log('[MAKI:DATASTORE]',name, '_query', 'dat result', err, docs); + cb(err, docs); + }); + }, + _post: function(path, obj, cb) { + // TODO: middlewares + var self = this; + console.log('[MAKI:DATASTORE]', '_post', '_publish', 'adding', path, obj); + + self.tips._get(path, function(err, tip) { + if (err) console.error('[MAKI:DATASTORE]', '_post', 'tip retrieval err:', err); + self.db._get(tip, { + convert: true + }, function(err, collection) { + if (err) console.error('[MAKI:DATASTORE]', '_post', 'getTip error:', err); + if (!collection) { + collection = []; + } + if (!(collection instanceof Array)) { + console.error('[MAKI:DATASTORE]', '_post', 'getTip not collection', collection); + return cb('Tip exists, but does not store a collection.'); + } + + console.log('[MAKI:DATASTORE]', '_post', '_publish', 'getTip results', collection); + + self._put(path + '/' + obj['id'], obj, function(err, doc) { + if (err) console.error('[MAKI:DATASTORE]', '_post', '_put', path + '/' + obj['id'], err); + // TODO: remove this condition, understand where and why `null` + // happens to `doc` sometimes... + if (doc) { + collection.unshift(doc); + } + + console.error('[MAKI:DATASTORE]', '_post', '_publish', 'collection (before):', path, collection); + + collection = collection.map(function(x) { + if (x['@id']) { + return x['@id']; + } else { + return x; + } + }); + collection = JSON.parse(JSON.stringify(collection)); + + console.error('[MAKI:DATASTORE]', '_post', '_publish', 'collection (after):', path, collection); + + self._put(path, collection, function(err) { + if (err) console.error('[MAKI:DATASTORE]', '_post', '_publish', 'adding result', err); + return cb(err, doc); + }); + }); + }); + }); + }, + _put: function(path, val, cb) { + // TODO: middlewares + var self = this; + var name = self.name; + self._bundle(val, function(err, obj) { + if (err) console.error(err); + console.log('[MAKI:DATASTORE]', '_put', '_post', '_bundle', '_publish', 'output', obj); + if (!obj) console.log('[MAKI:DATASTORE]', '_put', 'grave concern! no obj from bundle', path, val); + if (!obj['@id']) console.log('[MAKI:DATASTORE]', '_put', 'grave concern! no @id from bundle', obj); + + /*if (obj['@id'] === val['@id']) { + return cb(null, obj); + }*/ + + self.db._set(obj['@id'], obj, function(err) { + if (err) console.error(err); + console.log('[MAKI:DATASTORE]', name, '_put', '_publish', 'setting tip...', path, obj['@id']); + self.tips._set(path, obj['@id'], function(err) { + if (err) console.error(err); + console.log('[MAKI:DATASTORE]', name, '_put', '_publish', 'set the tip!', path, obj); + + self._flatten(obj, function(err, doc) { + var application = document.querySelector(self.for + '-application'); + // TODO: not do this. maybe use the `private` property? + if (!application) { + console.error('[MAKI:DATASTORE]', name, '_put', '_publish', 'could not find application', self.for); + self.fire('datastore:change', { + path: path, + val: obj, + old: undefined + }); + + return cb(err, obj); + } else { + var resource = application._pathToResource(path); + + resource.store.insert(obj, function(err, result) { + if (err) console.error('[MAKI:DATASTORE]', name, '_put', '_publish', 'store.insert:', err); + + self.fire('datastore:change', { + path: path, + val: obj, + old: undefined + }); + + console.log('[MAKI:DATASTORE]', name, '_put', '_publish', 'shared:', path, obj, result); + + return cb(err, obj); + }); + } + }); + }); + }); + }); + }, + _update: function(path, query, updates, opts, cb) { + var self = this; + + console.log('[MAKI:DATASTORE]', '_update', self.for); + console.log('[MAKI:DATASTORE]', '_update', path, query, updates, opts); + console.log('[MAKI:DATASTORE]', '_update', 'updates:', updates, 'opts:', opts); + + var application = document.querySelector(self.for + '-application'); + var resource = application._pathToResource(path); + resource.store.update(query, updates, opts, cb); + }, + _upsert: function(path, query, item, cb) { + var self = this; + self._update(path, query, item, { + upsert: true + }, function(err, numAffected) { + console.log('[MAKI:DATASTORE]', '_upsert end', err, numAffected); + cb(err); + }); + }, + _flatten: function(item, cb) { + var self = this; + window.traverse(item, function(node, next) { + var context = this; + if (context.isRoot) return next(); + var key = context.key; + var val = context.parent[key]; + if (val['@id']) { + context.parent[key] = val['@id']; + } + next(); + }, function(final) { + cb(null, final); + }); + }, + // HTTP-emulated GET request + _get: function(path, cb) { + // TODO: middlewares + var self = this; + var name = self.name; + console.log('[MAKI:DATASTORE]', '_get looking for:', path); + + var eventName = 'key-value:'+name+':open'; + console.log('[MAKI:DATASTORE]', name, '_get', 'waiting for (eventName):', eventName); + self.tips._get(path, function(err, tip) { + if (err) console.error('[MAKI:DATASTORE]', '_get', path, err); + + console.log('[MAKI:DATASTORE]', name, '_get', path, 'tip is:', tip); + + self.db._get(tip, { + convert: true, + //hydrate: true + }, function(err, obj) { + if (err || !obj) { + obj = []; + } + + console.log('[MAKI:DATASTORE]', name, '_get', 'db.get', 'will traverse:', err, tip, obj); + function resolveReferences(node, next) { + var context = this; + var key = context.key; + console.log('[MAKI:DATASTORE]', name, '_get', 'traverse', 'key', key, context, node); + if (typeof node !== 'string') return next(); + if (key === '@id') return next(); + + console.log('[MAKI:DATASTORE]', name, '_get', 'traverse', 'populating', key); + self.db._get(node, { + convert: true + }, function(err, item) { + if (err) console.error('[MAKI:DATASTORE]', '_get', 'error:', err); + if (!item) return next(); + console.log('[MAKI:DATASTORE]', name, '_get', 'key:', key, 'found:', item); + console.log('[MAKI:DATASTORE]', name, '_get', 'key:', key, 'replacing:', key, 'with', item, 'in', context.parent); + + console.log('[MAKI:DATASTORE]', name, '_get', 'key:', key, 'was:', context.parent[key], 'in', context.parent); + context.parent[key] = item; + console.log('[MAKI:DATASTORE]', name, '_get', 'key:', key, 'now:', context.parent[key]); + console.log('[MAKI:DATASTORE]', name, '_get', 'deep diving...', item); + // deep dive. + window.traverse(item, resolveReferences, function(inner) { + if (!inner) return next(); + console.log('[MAKI:DATASTORE]', name, '_get', 'inner:', inner); + next(); + }); + }); + } + + // TODO: make modular + window.traverse(obj, resolveReferences, function(final) { + console.log('[MAKI:DATASTORE]', '_get', path, 'final:', null, final); + return cb(null, final); + }); + }); + }); + + /*self.db._get(key, function(err, val) { + if (err) console.error(err); + if (val) return cb(null, val) && self.fire('datastore:miss', key); + self.fire('datastore:miss', key); + return cb('datastore:miss'); + });*/ + }, + _patch: function(key, ops, cb) { + // TODO: middlewares + var self = this; + console.log('[MAKI:DATASTORE]', 'datastore:patch:', key, ops); + self._get(key, function(err, obj) { + if (err) console.error(err); + console.log('[MAKI:DATASTORE]', 'applying to:', obj); + jsonpatch.apply(obj, ops); + console.log('[MAKI:DATASTORE]', 'obj now:', obj); + self._put(key, obj, function(err) { + if (err) console.error(err); + }); + }); + }, + _bundle: function(obj, cb) { + var self = this; + console.log('[MAKI:DATASTORE]', '_bundle', '_post', 'pre-parse', obj); + obj['@id'] = undefined; + console.log('[MAKI:DATASTORE]', '_bundle', '_post', 'post-parse', obj); + var worker = document.querySelector('maki-crypto-worker[name=datastore]'); + worker._digest(obj, function(err, hash) { + console.log('[MAKI:DATASTORE]', '_bundle', '_put', '_post', 'post-parse digest:', hash); + obj['@id'] = hash; + cb(err, obj); + }); + }, + _handleMiss: function(e, detail) { + return; + var self = this; + var key = e.detail; + console.log('[MAKI:DATASTORE]', '_handleMiss', e, detail); + if (self.private) return; + + // TODO: query network instead of server + $.getJSON(key, function(data) { + console.log('[MAKI:DATASTORE]', 'retrieved (from remote)', data); + if (!data) return; + self._put(key, data, function(err) { + if (err) console.error('[MAKI:DATASTORE]', '_handeMiss error:', err); + }); + }); + }, + _handlePatch: function(e) { + var self = this; + console.log('[MAKI:DATASTORE]', '_handlePatch', e.detail); + var channel = document.querySelector('maki-channel'); + channel._send('patch', { + channel: e.detail.key, + ops: e.detail.patches + }); + }, + _handleChange: function(e, detail) { + var self = this; + + console.log('[MAKI:DATASTORE]', '_handleChange', e, detail); + if (!detail) { + var detail = e.detail; + } + + var path = detail.path; + var val = detail.val; + var old = detail.old; + + /* if (!old) { + if (val instanceof Array) { + old = []; + } else { + old = {}; + } + } + + if (old) { + var worker = document.querySelector('maki-crypto-worker'); + var observer = jsonpatch.observe(old); + + console.log('[MAKI:DATASTORE]', 'extending', old, 'with', val); + var now = _.extend(old, val); + console.log('[MAKI:DATASTORE]', 'final:', now); + var patches = jsonpatch.generate(observer); + + console.log('[MAKI:DATASTORE]', 'patch set generated:', patches); + + var channel = document.querySelectorAll('maki-channel'); + /*channel._send('patch', { + channel: key, + ops: [{ op: 'add', }] + });**** + } */ + + var pattern = '[src="'+path+'"]'; + var elements = document.querySelectorAll(pattern); + console.log('[MAKI:DATASTORE]', 'elements bound to this key:', path, elements); + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + element._sync(); + } + }, + _sync: function() { + var elements = document.querySelectorAll('[src]'); + console.log('[MAKI:DATASTORE]', '_sync', elements); + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + if (typeof element._sync === 'function') { + console.log('[MAKI:DATASTORE]', 'syncing', element); + element._sync(); + } + } + }, + attached: function() { + var self = this; + console.log('[MAKI:DATASTORE]', 'attached'); + }, + ready: function() { + var self = this; + console.log('[MAKI:DATASTORE]', 'ready'); + document.addEventListener('key-value:tips:open', function() { + self.tips = document.querySelector('maki-key-value[name=tips][for='+self.name+']'); + }); + document.addEventListener('key-value:'+self.name+':open', function() { + console.log('[MAKI:DATASTORE]', 'key-value open received!'); + self.db = document.querySelector('maki-key-value[name='+self.name+']'); + + self.db.addEventListener('key-value:change', self._handleChange.bind(self)); + + self.fire('datastore:'+self.name+':open'); + self.fire('datastore:open'); + }); + //self.listen(self.db, 'key-value:change', '_handleChange'); + } + }); diff --git a/components/examples.jade b/components/examples.jade new file mode 100644 index 00000000..c4b45282 --- /dev/null +++ b/components/examples.jade @@ -0,0 +1,97 @@ +dom-module#maki-examples + template + .ui.vertical.segment + .ui.container + h2 Projects Using Maki + p We're really excited to have helped many people build awesome things. Here's a few of them, including special highlights when they've also shared their code! + + .ui.icon.message + i.icon.lab + .content + .header Building something cool? + p Go ahead and add it to the list! We'd love to highlight what you've built. Bonus points for being open source! 🍺 + + .ui.divided.items + template(is="dom-repeat", items="{{items}}") + .item + a.ui.tiny.image(href="{{item.uri}}") + template(if="{{item.image}}") + img(src="{{item.image}}") + template(else="{{item.source}}") + img(src="/img/image.png") + .content + .header + a(href="{{item.uri}}") {{item.name}} + template(if="{{item.source}}") + | + a.ui.label(href="{{item.source}}") + i.icon.code + | Source + p.description {{item.description}} + + script. + Polymer({ + is: 'maki-examples', + listeners: { + 'datastore:query': '_handleQuery', + 'state:change': '_applyState' + }, + properties: { + src: { + type: String, + observer: '_sourceChanged' + }, + resource: { + type: Object + }, + items: { + type: Array, + notify: true + }, + }, + _handleQuery: function(e, key) { + var self = this; + var datastore = document.querySelectorAll('maki-datastore')[0]; + console.log('[MAKI:COLLECTION]','_handleQuery:', e, key); + datastore._retrieve(key, function(err, data) { + if (!data) self.fire('datastore:miss', hash); + if (err) { + //console.error('_handleQuery error:', err); + data = []; + } + self.fire('state:change', data); + }); + }, + _applyState: function(e) { + var self = this; + var state = e.detail; + + if (!(state instanceof Array)) { + state = [state]; + } + + console.log('applying state', e, state); + self.items = state; + }, + _sourceChanged: function(source) { + var self = this; + var maki = document.querySelectorAll('maki-application')[0]; + console.log('[MAKI:COLLECTION]', 'collection sourceChanged:', source); + self.fire('datastore:query', source); + }, + _sync: function() { + var self = this; + console.log('[MAKI:COLLECTION]', '_sync'); + self.fire('datastore:query', self.src); + }, + ready: function() { + var self = this; + console.log('[MAKI:COLLECTION]', 'ready'); + }, + attached: function() { + var self = this; + var channel = document.querySelectorAll('maki-channel')[0]; + console.log('[MAKI:COLLECTION]', 'collection is attached:', self.src); + channel._subscribe(self.src); + } + }); diff --git a/components/identities.jade b/components/identities.jade new file mode 100644 index 00000000..761ae975 --- /dev/null +++ b/components/identities.jade @@ -0,0 +1,128 @@ +dom-module#maki-identities + template + maki-datastore(name="identity", private) + .ui.three.doubling.cards + template(is="dom-repeat", items="{{identities}}") + .ui.card + .image + img(src="/img/stevie.jpg") + .content + .header + //- TODO: break into its own component + maki-field(path="/name") + template(is="dom-if", if="{{item.name}}") + .value {{item.name}} + template(is="dom-if", if="{{!item.name}}") + .value anonymous + .ui.two.bottom.attached.buttons + template(is="dom-if", if="{{item.name}}") + .ui.button(on-tap="_beginEditing") change name + template(is="dom-if", if="{{!item.name}}") + .ui.bottom.attached.button(on-tap="_beginEditing") set name + .ui.button(on-tap="_delete") delete + script. + Polymer({ + is: 'maki-identities', + properties: { + identities: { + type: Array + } + }, + _handleChange: function(e) { + var self = this; + if (e.which === 13) { + e.preventDefault(); + self._lockName(); + } + + var field = $('maki-field[path="/name"] .value'); + var value = field.html(); + + var identity = self.identity; + + console.log('[MAKI:IDENTITIES]', identity); + identity.name = value; + + var db = document.querySelectorAll('maki-identity maki-datastore')[0]; + db._patch('/identities', [ + { op: 'replace', path: '/0', value: identity } + ], function(err) { + console.log('db._patch back:', err); + }); + + }, + _beginEditing: function() { + var self = this; + var field = $('maki-field[path="/name"] .value'); + var handler = _.debounce(self._handleChange, 250); + field.keypress(handler.bind(self)); + self._unlockName(); + field.focus(); + }, + _unlockName: function() { + var self = this; + var field = $('maki-field[path="/name"] .value'); + field.attr('contenteditable', true); + }, + _lockName: function() { + var self = this; + var field = $('maki-field[path="/name"] .value'); + field.attr('contenteditable', false); + }, + _list: function() { + var self = this; + console.log('identity datastore open, initializing work...'); + var db = document.querySelectorAll('maki-datastore[name=identity]')[0]; + var melody = document.querySelectorAll('melody-application')[0]; + + db._retrieve('/identities', function(err, identities) { + console.log('[MAKI:IDENTITIES]', 'retrieved:', err, identities); + if (err) console.error(err); + self.identities = identities; + self.identity = identities[0]; + melody.identity = identities[0]; + }); + }, + _store: function(identity) { + var self = this; + console.log('[MAKI:IDENTITIES]', '_storeIdentity', identity); + // TODO: only if autoregister enabled... + var db = document.querySelectorAll('maki-datastore[name=identity]')[0]; + var key = '/identities/' + identity.key.public.toString(); + + var clone = _.cloneDeep(identity); + clone.key.public = identity.key.public.toString(); + + db._store(key, clone, function(err) { + console.log('identity registered!', err); + }); + }, + _register: function(identity) { + var self = this; + console.log('[MAKI:IDENTITIES]', '_storeIdentity', identity); + // TODO: only if autoregister enabled... + var db = document.querySelectorAll('maki-datastore[name=melody]')[0]; + var key = '/identities/' + identity.key.public.toString(); + + var clone = _.cloneDeep(identity); + clone.key.public = identity.key.public.toString(); + + delete clone.key.private; + + db._store(key, clone, function(err) { + console.log('identity registered!', err); + }); + }, + _generate: function(done) { + // TODO: do this in a Web Worker to prevent UI jank + var Mnemonic = require('bitcore-mnemonic'); + var mnemonic = new Mnemonic(); + done(null, mnemonic); + }, + ready: function() { + var self = this; + var db = document.querySelectorAll('maki-identities maki-datastore')[0]; + console.log('[MAKI:IDENTITIES]', 'ready'); + document.addEventListener('datastore:identity:open', self._list.bind(self), false); + } + }); diff --git a/components/identity-card.jade b/components/identity-card.jade new file mode 100644 index 00000000..fbbf8036 --- /dev/null +++ b/components/identity-card.jade @@ -0,0 +1,10 @@ +dom-module#maki-identity-card + script. + Polymer({ + is: 'maki-identity-card', + attributes: { + identity: { + type: Object + } + } + }); diff --git a/components/identity.jade b/components/identity.jade new file mode 100644 index 00000000..aa340460 --- /dev/null +++ b/components/identity.jade @@ -0,0 +1,404 @@ +dom-module#maki-identity + template + maki-crypto-worker(name="identity") + maki-datastore(name="identity", for$="{{for}}", private) + a.item(href="/", on-tap="_reset") Reset + //- TODO: this should be a /people thing, not an identity + template(is="dom-if", if="{{!hasIdentities}}") + a.item(on-tap="_onboard") + i.icon.sign.in + | Sign In + template(is="dom-if", if="{{hasIdentities}}") + template(is="dom-if", if="{{!isLoggedIn}}") + .ui.dropdown.item + i.icon.sign.in + | Sign In + i.icon.dropdown + maki-identity-list.menu + template(is="dom-repeat", items="{{identities}}") + maki-identity-card.item(identity="{{item}}", on-tap="_selectIdentity") {{item.name}} + .green.icon.labeled.item(on-tap="_onboard") + i.icon.leaf + | Start Fresh + template(is="dom-if", if="{{isLoggedIn}}") + //-a.item(href="/settings") + i.icon.setting + a.item(href="/people/{{identity.name}}") + template(is="dom-if", if="{{isNamed}}") {{identity.name}} + template(is="dom-if", if="{{!isNamed}}") anonymous + .ui.button.item(on-tap="_logout") + i.icon.sign.out + | Sign Out + + maki-modal.ui.modal#identity-confirm + .header Let's introduce ourselves. How? + .content + .description + .ui.two.massive.stackable.buttons + .ui.blue.labeled.icon.button(on-tap="_importFromSeed") + i.icon.eyedropper + | Existing Seed + .or + .ui.green.right.labeled.icon.button(on-tap="_displayGeneratorModal") + i.icon.leaf + | Fresh Start + + .ui.icon.fluid.message + i.icon.idea + .content + .header Forget your worries, not your passwords. + p Maki-powered apps remember you, so you never have to click "forgot password" again. + a(href="/") Learn More » + + .actions + .ui.right.labeled.icon.button(on-tap="_closeSelectionModal") Some other time. + i.remove.icon + + maki-modal.ui.modal#identity-create + .header Identity Generator + .content + .description + maki-step-ladder + .clearing + + .actions + .ui.cancel.labeled.icon.button.hidden(on-tap="_displayNameModal") Nevermind, I'm done here. + i.remove.icon + + script(src="/js/lodash.min.js", async) + script(src="/assets/bitcore.min.js", async) + script(src="/assets/bitcore-mnemonic.min.js", async) + script. + Polymer({ + is: 'maki-identity', + properties: { + for: { type: String }, + seed: { type: String }, + words: { type: String }, + identity: { type: Object, notify: true, observer: '_identityChanged' }, + identityFull: { type: Object, }, + isLoggedIn: { type: Boolean, value: false }, + autoselect: { type: Boolean, value: false }, + hasIdentities: { type: Boolean, value: false }, + isNamed: { type: Boolean, value: false }, + display: { type: String } + }, + _generate: function(cb) { + var self = this; + console.log('[MAKI:IDENTITY]', '_generate'); + // TODO: do this in a Web Worker to prevent UI jank + var Mnemonic = require('bitcore-mnemonic'); + var mnemonic = new Mnemonic(); + + var key = mnemonic.toHDPrivateKey(); + var sub = key.derive('m/0'); + + self.seed = mnemonic; + self.words = mnemonic.toString(); + + var identity = { + id: sub.hdPublicKey.toString(), + _id: ObjectId().toString(), + seed: mnemonic.toString(), + //address: sub.hdPublicKey.toAddress(), + key: { + hd: true, + private: key.toString(), + public: sub.hdPublicKey.toString() + } + }; + + var clone = _.cloneDeep(identity); + delete clone.seed; + delete clone.key.private; + + self.identity = clone; + self.identityFull = identity; + + self._save(cb); + }, + _save: function(cb) { + var self = this; + var datastore = document.querySelector('maki-datastore[name=identity]'); + var identity = self.identityFull; + console.log('[MAKI:IDENTITY]', '_save', identity); + + datastore._upsert('/identities', { + 'key.public': identity.key.public + }, identity, function(err) { + if (err) console.log('err', err); + + console.log('[MAKI:IDENTITY]', '_upsert', 'callback', err, identity); + + datastore._query('/identities', { + 'key.public': identity.key.public + }, function(err, identities) { + if (err) console.error('[MAKI-IDENTITY]', '_save', '_query', err); + console.log('[MAKI-IDENTITY]', '_save', '_query', 'identities', identities); + cb(err, identities); + }); + }); + }, + // publishes to the local application scoped for this control + // makes the application aware of an identity + _publish: function(cb) { + var self = this; + console.log('[MAKI:IDENTITY]', '_publish'); + if (!cb) cb = new Function(); + + var clone = _.cloneDeep(self.identity); + delete clone.seed; + delete clone.key.private; + + // a simple stub to emulate only having a single identity. + // just queries the application datastore and assumes the first identity + // it finds is ours. net effect: will always overwrite one user. + var datastore = document.querySelector('maki-datastore[for='+self.for+']'); + console.log('[MAKI:IDENTITY]', '_publish', 'query', datastore); + // TODO: add unique keys to `maki-datastore` and/or `maki-resource`. + datastore._query('/identities', { + 'key.public': clone.key.public + }, function(err, identities) { + console.log('[MAKI:IDENTITY]', '_publish', 'melody knows these identities:', err, identities); + console.log('[MAKI:IDENTITY]', '_publish', 'you are:', clone.key.public); + + async.filter(identities, function(identity, callback) { + var doesMatch = (identity.key.public === clone.key.public); + console.log('[MAKI:IDENTITY]', '_publish', 'comparing:', identity.key.public, clone.key.public); + callback(null, doesMatch); + }, function(err, known) { + console.log('[MAKI:IDENTITY]', '_publish', 'matching', err, known); + if (!known.length) { + // TODO: transform into JSON-LD + datastore._post('/identities', clone, function(err, stored) { + console.log('[MAKI:IDENTITY]', '_publish', 'datastore put, identity return:', err, stored); + cb(err, stored); + }); + } else { + console.log('[MAKI:IDENTITY]', '_publish', 'datastore returning obj:', known[0]); + cb(err, known[0]); + } + }); + }); + + /*$.ajax({ + type: 'POST', + url: '/identities', + data: clone, + headers: { + Accept: 'application/json' + }, + success: function(data) { + console.log('[MAKI:IDENTITY]', 'published:', data); + self.identity._id = data._id; + cb(null, data); + } + });*/ + }, + _reset: function() { + var dbs = [ + 'IDBWrapper-fabric-key-value', + 'IDBWrapper-identity-key-value', + 'IDBWrapper-identity:tips-key-value', + 'IDBWrapper-melody-key-value', + 'IDBWrapper-melody:tips-key-value', + 'NeDB', + 'fabric-identity', + ]; + + dbs.forEach(function(name) { + var req = indexedDB.deleteDatabase(name); + req.onsuccess = function () { + console.log('[MAKI:IDENTITY]', "Deleted database successfully"); + }; + req.onerror = function () { + console.log('[MAKI:IDENTITY]', "Couldn't delete database"); + }; + req.onblocked = function () { + console.log('[MAKI:IDENTITY]', "Couldn't delete database due to the operation being blocked"); + }; + }); + + }, + _authenticate: function() { + + }, + _displaySelectionModal: function() { + $('.modal#identity-confirm').modal('show'); + }, + _closeSelectionModal: function() { + $('.modal#identity-confirm').modal('hide'); + }, + _displayGeneratorModal: function() { + $('.modal#identity-create').modal('show'); + }, + _closeGeneratorModal: function() { + $('.modal#identity-create').modal('hide'); + }, + _initializeDropdown: function() { + $('.ui.dropdown').dropdown({ + action: 'nothing' + }); + }, + _initiateGeneration: function() { + var self = this; + self._closeSelectionModal(); + self._generate(); + }, + _onboard: function() { + var self = this; + self._select(); + }, + _sign: function(input, done) { + var Message = require('bitcore-message'); + }, + _identityChanged: function(identity, old) { + var self = this; + self.identityFull = identity; + + if (self.identity) { + self.isLoggedIn = true; + } + if (self.identities) { + self.hasIdentities = true; + } + if (identity && identity.name) { + self.isNamed = true; + self.fire('identity', identity); + } + }, + _register: function() { + var self = this; + console.log('[MAKI:IDENTITY]', '_register', 'calling publish...'); + self._publish(function(err, identity) { + if (err) console.error(err); + + var identity = self.identity; + console.log('[MAKI:IDENTITY]', '_register', '_publish', 'identity:', identity); + + var datastore = document.querySelector('maki-datastore[name=melody]'); + datastore._bundle(identity, function(err, ident) { + console.log('[MAKI:IDENTITY]', '_register', '_publish', 'bundled:', ident); + console.log('[MAKI:IDENTITY]', '_register', '_publish', 'querying...', ident['@id']); + datastore._query('/people', { + identity: ident['@id'] + }, function(err, known) { + console.log('[MAKI:IDENTITY]', '_register', '_publish', 'melody knew:', err, known); + if (err || known.length) { + return console.log('[MAKI:IDENTITY]', '_register', 'application "melody" knew identity:', ident['@id'], 'as', known[0].name); + } + + datastore._post('/people', { + id: identity.name.toLowerCase(), + _id: ObjectId().toString(), + name: identity.name, + slug: identity.name.toLowerCase(), + identity: ident['@id'] + }, function(err, person) { + console.log('[MAKI:IDENTITY]', '_register', 'datastore put, person return:', err, person); + }); + }); + + + }); + + /* $.ajax({ + type: 'POST', + url: '/people', + data: { + name: identity.name, + identity: identity.key.public, + _identity: identity._id + }, + headers: { + Accept: 'application/json' + }, + success: function(data, res) { + console.log('[MAKI:IDENTITY]', '_register result:', res); + } + }); */ + }); + }, + _select: function() { + var self = this; + var db = document.querySelector('maki-datastore[name=identity]'); + var melody = document.querySelector('melody-application'); + + console.log('[MAKI:IDENTITY]', '_select'); + db._get('/identities', function(err, identities) { + console.log('[MAKI:IDENTITY]', 'retrieved', identities); + self.identities = identities || []; + self._displaySelectionModal(); + }); + }, + _selectIdentity: function(e, detail) { + var self = this; + console.log('[MAKI:IDENTITY]', '_selectIdentity', e, detail); + var manager = document.querySelector('maki-identity'); + e.target.classList.add('loading'); + manager.identity = e.target.identity; + manager._register(); + }, + _startAgent: function() { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.register('/worker.js').then(function(reg) { + console.log('[MAKI:IDENTITY]', 'service worker installled!'); + + navigator.serviceWorker.addEventListener('message', function(event) { + console.log('[MAKI:IDENTITY]', 'serviceworker message:', event ); + }); + + }).catch(function(err) { + console.log('[MAKI:IDENTITY]', 'service worker failed:', err); + }); + } + }, + _attach: function() { + var self = this; + var localIdentityStore = document.querySelector('maki-datastore[name=identity]'); + console.log('[MAKI:IDENTITY]', '_attach', 'querying...'); + //self._startAgent(); + // this emulates the HTTP API, but don't be fooled – this could be + // replaced with anything. use the tools you have, right? :) + // TODO: look at this. + //localIdentityStore._get('/identities', function(err, identities) { + localIdentityStore._query('/identities', {}, function(err, identities) { + console.log('[MAKI:IDENTITY]', '_attach', 'recovered:', identities); + + if (err) console.warn('[MAKI:IDENTITY]', 'retrieved', identities); + if (!identities) identities = []; + self.identities = identities; + if (identities.length) { + self.hasIdentities = true; + if (self.autoselect) { + self.identity = identities[0]; + console.warn('[MAKI:IDENTITY]', 'autoselect _register', self.identity); + self._register(); + } + } + self._initializeDropdown(); + }); + }, + _logout: function() { + var self = this; + self.identity = null; + self.isLoggedIn = false; + console.log('[MAKI:IDENTITY]', '_logout', self.identity); + self.fire('identity', null); + // TODO: why is a delay required here? + setTimeout(function() { + self._initializeDropdown(); + }, 50); + }, + attached: function() { + var self = this; + console.log('[MAKI:IDENTITY]', 'attached'); + self._initializeDropdown(); + }, + ready: function() { + var self = this; + console.log('[MAKI:IDENTITY]', 'ready'); + document.addEventListener('datastore:identity:open', self._attach.bind(self), false); + //self.addEventListener('identity', self._initializeDropdown.bind(self), false); + } + }); diff --git a/components/index.jade b/components/index.jade new file mode 100644 index 00000000..000b0df2 --- /dev/null +++ b/components/index.jade @@ -0,0 +1,42 @@ +dom-module#maki-index + template + .ui.container + .ui.header + h1.huge Hello, {{config.service.name}}. + h2 {{config.service.mission}} + + p {{config.service.description}} + + //-.ui.stackable.three.column.grid + for point in config.service.points + .column + .ui.fluid.card + .content + h2.header #{ point.header } + //- TODO: use marked config, not a regex, to fix errant

tags + p.description + | !{ markdown( point.description ).replace(/

(.*)<\/p>/, '$1') } + if (point.action) + a.ui.bottom.attached.button(href="#{point.action.link}") !{point.action.text} + + //-.ui.stackable.three.column.grid + .column + h3 Resources + .ui.list + each resource in resources + if (!resource.internal) + a.item(href="#{resource.routes.query}") #{resource.plural} + + .column + h3 Services + + .ui.list + each service in services + a.item(href="#{service.protocol}://#{service.authority}") #{service.name} + script. + Polymer({ + is: 'maki-index', + ready: function() { + console.log('[MAKI:INDEX]', 'ready'); + } + }); diff --git a/components/item.jade b/components/item.jade new file mode 100644 index 00000000..04e91bb8 --- /dev/null +++ b/components/item.jade @@ -0,0 +1,35 @@ +dom-module#maki-item + template + .ui.card + .image + img(src="/img/maki-logo.png") + .content + a.header(href="{{item.href}}") {{item.name}} + p.description {{item.description}} + template(if="{{item.action}}") + a.ui.bottom.attached.button(if="{{item.action}}", href="{{item.action.href}}") {{item.action.text}} + + script(src="/js/jquery.js", async) + script. + Polymer({ + is: 'maki-item', + properties: { + src: { + type: String, + //observer: '_srcChanged' + }, + hash: { + type: String + }, + item: { + type: Object + } + }, + created: function() { + var self = this; + console.log('created!', self.item); + }, + _srcChanged: function() { + console.log('source changed for item'); + } + }); diff --git a/components/key-value.jade b/components/key-value.jade new file mode 100644 index 00000000..b2c0009c --- /dev/null +++ b/components/key-value.jade @@ -0,0 +1,87 @@ +//- maki-key-value +//- keeps a simple key:value mapping +//- backed by LevelDB +dom-module#maki-key-value + //-script(src="/assets/level.js") + script. + Polymer({ + is: 'maki-key-value', + properties: { + name: { + type: String + }, + for: { + type: String + }, + level: { + type: Object + } + }, + _get: function(key, opts, cb) { + var self = this; + if (typeof opts == 'function') { + cb = opts; + opts = {}; + } + console.log('[MAKI:KV]', '_get', 'key', key); + self.level.get(key, { + asBuffer: false + }, function(err, val) { + + console.log('[MAKI:KV]', '_get', 'valfor', key, val); + + if (err) console.error(err); + if (!val) return cb('No such value: ' + key, null); + if (opts.convert) { + console.log('[MAKI:KV]', '_get', 'converting:', val); + try { + val = JSON.parse(val); + } catch (e) { + console.error('[MAKI:KV]', '_get', e); + } + } + console.log('[MAKI:KV]', '_get', key, val); + return cb(err, val); + }); + }, + _set: function(key, val, cb) { + var self = this; + console.log('[MAKI:KV]', '_set', key, val); + + if (typeof val !== 'string') { + val = JSON.stringify(val); + } + + // TODO: use async. + self.level.get(key, { + asBuffer: false + }, function(err, old) { + if (err) console.error(err); + self.level.put(key, val, function(err) { + if (err) console.error(err); + self.fire('key-value:change', { + key: key, + val: val, + old: old + }); + console.log('[MAKI:KV]', '_set', key, val); + return cb(err); + }); + }); + }, + ready: function() { + var self = this; + var name = self.name + '-key-value'; + if (self.for) { + name = self.for + ':' + name; + } + self.level = level(name); + self.level.open(function(err) { + if (err) console.error(err); + var event = new Event('key-value:open'); + document.dispatchEvent(event); + var event = new Event('key-value:'+self.name+':open'); + document.dispatchEvent(event); + }); + } + }); diff --git a/components/maki-splash.jade b/components/maki-splash.jade new file mode 100644 index 00000000..9f7502f8 --- /dev/null +++ b/components/maki-splash.jade @@ -0,0 +1,93 @@ +dom-module#maki-splash + style. + #navigation { + width: 100%; + } + + template + .ui.inverted.vertical.masthead.center.aligned.segment + .ui.text.container + h1.ui.inverted.header Code less. + h2 #{config.service.name} is !{config.service.mission} + + pre(style="font-size: 1.2em; margin-top: 2em;") + code.nohighlight. + npm install martindale/maki --save + + a.ui.huge.primary.button(href="/docs") + | Build Your MVP Faster + i.right.chevron.icon + + .ui.vertical.stripe.segment + .ui.middle.aligned.stackable.grid.container + .ui.equal.width.stackable.internally.celled.grid + .center.aligned.row + for point in config.service.points + .column + h3.header #{ point.header } + //- TODO: use marked config, not a regex, to fix errant

tags + p.description + | !{ markdown( point.description ).replace(/

(.*)<\/p>/, '$1') } + if (point.action) + a.ui.huge.fluid.button(href="#{point.action.link}") !{point.action.text} + + .ui.vertical.stripe.segment + .ui.text.container + h3.ui.header Powerful Helpers + p Maki comes with a suite of powerful tools, out of the box. Each is completely optional and replaceable! + + h4.ui.horizontal.header.divider The Power Suite + + p By default, Maki apps are composed with Jade, styled with Semantic UI, and bound together by custom Web Components (as implemented by Polymer). + pre.jade + code. + dom-module#maki-application + + template + maki-datastore(name="my-app") + maki-channel(autoconnect, reconnect="true") + + .ui.page + .row + message-list(src="/messages/custom-room") + .row + message-form + + p This allows you to write your application once, and we can derive native interfaces directly — by default, provided by React Native. + + h2.ui.header Loosely Coupled + p Have a better way to do things? Have a different compile target? All Maki components are optional, and can even be outright removed without disrupting the other components of the system. + + + .ui.vertical.stripe.quote.segment + .ui.equal.width.stackable.internally.celled.grid + .center.aligned.row + .column + h3 "This feels like the invention of the transistor." + p Will Ricketts, SailsJS Contributor + .column + h3 We're building something new. + a.ui.huge.primary.button(href="/developers/getting-involved") Come join us. + i.icon.right.chevron + + script(src="/js/highlight.pack.js") + script. + + Polymer({ + is: 'maki-splash', + ready: function() { + hljs.initHighlightingOnLoad(); + } + }); + + /*(function () { + window._BlabNS = {}; + window._BlabNS.user_id = '7f64ecb8166943cd896ea28ff8d0c5d0'; + window._BlabNS.enableMobile = true; + var s = document.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://cdn.blab.im/tinyplayer/js/sdk.js'; + var x = document.getElementsByTagName('script')[0]; + x.parentNode.insertBefore(s, x); + })();*/ diff --git a/components/navbar.jade b/components/navbar.jade new file mode 100644 index 00000000..6d50e8b8 --- /dev/null +++ b/components/navbar.jade @@ -0,0 +1,31 @@ +dom-module#maki-navbar + template + .ui.large.secondary.inverted.pointing.menu + a.toc.item + i.sidebar.icon + a.item(href="/") + img.tooltipped(src="/img/maki-icon.png", title="The hand-rolled, carefully crafted goodness that is Maki.", data-variation="inverted", style="max-height: 2em; max-width: 2em; margin-bottom: -0.75em; margin-right: -0.5em;") + a.item(href="/") + i.icon.left(class="#{ config.service.icon || 'lab' }") + | #{config.service.name} + each resource in resources + if (!resource.internal) + a.item(href="#{resource.routes.query}") + if (resource.options.icon) + i.icon(class="#{resource.options.icon}") + | #{resource.plural} + + //- block for prepend/append/replace-able menu items + block mainMenu + .right.menu + a.item.tooltipped(class="btn btn-default", href="bitcoin:1EBdAcEhP4Qn7sihJoCqinLC8A14zqHJ7R", title="If you have a bitcoin wallet installed and configured, this will launch it.") + i.icon.bitcoin(alt="Bitcoin", title="Donate Bitcoin") + | Donate » + a.item.tooltipped(href="#{ config.service.source }", title="View the Source, Luke! Source code for this site.") + i.fork.icon + | Code » + + script. + Polymer({ + is: 'maki-navbar' + }); diff --git a/components/peer-list.jade b/components/peer-list.jade new file mode 100644 index 00000000..4b7380ef --- /dev/null +++ b/components/peer-list.jade @@ -0,0 +1,25 @@ +dom-module#maki-peer-list + template + maki-datastore(name="fabric") + h2 Currently Connected Peers + .ui.cards + template(is="dom-repeat", items="{{peers}}") + .ui.card + .content + .header {{item.id}} + script. + Polymer({ + is: 'maki-peer-list', + properties: { + peers: Array + }, + ready: function() { + var self = this; + var fabric = document.querySelector('maki-datastore[name=melody]'); + console.log('[FABRIC:PEER-LIST]', 'ready'); + fabric._retrieve('/peers', function(err, peers) { + console.log('[FABRIC:PEER-LIST]', 'ready _retrieve', err, peers); + self.set('peers', peers); + }); + } + }); diff --git a/components/peer-manager.jade b/components/peer-manager.jade new file mode 100644 index 00000000..9eb71b21 --- /dev/null +++ b/components/peer-manager.jade @@ -0,0 +1,261 @@ +dom-module#maki-peer-manager + template + //-maki-datastore(name="fabric") + script(src="/assets/peer.min.js", async) + script. + Polymer({ + is: 'maki-peer-manager', + properties: { + peer: { + type: Object + }, + connections: { + type: Object, + value: {} + }, + peers: { + type: Object, + value: {}, + //observer: '_peersChanged', + notify: true + } + }, + observers: [ + //'_peersChanged(peers)' + '_peersChangedDeep(peers.*)' + ], + _broadcast: function(msg) { + var self = this; + console.log('[MAKI:PEER-MANAGER]', '_broadcast', msg); + if (typeof msg !== 'string') { + msg = JSON.stringify(msg); + } + + Object.keys(self.connections).forEach(function(id) { + var conn = self.connections[id]; + console.log('[MAKI:PEER-MANAGER]', 'connection iterator:', id); + conn.send(msg); + }); + }, + _relay: function(msg) { + var self = this; + console.log('[MAKI:PEER-MANAGER]', '_relay', msg); + self._broadcast(msg); + }, + _peerWith: function(id) { + var self = this; + if (!self.peer) return console.error('[MAKI:PEER-MANAGER]', 'no local peer'); + console.log('[MAKI:PEER-MANAGER]', '_peerWith', id, 'from:', self.peer.id)//, id); + if (id === self.peer.id) return console.error('[MAKI:PEER-MANAGER]', 'cannot peer with self'); + if (self.connections[id]) { + console.log('[MAKI:PEER-MANAGER]', 'connection exists!'); + } else { + var conn = self.peer.connect(id); + conn.on('open', function() { + conn.on('data', function(data) { + console.log('[MAKI:PEER-MANAGER]', 'connection data:', data); + + var channel = document.querySelector('maki-channel'); + channel._handleMessage({ + data: data + }); + + }); + self.connections[id] = conn; + }); + } + }, + _peersChangedDeep: function(change) { + var self = this; + console.log('[MAKI:PEER-MANAGER]', '_peersChangedDeep', change); + + var peer = change.value; + + if (peer && peer.state !== 'connected') { + return self._peerWith(peer.id); + } + + }, + _peersChanged: function(peers, old) { + var self = this; + console.log('[MAKI:PEER-MANAGER]', '_peersChanged', peers, old); + + Object.keys(peers).forEach(function(id) { + console.log('[MAKI:PEER-MANAGER]', 'iterating over:', id); + var peer = self.peers[id]; + if (peer && peer.state !== 'connected') { + return self._peerWith(id); + } + }); + + //setTimeout(self._connect.bind(self), 2500); + }, + _receivePeerChange: function(e) { + var self = this; + var db = document.querySelector('maki-datastore[name=melody]'); + console.log('[MAKI:PEER-MANAGER]', 'found datastore change:', e);//, detail); + if (e.detail.key === '/peers') { + var knownPeerIDs = Object.keys(self.peers); + var others = e.detail.val.map(function(x) { + return x.id; + }); + + var newPeerIDs = _.difference(others, knownPeerIDs); + + /*newPeerIDs.forEach(function(id) { + self._peerWith(id); + });*/ + + console.log('[MAKI:PEER-MANAGER]', 'peering with:', newPeerIDs[0]); + + self._peerWith(newPeerIDs[0]); + + console.log('[MAKI:PEER-MANAGER]', 'currently known', knownPeerIDs); + console.log('[MAKI:PEER-MANAGER]', 'others', others); + console.log('[MAKI:PEER-MANAGER]', 'newPeerIDs', newPeerIDs); + + } + }, + _register: function(done) { + var self = this; + console.log('[MAKI:PEER-MANAGER]', '_register', self.peer); + + var obj = { + id: self.peer.id + }; + + $.ajax({ + type: 'POST', + url: '/peers', + data: obj, + headers: { + 'Accept': 'application/json' + } + }).done(function(data) { + console.log('[MAKI:PEER-MANAGER]', '_register success:', data); + done(); + }).error(function(data) { + console.log('[MAKI:PEER-MANAGER]', '_register error:', data); + done(); + }); + }, + ready: function() { + var self = this; + console.log('[MAKI:PEER-MANAGER]', 'ready'); + /*var db = document.querySelector('maki-datastore[name=melody]'); + db.addEventListener('datastore:change', function(e) { + console.log('[MAKI:PEER-MANAGER]', 'found datastore change:', e); + });*/ + // TODO: get peerJS server working directly on the edge node + /*var options = { + host: window.location.hostname, + port: window.location.port, + path: '/peerjs' + };*/ + + var options = { + key: 'i31eg2i9x5p9o1or' + }; + // TODO: pass a peer ID based on a cryptographic identity + var peer = new Peer(options); + self.peer = peer; + + peer.on('connection', function(conn) { + console.log('[MAKI:PEER-MANAGER]', 'inbound connection', conn); + self.connections[conn.peer] = conn; + }); + + peer.on('open', function() { + console.log('[MAKI:PEER-MANAGER]', 'peer id:', peer.id); + self._register(function(err) { + self.peers[peer.id] = peer; + self.set('peers.' + peer.id, peer); + self.notifyPath('peers', self.peers); + + var db = document.querySelector('maki-datastore[name=melody]'); + db.addEventListener('datastore:change', self._receivePeerChange.bind(self)); + console.log('[MAKI:PEER-MANAGER]', 'peers now:', self.peers); + }); + }); + + /*var alice = new Peer({ + initiator: true, + trickle: false + }); + alice.on('error', function(err) { + console.error('[MAKI:PEER-MANAGER]', '(alice) error:', err); + }); + alice.on('signal', function(data) { + console.log('[MAKI:PEER-MANAGER]', '(alice) signal:', data); + bob.signal(data); + }); + alice.on('message', function(msg) { + console.log('[MAKI:PEER-MANAGER]', '(alice) message:', msg); + }); + alice.on('connect', function() { + console.log('[MAKI:PEER-MANAGER]', '(alice) connect'); + alice.send('Well hello there!'); + }); + + var bob = new Peer({ + //initiator: true, + trickle: false + }); + bob.on('error', function(err) { + console.error('[MAKI:PEER-MANAGER]', '(bob) error:', err); + }); + bob.on('signal', function(data) { + console.log('[MAKI:PEER-MANAGER]', '(bob) signal:', data); + alice.signal(data); + }); + bob.on('message', function(msg) { + console.log('[MAKI:PEER-MANAGER]', '(bob) message:', msg); + }); + bob.on('connect', function() { + console.log('[MAKI:PEER-MANAGER]', '(bob) connect'); + bob.send('Well hello there!'); + });*/ + + }, + _connect: function() { + console.log('[MAKI:PEER-MANAGER]', '_connect'); + + // TODO: get peerJS server working directly in Maki server + var options = { + host: window.location.hostname, + port: window.location.port, + path: '/peerjs' + }; + + var options = { + key: 'i31eg2i9x5p9o1or' + }; + + var alice = new Peer('alice', options); + var aliceConn = alice.connect('bob'); + aliceConn.on('open', function() { + console.log('[MAKI:PEER-MANAGER]', '(alice) open'); + aliceConn.send('ahem. hello there.'); + }); + alice.on('connection', function(peer) { + console.log('[MAKI:PEER-MANAGER]', '(alice) connection:', peer); + peer.on('data', function(data) { + console.log('[MAKI:PEER-MANAGER]', '(alice) data:', data); + }); + }); + + var bob = new Peer('bob', options); + var bobConn = bob.connect('alice'); + bobConn.on('open', function() { + console.log('[MAKI:PEER-MANAGER]', '(bob) open'); + bobConn.send('ahem. hello there.'); + }); + bob.on('connection', function(peer) { + console.log('[MAKI:PEER-MANAGER]', '(bob) connection:', peer); + peer.on('data', function(data) { + console.log('[MAKI:PEER-MANAGER]', '(bob) data:', data); + }); + }); + + }, + }); diff --git a/components/resource.jade b/components/resource.jade new file mode 100644 index 00000000..1ee8caaf --- /dev/null +++ b/components/resource.jade @@ -0,0 +1,29 @@ +dom-module#maki-resource + script(src="/assets/nedb.min.js", async) + script. + Polymer({ + is: 'maki-resource', + properties: { + name: { + type: String + }, + store: { + type: Object + }, + definition: { + type: Object + } + }, + _load: function() { + var self = this; + console.log('[MAKI:RESOURCE]', '_load', self.name); + self.store = new Nedb({ + filename: self.name, + autoload: true + }); + }, + ready: function() { + var self = this; + console.log('[MAKI:RESOURCE]', 'ready', self.name); + } + }); diff --git a/components/step-ladder.jade b/components/step-ladder.jade new file mode 100644 index 00000000..5633907c --- /dev/null +++ b/components/step-ladder.jade @@ -0,0 +1,158 @@ +dom-module#maki-step-ladder + style. + .hidden { + display: none; + } + template + .ui.three.steps + .active.step(data-step="generate") + i.leaf.icon + .content + .title Generate + .description Create a key. + .step(data-step="secure") + i.icon.lock + .content + .title Secure + .description Keep it safe. + .step(data-step="configure") + i.icon.setting + .content + .title Configure + .description Name yourself. + template(is="dom-repeat", items="{{steps}}") + .step x:{{item}} + + .step-view(data-step="generate") + .ui.bottom.attached.clearing.segment + h3 This is a different way. + p Instead of remembering passwords, your computer will always remember you. You can re-invent yourself any time you want, and even switch back and forth. + p But it's important to keep this one thing, the seed. The seed is a short list of words that can be used to restore your identity. Once we give it to you, we don't have it anymore. + p If you're ready to save your seed, generate it by using the button below. + .right.floated.buttons + a.ui.yellow.huge.fluid.button(on-tap="_startGenerator") + i.icon.plug + | Generate Seed + .step-view(data-step="secure") + .ui.bottom.attached.clearing.segment + h3 Write this down. + p This is your seed. It can be used to sign in as you anywhere, any time. Write it down and put it somewhere very safe. + pre + code {{words}} + p If you lose your seed, it's gone. We cannot recover it for you. Make sure you've really got it. + a.ui.huge.fluid.green.button(on-tap="_moveToConfigure") + i.icon.checkmark + | Yep, I've written it down. + .step-view(data-step="configure") + .ui.bottom.attached.clearing.segment + h3 Give yourself a name! + p This is how other people will see you! You can change it at any time, but then people might forget you. Make it memorable! + .ui.large.form + .field + label Your Name + input(type="text", placeholder="SomeUsername", name="name", value="{{identity.name}}") + .button.ui.positive.right.labeled.huge.icon.fluid.button(type="submit", on-tap="_setName") I'm happy. + i.right.chevron.icon + script. + Polymer({ + is: 'maki-step-ladder', + properties: { + words: { + type: String + }, + steps: { + type: Object + }, + step: { + type: String, + observer: '_stepChanged', + notify: true + } + }, + _createIdentity: function() { + var self = this; + var manager = document.querySelector('maki-identity'); + var button = document.querySelector('.step-view[data-step=generate] .segment .button'); + var step = document.querySelector('.step[data-step=generate]'); + var next = document.querySelector('.step[data-step=secure]'); + manager._generate(function(err, identity) { + console.log('generate complete:', err); + button.classList.remove('loading'); + step.classList.remove('active'); + next.classList.add('active'); + self.words = manager.words; + self.step = 'secure'; + }); + }, + _setName: function(e) { + e.preventDefault(); + var self = this; + var manager = document.querySelector('maki-identity'); + var name = $('*[data-step=configure] input[name=name]').val(); + var step = document.querySelector('.step[data-step=configure]'); + + $('*[data-step=configure] input[name=name]').val(''); + + console.log('[MAKI:STEP-LADDER]', '_setName', name); + // hack. + // TODO: fix this + manager.identity.name = name; + manager.identityFull.name = name; + // other old dust. unsure if necessary. + manager.set('identity.name', name); + manager.isNamed = true; + + console.log('[MAKI:STEP-LADDER]', '_setName', 'result:', manager.identity.name); + + manager._save(function(err) { + step.classList.remove('active'); + manager._register(); + manager._closeGeneratorModal(); + self.step = 'generate'; + }); + }, + _moveToConfigure: function() { + var self = this; + var step = document.querySelector('.step[data-step=secure]'); + var next = document.querySelector('.step[data-step=configure]'); + step.classList.remove('active'); + next.classList.add('active'); + self.step = 'configure'; + }, + _stepChanged: function(step) { + var self = this; + console.log('[MAKI:STEP-LADDER]', '_stepChanged', step); + + var steps = document.querySelectorAll('.step-view'); + console.log('[MAKI:STEP-LADDER]', 'pages found:', steps); + + for (var i = 0; i < steps.length; i++) { + var el = steps[i]; + var name = el.getAttribute('data-step'); + var cond = (self.step !== name); + var step = document.querySelector('.step[data-step='+name+']'); + + console.log('[MAKI:STEP-LADDER]', '_stepChanged cond', cond); + if (cond) { + el.classList.add('hidden'); + step.classList.remove('active'); + } else { + el.classList.remove('hidden'); + step.classList.add('active'); + } + } + }, + _startGenerator: function(e) { + var self = this; + var button = document.querySelector('.step-view[data-step=generate] .segment .button'); + + button.classList.add('loading'); + + self._createIdentity(); + + }, + attached: function() { + var self = this; + self.step = 'generate'; + } + }); diff --git a/docs/components.md b/docs/components.md new file mode 100644 index 00000000..1a3b3dad --- /dev/null +++ b/docs/components.md @@ -0,0 +1,16 @@ +## Components + + +Components reside in `components/`. + +### Creating a Component + + + + +### Special Components +Maki exposes a number of Components for your convenience. Most of the time, you +won't need to access these items directly. + +#### `` +Creates a browser datastore for Resources. diff --git a/lib/Maki.js b/lib/Maki.js index d304a49e..0c6270f6 100644 --- a/lib/Maki.js +++ b/lib/Maki.js @@ -61,6 +61,15 @@ Maki.prototype.define = function( name , options ) { Maki.prototype.use = function( plugin ) { var self = this; + if (!plugin.extends) { + plugin.extends = {}; + } + + if (plugin.provides) { + Object.keys(plugin.provides).forEach(function(name) { + self.define(name, plugin.provides[name]); + }); + } if (plugin.extends.resources) { Object.keys( plugin.extends.resources ).forEach(function( n ) { @@ -105,11 +114,15 @@ Maki.prototype.serve = function( services , cb ) { self.resources['Index'] = new self.Resource('Index', { name: 'Index', template: 'index', + components: { + query: 'maki-splash', + get: 'maki-splash' + }, routes: { query: '/' }, static: true, - internal: true + //internal: true }); } @@ -183,7 +196,7 @@ Maki.prototype.bootstrap = function(done) { '/views/layouts', '/views/partials' ]; - + if (!done) { var done = new Function(); } diff --git a/lib/Resource/index.js b/lib/Resource/index.js index 1b25c7d7..23e72592 100644 --- a/lib/Resource/index.js +++ b/lib/Resource/index.js @@ -1,3 +1,4 @@ +var fs = require('fs'); var util = require('util'); var pluralize = require('pluralize'); var pathToRegex = require('path-to-regexp'); @@ -21,6 +22,7 @@ var Resource = function( name , options ) { if (!options.routes) options.routes = {}; if (!options.methods) options.methods = {}; if (!options.templates) options.templates = {}; + if (!options.components) options.components = {}; if (!options.plugins) options.plugins = []; if (!options.requires) options.requires = []; if (!options.handlers) options.handlers = {}; @@ -49,6 +51,7 @@ var Resource = function( name , options ) { self.synopsis = options.synopsis || 'Resource.'; self.description = options.description || 'A Resource available on this server.'; self.template = options.template || nameLower; + self.templates = options.templates; self.routes = {}; self.paths = { query: new RegExp( self.routes.query ) }; @@ -59,10 +62,9 @@ var Resource = function( name , options ) { get: nameLower, create: nameLower }); - self.templates = { - query: options.templates.query || options.template || (options.singular) ? nameLower : collectionName, - get: options.templates.get || nameLower - }; + + if (!self.templates.query) self.templates.query = options.template || (options.singular) ? nameLower : collectionName; + if (!self.templates.get) self.templates.get = options.template || nameLower; if (self.options.routes) self.routes = _.merge( self.routes , self.options.routes ); @@ -174,10 +176,10 @@ Resource.prototype.attach = function( maki ) { maki: maki, // <- le sigh. can we do this another way? resource: self }); - + self.Schema.methods.Resource = self; self.Schema.methods.Resources = maki.resources; - + Object.keys( self.options.methods ).forEach(function( name ) { self.Schema.methods[ name ] = self.options.methods[ name ]; }); @@ -211,19 +213,19 @@ Resource.prototype.attach = function( maki ) { } }); - + if (self.options.indices && self.options.indices instanceof Array) { self.options.indices.forEach(function(index) { var fields = {}; - + index.fields.forEach(function(field) { fields[field] = 1; }); - + var opts = { unique: index.unique || false }; - + self.Schema.index(fields, opts); }); } @@ -238,7 +240,9 @@ Resource.prototype.attach = function( maki ) { self.Schema.plugin( plugin ); }); - self.Model = maki.mongoose.model( self.name , self.Schema ); + if (!self.internal) { + self.Model = maki.mongoose.model( self.name , self.Schema ); + } if (self.source) { @@ -311,6 +315,30 @@ Resource.prototype.attach = function( maki ) { } } + self.components = { + query: self.options.components.query || maki.config.service.namespace + '-' + self.names.query, + get: self.options.components.get || maki.config.service.namespace + '-' + self.names.get + }; + + var lib = __dirname + '/../../components/'; + var base = process.env.PWD + '/components/'; + ['query', 'get'].forEach(function(action) { + var name = self.components[action] + .replace(maki.config.service.namespace+'-', '') + .replace('maki-', ''); + + var path = base + self.components[action] + '.jade'; + var alt = base + name + '.jade'; + + var fall = lib + self.components[action] + '.jade'; + var back = lib + name + '.jade'; + + if (!fs.existsSync(path) && !fs.existsSync(alt) && !fs.existsSync(fall) && !fs.existsSync(back)) { + console.log('neither exist, defaulting'); + self.components[action] = 'maki-collection'; + } + }); + //if (self.internal || self.static) return; maki.resources[ self.name ] = self; }; @@ -416,7 +444,7 @@ Resource.prototype.get = function( q , opts , complete ) { }); function executeMethod( q , done ) { - var query = Model.findOne( q ).sort('-_id'); + var query = Model.findOne( q ).sort( opts.sort || '-_id' ); if (opts.populate instanceof String) { query.populate( opts.populate.path ); @@ -461,9 +489,9 @@ Resource.prototype.get = function( q , opts , complete ) { } -Resource.prototype.create = function( doc , params , complete ) { +Resource.prototype.create = function( doc , opts , complete ) { var self = this; - if (typeof( params ) === 'function') var complete = params; + if (typeof( opts ) === 'function') var complete = opts; if (!complete) var complete = new Function(); if (self.options.static) return complete(); @@ -483,6 +511,21 @@ Resource.prototype.create = function( doc , params , complete ) { var instance = new Model( doc ); instance.save(function(err) { if (err) return complete(err); + + if (opts.populate instanceof String) { + return instance.populate( opts.populate , done ); + } + + if (opts.populate instanceof Array) { + return opts.populate.forEach(function(field) { + if (field.fields) { + instance.populate( field , done ); + } else { + instance.populate( field , done ); + } + }); + } + return done( null , instance ); }); } @@ -494,7 +537,9 @@ Resource.prototype.create = function( doc , params , complete ) { // find one based on our query, and return it if it exists Model.findOne( query ).exec(function(err, instance) { if (err) return complete(err); - if (instance) return complete( err , instance ); + if (instance) { + return complete( err , instance ); + } return done( null ); }); } @@ -519,6 +564,12 @@ Resource.prototype.create = function( doc , params , complete ) { } +Resource.prototype.count = function(query, complete) { + var self = this; + var Model = self.Model; + Model.count(query, complete); +} + Resource.prototype.patch = function( query , params, complete ) { var self = this; if (!complete) var complete = new Function(); diff --git a/lib/Service/http.js b/lib/Service/http.js index a657a73f..9460946d 100644 --- a/lib/Service/http.js +++ b/lib/Service/http.js @@ -6,6 +6,7 @@ var express = require('express'); var fs = require('fs'); var pem = require('pem'); var async = require('async'); +var walk = require('walk'); var _ = require('lodash'); var streamifier = require('streamifier'); @@ -20,8 +21,17 @@ var HTTP = function() { this._pre = {}; this._post = {}; this._plugins = []; - this._scripts = []; + this._scripts = [ + __dirname + '/../../public/js/webcomponents-lite.min.js', + __dirname + '/../../public/js/semantic.min.js', + __dirname + '/../../public/assets/objectid.js', + //__dirname + '/../../public/assets/peer.js', + //'public/js/jquery.js', + //'public/js/maki.js' + ]; this._workers = []; + this._resourceMap = {}; + this._flatResourceMap = {}; }; require('util').inherits( HTTP , Service ); @@ -241,6 +251,36 @@ HTTP.prototype.attach = function( maki ) { maki.socks = new WebSocketServer(); maki.app.use( require('maki-forms') ); + Object.keys(maki.resources).forEach(function(name) { + var resource = maki.resources[name]; + self._resourceMap[name] = []; + Object.keys(resource.paths).forEach(function(method) { + self._resourceMap[name].push(resource.paths[method]); + }); + }); + + console.log('resourceMap:', self._resourceMap); + + /* maki.socks.on('patch', function(patch) { + console.log('inner received patch:', patch); + var match = null; + for (var name in self._resourceMap) { + var regii = self._resourceMap[name]; + for (var i = 0; i < regii.length; i++) { + var regex = regii[i]; + if (regex.test(patch.channel)) { + match = name; + break; + } + } + if (match) { + break; + }; + }; + console.log('match!', match); + maki.resources[match]._patch(patch.channel, patch.ops); + }); */ + var map = { 'query': 'get', 'create': 'post', @@ -251,13 +291,6 @@ HTTP.prototype.attach = function( maki ) { self.map = map; self.invertedMap = _.invert(map); - /*var jademin = require('jade-browser'); - maki.app.use( jademin('/js/templates.js', maki.app.set('views'), { - beforeCompile: function( input ) { - return input.replace(/extends (.*)\n/, ''); - } - }) );*/ - var lessmin = require('less-middleware'); maki.app.use( lessmin({ debug: self.debug, @@ -284,6 +317,17 @@ HTTP.prototype.attach = function( maki ) { inMemory: true })); + maki.httpd = require('http').createServer( maki.app ); + + var ExpressPeerServer = require('peer').ExpressPeerServer; + var peerServer = ExpressPeerServer(maki.httpd); + maki.app.use('/peerjs', peerServer); + peerServer.on('connection', function(id) { + var self = this; + console.log(self); + console.log('peerserver connection:', id); + }); + maki.app.locals[ 'config' ] = maki.config; maki.app.locals[ 'resources' ] = maki.resources; maki.app.locals[ 'services' ] = maki.services; @@ -303,6 +347,32 @@ HTTP.prototype.attach = function( maki ) { return next(); }); + maki.app.locals.componentMap = {}; + maki.app.locals.components = ''; + + var defaults = __dirname + '/../../components'; + var overrides = process.env.PWD + '/components'; + + [defaults, overrides].forEach(function(path) { + var options = { + listeners: { + file: function(root, fileStats, next) { + var component = path + '/' + fileStats.name; + maki.app.render(component, function(err, html) { + if (err) console.error(err); + maki.app.locals.componentMap[fileStats.name] = html; + next(); + }); + } + } + }; + walk.walkSync(path, options); + }); + + Object.keys(maki.app.locals.componentMap).forEach(function(name) { + maki.app.locals.components += maki.app.locals.componentMap[name]; + }); + maki.app.use( self.provide() ); if (maki.config.statics && maki.config.statics.length) { @@ -313,7 +383,7 @@ HTTP.prototype.attach = function( maki ) { maki.app.get( path , function(req, res) { res.provide( s ); }); - }) + }); } function serveDocumentation(req, res, next) { @@ -332,21 +402,30 @@ HTTP.prototype.attach = function( maki ) { return resource; }); + var resourceMap = {}; + Object.keys(maki.resources).filter(function(r) { + var resource = maki.resources[ r ]; + return true; + return !resource.internal || !resource.static; + }).forEach(function(name) { + var model = maki.resources[name]; + var resource = _.clone(model, true); + delete resource.Schema; + resourceMap[name] = resource; + }); + return res.format({ html: function() { res.render('endpoints', { resources: resourceList - }) + }); }, json: function() { res.send({ config: { - views: { - client: maki.config.views.client - } + service: maki.config.service }, - // TODO: fix circular JSON issue here - resources: resourceList + resources: resourceMap }); } }); @@ -359,6 +438,19 @@ HTTP.prototype.attach = function( maki ) { next(); }); + maki.app.get('/components', function(req, res, next) { + return res.send(maki.app.locals.components); + }); + + maki.app.get('/components/:name', function(req, res, next) { + var name = req.params.name; + var path = __dirname + '/../../components/'+name+'.jade'; + if (fs.existsSync(path)) return res.render(path); + var path = process.env.PWD + '/components/'+name+'.jade'; + if (fs.existsSync(path)) return res.render(path); + return next(); + }); + maki.app.get('/api', function(req, res, next) { return serveDocumentation(req, res, next); }); @@ -604,7 +696,7 @@ HTTP.prototype.attach = function( maki ) { // there is a slight difference in how Resource methods are implemented// // specifically, "editing" a resourcing requires 1) a query , and 2)// // patches. Perhaps we can use a "builder" and .apply() here. - + if (p === 'query') { var executor = function(req, res, next) { req.m = p; @@ -687,27 +779,31 @@ HTTP.prototype.attach = function( maki ) { doc[ field ] = file._id; }); - resource[ p ]( doc , function(err, instance) { + resource[ p ]( doc , { + populate: methodPopulationMap[ p ] + }, function(err, instance) { if (err) return res.error( err ); req.locals = instance; return res.provide( r , instance , handlers ); }); }); } - + maki.app['put']( regex + '/:id' , function(req, res, next) { req.m = p; if (resource.source) return res.status( 405 ).provide( r ); // TODO: query pipeline (facades) var doc = req.body; - resource[ p ]( doc , function(err, instance) { + resource[ p ]( doc , { + populate: methodPopulationMap[ p ] + }, function(err, instance) { if (err) return res.error( err ); req.locals = instance; return res.provide( r , instance ); }); }); - + } else if (p === 'update') { var executor = function(req, res, next) { req.m = p; @@ -752,7 +848,7 @@ HTTP.prototype.attach = function( maki ) { var stack = [ regex ]; var pre = []; var post = []; - + pre.push(function setupMiddleware(req, res, next) { req.resource = resource; next(); @@ -801,14 +897,13 @@ HTTP.prototype.start = function( started ) { // TODO: build an extensible service worker platform; events, triggers, etc. self._workers.forEach(function(w) { - var workerPath = __dirname + '/../../public/service.js'; // sadly at root :( + var workerPath = __dirname + '/../../public/worker.js'; // sadly at root :( var worker = fs.createWriteStream(workerPath); worker.on('open', function() { fs.createReadStream(w).pipe(worker); }); }); - self.on('started', function() { // TODO: final events, or mechanism for routes injected to Maki pre-start setTimeout(function() { @@ -822,14 +917,14 @@ HTTP.prototype.start = function( started ) { // TODO: allow configurable certificate, supplied by config // this will allow for standalone mode, as well as a "backend worker" mode. pem.createCertificate({ - days: 1, + days: 90, selfSigned: true }, function(err, keys) { var sslPort = self.maki.config.services.http.port + 443 - 80; //self.maki.config.services.spdy.port = sslPort; - self.maki.httpd = require('http').createServer( self.maki.app ); + //self.maki.httpd = require('http').createServer( self.maki.app ); self.maki.spdyd = require('spdy').createServer({ key: keys.serviceKey, cert: keys.certificate diff --git a/maki.js b/maki.js index 3eda8fd7..7fd58ad6 100644 --- a/maki.js +++ b/maki.js @@ -8,6 +8,8 @@ var passport = new Passport({ resource: 'Person' }); maki.use( passport ); +maki.use(require('maki-client-level')); +maki.use(require('maki-client-polymer')); var CMS = require('maki-cms-local'); var cms = new CMS({ @@ -45,6 +47,8 @@ maki.use(developers); maki.use(auth); var Person = maki.define('Person', { + icon: 'user', + description: 'People are the most important part of Maki, and this is where we list them. We\'re not users, we\'re _people_, damnit.', attributes: { username: { type: String , max: 80 , required: true , slug: true }, name: { @@ -56,13 +60,12 @@ var Person = maki.define('Person', { email: { type: String , max: 80 , restricted: true }, created: { type: Date , default: Date.now } }, - auth: { + /* auth: { 'patch': ['admin', function(done) { var person = this; return false; }] - }, - icon: 'user' + }, */ }); Person.post('patch', function(done) { var person = this; @@ -71,17 +74,24 @@ Person.post('patch', function(done) { }); maki.define('Example', { + icon: 'idea', + description: 'A list of applications Made With Maki.', + source: 'data/examples.json', + components: { + query: 'maki-examples' + }, attributes: { name: { type: String , max: 80 }, slug: { type: String , max: 80 , id: true }, content: { type: String }, screenshot: { type: 'File' } }, - source: 'data/examples.json', - icon: 'idea' }); maki.define('Release', { + icon: 'tags', + description: 'Officially tagged releases of the Maki library.', + source: 'https://api.github.com/repos/martindale/maki/releases', attributes: { name: { type: String , max: 80 }, tag: { type: String , max: 80 }, @@ -89,8 +99,6 @@ maki.define('Release', { published: { type: Date }, notes: { type: String , render: 'markdown' } }, - source: 'https://api.github.com/repos/martindale/maki/releases', - icon: 'tags', map: function( release ) { return { name: release.name, @@ -102,17 +110,36 @@ maki.define('Release', { }); maki.define('Plugin', { + icon: 'puzzle', + description: 'Modules that extend the default Maki behaviors.', attributes: { name: { type: String , max: 80 }, description: { type: String }, version: { type: String , max: 10 }, coverage: { type: Number , default: 0 }, }, - icon: 'puzzle' +}); + +maki.define('Index', { + name: 'Index', + templates: { + query: 'splash' + }, + components: { + query: 'maki-splash', + get: 'maki-splash' + }, + routes: { + query: '/' + }, + static: true, + //internal: true }); /*var Analytics = require('maki-analytics'); var analytics = new Analytics({ id: 'UA-57746323-2' }); maki.use( analytics ).serve(['http']).start();*/ -maki.start(); +maki.start(function() { + console.log('routes:', maki.routes); +}); diff --git a/package.json b/package.json index 78c0adc2..6927f06f 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "async": "~0.7.0", "body-parser": "~1.2.2", "browserify": "^11.0.1", + "browserify-shim": "^3.8.12", "coalescent": "^0.5.0-alpha.3", "colors": "^1.0.3", "connect-busboy": "0.0.2", @@ -47,9 +48,11 @@ "json-patch": "^0.4.3", "jsonpath-object-transform": "git://github.com/dvdln/jsonpath-object-transform", "less-middleware": "git://github.com/martindale/less.js-middleware#maki", - "lodash": "^2.4.1", + "lodash": "^4.6.1", "maki-analytics": "git://github.com/martindale/maki-analytics", "maki-auth-simple": "0.0.1", + "maki-client-level": "^0.1.0", + "maki-client-polymer": "git://github.com/martindale/maki-client-polymer", "maki-cms-local": "0.0.2", "maki-forms": "0.0.0", "maki-jsonrpc": "^0.1.1", @@ -68,6 +71,7 @@ "node-torrent-stream": "git://github.com/unusualbob/node-torrent-stream#master", "node-uuid": "^1.4.1", "path-to-regexp": "~0.2.1", + "peer": "^0.2.8", "pem": "^1.4.1", "pluralize": "^1.0.0", "procure": "^0.1.4", @@ -77,6 +81,7 @@ "spdy": "^1.28.1", "speakingurl": "^1.1.0", "streamifier": "^0.1.0", + "walk": "^2.3.9", "ws": "~0.4.31" }, "devDependencies": { diff --git a/public/assets/async.min.js b/public/assets/async.min.js new file mode 100644 index 00000000..9e8eaf4b --- /dev/null +++ b/public/assets/async.min.js @@ -0,0 +1,2 @@ +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.async=t.async||{})}(this,function(t){"use strict";function n(t,n,r){var e=r.length;switch(e){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}function r(t){var n=typeof t;return!!t&&("object"==n||"function"==n)}function e(t){var n=r(t)?Zn.call(t):"";return n==Vn||n==Xn}function o(t){if(r(t)){var n=e(t.valueOf)?t.valueOf():t;t=r(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(nr,"");var o=er.test(t);return o||or.test(t)?ur(t.slice(2),o?2:8):rr.test(t)?tr:+t}function u(t){if(!t)return 0===t?t:0;if(t=o(t),t===ir||t===-ir){var n=0>t?-1:1;return n*cr}var r=t%1;return t===t?r?t-r:t:0}function i(t,r){if("function"!=typeof t)throw new TypeError(ar);return r=fr(void 0===r?t.length-1:u(r),0),function(){for(var e=arguments,o=-1,u=fr(e.length-r,0),i=Array(u);++o0&&(r=n.apply(this,arguments)),1>=t&&(n=void 0),r}}function s(t){return l(2,t)}function p(t){return function(n){return null==n?void 0:n[t]}}function y(t){return"number"==typeof t&&t>-1&&t%1==0&&pr>=t}function h(t){return null!=t&&y(sr(t))&&!e(t)}function v(t){return yr&&t[yr]&&t[yr]()}function d(t,n){return vr.call(t,n)||"object"==typeof t&&n in t&&null===dr(t)}function m(t){return mr(Object(t))}function g(t,n){for(var r=-1,e=Array(t);++r-1&&t%1==0&&n>t}function k(t){var n=t&&t.constructor,r="function"==typeof n&&n.prototype||Lr;return t===r}function E(t){var n=k(t);if(!n&&!h(t))return m(t);var r=S(t),e=!!r,o=r||[],u=o.length;for(var i in t)!d(t,i)||e&&("length"==i||_(i,u))||n&&"constructor"==i||o.push(i);return o}function A(t){var n,r=-1;if(h(t))return n=t.length,function(){return r++,n>r?{value:t[r],key:r}:null};var e=v(t);if(e)return function(){var t=e.next();return t.done?null:(r++,{value:t.value,key:r})};var o=E(t);return n=o.length,function(){r++;var e=o[r];return n>r?{value:t[e],key:e}:null}}function x(t){return function(){if(null===t)throw new Error("Callback was already called.");t.apply(this,arguments),t=null}}function L(t){return function(n,r,e){e=s(e||f),n=n||[];var o=A(n);if(0>=t)return e(null);var u=!1,i=0,c=!1;!function a(){if(u&&0>=i)return e(null);for(;t>i&&!c;){var n=o();if(null===n)return u=!0,void(0>=i&&e(null));i+=1,r(n.value,n.key,x(function(t){i-=1,t?(e(t),c=!0):a()}))}}()}}function I(t,n,r,e){L(n)(t,r,e)}function T(t,n){return function(r,e,o){return t(r,n,e,o)}}function F(t){return c(function(n,e){var o;try{o=t.apply(this,n)}catch(u){return e(u)}r(o)&&"function"==typeof o.then?o.then(function(t){e(null,t)})["catch"](function(t){e(t.message?t:new Error(t))}):e(null,o)})}function M(t,n){for(var r=-1,e=t.length;++rr&&(r=Pr(e+r,0)),q(t,n,r)):-1}function R(t,n,r){function e(t,n){m.push(function(){a(t,n)})}function o(){if(0===m.length&&0===h)return r(null,y);for(;m.length&&n>h;){var t=m.shift();t()}}function u(t,n){var r=d[t];r||(r=d[t]=[]),r.push(n)}function c(t){var n=d[t]||[];M(n,function(t){t()}),o()}function a(t,n){if(!v){var e=x(i(function(n,e){if(h--,e.length<=1&&(e=e[0]),n){var o={};B(y,function(t,n){o[n]=t}),o[t]=e,v=!0,d=[],r(n,o)}else y[t]=e,c(t)}));h++;var o=n[n.length-1];n.length>1?o(y,e):o(e)}}"function"==typeof n&&(r=n,n=null),r=s(r||f);var l=E(t),p=l.length;if(!p)return r(null);n||(n=p);var y={},h=0,v=!1,d={},m=[];B(t,function(n,r){function o(){for(var n,e=i.length;e--;){if(!(n=t[i[e]]))throw new Error("async.auto task `"+r+"` has non-existent dependency in "+i.join(", "));if(Sr(n)&&D(n,r)>=0)throw new Error("async.auto task `"+r+"`Has cyclic dependencies")}}if(!Sr(n))return void e(r,[n]);var i=n.slice(0,n.length-1),c=i.length;o(),M(i,function(t){u(t,function(){c--,0===c&&e(r,n)})})}),o()}function W(t,n){for(var r=-1,e=t.length,o=Array(e);++rr)return!1;var e=t.length-1;return r==e?t.pop():Br.call(t,r,1),!0}function J(t){var n=this.__data__,r=n.array;return r?H(r,t):n.map["delete"](t)}function K(t,n){var r=Q(t,n);return 0>r?void 0:t[r][1]}function V(t){var n=this.__data__,r=n.array;return r?K(r,t):n.map.get(t)}function X(t,n){return Q(t,n)>-1}function Y(t){var n=this.__data__,r=n.array;return r?X(r,t):n.map.has(t)}function Z(t){var n=!1;if(null!=t&&"function"!=typeof t.toString)try{n=!!(t+"")}catch(r){}return n}function tt(t){return null==t?!1:e(t)?Nr.test(Rr.call(t)):b(t)&&(Z(t)?Nr:qr).test(t)}function nt(t,n){var r=t[n];return tt(r)?r:void 0}function rt(){}function et(t){return t&&t.Object===Object?t:null}function ot(){this.__data__={hash:new rt,map:ne?new ne:[],string:new rt}}function ut(t,n){return Gr?void 0!==t[n]:ee.call(t,n)}function it(t,n){return ut(t,n)&&delete t[n]}function ct(t){var n=typeof t;return"number"==n||"boolean"==n||"string"==n&&"__proto__"!=t||null==t}function at(t){var n=this.__data__;return ct(t)?it("string"==typeof t?n.string:n.hash,t):ne?n.map["delete"](t):H(n.map,t)}function ft(t,n){if(Gr){var r=t[n];return r===oe?void 0:r}return ie.call(t,n)?t[n]:void 0}function lt(t){var n=this.__data__;return ct(t)?ft("string"==typeof t?n.string:n.hash,t):ne?n.map.get(t):K(n.map,t)}function st(t){var n=this.__data__;return ct(t)?ut("string"==typeof t?n.string:n.hash,t):ne?n.map.has(t):X(n.map,t)}function pt(t,n,r){var e=Q(t,n);0>e?t.push([n,r]):t[e][1]=r}function yt(t,n,r){t[n]=Gr&&void 0===r?ce:r}function ht(t,n){var r=this.__data__;return ct(t)?yt("string"==typeof t?r.string:r.hash,t,n):ne?r.map.set(t,n):pt(r.map,t,n),this}function vt(t){var n=-1,r=t?t.length:0;for(this.clear();++n=n;n++)Uo(c.process)}}};return c}function Qt(t,n){return Gt(t,1,n)}function Ht(t,n,r,e){Fr(t,function(t,e,o){r(n,t,function(t,r){n=r,o(t)})},function(t){e(t,n)})}function Jt(){var t=arguments;return i(function(n){var r=this,e=n[n.length-1];"function"==typeof e?n.pop():e=f,Ht(t,n,function(t,n,e){n.apply(r,t.concat([i(function(t,n){e(t,n)})]))},function(t,n){e.apply(r,[t].concat(n))})})}function Kt(){return Jt.apply(null,Po.call(arguments))}function Vt(t,n,r,e){var o=[];t(n,function(t,n,e){r(t,function(t,n){o=o.concat(n||[]),e(t)})},function(t){e(t,o)})}function Xt(t){return function(n,r,e){return t(Ir,n,r,e)}}function Yt(t){return function(n,r,e){return t(Fr,n,r,e)}}function Zt(t,n,r){return function(e,o,u,i){function c(t){i&&(t?i(t):i(null,r(!1)))}function a(t,e,o){return i?void u(t,function(e,c){i&&(e?(i(e),i=u=!1):n(c)&&(i(null,r(!0,t)),i=u=!1)),o()}):o()}arguments.length>3?t(e,o,a,c):(i=u,u=o,t(e,a,c))}}function tn(t,n){return n}function nn(t){return i(function(n,r){n.apply(null,r.concat([i(function(n,r){"object"==typeof console&&(n?console.error&&console.error(n):console[t]&&M(r,function(n){console[t](n)}))})]))})}function rn(t,n,r){r=r||f;var e=i(function(n,e){n?r(n):(e.push(o),t.apply(this,e))}),o=function(t,o){return t?r(t):o?void n(e):r(null)};t(o)}function en(t,n,r){var e=0;rn(function(t){return e++<1?t(null,!0):void n.apply(this,arguments)},t,r)}function on(t,n,r){if(r=r||f,!t())return r(null);var e=i(function(o,u){return o?r(o):t.apply(this,u)?n(e):void r.apply(null,[null].concat(u))});n(e)}function un(t,n,r){var e=0;return on(function(){return++e<=1||n.apply(this,arguments)},t,r)}function cn(t,n,r){return un(t,function(){return!n.apply(this,arguments)},r)}function an(t){return function(n,r,e){return t(n,e)}}function fn(t,n,r,e){return L(n)(t,an(r),e)}function ln(t){return c(function(n,r){var e=!0;n.push(function(){var t=arguments;e?Uo(function(){r.apply(null,t)}):r.apply(null,t)}),t.apply(this,n),e=!1})}function sn(t){return!t}function pn(t,n,r,e){var o=[];t(n,function(t,n,e){r(t,function(r,u){r?e(r):(u&&o.push({index:n,value:t}),e())})},function(t){t?e(t):e(null,W(o.sort(function(t,n){return t.index-n.index}),p("value")))})}function yn(t){return function(n,r,e,o){return t(L(r),n,e,o)}}function hn(t,n){function r(t){return t?e(t):void o(r)}var e=x(n||f),o=ln(t);r()}function vn(t){function n(r){function e(){return t.length&&t[r].apply(null,arguments),e.next()}return e.next=function(){return rn&&(n=-n>o?0:o+n),r=r>o?o:r,0>r&&(r+=o),o=n>r?0:r-n>>>0,n>>>=0;for(var u=Array(o);++er;)t=t[n[r++]];return r&&r==e?t:void 0}function kn(t,n,r){var e=null==t?void 0:_n(t,n);return void 0===e?r:e}function En(t,n){return 1==n.length?t:kn(t,Sn(n,0,-1))}function An(t,n,r){if(null==t)return!1;var e=r(t,n);e||wn(n)||(n=jn(n),t=En(t,n),null!=t&&(n=On(n),e=r(t,n)));var o=t?t.length:void 0;return e||!!o&&y(o)&&_(n,o)&&(Sr(t)||O(t)||w(t))}function xn(t,n){return An(t,n,d)}function Ln(t,n){var r=Object.create(null),e=Object.create(null);n=n||$;var o=c(function(o,u){var c=n.apply(null,o);xn(r,c)?Uo(function(){u.apply(null,r[c])}):xn(e,c)?e[c].push(u):(e[c]=[u],t.apply(null,o.concat([i(function(t){r[c]=t;var n=e[c];delete e[c];for(var o=0,u=n.length;u>o;o++)n[o].apply(null,t)})])))});return o.memo=r,o.unmemoized=t,o}function In(t,n,r){r=r||f;var e=h(n)?[]:{};t(n,function(t,n,r){t(i(function(t,o){o.length<=1&&(o=o[0]),e[n]=o,r(t)}))},function(t){r(t,e)})}function Tn(t,n,r){return In(L(n),t,r)}function Fn(t,n){return Gt(function(n,r){t(n[0],r)},n,1)}function Mn(t,n){function r(t,n){return t.priority-n.priority}function e(t,n,r){for(var e=-1,o=t.length-1;o>e;){var u=e+(o-e+1>>>1);r(n,t[u])>=0?e=u:o=u-1}return e}function o(t,n,o,u){if(null!=u&&"function"!=typeof u)throw new Error("task callback must be a function");return t.started=!0,Sr(n)||(n=[n]),0===n.length?Uo(function(){t.drain()}):void M(n,function(n){var i={data:n,priority:o,callback:"function"==typeof u?u:f};t.tasks.splice(e(t.tasks,i,r)+1,0,i),t.tasks.length===t.concurrency&&t.saturated(),t.tasks.length<=t.concurrency-t.buffer&&t.unsaturated(),Uo(t.process)})}var u=Fn(t,n);return u.push=function(t,n,r){o(u,t,n,r)},delete u.unshift,u}function $n(t,n){return function(r,e){if(null==r)return r;if(!h(r))return t(r,e);for(var o=r.length,u=n?o:-1,i=Object(r);(n?u--:++u0&&l.push(u(a.interval))}Cn(l,function(t,n){n=n[n.length-1],r(n.err,n.result)})}function Dn(t,n){return n||(n=t,t=null),c(function(r,e){function o(t){n.apply(null,r.concat([t]))}t?qn(t,o,e):qn(o,e)})}function Rn(t,n,r){function e(t,n){var r=t.criteria,e=n.criteria;return e>r?-1:r>e?1:0}tu(t,function(t,r){n(t,function(n,e){return n?r(n):void r(null,{value:t,criteria:e})})},function(t,n){return t?r(t):void r(null,W(n.sort(e),p("value")))})}function Wn(t,n){function r(){i||(o.apply(null,arguments),clearTimeout(u))}function e(){var t=new Error("Callback function timed out.");t.code="ETIMEDOUT",i=!0,o(t)}var o,u,i=!1;return c(function(i,c){o=c,u=setTimeout(e,n),t.apply(null,i.concat(r))})}function Nn(t,n,r,e){for(var o=-1,u=Ou(wu((n-t)/(r||1)),0),i=Array(u);u--;)i[e?u:++o]=t,t+=r;return i}function Gn(t,n,r,e){return Zo(Nn(0,t,1),n,r,e)}function Qn(t,n,r,e){3===arguments.length&&(e=r,r=n,n=Sr(t)?[]:{}),Ir(t,function(t,e,o){r(n,t,e,o)},function(t){e(t,n)})}function Hn(t){return function(){return(t.unmemoized||t).apply(null,arguments)}}function Jn(t,n,r){return on(function(){return!t.apply(this,arguments)},n,r)}function Kn(t,n){function r(o){if(e===t.length)return n.apply(null,[null].concat(o));var u=x(i(function(t,e){return t?n.apply(null,[t].concat(e)):void r(e)}));o.push(u);var c=t[e++];c.apply(null,o)}if(n=s(n||f),!Sr(t))return n(new Error("First argument to waterfall must be an array of functions"));if(!t.length)return n();var e=0;r([])}var Vn="[object Function]",Xn="[object GeneratorFunction]",Yn=Object.prototype,Zn=Yn.toString,tr=NaN,nr=/^\s+|\s+$/g,rr=/^[-+]0x[0-9a-f]+$/i,er=/^0b[01]+$/i,or=/^0o[0-7]+$/i,ur=parseInt,ir=1/0,cr=1.7976931348623157e308,ar="Expected a function",fr=Math.max,lr="Expected a function",sr=p("length"),pr=9007199254740991,yr="function"==typeof Symbol&&Symbol.iterator,hr=Object.prototype,vr=hr.hasOwnProperty,dr=Object.getPrototypeOf,mr=Object.keys,gr="[object Arguments]",br=Object.prototype,jr=br.hasOwnProperty,wr=br.toString,Or=br.propertyIsEnumerable,Sr=Array.isArray,_r="[object String]",kr=Object.prototype,Er=kr.toString,Ar=9007199254740991,xr=/^(?:0|[1-9]\d*)$/,Lr=Object.prototype,Ir=T(I,1/0),Tr=a(Ir),Fr=T(I,1),Mr=a(Fr),$r=i(function(t,n){return i(function(r){return t.apply(null,n.concat(r))})}),Ur=P(),Pr=Math.max,zr=Array.prototype,Br=zr.splice,Cr=/[\\^$.*+?()[\]{}|]/g,qr=/^\[object .+?Constructor\]$/,Dr=Object.prototype,Rr=Function.prototype.toString,Wr=Dr.hasOwnProperty,Nr=RegExp("^"+Rr.call(Wr).replace(Cr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Gr=nt(Object,"create"),Qr=Object.prototype;rt.prototype=Gr?Gr(null):Qr;var Hr={"function":!0,object:!0},Jr=Hr[typeof t]&&t&&!t.nodeType?t:void 0,Kr=Hr[typeof module]&&module&&!module.nodeType?module:void 0,Vr=et(Jr&&Kr&&"object"==typeof global&&global),Xr=et(Hr[typeof self]&&self),Yr=et(Hr[typeof window]&&window),Zr=et(Hr[typeof this]&&this),te=Vr||Yr!==(Zr&&Zr.window)&&Yr||Xr||Zr||Function("return this")(),ne=nt(te,"Map"),re=Object.prototype,ee=re.hasOwnProperty,oe="__lodash_hash_undefined__",ue=Object.prototype,ie=ue.hasOwnProperty,ce="__lodash_hash_undefined__";vt.prototype.clear=ot,vt.prototype["delete"]=at,vt.prototype.get=lt,vt.prototype.has=st,vt.prototype.set=ht;var ae=200;mt.prototype.clear=N,mt.prototype["delete"]=J,mt.prototype.get=V,mt.prototype.has=Y,mt.prototype.set=dt;var fe=Object.prototype,le=fe.hasOwnProperty,se=Object.getOwnPropertySymbols,pe=se||function(){return[]},ye=nt(te,"Set"),he=nt(te,"WeakMap"),ve="[object Map]",de="[object Object]",me="[object Set]",ge="[object WeakMap]",be=Object.prototype,je=Function.prototype.toString,we=be.toString,Oe=ne?je.call(ne):"",Se=ye?je.call(ye):"",_e=he?je.call(he):"";(ne&&kt(new ne)!=ve||ye&&kt(new ye)!=me||he&&kt(new he)!=ge)&&(kt=function(t){var n=we.call(t),r=n==de?t.constructor:null,e="function"==typeof r?je.call(r):"";if(e)switch(e){case Oe:return ve;case Se:return me;case _e:return ge}return n});var ke=kt,Ee=Object.prototype,Ae=Ee.hasOwnProperty,xe=te.Uint8Array,Le=/\w*$/,Ie=te.Symbol,Te=Ie?Ie.prototype:void 0,Fe=Te?Te.valueOf:void 0,Me="[object Boolean]",$e="[object Date]",Ue="[object Map]",Pe="[object Number]",ze="[object RegExp]",Be="[object Set]",Ce="[object String]",qe="[object Symbol]",De="[object ArrayBuffer]",Re="[object Float32Array]",We="[object Float64Array]",Ne="[object Int8Array]",Ge="[object Int16Array]",Qe="[object Int32Array]",He="[object Uint8Array]",Je="[object Uint8ClampedArray]",Ke="[object Uint16Array]",Ve="[object Uint32Array]",Xe=Object.create,Ye=Object.getPrototypeOf,Ze={"function":!0,object:!0},to=Ze[typeof t]&&t&&!t.nodeType?t:void 0,no=Ze[typeof module]&&module&&!module.nodeType?module:void 0,ro=no&&no.exports===to?to:void 0,eo=ro?te.Buffer:void 0,oo=eo?function(t){return t instanceof eo}:Dt(!1),uo="[object Arguments]",io="[object Array]",co="[object Boolean]",ao="[object Date]",fo="[object Error]",lo="[object Function]",so="[object GeneratorFunction]",po="[object Map]",yo="[object Number]",ho="[object Object]",vo="[object RegExp]",mo="[object Set]",go="[object String]",bo="[object Symbol]",jo="[object WeakMap]",wo="[object ArrayBuffer]",Oo="[object Float32Array]",So="[object Float64Array]",_o="[object Int8Array]",ko="[object Int16Array]",Eo="[object Int32Array]",Ao="[object Uint8Array]",xo="[object Uint8ClampedArray]",Lo="[object Uint16Array]",Io="[object Uint32Array]",To={};To[uo]=To[io]=To[wo]=To[co]=To[ao]=To[Oo]=To[So]=To[_o]=To[ko]=To[Eo]=To[po]=To[yo]=To[ho]=To[vo]=To[mo]=To[go]=To[bo]=To[Ao]=To[xo]=To[Lo]=To[Io]=!0,To[fo]=To[lo]=To[jo]=!1;var Fo,Mo=/^function\s*[^\(]*\(\s*([^\)]*)\)/m,$o="function"==typeof setImmediate&&setImmediate;Fo=$o?$o:"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:function(t){setTimeout(t,0)};var Uo=i(function(t,n){Fo(function(){t.apply(null,n)})}),Po=Array.prototype.reverse,zo=Xt(Vt),Bo=Yt(Vt),Co=i(function(t){var n=[null].concat(t);return c(function(t,r){return r.apply(this,n)})}),qo=Zt(Ir,$,tn),Do=Zt(I,$,tn),Ro=Zt(Fr,$,tn),Wo=nn("dir"),No=T(fn,1/0),Go=T(fn,1),Qo=Zt(I,sn,sn),Ho=T(Qo,1/0),Jo=T(Qo,1),Ko=yn(pn),Vo=T(Ko,1/0),Xo=T(Ko,1),Yo=nn("log"),Zo=yn(dn),tu=T(Zo,1/0),nu=T(Zo,1),ru="[object Symbol]",eu=Object.prototype,ou=eu.toString,uu=1/0,iu=Ie?Ie.prototype:void 0,cu=iu?iu.toString:void 0,au=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g,fu=/\\(\\)?/g,lu=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,su=/^\w*$/,pu=T(Tn,1/0),yu=$n(z),hu=Array.prototype.slice,vu=yn(Bn),du=T(vu,1/0),mu=T(vu,1),gu=Zt(I,Boolean,$),bu=T(gu,1/0),ju=T(gu,1),wu=Math.ceil,Ou=Math.max,Su=T(Gn,1/0),_u=T(Gn,1),ku={applyEach:Tr,applyEachSeries:Mr,apply:$r,asyncify:F,auto:R,autoInject:Nt,cargo:Qt,compose:Kt,concat:zo,concatSeries:Bo,constant:Co,detect:qo,detectLimit:Do,detectSeries:Ro,dir:Wo,doDuring:en,doUntil:cn,doWhilst:un,during:rn,each:No,eachLimit:fn,eachOf:Ir,eachOfLimit:I,eachOfSeries:Fr,eachSeries:Go,ensureAsync:ln,every:Ho,everyLimit:Qo,everySeries:Jo,filter:Vo,filterLimit:Ko,filterSeries:Xo,forever:hn,iterator:vn,log:Yo,map:tu,mapLimit:Zo,mapSeries:nu,memoize:Ln,nextTick:Uo,parallel:pu,parallelLimit:Tn,priorityQueue:Mn,queue:Fn,race:Pn,reduce:Ht,reduceRight:zn,reject:du,rejectLimit:vu,rejectSeries:mu,retry:qn,retryable:Dn,seq:Jt,series:Cn,setImmediate:Uo,some:bu,someLimit:gu,someSeries:ju,sortBy:Rn,timeout:Wn,times:Su,timesLimit:Gn,timesSeries:_u,transform:Qn,unmemoize:Hn,until:Jn,waterfall:Kn,whilst:on,all:Ho,any:bu,forEach:No,forEachSeries:Go,forEachLimit:fn,forEachOf:Ir,forEachOfSeries:Fr,forEachOfLimit:I,inject:Ht,foldl:Ht,foldr:zn,select:Vo,selectLimit:Ko,selectSeries:Xo,wrapSync:F};t["default"]=ku,t.applyEach=Tr,t.applyEachSeries=Mr,t.apply=$r,t.asyncify=F,t.auto=R,t.autoInject=Nt,t.cargo=Qt,t.compose=Kt,t.concat=zo,t.concatSeries=Bo,t.constant=Co,t.detect=qo,t.detectLimit=Do,t.detectSeries=Ro,t.dir=Wo,t.doDuring=en,t.doUntil=cn,t.doWhilst=un,t.during=rn,t.each=No,t.eachLimit=fn,t.eachOf=Ir,t.eachOfLimit=I,t.eachOfSeries=Fr,t.eachSeries=Go,t.ensureAsync=ln,t.every=Ho,t.everyLimit=Qo,t.everySeries=Jo,t.filter=Vo,t.filterLimit=Ko,t.filterSeries=Xo,t.forever=hn,t.iterator=vn,t.log=Yo,t.map=tu,t.mapLimit=Zo,t.mapSeries=nu,t.memoize=Ln,t.nextTick=Uo,t.parallel=pu,t.parallelLimit=Tn,t.priorityQueue=Mn,t.queue=Fn,t.race=Pn,t.reduce=Ht,t.reduceRight=zn,t.reject=du,t.rejectLimit=vu,t.rejectSeries=mu,t.retry=qn,t.retryable=Dn,t.seq=Jt,t.series=Cn,t.setImmediate=Uo,t.some=bu,t.someLimit=gu,t.someSeries=ju,t.sortBy=Rn,t.timeout=Wn,t.times=Su,t.timesLimit=Gn,t.timesSeries=_u,t.transform=Qn,t.unmemoize=Hn,t.until=Jn,t.waterfall=Kn,t.whilst=on,t.all=Ho,t.allLimit=Qo,t.allSeries=Jo,t.any=bu,t.anyLimit=gu,t.anySeries=ju,t.find=qo,t.findLimit=Do,t.findSeries=Ro,t.forEach=No,t.forEachSeries=Go,t.forEachLimit=fn,t.forEachOf=Ir,t.forEachOfSeries=Fr,t.forEachOfLimit=I,t.inject=Ht,t.foldl=Ht,t.foldr=zn,t.select=Vo,t.selectLimit=Ko,t.selectSeries=Xo,t.wrapSync=F}); +//# sourceMappingURL=dist/async.min.map \ No newline at end of file diff --git a/public/assets/bitcore-mnemonic.min.js b/public/assets/bitcore-mnemonic.min.js new file mode 100644 index 00000000..fb8bf55e --- /dev/null +++ b/public/assets/bitcore-mnemonic.min.js @@ -0,0 +1,15 @@ +require=function e(t,r,i){function n(o,s){if(!r[o]){if(!t[o]){var c="function"==typeof require&&require;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var u=r[o]={exports:{}};t[o][0].call(u.exports,function(e){var r=t[o][1][e];return n(r?r:e)},u,u.exports,e,t,r,i)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;on)throw new i.errors.InvalidArgument("ENT","Values must be ENT > 128 and ENT % 32 == 0");s=s||h._mnemonic(n,t),Object.defineProperty(this,"wordlist",{configurable:!1,value:t}),Object.defineProperty(this,"phrase",{configurable:!1,value:s})};h.Words=e("./words"),h.isValid=function(e,t){if(e=a.nfkd(e),t=t||h._getDictionary(e),!t)return!1;for(var i=e.split(" "),n="",o=0;os)return!1;n+=("00000000000"+s.toString(2)).slice(-11)}var c=n.length/33,f=n.slice(-c),u=n.slice(0,n.length-c),d=new r(u.length/8);for(o=0;on)return!1}return!0},h._getDictionary=function(e){if(!e)return null;for(var t=Object.keys(h.Words),r=0;r"},h._mnemonic=function(e,t){var r=u.getRandomBuffer(e/8);return h._entropy2mnemonic(r,t)},h._entropy2mnemonic=function(e,t){for(var r="",i=0;i(Math.pow(2,32)-1)*o)throw Error("Requested key length too long");if("string"!=typeof e&&!r.isBuffer(e))throw new TypeError("key must a string or Buffer");if("string"!=typeof t&&!r.isBuffer(t))throw new TypeError("salt must a string or Buffer");"string"==typeof e&&(e=new r(e)),"string"==typeof t&&(t=new r(t));var s=new r(a),c=new r(o),f=new r(o),u=new r(t.length+4),d=Math.ceil(a/o),h=a-(d-1)*o;t.copy(u,0,0,t.length);for(var l=1;d>=l;l++){u[t.length+0]=l>>24&255,u[t.length+1]=l>>16&255,u[t.length+2]=l>>8&255,u[t.length+3]=l>>0&255,c=n.createHmac("sha512",e).update(u).digest(),c.copy(f,0,0,o);for(var p=1;i>p;p++){c=n.createHmac("sha512",e).update(c).digest();for(var b=0;o>b;b++)f[b]^=c[b]}var m=(l-1)*o,g=l===d?h:o;f.copy(s,m,0,g)}return s}var n=e("crypto");t.exports=i}).call(this,e("buffer").Buffer)},{buffer:11,crypto:15}],4:[function(e,t,r){"use strict";var i=["的","一","是","在","不","了","有","和","人","这","中","大","为","上","个","国","我","以","要","他","时","来","用","们","生","到","作","地","于","出","就","分","对","成","会","可","主","发","年","动","同","工","也","能","下","过","子","说","产","种","面","而","方","后","多","定","行","学","法","所","民","得","经","十","三","之","进","着","等","部","度","家","电","力","里","如","水","化","高","自","二","理","起","小","物","现","实","加","量","都","两","体","制","机","当","使","点","从","业","本","去","把","性","好","应","开","它","合","还","因","由","其","些","然","前","外","天","政","四","日","那","社","义","事","平","形","相","全","表","间","样","与","关","各","重","新","线","内","数","正","心","反","你","明","看","原","又","么","利","比","或","但","质","气","第","向","道","命","此","变","条","只","没","结","解","问","意","建","月","公","无","系","军","很","情","者","最","立","代","想","已","通","并","提","直","题","党","程","展","五","果","料","象","员","革","位","入","常","文","总","次","品","式","活","设","及","管","特","件","长","求","老","头","基","资","边","流","路","级","少","图","山","统","接","知","较","将","组","见","计","别","她","手","角","期","根","论","运","农","指","几","九","区","强","放","决","西","被","干","做","必","战","先","回","则","任","取","据","处","队","南","给","色","光","门","即","保","治","北","造","百","规","热","领","七","海","口","东","导","器","压","志","世","金","增","争","济","阶","油","思","术","极","交","受","联","什","认","六","共","权","收","证","改","清","美","再","采","转","更","单","风","切","打","白","教","速","花","带","安","场","身","车","例","真","务","具","万","每","目","至","达","走","积","示","议","声","报","斗","完","类","八","离","华","名","确","才","科","张","信","马","节","话","米","整","空","元","况","今","集","温","传","土","许","步","群","广","石","记","需","段","研","界","拉","林","律","叫","且","究","观","越","织","装","影","算","低","持","音","众","书","布","复","容","儿","须","际","商","非","验","连","断","深","难","近","矿","千","周","委","素","技","备","半","办","青","省","列","习","响","约","支","般","史","感","劳","便","团","往","酸","历","市","克","何","除","消","构","府","称","太","准","精","值","号","率","族","维","划","选","标","写","存","候","毛","亲","快","效","斯","院","查","江","型","眼","王","按","格","养","易","置","派","层","片","始","却","专","状","育","厂","京","识","适","属","圆","包","火","住","调","满","县","局","照","参","红","细","引","听","该","铁","价","严","首","底","液","官","德","随","病","苏","失","尔","死","讲","配","女","黄","推","显","谈","罪","神","艺","呢","席","含","企","望","密","批","营","项","防","举","球","英","氧","势","告","李","台","落","木","帮","轮","破","亚","师","围","注","远","字","材","排","供","河","态","封","另","施","减","树","溶","怎","止","案","言","士","均","武","固","叶","鱼","波","视","仅","费","紧","爱","左","章","早","朝","害","续","轻","服","试","食","充","兵","源","判","护","司","足","某","练","差","致","板","田","降","黑","犯","负","击","范","继","兴","似","余","坚","曲","输","修","故","城","夫","够","送","笔","船","占","右","财","吃","富","春","职","觉","汉","画","功","巴","跟","虽","杂","飞","检","吸","助","升","阳","互","初","创","抗","考","投","坏","策","古","径","换","未","跑","留","钢","曾","端","责","站","简","述","钱","副","尽","帝","射","草","冲","承","独","令","限","阿","宣","环","双","请","超","微","让","控","州","良","轴","找","否","纪","益","依","优","顶","础","载","倒","房","突","坐","粉","敌","略","客","袁","冷","胜","绝","析","块","剂","测","丝","协","诉","念","陈","仍","罗","盐","友","洋","错","苦","夜","刑","移","频","逐","靠","混","母","短","皮","终","聚","汽","村","云","哪","既","距","卫","停","烈","央","察","烧","迅","境","若","印","洲","刻","括","激","孔","搞","甚","室","待","核","校","散","侵","吧","甲","游","久","菜","味","旧","模","湖","货","损","预","阻","毫","普","稳","乙","妈","植","息","扩","银","语","挥","酒","守","拿","序","纸","医","缺","雨","吗","针","刘","啊","急","唱","误","训","愿","审","附","获","茶","鲜","粮","斤","孩","脱","硫","肥","善","龙","演","父","渐","血","欢","械","掌","歌","沙","刚","攻","谓","盾","讨","晚","粒","乱","燃","矛","乎","杀","药","宁","鲁","贵","钟","煤","读","班","伯","香","介","迫","句","丰","培","握","兰","担","弦","蛋","沉","假","穿","执","答","乐","谁","顺","烟","缩","征","脸","喜","松","脚","困","异","免","背","星","福","买","染","井","概","慢","怕","磁","倍","祖","皇","促","静","补","评","翻","肉","践","尼","衣","宽","扬","棉","希","伤","操","垂","秋","宜","氢","套","督","振","架","亮","末","宪","庆","编","牛","触","映","雷","销","诗","座","居","抓","裂","胞","呼","娘","景","威","绿","晶","厚","盟","衡","鸡","孙","延","危","胶","屋","乡","临","陆","顾","掉","呀","灯","岁","措","束","耐","剧","玉","赵","跳","哥","季","课","凯","胡","额","款","绍","卷","齐","伟","蒸","殖","永","宗","苗","川","炉","岩","弱","零","杨","奏","沿","露","杆","探","滑","镇","饭","浓","航","怀","赶","库","夺","伊","灵","税","途","灭","赛","归","召","鼓","播","盘","裁","险","康","唯","录","菌","纯","借","糖","盖","横","符","私","努","堂","域","枪","润","幅","哈","竟","熟","虫","泽","脑","壤","碳","欧","遍","侧","寨","敢","彻","虑","斜","薄","庭","纳","弹","饲","伸","折","麦","湿","暗","荷","瓦","塞","床","筑","恶","户","访","塔","奇","透","梁","刀","旋","迹","卡","氯","遇","份","毒","泥","退","洗","摆","灰","彩","卖","耗","夏","择","忙","铜","献","硬","予","繁","圈","雪","函","亦","抽","篇","阵","阴","丁","尺","追","堆","雄","迎","泛","爸","楼","避","谋","吨","野","猪","旗","累","偏","典","馆","索","秦","脂","潮","爷","豆","忽","托","惊","塑","遗","愈","朱","替","纤","粗","倾","尚","痛","楚","谢","奋","购","磨","君","池","旁","碎","骨","监","捕","弟","暴","割","贯","殊","释","词","亡","壁","顿","宝","午","尘","闻","揭","炮","残","冬","桥","妇","警","综","招","吴","付","浮","遭","徐","您","摇","谷","赞","箱","隔","订","男","吹","园","纷","唐","败","宋","玻","巨","耕","坦","荣","闭","湾","键","凡","驻","锅","救","恩","剥","凝","碱","齿","截","炼","麻","纺","禁","废","盛","版","缓","净","睛","昌","婚","涉","筒","嘴","插","岸","朗","庄","街","藏","姑","贸","腐","奴","啦","惯","乘","伙","恢","匀","纱","扎","辩","耳","彪","臣","亿","璃","抵","脉","秀","萨","俄","网","舞","店","喷","纵","寸","汗","挂","洪","贺","闪","柬","爆","烯","津","稻","墙","软","勇","像","滚","厘","蒙","芳","肯","坡","柱","荡","腿","仪","旅","尾","轧","冰","贡","登","黎","削","钻","勒","逃","障","氨","郭","峰","币","港","伏","轨","亩","毕","擦","莫","刺","浪","秘","援","株","健","售","股","岛","甘","泡","睡","童","铸","汤","阀","休","汇","舍","牧","绕","炸","哲","磷","绩","朋","淡","尖","启","陷","柴","呈","徒","颜","泪","稍","忘","泵","蓝","拖","洞","授","镜","辛","壮","锋","贫","虚","弯","摩","泰","幼","廷","尊","窗","纲","弄","隶","疑","氏","宫","姐","震","瑞","怪","尤","琴","循","描","膜","违","夹","腰","缘","珠","穷","森","枝","竹","沟","催","绳","忆","邦","剩","幸","浆","栏","拥","牙","贮","礼","滤","钠","纹","罢","拍","咱","喊","袖","埃","勤","罚","焦","潜","伍","墨","欲","缝","姓","刊","饱","仿","奖","铝","鬼","丽","跨","默","挖","链","扫","喝","袋","炭","污","幕","诸","弧","励","梅","奶","洁","灾","舟","鉴","苯","讼","抱","毁","懂","寒","智","埔","寄","届","跃","渡","挑","丹","艰","贝","碰","拔","爹","戴","码","梦","芽","熔","赤","渔","哭","敬","颗","奔","铅","仲","虎","稀","妹","乏","珍","申","桌","遵","允","隆","螺","仓","魏","锐","晓","氮","兼","隐","碍","赫","拨","忠","肃","缸","牵","抢","博","巧","壳","兄","杜","讯","诚","碧","祥","柯","页","巡","矩","悲","灌","龄","伦","票","寻","桂","铺","圣","恐","恰","郑","趣","抬","荒","腾","贴","柔","滴","猛","阔","辆","妻","填","撤","储","签","闹","扰","紫","砂","递","戏","吊","陶","伐","喂","疗","瓶","婆","抚","臂","摸","忍","虾","蜡","邻","胸","巩","挤","偶","弃","槽","劲","乳","邓","吉","仁","烂","砖","租","乌","舰","伴","瓜","浅","丙","暂","燥","橡","柳","迷","暖","牌","秧","胆","详","簧","踏","瓷","谱","呆","宾","糊","洛","辉","愤","竞","隙","怒","粘","乃","绪","肩","籍","敏","涂","熙","皆","侦","悬","掘","享","纠","醒","狂","锁","淀","恨","牲","霸","爬","赏","逆","玩","陵","祝","秒","浙","貌","役","彼","悉","鸭","趋","凤","晨","畜","辈","秩","卵","署","梯","炎","滩","棋","驱","筛","峡","冒","啥","寿","译","浸","泉","帽","迟","硅","疆","贷","漏","稿","冠","嫩","胁","芯","牢","叛","蚀","奥","鸣","岭","羊","凭","串","塘","绘","酵","融","盆","锡","庙","筹","冻","辅","摄","袭","筋","拒","僚","旱","钾","鸟","漆","沈","眉","疏","添","棒","穗","硝","韩","逼","扭","侨","凉","挺","碗","栽","炒","杯","患","馏","劝","豪","辽","勃","鸿","旦","吏","拜","狗","埋","辊","掩","饮","搬","骂","辞","勾","扣","估","蒋","绒","雾","丈","朵","姆","拟","宇","辑","陕","雕","偿","蓄","崇","剪","倡","厅","咬","驶","薯","刷","斥","番","赋","奉","佛","浇","漫","曼","扇","钙","桃","扶","仔","返","俗","亏","腔","鞋","棱","覆","框","悄","叔","撞","骗","勘","旺","沸","孤","吐","孟","渠","屈","疾","妙","惜","仰","狠","胀","谐","抛","霉","桑","岗","嘛","衰","盗","渗","脏","赖","涌","甜","曹","阅","肌","哩","厉","烃","纬","毅","昨","伪","症","煮","叹","钉","搭","茎","笼","酷","偷","弓","锥","恒","杰","坑","鼻","翼","纶","叙","狱","逮","罐","络","棚","抑","膨","蔬","寺","骤","穆","冶","枯","册","尸","凸","绅","坯","牺","焰","轰","欣","晋","瘦","御","锭","锦","丧","旬","锻","垄","搜","扑","邀","亭","酯","迈","舒","脆","酶","闲","忧","酚","顽","羽","涨","卸","仗","陪","辟","惩","杭","姚","肚","捉","飘","漂","昆","欺","吾","郎","烷","汁","呵","饰","萧","雅","邮","迁","燕","撒","姻","赴","宴","烦","债","帐","斑","铃","旨","醇","董","饼","雏","姿","拌","傅","腹","妥","揉","贤","拆","歪","葡","胺","丢","浩","徽","昂","垫","挡","览","贪","慰","缴","汪","慌","冯","诺","姜","谊","凶","劣","诬","耀","昏","躺","盈","骑","乔","溪","丛","卢","抹","闷","咨","刮","驾","缆","悟","摘","铒","掷","颇","幻","柄","惠","惨","佳","仇","腊","窝","涤","剑","瞧","堡","泼","葱","罩","霍","捞","胎","苍","滨","俩","捅","湘","砍","霞","邵","萄","疯","淮","遂","熊","粪","烘","宿","档","戈","驳","嫂","裕","徙","箭","捐","肠","撑","晒","辨","殿","莲","摊","搅","酱","屏","疫","哀","蔡","堵","沫","皱","畅","叠","阁","莱","敲","辖","钩","痕","坝","巷","饿","祸","丘","玄","溜","曰","逻","彭","尝","卿","妨","艇","吞","韦","怨","矮","歇"];t.exports=i},{}],5:[function(e,t,r){"use strict";var i=["abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse","access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act","action","actor","actress","actual","adapt","add","addict","address","adjust","admit","adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent","agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert","alien","all","alley","allow","almost","alone","alpha","already","also","alter","always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger","angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique","anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic","area","arena","argue","arm","armed","armor","army","around","arrange","arrest","arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset","assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction","audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake","aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge","bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain","barrel","base","basic","basket","battle","beach","bean","beauty","because","become","beef","before","begin","behave","behind","believe","below","belt","bench","benefit","best","betray","better","between","beyond","bicycle","bid","bike","bind","biology","bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless","blind","blood","blossom","blouse","blue","blur","blush","board","boat","body","boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss","bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread","breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze","broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb","bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy","butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call","calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas","canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry","cart","case","cash","casino","castle","casual","cat","catalog","catch","category","cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century","cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase","chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child","chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle","citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk","clever","click","client","cliff","climb","clinic","clip","clock","clog","close","cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut","code","coffee","coil","coin","collect","color","column","combine","come","comfort","comic","common","company","concert","conduct","confirm","congress","connect","consider","control","convince","cook","cool","copper","copy","coral","core","corn","correct","cost","cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle","craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek","crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial","cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup","cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad","damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal","debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense","define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny","depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk","despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond","diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur","direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance","divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain","donate","donkey","donor","door","dose","double","dove","draft","dragon","drama","drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop","drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf","dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo","ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow","elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody","embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless","endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough","enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip","era","erase","erode","erosion","error","erupt","escape","essay","essence","estate","eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange","excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit","exotic","expand","expect","expire","explain","expose","express","extend","extra","eye","eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame","family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father","fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female","fence","festival","fetch","fever","few","fiber","fiction","field","figure","file","film","filter","final","find","fine","finger","finish","fire","firm","first","fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor","flee","flight","flip","float","flock","floor","flower","fluid","flush","fly","foam","focus","fog","foil","fold","follow","food","foot","force","forest","forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile","frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen","fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy","gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp","gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture","ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance","glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue","goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown","grab","grace","grain","grant","grape","grass","gravity","great","green","grid","grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt","guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy","harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health","heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden","high","hill","hint","hip","hire","history","hobby","hockey","hold","hole","holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital","host","hotel","hour","hover","hub","huge","human","humble","humor","hundred","hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea","identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune","impact","impose","improve","impulse","inch","include","income","increase","index","indicate","indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury","inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install","intact","interest","into","invest","invite","involve","iron","island","isolate","issue","item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel","job","join","joke","journey","joy","judge","juice","jump","jungle","junior","junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney","kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife","knock","know","lab","label","labor","ladder","lady","lake","lamp","language","laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit","layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal","legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level","liar","liberty","library","license","life","lift","light","like","limb","limit","link","lion","liquid","list","little","live","lizard","load","loan","lobster","local","lock","logic","lonely","long","loop","lottery","loud","lounge","love","loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad","magic","magnet","maid","mail","main","major","make","mammal","man","manage","mandate","mango","mansion","manual","maple","marble","march","margin","marine","market","marriage","mask","mass","master","match","material","math","matrix","matter","maximum","maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt","member","memory","mention","menu","mercy","merge","merit","merry","mesh","message","metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor","minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile","model","modify","mom","moment","monitor","monkey","monster","month","moon","moral","more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie","much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual","myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature","near","neck","need","negative","neglect","neither","nephew","nerve","nest","net","network","neutral","never","news","next","nice","night","noble","noise","nominee","noodle","normal","north","nose","notable","note","nothing","notice","novel","now","nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe","obtain","obvious","occur","ocean","october","odor","off","offer","office","often","oil","okay","old","olive","olympic","omit","once","one","onion","online","only","open","opera","opinion","oppose","option","orange","orbit","orchard","order","ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output","outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact","paddle","page","pair","palace","palm","panda","panel","panic","panther","paper","parade","parent","park","parrot","party","pass","patch","path","patient","patrol","pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen","penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo","phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot","pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate","play","please","pledge","pluck","plug","plunge","poem","poet","point","polar","pole","police","pond","pony","pool","popular","portion","position","possible","post","potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare","present","pretty","prevent","price","pride","primary","print","priority","prison","private","prize","problem","process","produce","profit","program","project","promote","proof","property","prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin","punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle","pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit","raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp","ranch","random","range","rapid","rare","rate","rather","raven","raw","razor","ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle","reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release","relief","rely","remain","remember","remind","remove","render","renew","rent","reopen","repair","repeat","replace","report","require","rescue","resemble","resist","resource","response","result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib","ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot","ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket","romance","roof","rookie","room","rose","rotate","rough","round","route","royal","rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness","safe","sail","salad","salmon","salon","salt","salute","same","sample","sand","satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter","scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script","scrub","sea","search","season","seat","second","secret","section","security","seed","seek","segment","select","sell","seminar","senior","sense","sentence","series","service","session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell","sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop","short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side","siege","sight","sign","silent","silk","silly","silver","similar","simple","since","sing","siren","sister","situate","six","size","skate","sketch","ski","skill","skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight","slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth","snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda","soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry","sort","soul","sound","soup","source","south","space","spare","spatial","spawn","speak","special","speed","spell","spend","sphere","spice","spider","spike","spin","spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring","spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp","stand","start","state","stay","steak","steel","stem","step","stereo","stick","still","sting","stock","stomach","stone","stool","story","stove","strategy","street","strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway","success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny","sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey","suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim","swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag","tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi","teach","team","tell","ten","tenant","tennis","tent","term","test","text","thank","that","theme","then","theory","there","they","thing","this","thought","three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber","time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler","toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool","tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist","toward","tower","town","toy","track","trade","traffic","tragic","train","transfer","trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick","trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust","truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle","twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella","unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform","unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade","uphold","upon","upper","upset","urban","urge","usage","use","used","useful","useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van","vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue","verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory","video","view","village","vintage","violin","virtual","virus","visa","visit","visual","vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage","wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash","wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather","web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat","wheel","when","where","whip","whisper","wide","width","wife","wild","will","win","window","wine","wing","wink","winner","winter","wire","wisdom","wise","wish","witness","wolf","woman","wonder","wood","wool","word","work","world","worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year","yellow","you","young","youth","zebra","zero","zone","zoo"];t.exports=i},{}],6:[function(e,t,r){"use string";var i=["abaisser","abandon","abdiquer","abeille","abolir","aborder","aboutir","aboyer","abrasif","abreuver","abriter","abroger","abrupt","absence","absolu","absurde","abusif","abyssal","académie","acajou","acarien","accabler","accepter","acclamer","accolade","accroche","accuser","acerbe","achat","acheter","aciduler","acier","acompte","acquérir","acronyme","acteur","actif","actuel","adepte","adéquat","adhésif","adjectif","adjuger","admettre","admirer","adopter","adorer","adoucir","adresse","adroit","adulte","adverbe","aérer","aéronef","affaire","affecter","affiche","affreux","affubler","agacer","agencer","agile","agiter","agrafer","agréable","agrume","aider","aiguille","ailier","aimable","aisance","ajouter","ajuster","alarmer","alchimie","alerte","algèbre","algue","aliéner","aliment","alléger","alliage","allouer","allumer","alourdir","alpaga","altesse","alvéole","amateur","ambigu","ambre","aménager","amertume","amidon","amiral","amorcer","amour","amovible","amphibie","ampleur","amusant","analyse","anaphore","anarchie","anatomie","ancien","anéantir","angle","angoisse","anguleux","animal","annexer","annonce","annuel","anodin","anomalie","anonyme","anormal","antenne","antidote","anxieux","apaiser","apéritif","aplanir","apologie","appareil","appeler","apporter","appuyer","aquarium","aqueduc","arbitre","arbuste","ardeur","ardoise","argent","arlequin","armature","armement","armoire","armure","arpenter","arracher","arriver","arroser","arsenic","artériel","article","aspect","asphalte","aspirer","assaut","asservir","assiette","associer","assurer","asticot","astre","astuce","atelier","atome","atrium","atroce","attaque","attentif","attirer","attraper","aubaine","auberge","audace","audible","augurer","aurore","automne","autruche","avaler","avancer","avarice","avenir","averse","aveugle","aviateur","avide","avion","aviser","avoine","avouer","avril","axial","axiome","badge","bafouer","bagage","baguette","baignade","balancer","balcon","baleine","balisage","bambin","bancaire","bandage","banlieue","bannière","banquier","barbier","baril","baron","barque","barrage","bassin","bastion","bataille","bateau","batterie","baudrier","bavarder","belette","bélier","belote","bénéfice","berceau","berger","berline","bermuda","besace","besogne","bétail","beurre","biberon","bicycle","bidule","bijou","bilan","bilingue","billard","binaire","biologie","biopsie","biotype","biscuit","bison","bistouri","bitume","bizarre","blafard","blague","blanchir","blessant","blinder","blond","bloquer","blouson","bobard","bobine","boire","boiser","bolide","bonbon","bondir","bonheur","bonifier","bonus","bordure","borne","botte","boucle","boueux","bougie","boulon","bouquin","bourse","boussole","boutique","boxeur","branche","brasier","brave","brebis","brèche","breuvage","bricoler","brigade","brillant","brioche","brique","brochure","broder","bronzer","brousse","broyeur","brume","brusque","brutal","bruyant","buffle","buisson","bulletin","bureau","burin","bustier","butiner","butoir","buvable","buvette","cabanon","cabine","cachette","cadeau","cadre","caféine","caillou","caisson","calculer","calepin","calibre","calmer","calomnie","calvaire","camarade","caméra","camion","campagne","canal","caneton","canon","cantine","canular","capable","caporal","caprice","capsule","capter","capuche","carabine","carbone","caresser","caribou","carnage","carotte","carreau","carton","cascade","casier","casque","cassure","causer","caution","cavalier","caverne","caviar","cédille","ceinture","céleste","cellule","cendrier","censurer","central","cercle","cérébral","cerise","cerner","cerveau","cesser","chagrin","chaise","chaleur","chambre","chance","chapitre","charbon","chasseur","chaton","chausson","chavirer","chemise","chenille","chéquier","chercher","cheval","chien","chiffre","chignon","chimère","chiot","chlorure","chocolat","choisir","chose","chouette","chrome","chute","cigare","cigogne","cimenter","cinéma","cintrer","circuler","cirer","cirque","citerne","citoyen","citron","civil","clairon","clameur","claquer","classe","clavier","client","cligner","climat","clivage","cloche","clonage","cloporte","cobalt","cobra","cocasse","cocotier","coder","codifier","coffre","cogner","cohésion","coiffer","coincer","colère","colibri","colline","colmater","colonel","combat","comédie","commande","compact","concert","conduire","confier","congeler","connoter","consonne","contact","convexe","copain","copie","corail","corbeau","cordage","corniche","corpus","correct","cortège","cosmique","costume","coton","coude","coupure","courage","couteau","couvrir","coyote","crabe","crainte","cravate","crayon","créature","créditer","crémeux","creuser","crevette","cribler","crier","cristal","critère","croire","croquer","crotale","crucial","cruel","crypter","cubique","cueillir","cuillère","cuisine","cuivre","culminer","cultiver","cumuler","cupide","curatif","curseur","cyanure","cycle","cylindre","cynique","daigner","damier","danger","danseur","dauphin","débattre","débiter","déborder","débrider","débutant","décaler","décembre","déchirer","décider","déclarer","décorer","décrire","décupler","dédale","déductif","déesse","défensif","défiler","défrayer","dégager","dégivrer","déglutir","dégrafer","déjeuner","délice","déloger","demander","demeurer","démolir","dénicher","dénouer","dentelle","dénuder","départ","dépenser","déphaser","déplacer","déposer","déranger","dérober","désastre","descente","désert","désigner","désobéir","dessiner","destrier","détacher","détester","détourer","détresse","devancer","devenir","deviner","devoir","diable","dialogue","diamant","dicter","différer","digérer","digital","digne","diluer","dimanche","diminuer","dioxyde","directif","diriger","discuter","disposer","dissiper","distance","divertir","diviser","docile","docteur","dogme","doigt","domaine","domicile","dompter","donateur","donjon","donner","dopamine","dortoir","dorure","dosage","doseur","dossier","dotation","douanier","double","douceur","douter","doyen","dragon","draper","dresser","dribbler","droiture","duperie","duplexe","durable","durcir","dynastie","éblouir","écarter","écharpe","échelle","éclairer","éclipse","éclore","écluse","école","économie","écorce","écouter","écraser","écrémer","écrivain","écrou","écume","écureuil","édifier","éduquer","effacer","effectif","effigie","effort","effrayer","effusion","égaliser","égarer","éjecter","élaborer","élargir","électron","élégant","éléphant","élève","éligible","élitisme","éloge","élucider","éluder","emballer","embellir","embryon","émeraude","émission","emmener","émotion","émouvoir","empereur","employer","emporter","emprise","émulsion","encadrer","enchère","enclave","encoche","endiguer","endosser","endroit","enduire","énergie","enfance","enfermer","enfouir","engager","engin","englober","énigme","enjamber","enjeu","enlever","ennemi","ennuyeux","enrichir","enrobage","enseigne","entasser","entendre","entier","entourer","entraver","énumérer","envahir","enviable","envoyer","enzyme","éolien","épaissir","épargne","épatant","épaule","épicerie","épidémie","épier","épilogue","épine","épisode","épitaphe","époque","épreuve","éprouver","épuisant","équerre","équipe","ériger","érosion","erreur","éruption","escalier","espadon","espèce","espiègle","espoir","esprit","esquiver","essayer","essence","essieu","essorer","estime","estomac","estrade","étagère","étaler","étanche","étatique","éteindre","étendoir","éternel","éthanol","éthique","ethnie","étirer","étoffer","étoile","étonnant","étourdir","étrange","étroit","étude","euphorie","évaluer","évasion","éventail","évidence","éviter","évolutif","évoquer","exact","exagérer","exaucer","exceller","excitant","exclusif","excuse","exécuter","exemple","exercer","exhaler","exhorter","exigence","exiler","exister","exotique","expédier","explorer","exposer","exprimer","exquis","extensif","extraire","exulter","fable","fabuleux","facette","facile","facture","faiblir","falaise","fameux","famille","farceur","farfelu","farine","farouche","fasciner","fatal","fatigue","faucon","fautif","faveur","favori","fébrile","féconder","fédérer","félin","femme","fémur","fendoir","féodal","fermer","féroce","ferveur","festival","feuille","feutre","février","fiasco","ficeler","fictif","fidèle","figure","filature","filetage","filière","filleul","filmer","filou","filtrer","financer","finir","fiole","firme","fissure","fixer","flairer","flamme","flasque","flatteur","fléau","flèche","fleur","flexion","flocon","flore","fluctuer","fluide","fluvial","folie","fonderie","fongible","fontaine","forcer","forgeron","formuler","fortune","fossile","foudre","fougère","fouiller","foulure","fourmi","fragile","fraise","franchir","frapper","frayeur","frégate","freiner","frelon","frémir","frénésie","frère","friable","friction","frisson","frivole","froid","fromage","frontal","frotter","fruit","fugitif","fuite","fureur","furieux","furtif","fusion","futur","gagner","galaxie","galerie","gambader","garantir","gardien","garnir","garrigue","gazelle","gazon","géant","gélatine","gélule","gendarme","général","génie","genou","gentil","géologie","géomètre","géranium","germe","gestuel","geyser","gibier","gicler","girafe","givre","glace","glaive","glisser","globe","gloire","glorieux","golfeur","gomme","gonfler","gorge","gorille","goudron","gouffre","goulot","goupille","gourmand","goutte","graduel","graffiti","graine","grand","grappin","gratuit","gravir","grenat","griffure","griller","grimper","grogner","gronder","grotte","groupe","gruger","grutier","gruyère","guépard","guerrier","guide","guimauve","guitare","gustatif","gymnaste","gyrostat","habitude","hachoir","halte","hameau","hangar","hanneton","haricot","harmonie","harpon","hasard","hélium","hématome","herbe","hérisson","hermine","héron","hésiter","heureux","hiberner","hibou","hilarant","histoire","hiver","homard","hommage","homogène","honneur","honorer","honteux","horde","horizon","horloge","hormone","horrible","houleux","housse","hublot","huileux","humain","humble","humide","humour","hurler","hydromel","hygiène","hymne","hypnose","idylle","ignorer","iguane","illicite","illusion","image","imbiber","imiter","immense","immobile","immuable","impact","impérial","implorer","imposer","imprimer","imputer","incarner","incendie","incident","incliner","incolore","indexer","indice","inductif","inédit","ineptie","inexact","infini","infliger","informer","infusion","ingérer","inhaler","inhiber","injecter","injure","innocent","inoculer","inonder","inscrire","insecte","insigne","insolite","inspirer","instinct","insulter","intact","intense","intime","intrigue","intuitif","inutile","invasion","inventer","inviter","invoquer","ironique","irradier","irréel","irriter","isoler","ivoire","ivresse","jaguar","jaillir","jambe","janvier","jardin","jauger","jaune","javelot","jetable","jeton","jeudi","jeunesse","joindre","joncher","jongler","joueur","jouissif","journal","jovial","joyau","joyeux","jubiler","jugement","junior","jupon","juriste","justice","juteux","juvénile","kayak","kimono","kiosque","label","labial","labourer","lacérer","lactose","lagune","laine","laisser","laitier","lambeau","lamelle","lampe","lanceur","langage","lanterne","lapin","largeur","larme","laurier","lavabo","lavoir","lecture","légal","léger","légume","lessive","lettre","levier","lexique","lézard","liasse","libérer","libre","licence","licorne","liège","lièvre","ligature","ligoter","ligue","limer","limite","limonade","limpide","linéaire","lingot","lionceau","liquide","lisière","lister","lithium","litige","littoral","livreur","logique","lointain","loisir","lombric","loterie","louer","lourd","loutre","louve","loyal","lubie","lucide","lucratif","lueur","lugubre","luisant","lumière","lunaire","lundi","luron","lutter","luxueux","machine","magasin","magenta","magique","maigre","maillon","maintien","mairie","maison","majorer","malaxer","maléfice","malheur","malice","mallette","mammouth","mandater","maniable","manquant","manteau","manuel","marathon","marbre","marchand","mardi","maritime","marqueur","marron","marteler","mascotte","massif","matériel","matière","matraque","maudire","maussade","mauve","maximal","méchant","méconnu","médaille","médecin","méditer","méduse","meilleur","mélange","mélodie","membre","mémoire","menacer","mener","menhir","mensonge","mentor","mercredi","mérite","merle","messager","mesure","métal","météore","méthode","métier","meuble","miauler","microbe","miette","mignon","migrer","milieu","million","mimique","mince","minéral","minimal","minorer","minute","miracle","miroiter","missile","mixte","mobile","moderne","moelleux","mondial","moniteur","monnaie","monotone","monstre","montagne","monument","moqueur","morceau","morsure","mortier","moteur","motif","mouche","moufle","moulin","mousson","mouton","mouvant","multiple","munition","muraille","murène","murmure","muscle","muséum","musicien","mutation","muter","mutuel","myriade","myrtille","mystère","mythique","nageur","nappe","narquois","narrer","natation","nation","nature","naufrage","nautique","navire","nébuleux","nectar","néfaste","négation","négliger","négocier","neige","nerveux","nettoyer","neurone","neutron","neveu","niche","nickel","nitrate","niveau","noble","nocif","nocturne","noirceur","noisette","nomade","nombreux","nommer","normatif","notable","notifier","notoire","nourrir","nouveau","novateur","novembre","novice","nuage","nuancer","nuire","nuisible","numéro","nuptial","nuque","nutritif","obéir","objectif","obliger","obscur","observer","obstacle","obtenir","obturer","occasion","occuper","océan","octobre","octroyer","octupler","oculaire","odeur","odorant","offenser","officier","offrir","ogive","oiseau","oisillon","olfactif","olivier","ombrage","omettre","onctueux","onduler","onéreux","onirique","opale","opaque","opérer","opinion","opportun","opprimer","opter","optique","orageux","orange","orbite","ordonner","oreille","organe","orgueil","orifice","ornement","orque","ortie","osciller","osmose","ossature","otarie","ouragan","ourson","outil","outrager","ouvrage","ovation","oxyde","oxygène","ozone","paisible","palace","palmarès","palourde","palper","panache","panda","pangolin","paniquer","panneau","panorama","pantalon","papaye","papier","papoter","papyrus","paradoxe","parcelle","paresse","parfumer","parler","parole","parrain","parsemer","partager","parure","parvenir","passion","pastèque","paternel","patience","patron","pavillon","pavoiser","payer","paysage","peigne","peintre","pelage","pélican","pelle","pelouse","peluche","pendule","pénétrer","pénible","pensif","pénurie","pépite","péplum","perdrix","perforer","période","permuter","perplexe","persil","perte","peser","pétale","petit","pétrir","peuple","pharaon","phobie","phoque","photon","phrase","physique","piano","pictural","pièce","pierre","pieuvre","pilote","pinceau","pipette","piquer","pirogue","piscine","piston","pivoter","pixel","pizza","placard","plafond","plaisir","planer","plaque","plastron","plateau","pleurer","plexus","pliage","plomb","plonger","pluie","plumage","pochette","poésie","poète","pointe","poirier","poisson","poivre","polaire","policier","pollen","polygone","pommade","pompier","ponctuel","pondérer","poney","portique","position","posséder","posture","potager","poteau","potion","pouce","poulain","poumon","pourpre","poussin","pouvoir","prairie","pratique","précieux","prédire","préfixe","prélude","prénom","présence","prétexte","prévoir","primitif","prince","prison","priver","problème","procéder","prodige","profond","progrès","proie","projeter","prologue","promener","propre","prospère","protéger","prouesse","proverbe","prudence","pruneau","psychose","public","puceron","puiser","pulpe","pulsar","punaise","punitif","pupitre","purifier","puzzle","pyramide","quasar","querelle","question","quiétude","quitter","quotient","racine","raconter","radieux","ragondin","raideur","raisin","ralentir","rallonge","ramasser","rapide","rasage","ratisser","ravager","ravin","rayonner","réactif","réagir","réaliser","réanimer","recevoir","réciter","réclamer","récolter","recruter","reculer","recycler","rédiger","redouter","refaire","réflexe","réformer","refrain","refuge","régalien","région","réglage","régulier","réitérer","rejeter","rejouer","relatif","relever","relief","remarque","remède","remise","remonter","remplir","remuer","renard","renfort","renifler","renoncer","rentrer","renvoi","replier","reporter","reprise","reptile","requin","réserve","résineux","résoudre","respect","rester","résultat","rétablir","retenir","réticule","retomber","retracer","réunion","réussir","revanche","revivre","révolte","révulsif","richesse","rideau","rieur","rigide","rigoler","rincer","riposter","risible","risque","rituel","rival","rivière","rocheux","romance","rompre","ronce","rondin","roseau","rosier","rotatif","rotor","rotule","rouge","rouille","rouleau","routine","royaume","ruban","rubis","ruche","ruelle","rugueux","ruiner","ruisseau","ruser","rustique","rythme","sabler","saboter","sabre","sacoche","safari","sagesse","saisir","salade","salive","salon","saluer","samedi","sanction","sanglier","sarcasme","sardine","saturer","saugrenu","saumon","sauter","sauvage","savant","savonner","scalpel","scandale","scélérat","scénario","sceptre","schéma","science","scinder","score","scrutin","sculpter","séance","sécable","sécher","secouer","sécréter","sédatif","séduire","seigneur","séjour","sélectif","semaine","sembler","semence","séminal","sénateur","sensible","sentence","séparer","séquence","serein","sergent","sérieux","serrure","sérum","service","sésame","sévir","sevrage","sextuple","sidéral","siècle","siéger","siffler","sigle","signal","silence","silicium","simple","sincère","sinistre","siphon","sirop","sismique","situer","skier","social","socle","sodium","soigneux","soldat","soleil","solitude","soluble","sombre","sommeil","somnoler","sonde","songeur","sonnette","sonore","sorcier","sortir","sosie","sottise","soucieux","soudure","souffle","soulever","soupape","source","soutirer","souvenir","spacieux","spatial","spécial","sphère","spiral","stable","station","sternum","stimulus","stipuler","strict","studieux","stupeur","styliste","sublime","substrat","subtil","subvenir","succès","sucre","suffixe","suggérer","suiveur","sulfate","superbe","supplier","surface","suricate","surmener","surprise","sursaut","survie","suspect","syllabe","symbole","symétrie","synapse","syntaxe","système","tabac","tablier","tactile","tailler","talent","talisman","talonner","tambour","tamiser","tangible","tapis","taquiner","tarder","tarif","tartine","tasse","tatami","tatouage","taupe","taureau","taxer","témoin","temporel","tenaille","tendre","teneur","tenir","tension","terminer","terne","terrible","tétine","texte","thème","théorie","thérapie","thorax","tibia","tiède","timide","tirelire","tiroir","tissu","titane","titre","tituber","toboggan","tolérant","tomate","tonique","tonneau","toponyme","torche","tordre","tornade","torpille","torrent","torse","tortue","totem","toucher","tournage","tousser","toxine","traction","trafic","tragique","trahir","train","trancher","travail","trèfle","tremper","trésor","treuil","triage","tribunal","tricoter","trilogie","triomphe","tripler","triturer","trivial","trombone","tronc","tropical","troupeau","tuile","tulipe","tumulte","tunnel","turbine","tuteur","tutoyer","tuyau","tympan","typhon","typique","tyran","ubuesque","ultime","ultrason","unanime","unifier","union","unique","unitaire","univers","uranium","urbain","urticant","usage","usine","usuel","usure","utile","utopie","vacarme","vaccin","vagabond","vague","vaillant","vaincre","vaisseau","valable","valise","vallon","valve","vampire","vanille","vapeur","varier","vaseux","vassal","vaste","vecteur","vedette","végétal","véhicule","veinard","véloce","vendredi","vénérer","venger","venimeux","ventouse","verdure","vérin","vernir","verrou","verser","vertu","veston","vétéran","vétuste","vexant","vexer","viaduc","viande","victoire","vidange","vidéo","vignette","vigueur","vilain","village","vinaigre","violon","vipère","virement","virtuose","virus","visage","viseur","vision","visqueux","visuel","vital","vitesse","viticole","vitrine","vivace","vivipare","vocation","voguer","voile","voisin","voiture","volaille","volcan","voltiger","volume","vorace","vortex","voter","vouloir","voyage","voyelle","wagon","xénon","yacht","zèbre","zénith","zeste","zoologie"]; +t.exports=i},{}],7:[function(e,t,r){t.exports={CHINESE:e("./chinese"),ENGLISH:e("./english"),FRENCH:e("./french"),JAPANESE:e("./japanese"),SPANISH:e("./spanish")}},{"./chinese":4,"./english":5,"./french":6,"./japanese":8,"./spanish":9}],8:[function(e,t,r){"use strict";var i=["あいこくしん","あいさつ","あいだ","あおぞら","あかちゃん","あきる","あけがた","あける","あこがれる","あさい","あさひ","あしあと","あじわう","あずかる","あずき","あそぶ","あたえる","あたためる","あたりまえ","あたる","あつい","あつかう","あっしゅく","あつまり","あつめる","あてな","あてはまる","あひる","あぶら","あぶる","あふれる","あまい","あまど","あまやかす","あまり","あみもの","あめりか","あやまる","あゆむ","あらいぐま","あらし","あらすじ","あらためる","あらゆる","あらわす","ありがとう","あわせる","あわてる","あんい","あんがい","あんこ","あんぜん","あんてい","あんない","あんまり","いいだす","いおん","いがい","いがく","いきおい","いきなり","いきもの","いきる","いくじ","いくぶん","いけばな","いけん","いこう","いこく","いこつ","いさましい","いさん","いしき","いじゅう","いじょう","いじわる","いずみ","いずれ","いせい","いせえび","いせかい","いせき","いぜん","いそうろう","いそがしい","いだい","いだく","いたずら","いたみ","いたりあ","いちおう","いちじ","いちど","いちば","いちぶ","いちりゅう","いつか","いっしゅん","いっせい","いっそう","いったん","いっち","いってい","いっぽう","いてざ","いてん","いどう","いとこ","いない","いなか","いねむり","いのち","いのる","いはつ","いばる","いはん","いびき","いひん","いふく","いへん","いほう","いみん","いもうと","いもたれ","いもり","いやがる","いやす","いよかん","いよく","いらい","いらすと","いりぐち","いりょう","いれい","いれもの","いれる","いろえんぴつ","いわい","いわう","いわかん","いわば","いわゆる","いんげんまめ","いんさつ","いんしょう","いんよう","うえき","うえる","うおざ","うがい","うかぶ","うかべる","うきわ","うくらいな","うくれれ","うけたまわる","うけつけ","うけとる","うけもつ","うける","うごかす","うごく","うこん","うさぎ","うしなう","うしろがみ","うすい","うすぎ","うすぐらい","うすめる","うせつ","うちあわせ","うちがわ","うちき","うちゅう","うっかり","うつくしい","うったえる","うつる","うどん","うなぎ","うなじ","うなずく","うなる","うねる","うのう","うぶげ","うぶごえ","うまれる","うめる","うもう","うやまう","うよく","うらがえす","うらぐち","うらない","うりあげ","うりきれ","うるさい","うれしい","うれゆき","うれる","うろこ","うわき","うわさ","うんこう","うんちん","うんてん","うんどう","えいえん","えいが","えいきょう","えいご","えいせい","えいぶん","えいよう","えいわ","えおり","えがお","えがく","えきたい","えくせる","えしゃく","えすて","えつらん","えのぐ","えほうまき","えほん","えまき","えもじ","えもの","えらい","えらぶ","えりあ","えんえん","えんかい","えんぎ","えんげき","えんしゅう","えんぜつ","えんそく","えんちょう","えんとつ","おいかける","おいこす","おいしい","おいつく","おうえん","おうさま","おうじ","おうせつ","おうたい","おうふく","おうべい","おうよう","おえる","おおい","おおう","おおどおり","おおや","おおよそ","おかえり","おかず","おがむ","おかわり","おぎなう","おきる","おくさま","おくじょう","おくりがな","おくる","おくれる","おこす","おこなう","おこる","おさえる","おさない","おさめる","おしいれ","おしえる","おじぎ","おじさん","おしゃれ","おそらく","おそわる","おたがい","おたく","おだやか","おちつく","おっと","おつり","おでかけ","おとしもの","おとなしい","おどり","おどろかす","おばさん","おまいり","おめでとう","おもいで","おもう","おもたい","おもちゃ","おやつ","おやゆび","およぼす","おらんだ","おろす","おんがく","おんけい","おんしゃ","おんせん","おんだん","おんちゅう","おんどけい","かあつ","かいが","がいき","がいけん","がいこう","かいさつ","かいしゃ","かいすいよく","かいぜん","かいぞうど","かいつう","かいてん","かいとう","かいふく","がいへき","かいほう","かいよう","がいらい","かいわ","かえる","かおり","かかえる","かがく","かがし","かがみ","かくご","かくとく","かざる","がぞう","かたい","かたち","がちょう","がっきゅう","がっこう","がっさん","がっしょう","かなざわし","かのう","がはく","かぶか","かほう","かほご","かまう","かまぼこ","かめれおん","かゆい","かようび","からい","かるい","かろう","かわく","かわら","がんか","かんけい","かんこう","かんしゃ","かんそう","かんたん","かんち","がんばる","きあい","きあつ","きいろ","ぎいん","きうい","きうん","きえる","きおう","きおく","きおち","きおん","きかい","きかく","きかんしゃ","ききて","きくばり","きくらげ","きけんせい","きこう","きこえる","きこく","きさい","きさく","きさま","きさらぎ","ぎじかがく","ぎしき","ぎじたいけん","ぎじにってい","ぎじゅつしゃ","きすう","きせい","きせき","きせつ","きそう","きぞく","きぞん","きたえる","きちょう","きつえん","ぎっちり","きつつき","きつね","きてい","きどう","きどく","きない","きなが","きなこ","きぬごし","きねん","きのう","きのした","きはく","きびしい","きひん","きふく","きぶん","きぼう","きほん","きまる","きみつ","きむずかしい","きめる","きもだめし","きもち","きもの","きゃく","きやく","ぎゅうにく","きよう","きょうりゅう","きらい","きらく","きりん","きれい","きれつ","きろく","ぎろん","きわめる","ぎんいろ","きんかくじ","きんじょ","きんようび","ぐあい","くいず","くうかん","くうき","くうぐん","くうこう","ぐうせい","くうそう","ぐうたら","くうふく","くうぼ","くかん","くきょう","くげん","ぐこう","くさい","くさき","くさばな","くさる","くしゃみ","くしょう","くすのき","くすりゆび","くせげ","くせん","ぐたいてき","くださる","くたびれる","くちこみ","くちさき","くつした","ぐっすり","くつろぐ","くとうてん","くどく","くなん","くねくね","くのう","くふう","くみあわせ","くみたてる","くめる","くやくしょ","くらす","くらべる","くるま","くれる","くろう","くわしい","ぐんかん","ぐんしょく","ぐんたい","ぐんて","けあな","けいかく","けいけん","けいこ","けいさつ","げいじゅつ","けいたい","げいのうじん","けいれき","けいろ","けおとす","けおりもの","げきか","げきげん","げきだん","げきちん","げきとつ","げきは","げきやく","げこう","げこくじょう","げざい","けさき","げざん","けしき","けしごむ","けしょう","げすと","けたば","けちゃっぷ","けちらす","けつあつ","けつい","けつえき","けっこん","けつじょ","けっせき","けってい","けつまつ","げつようび","げつれい","けつろん","げどく","けとばす","けとる","けなげ","けなす","けなみ","けぬき","げねつ","けねん","けはい","げひん","けぶかい","げぼく","けまり","けみかる","けむし","けむり","けもの","けらい","けろけろ","けわしい","けんい","けんえつ","けんお","けんか","げんき","けんげん","けんこう","けんさく","けんしゅう","けんすう","げんそう","けんちく","けんてい","けんとう","けんない","けんにん","げんぶつ","けんま","けんみん","けんめい","けんらん","けんり","こあくま","こいぬ","こいびと","ごうい","こうえん","こうおん","こうかん","ごうきゅう","ごうけい","こうこう","こうさい","こうじ","こうすい","ごうせい","こうそく","こうたい","こうちゃ","こうつう","こうてい","こうどう","こうない","こうはい","ごうほう","ごうまん","こうもく","こうりつ","こえる","こおり","ごかい","ごがつ","ごかん","こくご","こくさい","こくとう","こくない","こくはく","こぐま","こけい","こける","ここのか","こころ","こさめ","こしつ","こすう","こせい","こせき","こぜん","こそだて","こたい","こたえる","こたつ","こちょう","こっか","こつこつ","こつばん","こつぶ","こてい","こてん","ことがら","ことし","ことば","ことり","こなごな","こねこね","このまま","このみ","このよ","ごはん","こひつじ","こふう","こふん","こぼれる","ごまあぶら","こまかい","ごますり","こまつな","こまる","こむぎこ","こもじ","こもち","こもの","こもん","こやく","こやま","こゆう","こゆび","こよい","こよう","こりる","これくしょん","ころっけ","こわもて","こわれる","こんいん","こんかい","こんき","こんしゅう","こんすい","こんだて","こんとん","こんなん","こんびに","こんぽん","こんまけ","こんや","こんれい","こんわく","ざいえき","さいかい","さいきん","ざいげん","ざいこ","さいしょ","さいせい","ざいたく","ざいちゅう","さいてき","ざいりょう","さうな","さかいし","さがす","さかな","さかみち","さがる","さぎょう","さくし","さくひん","さくら","さこく","さこつ","さずかる","ざせき","さたん","さつえい","ざつおん","ざっか","ざつがく","さっきょく","ざっし","さつじん","ざっそう","さつたば","さつまいも","さてい","さといも","さとう","さとおや","さとし","さとる","さのう","さばく","さびしい","さべつ","さほう","さほど","さます","さみしい","さみだれ","さむけ","さめる","さやえんどう","さゆう","さよう","さよく","さらだ","ざるそば","さわやか","さわる","さんいん","さんか","さんきゃく","さんこう","さんさい","ざんしょ","さんすう","さんせい","さんそ","さんち","さんま","さんみ","さんらん","しあい","しあげ","しあさって","しあわせ","しいく","しいん","しうち","しえい","しおけ","しかい","しかく","じかん","しごと","しすう","じだい","したうけ","したぎ","したて","したみ","しちょう","しちりん","しっかり","しつじ","しつもん","してい","してき","してつ","じてん","じどう","しなぎれ","しなもの","しなん","しねま","しねん","しのぐ","しのぶ","しはい","しばかり","しはつ","しはらい","しはん","しひょう","しふく","じぶん","しへい","しほう","しほん","しまう","しまる","しみん","しむける","じむしょ","しめい","しめる","しもん","しゃいん","しゃうん","しゃおん","じゃがいも","しやくしょ","しゃくほう","しゃけん","しゃこ","しゃざい","しゃしん","しゃせん","しゃそう","しゃたい","しゃちょう","しゃっきん","じゃま","しゃりん","しゃれい","じゆう","じゅうしょ","しゅくはく","じゅしん","しゅっせき","しゅみ","しゅらば","じゅんばん","しょうかい","しょくたく","しょっけん","しょどう","しょもつ","しらせる","しらべる","しんか","しんこう","じんじゃ","しんせいじ","しんちく","しんりん","すあげ","すあし","すあな","ずあん","すいえい","すいか","すいとう","ずいぶん","すいようび","すうがく","すうじつ","すうせん","すおどり","すきま","すくう","すくない","すける","すごい","すこし","ずさん","すずしい","すすむ","すすめる","すっかり","ずっしり","ずっと","すてき","すてる","すねる","すのこ","すはだ","すばらしい","ずひょう","ずぶぬれ","すぶり","すふれ","すべて","すべる","ずほう","すぼん","すまい","すめし","すもう","すやき","すらすら","するめ","すれちがう","すろっと","すわる","すんぜん","すんぽう","せあぶら","せいかつ","せいげん","せいじ","せいよう","せおう","せかいかん","せきにん","せきむ","せきゆ","せきらんうん","せけん","せこう","せすじ","せたい","せたけ","せっかく","せっきゃく","ぜっく","せっけん","せっこつ","せっさたくま","せつぞく","せつだん","せつでん","せっぱん","せつび","せつぶん","せつめい","せつりつ","せなか","せのび","せはば","せびろ","せぼね","せまい","せまる","せめる","せもたれ","せりふ","ぜんあく","せんい","せんえい","せんか","せんきょ","せんく","せんげん","ぜんご","せんさい","せんしゅ","せんすい","せんせい","せんぞ","せんたく","せんちょう","せんてい","せんとう","せんぬき","せんねん","せんぱい","ぜんぶ","ぜんぽう","せんむ","せんめんじょ","せんもん","せんやく","せんゆう","せんよう","ぜんら","ぜんりゃく","せんれい","せんろ","そあく","そいとげる","そいね","そうがんきょう","そうき","そうご","そうしん","そうだん","そうなん","そうび","そうめん","そうり","そえもの","そえん","そがい","そげき","そこう","そこそこ","そざい","そしな","そせい","そせん","そそぐ","そだてる","そつう","そつえん","そっかん","そつぎょう","そっけつ","そっこう","そっせん","そっと","そとがわ","そとづら","そなえる","そなた","そふぼ","そぼく","そぼろ","そまつ","そまる","そむく","そむりえ","そめる","そもそも","そよかぜ","そらまめ","そろう","そんかい","そんけい","そんざい","そんしつ","そんぞく","そんちょう","ぞんび","ぞんぶん","そんみん","たあい","たいいん","たいうん","たいえき","たいおう","だいがく","たいき","たいぐう","たいけん","たいこ","たいざい","だいじょうぶ","だいすき","たいせつ","たいそう","だいたい","たいちょう","たいてい","だいどころ","たいない","たいねつ","たいのう","たいはん","だいひょう","たいふう","たいへん","たいほ","たいまつばな","たいみんぐ","たいむ","たいめん","たいやき","たいよう","たいら","たいりょく","たいる","たいわん","たうえ","たえる","たおす","たおる","たおれる","たかい","たかね","たきび","たくさん","たこく","たこやき","たさい","たしざん","だじゃれ","たすける","たずさわる","たそがれ","たたかう","たたく","ただしい","たたみ","たちばな","だっかい","だっきゃく","だっこ","だっしゅつ","だったい","たてる","たとえる","たなばた","たにん","たぬき","たのしみ","たはつ","たぶん","たべる","たぼう","たまご","たまる","だむる","ためいき","ためす","ためる","たもつ","たやすい","たよる","たらす","たりきほんがん","たりょう","たりる","たると","たれる","たれんと","たろっと","たわむれる","だんあつ","たんい","たんおん","たんか","たんき","たんけん","たんご","たんさん","たんじょうび","だんせい","たんそく","たんたい","だんち","たんてい","たんとう","だんな","たんにん","だんねつ","たんのう","たんぴん","だんぼう","たんまつ","たんめい","だんれつ","だんろ","だんわ","ちあい","ちあん","ちいき","ちいさい","ちえん","ちかい","ちから","ちきゅう","ちきん","ちけいず","ちけん","ちこく","ちさい","ちしき","ちしりょう","ちせい","ちそう","ちたい","ちたん","ちちおや","ちつじょ","ちてき","ちてん","ちぬき","ちぬり","ちのう","ちひょう","ちへいせん","ちほう","ちまた","ちみつ","ちみどろ","ちめいど","ちゃんこなべ","ちゅうい","ちゆりょく","ちょうし","ちょさくけん","ちらし","ちらみ","ちりがみ","ちりょう","ちるど","ちわわ","ちんたい","ちんもく","ついか","ついたち","つうか","つうじょう","つうはん","つうわ","つかう","つかれる","つくね","つくる","つけね","つける","つごう","つたえる","つづく","つつじ","つつむ","つとめる","つながる","つなみ","つねづね","つのる","つぶす","つまらない","つまる","つみき","つめたい","つもり","つもる","つよい","つるぼ","つるみく","つわもの","つわり","てあし","てあて","てあみ","ていおん","ていか","ていき","ていけい","ていこく","ていさつ","ていし","ていせい","ていたい","ていど","ていねい","ていひょう","ていへん","ていぼう","てうち","ておくれ","てきとう","てくび","でこぼこ","てさぎょう","てさげ","てすり","てそう","てちがい","てちょう","てつがく","てつづき","でっぱ","てつぼう","てつや","でぬかえ","てぬき","てぬぐい","てのひら","てはい","てぶくろ","てふだ","てほどき","てほん","てまえ","てまきずし","てみじか","てみやげ","てらす","てれび","てわけ","てわたし","でんあつ","てんいん","てんかい","てんき","てんぐ","てんけん","てんごく","てんさい","てんし","てんすう","でんち","てんてき","てんとう","てんない","てんぷら","てんぼうだい","てんめつ","てんらんかい","でんりょく","でんわ","どあい","といれ","どうかん","とうきゅう","どうぐ","とうし","とうむぎ","とおい","とおか","とおく","とおす","とおる","とかい","とかす","ときおり","ときどき","とくい","とくしゅう","とくてん","とくに","とくべつ","とけい","とける","とこや","とさか","としょかん","とそう","とたん","とちゅう","とっきゅう","とっくん","とつぜん","とつにゅう","とどける","ととのえる","とない","となえる","となり","とのさま","とばす","どぶがわ","とほう","とまる","とめる","ともだち","ともる","どようび","とらえる","とんかつ","どんぶり","ないかく","ないこう","ないしょ","ないす","ないせん","ないそう","なおす","ながい","なくす","なげる","なこうど","なさけ","なたでここ","なっとう","なつやすみ","ななおし","なにごと","なにもの","なにわ","なのか","なふだ","なまいき","なまえ","なまみ","なみだ","なめらか","なめる","なやむ","ならう","ならび","ならぶ","なれる","なわとび","なわばり","にあう","にいがた","にうけ","におい","にかい","にがて","にきび","にくしみ","にくまん","にげる","にさんかたんそ","にしき","にせもの","にちじょう","にちようび","にっか","にっき","にっけい","にっこう","にっさん","にっしょく","にっすう","にっせき","にってい","になう","にほん","にまめ","にもつ","にやり","にゅういん","にりんしゃ","にわとり","にんい","にんか","にんき","にんげん","にんしき","にんずう","にんそう","にんたい","にんち","にんてい","にんにく","にんぷ","にんまり","にんむ","にんめい","にんよう","ぬいくぎ","ぬかす","ぬぐいとる","ぬぐう","ぬくもり","ぬすむ","ぬまえび","ぬめり","ぬらす","ぬんちゃく","ねあげ","ねいき","ねいる","ねいろ","ねぐせ","ねくたい","ねくら","ねこぜ","ねこむ","ねさげ","ねすごす","ねそべる","ねだん","ねつい","ねっしん","ねつぞう","ねったいぎょ","ねぶそく","ねふだ","ねぼう","ねほりはほり","ねまき","ねまわし","ねみみ","ねむい","ねむたい","ねもと","ねらう","ねわざ","ねんいり","ねんおし","ねんかん","ねんきん","ねんぐ","ねんざ","ねんし","ねんちゃく","ねんど","ねんぴ","ねんぶつ","ねんまつ","ねんりょう","ねんれい","のいず","のおづま","のがす","のきなみ","のこぎり","のこす","のこる","のせる","のぞく","のぞむ","のたまう","のちほど","のっく","のばす","のはら","のべる","のぼる","のみもの","のやま","のらいぬ","のらねこ","のりもの","のりゆき","のれん","のんき","ばあい","はあく","ばあさん","ばいか","ばいく","はいけん","はいご","はいしん","はいすい","はいせん","はいそう","はいち","ばいばい","はいれつ","はえる","はおる","はかい","ばかり","はかる","はくしゅ","はけん","はこぶ","はさみ","はさん","はしご","ばしょ","はしる","はせる","ぱそこん","はそん","はたん","はちみつ","はつおん","はっかく","はづき","はっきり","はっくつ","はっけん","はっこう","はっさん","はっしん","はったつ","はっちゅう","はってん","はっぴょう","はっぽう","はなす","はなび","はにかむ","はぶらし","はみがき","はむかう","はめつ","はやい","はやし","はらう","はろうぃん","はわい","はんい","はんえい","はんおん","はんかく","はんきょう","ばんぐみ","はんこ","はんしゃ","はんすう","はんだん","ぱんち","ぱんつ","はんてい","はんとし","はんのう","はんぱ","はんぶん","はんぺん","はんぼうき","はんめい","はんらん","はんろん","ひいき","ひうん","ひえる","ひかく","ひかり","ひかる","ひかん","ひくい","ひけつ","ひこうき","ひこく","ひさい","ひさしぶり","ひさん","びじゅつかん","ひしょ","ひそか","ひそむ","ひたむき","ひだり","ひたる","ひつぎ","ひっこし","ひっし","ひつじゅひん","ひっす","ひつぜん","ぴったり","ぴっちり","ひつよう","ひてい","ひとごみ","ひなまつり","ひなん","ひねる","ひはん","ひびく","ひひょう","ひほう","ひまわり","ひまん","ひみつ","ひめい","ひめじし","ひやけ","ひやす","ひよう","びょうき","ひらがな","ひらく","ひりつ","ひりょう","ひるま","ひるやすみ","ひれい","ひろい","ひろう","ひろき","ひろゆき","ひんかく","ひんけつ","ひんこん","ひんしゅ","ひんそう","ぴんち","ひんぱん","びんぼう","ふあん","ふいうち","ふうけい","ふうせん","ぷうたろう","ふうとう","ふうふ","ふえる","ふおん","ふかい","ふきん","ふくざつ","ふくぶくろ","ふこう","ふさい","ふしぎ","ふじみ","ふすま","ふせい","ふせぐ","ふそく","ぶたにく","ふたん","ふちょう","ふつう","ふつか","ふっかつ","ふっき","ふっこく","ぶどう","ふとる","ふとん","ふのう","ふはい","ふひょう","ふへん","ふまん","ふみん","ふめつ","ふめん","ふよう","ふりこ","ふりる","ふるい","ふんいき","ぶんがく","ぶんぐ","ふんしつ","ぶんせき","ふんそう","ぶんぽう","へいあん","へいおん","へいがい","へいき","へいげん","へいこう","へいさ","へいしゃ","へいせつ","へいそ","へいたく","へいてん","へいねつ","へいわ","へきが","へこむ","べにいろ","べにしょうが","へらす","へんかん","べんきょう","べんごし","へんさい","へんたい","べんり","ほあん","ほいく","ぼうぎょ","ほうこく","ほうそう","ほうほう","ほうもん","ほうりつ","ほえる","ほおん","ほかん","ほきょう","ぼきん","ほくろ","ほけつ","ほけん","ほこう","ほこる","ほしい","ほしつ","ほしゅ","ほしょう","ほせい","ほそい","ほそく","ほたて","ほたる","ぽちぶくろ","ほっきょく","ほっさ","ほったん","ほとんど","ほめる","ほんい","ほんき","ほんけ","ほんしつ","ほんやく","まいにち","まかい","まかせる","まがる","まける","まこと","まさつ","まじめ","ますく","まぜる","まつり","まとめ","まなぶ","まぬけ","まねく","まほう","まもる","まゆげ","まよう","まろやか","まわす","まわり","まわる","まんが","まんきつ","まんぞく","まんなか","みいら","みうち","みえる","みがく","みかた","みかん","みけん","みこん","みじかい","みすい","みすえる","みせる","みっか","みつかる","みつける","みてい","みとめる","みなと","みなみかさい","みねらる","みのう","みのがす","みほん","みもと","みやげ","みらい","みりょく","みわく","みんか","みんぞく","むいか","むえき","むえん","むかい","むかう","むかえ","むかし","むぎちゃ","むける","むげん","むさぼる","むしあつい","むしば","むじゅん","むしろ","むすう","むすこ","むすぶ","むすめ","むせる","むせん","むちゅう","むなしい","むのう","むやみ","むよう","むらさき","むりょう","むろん","めいあん","めいうん","めいえん","めいかく","めいきょく","めいさい","めいし","めいそう","めいぶつ","めいれい","めいわく","めぐまれる","めざす","めした","めずらしい","めだつ","めまい","めやす","めんきょ","めんせき","めんどう","もうしあげる","もうどうけん","もえる","もくし","もくてき","もくようび","もちろん","もどる","もらう","もんく","もんだい","やおや","やける","やさい","やさしい","やすい","やすたろう","やすみ","やせる","やそう","やたい","やちん","やっと","やっぱり","やぶる","やめる","ややこしい","やよい","やわらかい","ゆうき","ゆうびんきょく","ゆうべ","ゆうめい","ゆけつ","ゆしゅつ","ゆせん","ゆそう","ゆたか","ゆちゃく","ゆでる","ゆにゅう","ゆびわ","ゆらい","ゆれる","ようい","ようか","ようきゅう","ようじ","ようす","ようちえん","よかぜ","よかん","よきん","よくせい","よくぼう","よけい","よごれる","よさん","よしゅう","よそう","よそく","よっか","よてい","よどがわく","よねつ","よやく","よゆう","よろこぶ","よろしい","らいう","らくがき","らくご","らくさつ","らくだ","らしんばん","らせん","らぞく","らたい","らっか","られつ","りえき","りかい","りきさく","りきせつ","りくぐん","りくつ","りけん","りこう","りせい","りそう","りそく","りてん","りねん","りゆう","りゅうがく","りよう","りょうり","りょかん","りょくちゃ","りょこう","りりく","りれき","りろん","りんご","るいけい","るいさい","るいじ","るいせき","るすばん","るりがわら","れいかん","れいぎ","れいせい","れいぞうこ","れいとう","れいぼう","れきし","れきだい","れんあい","れんけい","れんこん","れんさい","れんしゅう","れんぞく","れんらく","ろうか","ろうご","ろうじん","ろうそく","ろくが","ろこつ","ろじうら","ろしゅつ","ろせん","ろてん","ろめん","ろれつ","ろんぎ","ろんぱ","ろんぶん","ろんり","わかす","わかめ","わかやま","わかれる","わしつ","わじまし","わすれもの","わらう","われる"];t.exports=i},{}],9:[function(e,t,r){"use strict";var i=["ábaco","abdomen","abeja","abierto","abogado","abono","aborto","abrazo","abrir","abuelo","abuso","acabar","academia","acceso","acción","aceite","acelga","acento","aceptar","ácido","aclarar","acné","acoger","acoso","activo","acto","actriz","actuar","acudir","acuerdo","acusar","adicto","admitir","adoptar","adorno","aduana","adulto","aéreo","afectar","afición","afinar","afirmar","ágil","agitar","agonía","agosto","agotar","agregar","agrio","agua","agudo","águila","aguja","ahogo","ahorro","aire","aislar","ajedrez","ajeno","ajuste","alacrán","alambre","alarma","alba","álbum","alcalde","aldea","alegre","alejar","alerta","aleta","alfiler","alga","algodón","aliado","aliento","alivio","alma","almeja","almíbar","altar","alteza","altivo","alto","altura","alumno","alzar","amable","amante","amapola","amargo","amasar","ámbar","ámbito","ameno","amigo","amistad","amor","amparo","amplio","ancho","anciano","ancla","andar","andén","anemia","ángulo","anillo","ánimo","anís","anotar","antena","antiguo","antojo","anual","anular","anuncio","añadir","añejo","año","apagar","aparato","apetito","apio","aplicar","apodo","aporte","apoyo","aprender","aprobar","apuesta","apuro","arado","araña","arar","árbitro","árbol","arbusto","archivo","arco","arder","ardilla","arduo","área","árido","aries","armonía","arnés","aroma","arpa","arpón","arreglo","arroz","arruga","arte","artista","asa","asado","asalto","ascenso","asegurar","aseo","asesor","asiento","asilo","asistir","asno","asombro","áspero","astilla","astro","astuto","asumir","asunto","atajo","ataque","atar","atento","ateo","ático","atleta","átomo","atraer","atroz","atún","audaz","audio","auge","aula","aumento","ausente","autor","aval","avance","avaro","ave","avellana","avena","avestruz","avión","aviso","ayer","ayuda","ayuno","azafrán","azar","azote","azúcar","azufre","azul","baba","babor","bache","bahía","baile","bajar","balanza","balcón","balde","bambú","banco","banda","baño","barba","barco","barniz","barro","báscula","bastón","basura","batalla","batería","batir","batuta","baúl","bazar","bebé","bebida","bello","besar","beso","bestia","bicho","bien","bingo","blanco","bloque","blusa","boa","bobina","bobo","boca","bocina","boda","bodega","boina","bola","bolero","bolsa","bomba","bondad","bonito","bono","bonsái","borde","borrar","bosque","bote","botín","bóveda","bozal","bravo","brazo","brecha","breve","brillo","brinco","brisa","broca","broma","bronce","brote","bruja","brusco","bruto","buceo","bucle","bueno","buey","bufanda","bufón","búho","buitre","bulto","burbuja","burla","burro","buscar","butaca","buzón","caballo","cabeza","cabina","cabra","cacao","cadáver","cadena","caer","café","caída","caimán","caja","cajón","cal","calamar","calcio","caldo","calidad","calle","calma","calor","calvo","cama","cambio","camello","camino","campo","cáncer","candil","canela","canguro","canica","canto","caña","cañón","caoba","caos","capaz","capitán","capote","captar","capucha","cara","carbón","cárcel","careta","carga","cariño","carne","carpeta","carro","carta","casa","casco","casero","caspa","castor","catorce","catre","caudal","causa","cazo","cebolla","ceder","cedro","celda","célebre","celoso","célula","cemento","ceniza","centro","cerca","cerdo","cereza","cero","cerrar","certeza","césped","cetro","chacal","chaleco","champú","chancla","chapa","charla","chico","chiste","chivo","choque","choza","chuleta","chupar","ciclón","ciego","cielo","cien","cierto","cifra","cigarro","cima","cinco","cine","cinta","ciprés","circo","ciruela","cisne","cita","ciudad","clamor","clan","claro","clase","clave","cliente","clima","clínica","cobre","cocción","cochino","cocina","coco","código","codo","cofre","coger","cohete","cojín","cojo","cola","colcha","colegio","colgar","colina","collar","colmo","columna","combate","comer","comida","cómodo","compra","conde","conejo","conga","conocer","consejo","contar","copa","copia","corazón","corbata","corcho","cordón","corona","correr","coser","cosmos","costa","cráneo","cráter","crear","crecer","creído","crema","cría","crimen","cripta","crisis","cromo","crónica","croqueta","crudo","cruz","cuadro","cuarto","cuatro","cubo","cubrir","cuchara","cuello","cuento","cuerda","cuesta","cueva","cuidar","culebra","culpa","culto","cumbre","cumplir","cuna","cuneta","cuota","cupón","cúpula","curar","curioso","curso","curva","cutis","dama","danza","dar","dardo","dátil","deber","débil","década","decir","dedo","defensa","definir","dejar","delfín","delgado","delito","demora","denso","dental","deporte","derecho","derrota","desayuno","deseo","desfile","desnudo","destino","desvío","detalle","detener","deuda","día","diablo","diadema","diamante","diana","diario","dibujo","dictar","diente","dieta","diez","difícil","digno","dilema","diluir","dinero","directo","dirigir","disco","diseño","disfraz","diva","divino","doble","doce","dolor","domingo","don","donar","dorado","dormir","dorso","dos","dosis","dragón","droga","ducha","duda","duelo","dueño","dulce","dúo","duque","durar","dureza","duro","ébano","ebrio","echar","eco","ecuador","edad","edición","edificio","editor","educar","efecto","eficaz","eje","ejemplo","elefante","elegir","elemento","elevar","elipse","élite","elixir","elogio","eludir","embudo","emitir","emoción","empate","empeño","empleo","empresa","enano","encargo","enchufe","encía","enemigo","enero","enfado","enfermo","engaño","enigma","enlace","enorme","enredo","ensayo","enseñar","entero","entrar","envase","envío","época","equipo","erizo","escala","escena","escolar","escribir","escudo","esencia","esfera","esfuerzo","espada","espejo","espía","esposa","espuma","esquí","estar","este","estilo","estufa","etapa","eterno","ética","etnia","evadir","evaluar","evento","evitar","exacto","examen","exceso","excusa","exento","exigir","exilio","existir","éxito","experto","explicar","exponer","extremo","fábrica","fábula","fachada","fácil","factor","faena","faja","falda","fallo","falso","faltar","fama","familia","famoso","faraón","farmacia","farol","farsa","fase","fatiga","fauna","favor","fax","febrero","fecha","feliz","feo","feria","feroz","fértil","fervor","festín","fiable","fianza","fiar","fibra","ficción","ficha","fideo","fiebre","fiel","fiera","fiesta","figura","fijar","fijo","fila","filete","filial","filtro","fin","finca","fingir","finito","firma","flaco","flauta","flecha","flor","flota","fluir","flujo","flúor","fobia","foca","fogata","fogón","folio","folleto","fondo","forma","forro","fortuna","forzar","fosa","foto","fracaso","frágil","franja","frase","fraude","freír","freno","fresa","frío","frito","fruta","fuego","fuente","fuerza","fuga","fumar","función","funda","furgón","furia","fusil","fútbol","futuro","gacela","gafas","gaita","gajo","gala","galería","gallo","gamba","ganar","gancho","ganga","ganso","garaje","garza","gasolina","gastar","gato","gavilán","gemelo","gemir","gen","género","genio","gente","geranio","gerente","germen","gesto","gigante","gimnasio","girar","giro","glaciar","globo","gloria","gol","golfo","goloso","golpe","goma","gordo","gorila","gorra","gota","goteo","gozar","grada","gráfico","grano","grasa","gratis","grave","grieta","grillo","gripe","gris","grito","grosor","grúa","grueso","grumo","grupo","guante","guapo","guardia","guerra","guía","guiño","guion","guiso","guitarra","gusano","gustar","haber","hábil","hablar","hacer","hacha","hada","hallar","hamaca","harina","haz","hazaña","hebilla","hebra","hecho","helado","helio","hembra","herir","hermano","héroe","hervir","hielo","hierro","hígado","higiene","hijo","himno","historia","hocico","hogar","hoguera","hoja","hombre","hongo","honor","honra","hora","hormiga","horno","hostil","hoyo","hueco","huelga","huerta","hueso","huevo","huida","huir","humano","húmedo","humilde","humo","hundir","huracán","hurto","icono","ideal","idioma","ídolo","iglesia","iglú","igual","ilegal","ilusión","imagen","imán","imitar","impar","imperio","imponer","impulso","incapaz","índice","inerte","infiel","informe","ingenio","inicio","inmenso","inmune","innato","insecto","instante","interés","íntimo","intuir","inútil","invierno","ira","iris","ironía","isla","islote","jabalí","jabón","jamón","jarabe","jardín","jarra","jaula","jazmín","jefe","jeringa","jinete","jornada","joroba","joven","joya","juerga","jueves","juez","jugador","jugo","juguete","juicio","junco","jungla","junio","juntar","júpiter","jurar","justo","juvenil","juzgar","kilo","koala","labio","lacio","lacra","lado","ladrón","lagarto","lágrima","laguna","laico","lamer","lámina","lámpara","lana","lancha","langosta","lanza","lápiz","largo","larva","lástima","lata","látex","latir","laurel","lavar","lazo","leal","lección","leche","lector","leer","legión","legumbre","lejano","lengua","lento","leña","león","leopardo","lesión","letal","letra","leve","leyenda","libertad","libro","licor","líder","lidiar","lienzo","liga","ligero","lima","límite","limón","limpio","lince","lindo","línea","lingote","lino","linterna","líquido","liso","lista","litera","litio","litro","llaga","llama","llanto","llave","llegar","llenar","llevar","llorar","llover","lluvia","lobo","loción","loco","locura","lógica","logro","lombriz","lomo","lonja","lote","lucha","lucir","lugar","lujo","luna","lunes","lupa","lustro","luto","luz","maceta","macho","madera","madre","maduro","maestro","mafia","magia","mago","maíz","maldad","maleta","malla","malo","mamá","mambo","mamut","manco","mando","manejar","manga","maniquí","manjar","mano","manso","manta","mañana","mapa","máquina","mar","marco","marea","marfil","margen","marido","mármol","marrón","martes","marzo","masa","máscara","masivo","matar","materia","matiz","matriz","máximo","mayor","mazorca","mecha","medalla","medio","médula","mejilla","mejor","melena","melón","memoria","menor","mensaje","mente","menú","mercado","merengue","mérito","mes","mesón","meta","meter","método","metro","mezcla","miedo","miel","miembro","miga","mil","milagro","militar","millón","mimo","mina","minero","mínimo","minuto","miope","mirar","misa","miseria","misil","mismo","mitad","mito","mochila","moción","moda","modelo","moho","mojar","molde","moler","molino","momento","momia","monarca","moneda","monja","monto","moño","morada","morder","moreno","morir","morro","morsa","mortal","mosca","mostrar","motivo","mover","móvil","mozo","mucho","mudar","mueble","muela","muerte","muestra","mugre","mujer","mula","muleta","multa","mundo","muñeca","mural","muro","músculo","museo","musgo","música","muslo","nácar","nación","nadar","naipe","naranja","nariz","narrar","nasal","natal","nativo","natural","náusea","naval","nave","navidad","necio","néctar","negar","negocio","negro","neón","nervio","neto","neutro","nevar","nevera","nicho","nido","niebla","nieto","niñez","niño","nítido","nivel","nobleza","noche","nómina","noria","norma","norte","nota","noticia","novato","novela","novio","nube","nuca","núcleo","nudillo","nudo","nuera","nueve","nuez","nulo","número","nutria","oasis","obeso","obispo","objeto","obra","obrero","observar","obtener","obvio","oca","ocaso","océano","ochenta","ocho","ocio","ocre","octavo","octubre","oculto","ocupar","ocurrir","odiar","odio","odisea","oeste","ofensa","oferta","oficio","ofrecer","ogro","oído","oír","ojo","ola","oleada","olfato","olivo","olla","olmo","olor","olvido","ombligo","onda","onza","opaco","opción","ópera","opinar","oponer","optar","óptica","opuesto","oración","orador","oral","órbita","orca","orden","oreja","órgano","orgía","orgullo","oriente","origen","orilla","oro","orquesta","oruga","osadía","oscuro","osezno","oso","ostra","otoño","otro","oveja","óvulo","óxido","oxígeno","oyente","ozono","pacto","padre","paella","página","pago","país","pájaro","palabra","palco","paleta","pálido","palma","paloma","palpar","pan","panal","pánico","pantera","pañuelo","papá","papel","papilla","paquete","parar","parcela","pared","parir","paro","párpado","parque","párrafo","parte","pasar","paseo","pasión","paso","pasta","pata","patio","patria","pausa","pauta","pavo","payaso","peatón","pecado","pecera","pecho","pedal","pedir","pegar","peine","pelar","peldaño","pelea","peligro","pellejo","pelo","peluca","pena","pensar","peñón","peón","peor","pepino","pequeño","pera","percha","perder","pereza","perfil","perico","perla","permiso","perro","persona","pesa","pesca","pésimo","pestaña","pétalo","petróleo","pez","pezuña","picar","pichón","pie","piedra","pierna","pieza","pijama","pilar","piloto","pimienta","pino","pintor","pinza","piña","piojo","pipa","pirata","pisar","piscina","piso","pista","pitón","pizca","placa","plan","plata","playa","plaza","pleito","pleno","plomo","pluma","plural","pobre","poco","poder","podio","poema","poesía","poeta","polen","policía","pollo","polvo","pomada","pomelo","pomo","pompa","poner","porción","portal","posada","poseer","posible","poste","potencia","potro","pozo","prado","precoz","pregunta","premio","prensa","preso","previo","primo","príncipe","prisión","privar","proa","probar","proceso","producto","proeza","profesor","programa","prole","promesa","pronto","propio","próximo","prueba","público","puchero","pudor","pueblo","puerta","puesto","pulga","pulir","pulmón","pulpo","pulso","puma","punto","puñal","puño","pupa","pupila","puré","quedar","queja","quemar","querer","queso","quieto","química","quince","quitar","rábano","rabia","rabo","ración","radical","raíz","rama","rampa","rancho","rango","rapaz","rápido","rapto","rasgo","raspa","rato","rayo","raza","razón","reacción","realidad","rebaño","rebote","recaer","receta","rechazo","recoger","recreo","recto","recurso","red","redondo","reducir","reflejo","reforma","refrán","refugio","regalo","regir","regla","regreso","rehén","reino","reír","reja","relato","relevo","relieve","relleno","reloj","remar","remedio","remo","rencor","rendir","renta","reparto","repetir","reposo","reptil","res","rescate","resina","respeto","resto","resumen","retiro","retorno","retrato","reunir","revés","revista","rey","rezar","rico","riego","rienda","riesgo","rifa","rígido","rigor","rincón","riñón","río","riqueza","risa","ritmo","rito","rizo","roble","roce","rociar","rodar","rodeo","rodilla","roer","rojizo","rojo","romero","romper","ron","ronco","ronda","ropa","ropero","rosa","rosca","rostro","rotar","rubí","rubor","rudo","rueda","rugir","ruido","ruina","ruleta","rulo","rumbo","rumor","ruptura","ruta","rutina","sábado","saber","sabio","sable","sacar","sagaz","sagrado","sala","saldo","salero","salir","salmón","salón","salsa","salto","salud","salvar","samba","sanción","sandía","sanear","sangre","sanidad","sano","santo","sapo","saque","sardina","sartén","sastre","satán","sauna","saxofón","sección","seco","secreto","secta","sed","seguir","seis","sello","selva","semana","semilla","senda","sensor","señal","señor","separar","sepia","sequía","ser","serie","sermón","servir","sesenta","sesión","seta","setenta","severo","sexo","sexto","sidra","siesta","siete","siglo","signo","sílaba","silbar","silencio","silla","símbolo","simio","sirena","sistema","sitio","situar","sobre","socio","sodio","sol","solapa","soldado","soledad","sólido","soltar","solución","sombra","sondeo","sonido","sonoro","sonrisa","sopa","soplar","soporte","sordo","sorpresa","sorteo","sostén","sótano","suave","subir","suceso","sudor","suegra","suelo","sueño","suerte","sufrir","sujeto","sultán","sumar","superar","suplir","suponer","supremo","sur","surco","sureño","surgir","susto","sutil","tabaco","tabique","tabla","tabú","taco","tacto","tajo","talar","talco","talento","talla","talón","tamaño","tambor","tango","tanque","tapa","tapete","tapia","tapón","taquilla","tarde","tarea","tarifa","tarjeta","tarot","tarro","tarta","tatuaje","tauro","taza","tazón","teatro","techo","tecla","técnica","tejado","tejer","tejido","tela","teléfono","tema","temor","templo","tenaz","tender","tener","tenis","tenso","teoría","terapia","terco","término","ternura","terror","tesis","tesoro","testigo","tetera","texto","tez","tibio","tiburón","tiempo","tienda","tierra","tieso","tigre","tijera","tilde","timbre","tímido","timo","tinta","tío","típico","tipo","tira","tirón","titán","títere","título","tiza","toalla","tobillo","tocar","tocino","todo","toga","toldo","tomar","tono","tonto","topar","tope","toque","tórax","torero","tormenta","torneo","toro","torpedo","torre","torso","tortuga","tos","tosco","toser","tóxico","trabajo","tractor","traer","tráfico","trago","traje","tramo","trance","trato","trauma","trazar","trébol","tregua","treinta","tren","trepar","tres","tribu","trigo","tripa","triste","triunfo","trofeo","trompa","tronco","tropa","trote","trozo","truco","trueno","trufa","tubería","tubo","tuerto","tumba","tumor","túnel","túnica","turbina","turismo","turno","tutor","ubicar","úlcera","umbral","unidad","unir","universo","uno","untar","uña","urbano","urbe","urgente","urna","usar","usuario","útil","utopía","uva","vaca","vacío","vacuna","vagar","vago","vaina","vajilla","vale","válido","valle","valor","válvula","vampiro","vara","variar","varón","vaso","vecino","vector","vehículo","veinte","vejez","vela","velero","veloz","vena","vencer","venda","veneno","vengar","venir","venta","venus","ver","verano","verbo","verde","vereda","verja","verso","verter","vía","viaje","vibrar","vicio","víctima","vida","vídeo","vidrio","viejo","viernes","vigor","vil","villa","vinagre","vino","viñedo","violín","viral","virgo","virtud","visor","víspera","vista","vitamina","viudo","vivaz","vivero","vivir","vivo","volcán","volumen","volver","voraz","votar","voto","voz","vuelo","vulgar","yacer","yate","yegua","yema","yerno","yeso","yodo","yoga","yogur","zafiro","zanja","zapato","zarza","zona","zorro","zumo","zurdo"]; +t.exports=i},{}],10:[function(e,t,r){},{}],11:[function(e,t,r){(function(t){function i(){function e(){}try{var t=new Uint8Array(1);return t.foo=function(){return 42},t.constructor=e,42===t.foo()&&t.constructor===e&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(r){return!1}}function n(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e){return this instanceof a?(this.length=0,this.parent=void 0,"number"==typeof e?o(this,e):"string"==typeof e?s(this,e,arguments.length>1?arguments[1]:"utf8"):c(this,e)):arguments.length>1?new a(e,arguments[1]):new a(e)}function o(e,t){if(e=b(e,0>t?0:0|m(t)),!a.TYPED_ARRAY_SUPPORT)for(var r=0;t>r;r++)e[r]=0;return e}function s(e,t,r){("string"!=typeof r||""===r)&&(r="utf8");var i=0|v(t,r);return e=b(e,i),e.write(t,r),e}function c(e,t){if(a.isBuffer(t))return f(e,t);if(G(t))return u(e,t);if(null==t)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(t.buffer instanceof ArrayBuffer)return d(e,t);if(t instanceof ArrayBuffer)return h(e,t)}return t.length?l(e,t):p(e,t)}function f(e,t){var r=0|m(t.length);return e=b(e,r),t.copy(e,0,0,r),e}function u(e,t){var r=0|m(t.length);e=b(e,r);for(var i=0;r>i;i+=1)e[i]=255&t[i];return e}function d(e,t){var r=0|m(t.length);e=b(e,r);for(var i=0;r>i;i+=1)e[i]=255&t[i];return e}function h(e,t){return a.TYPED_ARRAY_SUPPORT?(t.byteLength,e=a._augment(new Uint8Array(t))):e=d(e,new Uint8Array(t)),e}function l(e,t){var r=0|m(t.length);e=b(e,r);for(var i=0;r>i;i+=1)e[i]=255&t[i];return e}function p(e,t){var r,i=0;"Buffer"===t.type&&G(t.data)&&(r=t.data,i=0|m(r.length)),e=b(e,i);for(var n=0;i>n;n+=1)e[n]=255&r[n];return e}function b(e,t){a.TYPED_ARRAY_SUPPORT?(e=a._augment(new Uint8Array(t)),e.__proto__=a.prototype):(e.length=t,e._isBuffer=!0);var r=0!==t&&t<=a.poolSize>>>1;return r&&(e.parent=Z),e}function m(e){if(e>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function g(e,t){if(!(this instanceof g))return new g(e,t);var r=new a(e,t);return delete r.parent,r}function v(e,t){"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return F(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(e).length;default:if(i)return F(e).length;t=(""+t).toLowerCase(),i=!0}}function y(e,t,r){var i=!1;if(t=0|t,r=void 0===r||r===1/0?this.length:0|r,e||(e="utf8"),0>t&&(t=0),r>this.length&&(r=this.length),t>=r)return"";for(;;)switch(e){case"hex":return R(this,t,r);case"utf8":case"utf-8":return j(this,t,r);case"ascii":return I(this,t,r);case"binary":return z(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function w(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i),i>n&&(i=n)):i=n;var a=t.length;if(a%2!==0)throw new Error("Invalid hex string");i>a/2&&(i=a/2);for(var o=0;i>o;o++){var s=parseInt(t.substr(2*o,2),16);if(isNaN(s))throw new Error("Invalid hex string");e[r+o]=s}return o}function _(e,t,r,i){return V(F(t,e.length-r),e,r,i)}function S(e,t,r,i){return V(H(t),e,r,i)}function k(e,t,r,i){return S(e,t,r,i)}function E(e,t,r,i){return V(W(t),e,r,i)}function x(e,t,r,i){return V(Y(t,e.length-r),e,r,i)}function A(e,t,r){return 0===t&&r===e.length?X.fromByteArray(e):X.fromByteArray(e.slice(t,r))}function j(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;r>n;){var a=e[n],o=null,s=a>239?4:a>223?3:a>191?2:1;if(r>=n+s){var c,f,u,d;switch(s){case 1:128>a&&(o=a);break;case 2:c=e[n+1],128===(192&c)&&(d=(31&a)<<6|63&c,d>127&&(o=d));break;case 3:c=e[n+1],f=e[n+2],128===(192&c)&&128===(192&f)&&(d=(15&a)<<12|(63&c)<<6|63&f,d>2047&&(55296>d||d>57343)&&(o=d));break;case 4:c=e[n+1],f=e[n+2],u=e[n+3],128===(192&c)&&128===(192&f)&&128===(192&u)&&(d=(15&a)<<18|(63&c)<<12|(63&f)<<6|63&u,d>65535&&1114112>d&&(o=d))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),n+=s}return B(i)}function B(e){var t=e.length;if($>=t)return String.fromCharCode.apply(String,e);for(var r="",i=0;t>i;)r+=String.fromCharCode.apply(String,e.slice(i,i+=$));return r}function I(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;r>n;n++)i+=String.fromCharCode(127&e[n]);return i}function z(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;r>n;n++)i+=String.fromCharCode(e[n]);return i}function R(e,t,r){var i=e.length;(!t||0>t)&&(t=0),(!r||0>r||r>i)&&(r=i);for(var n="",a=t;r>a;a++)n+=K(e[a]);return n}function M(e,t,r){for(var i=e.slice(t,r),n="",a=0;ae)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function C(e,t,r,i,n,o){if(!a.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>n||o>t)throw new RangeError("value is out of bounds");if(r+i>e.length)throw new RangeError("index out of range")}function P(e,t,r,i){0>t&&(t=65535+t+1);for(var n=0,a=Math.min(e.length-r,2);a>n;n++)e[r+n]=(t&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function L(e,t,r,i){0>t&&(t=4294967295+t+1);for(var n=0,a=Math.min(e.length-r,4);a>n;n++)e[r+n]=t>>>8*(i?n:3-n)&255}function D(e,t,r,i,n,a){if(t>n||a>t)throw new RangeError("value is out of bounds");if(r+i>e.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function T(e,t,r,i,n){return n||D(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),J.write(e,t,r,i,23,4),r+4}function U(e,t,r,i,n){return n||D(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),J.write(e,t,r,i,52,8),r+8}function O(e){if(e=N(e).replace(ee,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function N(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function K(e){return 16>e?"0"+e.toString(16):e.toString(16)}function F(e,t){t=t||1/0;for(var r,i=e.length,n=null,a=[],o=0;i>o;o++){if(r=e.charCodeAt(o),r>55295&&57344>r){if(!n){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&a.push(239,191,189);continue}n=r;continue}if(56320>r){(t-=3)>-1&&a.push(239,191,189),n=r;continue}r=n-55296<<10|r-56320|65536}else n&&(t-=3)>-1&&a.push(239,191,189);if(n=null,128>r){if((t-=1)<0)break;a.push(r)}else if(2048>r){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(65536>r){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function H(e){for(var t=[],r=0;r>8,n=r%256,a.push(n),a.push(i);return a}function W(e){return X.toByteArray(O(e))}function V(e,t,r,i){for(var n=0;i>n&&!(n+r>=t.length||n>=e.length);n++)t[n+r]=e[n];return n}var X=e("base64-js"),J=e("ieee754"),G=e("is-array");r.Buffer=a,r.SlowBuffer=g,r.INSPECT_MAX_BYTES=50,a.poolSize=8192;var Z={};a.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:i(),a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array),a.isBuffer=function(e){return!(null==e||!e._isBuffer)},a.compare=function(e,t){if(!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,i=t.length,n=0,o=Math.min(r,i);o>n&&e[n]===t[n];)++n;return n!==o&&(r=e[n],i=t[n]),i>r?-1:r>i?1:0},a.isEncoding=function(e){switch(String(e).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}},a.concat=function(e,t){if(!G(e))throw new TypeError("list argument must be an Array of Buffers.");if(0===e.length)return new a(0);var r;if(void 0===t)for(t=0,r=0;r0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},a.prototype.compare=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:a.compare(this,e)},a.prototype.indexOf=function(e,t){function r(e,t,r){for(var i=-1,n=0;r+n2147483647?t=2147483647:-2147483648>t&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(0>t&&(t=Math.max(this.length+t,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,t);if(a.isBuffer(e))return r(this,e,t);if("number"==typeof e)return a.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):r(this,[e],t);throw new TypeError("val must be string, number or Buffer")},a.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},a.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},a.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else if(isFinite(t))t=0|t,isFinite(r)?(r=0|r,void 0===i&&(i="utf8")):(i=r,r=void 0);else{var n=i;i=t,t=0|r,r=n}var a=this.length-t;if((void 0===r||r>a)&&(r=a),e.length>0&&(0>r||0>t)||t>this.length)throw new RangeError("attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":return S(this,e,t,r);case"binary":return k(this,e,t,r);case"base64":return E(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;a.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),e>t&&(t=e);var i;if(a.TYPED_ARRAY_SUPPORT)i=a._augment(this.subarray(e,t));else{var n=t-e;i=new a(n,void 0);for(var o=0;n>o;o++)i[o]=this[o+e]}return i.length&&(i.parent=this.parent||this),i},a.prototype.readUIntLE=function(e,t,r){e=0|e,t=0|t,r||q(e,t,this.length);for(var i=this[e],n=1,a=0;++a0&&(n*=256);)i+=this[e+--t]*n;return i},a.prototype.readUInt8=function(e,t){return t||q(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||q(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||q(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return t||q(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return t||q(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e=0|e,t=0|t,r||q(e,t,this.length);for(var i=this[e],n=1,a=0;++a=n&&(i-=Math.pow(2,8*t)),i},a.prototype.readIntBE=function(e,t,r){e=0|e,t=0|t,r||q(e,t,this.length);for(var i=t,n=1,a=this[e+--i];i>0&&(n*=256);)a+=this[e+--i]*n;return n*=128,a>=n&&(a-=Math.pow(2,8*t)),a},a.prototype.readInt8=function(e,t){return t||q(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){t||q(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){t||q(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return t||q(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return t||q(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return t||q(e,4,this.length),J.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||q(e,4,this.length),J.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||q(e,8,this.length),J.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||q(e,8,this.length),J.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,i){e=+e,t=0|t,r=0|r,i||C(this,e,t,r,Math.pow(2,8*r),0);var n=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+n]=e/a&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t=0|t,r||C(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=0|t,r||C(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=0|t,r||C(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=0|t,r||C(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):L(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=0|t,r||C(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},a.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t=0|t,!i){var n=Math.pow(2,8*r-1);C(this,e,t,r,n-1,-n)}var a=0,o=1,s=0>e?1:0;for(this[t]=255&e;++a>0)-s&255;return t+r},a.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t=0|t,!i){var n=Math.pow(2,8*r-1);C(this,e,t,r,n-1,-n)}var a=r-1,o=1,s=0>e?1:0;for(this[t+a]=255&e;--a>=0&&(o*=256);)this[t+a]=(e/o>>0)-s&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t=0|t,r||C(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t=0|t,r||C(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t=0|t,r||C(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t=0|t,r||C(this,e,t,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):L(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t=0|t,r||C(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},a.prototype.writeFloatLE=function(e,t,r){return T(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return T(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return U(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return U(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,i){if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&r>i&&(i=r),i===r)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-tr&&i>t)for(n=o-1;n>=0;n--)e[n+t]=this[n+r];else if(1e3>o||!a.TYPED_ARRAY_SUPPORT)for(n=0;o>n;n++)e[n+t]=this[n+r];else e._set(this.subarray(r,r+o),t);return o},a.prototype.fill=function(e,t,r){if(e||(e=0),t||(t=0),r||(r=this.length),t>r)throw new RangeError("end < start");if(r!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var i;if("number"==typeof e)for(i=t;r>i;i++)this[i]=e;else{var n=F(e.toString()),a=n.length;for(i=t;r>i;i++)this[i]=n[i%a]}return this}},a.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(a.TYPED_ARRAY_SUPPORT)return new a(this).buffer;for(var e=new Uint8Array(this.length),t=0,r=e.length;r>t;t+=1)e[t]=this[t];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var Q=a.prototype;a._augment=function(e){return e.constructor=a,e._isBuffer=!0,e._set=e.set,e.get=Q.get,e.set=Q.set,e.write=Q.write,e.toString=Q.toString,e.toLocaleString=Q.toString,e.toJSON=Q.toJSON,e.equals=Q.equals,e.compare=Q.compare,e.indexOf=Q.indexOf,e.copy=Q.copy,e.slice=Q.slice,e.readUIntLE=Q.readUIntLE,e.readUIntBE=Q.readUIntBE,e.readUInt8=Q.readUInt8,e.readUInt16LE=Q.readUInt16LE,e.readUInt16BE=Q.readUInt16BE,e.readUInt32LE=Q.readUInt32LE,e.readUInt32BE=Q.readUInt32BE,e.readIntLE=Q.readIntLE,e.readIntBE=Q.readIntBE,e.readInt8=Q.readInt8,e.readInt16LE=Q.readInt16LE,e.readInt16BE=Q.readInt16BE,e.readInt32LE=Q.readInt32LE,e.readInt32BE=Q.readInt32BE,e.readFloatLE=Q.readFloatLE,e.readFloatBE=Q.readFloatBE,e.readDoubleLE=Q.readDoubleLE,e.readDoubleBE=Q.readDoubleBE,e.writeUInt8=Q.writeUInt8,e.writeUIntLE=Q.writeUIntLE,e.writeUIntBE=Q.writeUIntBE,e.writeUInt16LE=Q.writeUInt16LE,e.writeUInt16BE=Q.writeUInt16BE,e.writeUInt32LE=Q.writeUInt32LE,e.writeUInt32BE=Q.writeUInt32BE,e.writeIntLE=Q.writeIntLE,e.writeIntBE=Q.writeIntBE,e.writeInt8=Q.writeInt8,e.writeInt16LE=Q.writeInt16LE,e.writeInt16BE=Q.writeInt16BE,e.writeInt32LE=Q.writeInt32LE,e.writeInt32BE=Q.writeInt32BE,e.writeFloatLE=Q.writeFloatLE,e.writeFloatBE=Q.writeFloatBE,e.writeDoubleLE=Q.writeDoubleLE,e.writeDoubleBE=Q.writeDoubleBE,e.fill=Q.fill,e.inspect=Q.inspect,e.toArrayBuffer=Q.toArrayBuffer,e};var ee=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":12,ieee754:13,"is-array":14}],12:[function(e,t,r){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===o||t===d?62:t===s||t===h?63:c>t?-1:c+10>t?t-c+26+26:u+26>t?t-u:f+26>t?t-f+26:void 0}function r(e){function r(e){f[d++]=e}var i,n,o,s,c,f;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var u=e.length;c="="===e.charAt(u-2)?2:"="===e.charAt(u-1)?1:0,f=new a(3*e.length/4-c),o=c>0?e.length-4:e.length;var d=0;for(i=0,n=0;o>i;i+=4,n+=3)s=t(e.charAt(i))<<18|t(e.charAt(i+1))<<12|t(e.charAt(i+2))<<6|t(e.charAt(i+3)),r((16711680&s)>>16),r((65280&s)>>8),r(255&s);return 2===c?(s=t(e.charAt(i))<<2|t(e.charAt(i+1))>>4,r(255&s)):1===c&&(s=t(e.charAt(i))<<10|t(e.charAt(i+1))<<4|t(e.charAt(i+2))>>2,r(s>>8&255),r(255&s)),f}function n(e){function t(e){return i.charAt(e)}function r(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var n,a,o,s=e.length%3,c="";for(n=0,o=e.length-s;o>n;n+=3)a=(e[n]<<16)+(e[n+1]<<8)+e[n+2],c+=r(a);switch(s){case 1:a=e[e.length-1],c+=t(a>>2),c+=t(a<<4&63),c+="==";break;case 2:a=(e[e.length-2]<<8)+e[e.length-1],c+=t(a>>10),c+=t(a>>4&63),c+=t(a<<2&63),c+="="}return c}var a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="+".charCodeAt(0),s="/".charCodeAt(0),c="0".charCodeAt(0),f="a".charCodeAt(0),u="A".charCodeAt(0),d="-".charCodeAt(0),h="_".charCodeAt(0);e.toByteArray=r,e.fromByteArray=n}("undefined"==typeof r?this.base64js={}:r)},{}],13:[function(e,t,r){r.read=function(e,t,r,i,n){var a,o,s=8*n-i-1,c=(1<>1,u=-7,d=r?n-1:0,h=r?-1:1,l=e[t+d];for(d+=h,a=l&(1<<-u)-1,l>>=-u,u+=s;u>0;a=256*a+e[t+d],d+=h,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=i;u>0;o=256*o+e[t+d],d+=h,u-=8);if(0===a)a=1-f;else{if(a===c)return o?NaN:(l?-1:1)*(1/0);o+=Math.pow(2,i),a-=f}return(l?-1:1)*o*Math.pow(2,a-i)},r.write=function(e,t,r,i,n,a){var o,s,c,f=8*a-n-1,u=(1<>1,h=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,l=i?0:a-1,p=i?1:-1,b=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),t+=o+d>=1?h/c:h*Math.pow(2,1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*Math.pow(2,n),o+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,n),o=0));n>=8;e[r+l]=255&s,l+=p,s/=256,n-=8);for(o=o<0;e[r+l]=255&o,l+=p,o/=256,f-=8);e[r+l-p]|=128*b}},{}],14:[function(e,t,r){var i=Array.isArray,n=Object.prototype.toString;t.exports=i||function(e){return!!e&&"[object Array]"==n.call(e)}},{}],15:[function(e,t,r){"use strict";r.randomBytes=r.rng=r.pseudoRandomBytes=r.prng=e("randombytes"),r.createHash=r.Hash=e("create-hash"),r.createHmac=r.Hmac=e("create-hmac");var i=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(Object.keys(e("browserify-sign/algos")));r.getHashes=function(){return i};var n=e("pbkdf2");r.pbkdf2=n.pbkdf2,r.pbkdf2Sync=n.pbkdf2Sync;var a=e("browserify-cipher");["Cipher","createCipher","Cipheriv","createCipheriv","Decipher","createDecipher","Decipheriv","createDecipheriv","getCiphers","listCiphers"].forEach(function(e){r[e]=a[e]});var o=e("diffie-hellman");["DiffieHellmanGroup","createDiffieHellmanGroup","getDiffieHellman","createDiffieHellman","DiffieHellman"].forEach(function(e){r[e]=o[e]});var s=e("browserify-sign");["createSign","Sign","createVerify","Verify"].forEach(function(e){r[e]=s[e]}),r.createECDH=e("create-ecdh");var c=e("public-encrypt");["publicEncrypt","privateEncrypt","publicDecrypt","privateDecrypt"].forEach(function(e){r[e]=c[e]}),["createCredentials"].forEach(function(e){r[e]=function(){throw new Error(["sorry, "+e+" is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))}})},{"browserify-cipher":16,"browserify-sign":46,"browserify-sign/algos":45,"create-ecdh":110,"create-hash":133,"create-hmac":146,"diffie-hellman":147,pbkdf2:154,"public-encrypt":155,randombytes:200}],16:[function(e,t,r){function i(e,t){var r,i;if(e=e.toLowerCase(),h[e])r=h[e].key,i=h[e].iv;else{if(!d[e])throw new TypeError("invalid suite type");r=8*d[e].key,i=d[e].iv}var n=c(t,!1,r,i);return a(e,n.key,n.iv)}function n(e,t){var r,i;if(e=e.toLowerCase(),h[e])r=h[e].key,i=h[e].iv;else{if(!d[e])throw new TypeError("invalid suite type");r=8*d[e].key,i=d[e].iv}var n=c(t,!1,r,i);return o(e,n.key,n.iv)}function a(e,t,r){if(e=e.toLowerCase(),h[e])return f.createCipheriv(e,t,r);if(d[e])return new u({key:t,iv:r,mode:e});throw new TypeError("invalid suite type")}function o(e,t,r){if(e=e.toLowerCase(),h[e])return f.createDecipheriv(e,t,r);if(d[e])return new u({key:t,iv:r,mode:e,decrypt:!0});throw new TypeError("invalid suite type")}function s(){return Object.keys(d).concat(f.getCiphers())}var c=e("evp_bytestokey"),f=e("browserify-aes/browser"),u=e("browserify-des"),d=e("browserify-des/modes"),h=e("browserify-aes/modes");r.createCipher=r.Cipher=i,r.createCipheriv=r.Cipheriv=a,r.createDecipher=r.Decipher=n,r.createDecipheriv=r.Decipheriv=o,r.listCiphers=r.getCiphers=s},{"browserify-aes/browser":19,"browserify-aes/modes":23,"browserify-des":34,"browserify-des/modes":35,evp_bytestokey:44}],17:[function(e,t,r){(function(e){function t(e){var t,r;return t=e>s||0>e?(r=Math.abs(e)%s,0>e?s-r:r):e}function i(e){for(var t=0;te;t=++e)128>t?r.push(t<<1):r.push(t<<1^283);return r}(),n=0,c=0,t=f=0;256>f;t=++f)r=c^c<<1^c<<2^c<<3^c<<4,r=r>>>8^255&r^99,this.SBOX[n]=r,this.INV_SBOX[r]=n,a=e[n],o=e[a],s=e[o],i=257*e[r]^16843008*r,this.SUB_MIX[0][n]=i<<24|i>>>8,this.SUB_MIX[1][n]=i<<16|i>>>16,this.SUB_MIX[2][n]=i<<8|i>>>24,this.SUB_MIX[3][n]=i,i=16843009*s^65537*o^257*a^16843008*n,this.INV_SUB_MIX[0][r]=i<<24|i>>>8,this.INV_SUB_MIX[1][r]=i<<16|i>>>16,this.INV_SUB_MIX[2][r]=i<<8|i>>>24,this.INV_SUB_MIX[3][r]=i,0===n?n=c=1:(n=a^e[e[e[s^a]]],c^=e[e[c]]);return!0};var c=new n;o.blockSize=16,o.prototype.blockSize=o.blockSize,o.keySize=32,o.prototype.keySize=o.keySize,o.prototype._doReset=function(){var e,t,r,i,n,a;for(r=this._key,t=r.length,this._nRounds=t+6,n=4*(this._nRounds+1),this._keySchedule=[],i=0;n>i;i++)this._keySchedule[i]=t>i?r[i]:(a=this._keySchedule[i-1],i%t===0?(a=a<<8|a>>>24,a=c.SBOX[a>>>24]<<24|c.SBOX[a>>>16&255]<<16|c.SBOX[a>>>8&255]<<8|c.SBOX[255&a],a^=c.RCON[i/t|0]<<24):t>6&&i%t===4?a=c.SBOX[a>>>24]<<24|c.SBOX[a>>>16&255]<<16|c.SBOX[a>>>8&255]<<8|c.SBOX[255&a]:void 0,this._keySchedule[i-t]^a);for(this._invKeySchedule=[],e=0;n>e;e++)i=n-e,a=this._keySchedule[i-(e%4?0:4)],this._invKeySchedule[e]=4>e||4>=i?a:c.INV_SUB_MIX[0][c.SBOX[a>>>24]]^c.INV_SUB_MIX[1][c.SBOX[a>>>16&255]]^c.INV_SUB_MIX[2][c.SBOX[a>>>8&255]]^c.INV_SUB_MIX[3][c.SBOX[255&a]];return!0},o.prototype.encryptBlock=function(t){t=a(new e(t));var r=this._doCryptBlock(t,this._keySchedule,c.SUB_MIX,c.SBOX),i=new e(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[1],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[3],12),i},o.prototype.decryptBlock=function(t){t=a(new e(t));var r=[t[3],t[1]];t[1]=r[0],t[3]=r[1];var i=this._doCryptBlock(t,this._invKeySchedule,c.INV_SUB_MIX,c.INV_SBOX),n=new e(16);return n.writeUInt32BE(i[0],0),n.writeUInt32BE(i[3],4),n.writeUInt32BE(i[2],8),n.writeUInt32BE(i[1],12),n},o.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},o.prototype._doCryptBlock=function(e,r,i,n){var a,o,s,c,f,u,d,h,l;o=e[0]^r[0],s=e[1]^r[1],c=e[2]^r[2],f=e[3]^r[3],a=4;for(var p=1;p>>24]^i[1][s>>>16&255]^i[2][c>>>8&255]^i[3][255&f]^r[a++],d=i[0][s>>>24]^i[1][c>>>16&255]^i[2][f>>>8&255]^i[3][255&o]^r[a++],h=i[0][c>>>24]^i[1][f>>>16&255]^i[2][o>>>8&255]^i[3][255&s]^r[a++],l=i[0][f>>>24]^i[1][o>>>16&255]^i[2][s>>>8&255]^i[3][255&c]^r[a++],o=u,s=d,c=h,f=l;return u=(n[o>>>24]<<24|n[s>>>16&255]<<16|n[c>>>8&255]<<8|n[255&f])^r[a++],d=(n[s>>>24]<<24|n[c>>>16&255]<<16|n[f>>>8&255]<<8|n[255&o])^r[a++],h=(n[c>>>24]<<24|n[f>>>16&255]<<16|n[o>>>8&255]<<8|n[255&s])^r[a++],l=(n[f>>>24]<<24|n[o>>>16&255]<<16|n[s>>>8&255]<<8|n[255&c])^r[a++],[t(u),t(d),t(h),t(l)]},r.AES=o}).call(this,e("buffer").Buffer)},{buffer:11}],18:[function(e,t,r){(function(r){function i(e,t,n,s){if(!(this instanceof i))return new i(e,t,n);o.call(this),this._finID=r.concat([n,new r([0,0,0,1])]),n=r.concat([n,new r([0,0,0,2])]),this._cipher=new a.AES(t),this._prev=new r(n.length),this._cache=new r(""),this._secCache=new r(""),this._decrypt=s,this._alen=0,this._len=0,n.copy(this._prev),this._mode=e;var f=new r(4);f.fill(0),this._ghash=new c(this._cipher.encryptBlock(f)),this._authTag=null,this._called=!1}function n(e,t){var r=0;e.length!==t.length&&r++;for(var i=Math.min(e.length,t.length),n=-1;++nt&&(t=new r(t),t.fill(0),this._ghash.update(t))}this._called=!0;var i=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(i),this._len+=e.length,i},i.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=f(this._ghash["final"](8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt){if(n(e,this._authTag))throw new Error("Unsupported state or unable to authenticate data")}else this._authTag=e;this._cipher.scrub()},i.prototype.getAuthTag=function(){if(!this._decrypt&&r.isBuffer(this._authTag))return this._authTag;throw new Error("Attempting to get auth tag in unsupported state")},i.prototype.setAuthTag=function(e){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=e},i.prototype.setAAD=function(e){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(e),this._alen+=e.length}}).call(this,e("buffer").Buffer)},{"./aes":17,"./ghash":22,buffer:11,"buffer-xor":31,"cipher-base":32,inherits:202}],19:[function(e,t,r){function i(){return Object.keys(o)}var n=e("./encrypter");r.createCipher=r.Cipher=n.createCipher,r.createCipheriv=r.Cipheriv=n.createCipheriv;var a=e("./decrypter");r.createDecipher=r.Decipher=a.createDecipher,r.createDecipheriv=r.Decipheriv=a.createDecipheriv;var o=e("./modes");r.listCiphers=r.getCiphers=i},{"./decrypter":20,"./encrypter":21,"./modes":23}],20:[function(e,t,r){(function(t){function i(e,r,a){return this instanceof i?(f.call(this),this._cache=new n,this._last=void 0,this._cipher=new c.AES(r),this._prev=new t(a.length),a.copy(this._prev),this._mode=e,void(this._autopadding=!0)):new i(e,r,a)}function n(){return this instanceof n?void(this.cache=new t("")):new n}function a(e){for(var t=e[15],r=-1;++r16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},n.prototype.flush=function(){return this.cache.length?this.cache:void 0};var b={ECB:e("./modes/ecb"),CBC:e("./modes/cbc"),CFB:e("./modes/cfb"),CFB8:e("./modes/cfb8"),CFB1:e("./modes/cfb1"),OFB:e("./modes/ofb"),CTR:e("./modes/ctr"),GCM:e("./modes/ctr")};r.createDecipher=s,r.createDecipheriv=o}).call(this,e("buffer").Buffer)},{"./aes":17,"./authCipher":18,"./modes":23,"./modes/cbc":24,"./modes/cfb":25,"./modes/cfb1":26,"./modes/cfb8":27,"./modes/ctr":28,"./modes/ecb":29,"./modes/ofb":30,"./streamCipher":33,buffer:11,"cipher-base":32,evp_bytestokey:44,inherits:202}],21:[function(e,t,r){(function(t){function i(e,r,a){return this instanceof i?(c.call(this),this._cache=new n,this._cipher=new s.AES(r), +this._prev=new t(a.length),a.copy(this._prev),this._mode=e,void(this._autopadding=!0)):new i(e,r,a)}function n(){return this instanceof n?void(this.cache=new t("")):new n}function a(e,r,n){var a=u[e.toLowerCase()];if(!a)throw new TypeError("invalid suite type");if("string"==typeof n&&(n=new t(n)),"string"==typeof r&&(r=new t(r)),r.length!==a.key/8)throw new TypeError("invalid key length "+r.length);if(n.length!==a.iv)throw new TypeError("invalid iv length "+n.length);return"stream"===a.type?new h(p[a.mode],r,n):"auth"===a.type?new l(p[a.mode],r,n):new i(p[a.mode],r,n)}function o(e,t){var r=u[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var i=d(t,!1,r.key,r.iv);return a(e,i.key,i.iv)}var s=e("./aes"),c=e("cipher-base"),f=e("inherits"),u=e("./modes"),d=e("evp_bytestokey"),h=e("./streamCipher"),l=e("./authCipher");f(i,c),i.prototype._update=function(e){this._cache.add(e);for(var r,i,n=[];r=this._cache.get();)i=this._mode.encrypt(this,r),n.push(i);return t.concat(n)},i.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if("10101010101010101010101010101010"!==e.toString("hex"))throw this._cipher.scrub(),new Error("data not multiple of block length")},i.prototype.setAutoPadding=function(e){this._autopadding=!!e},n.prototype.add=function(e){this.cache=t.concat([this.cache,e])},n.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},n.prototype.flush=function(){for(var e=16-this.cache.length,r=new t(e),i=-1;++ic||0>e?(r=Math.abs(e)%c,0>e?c-r:r):e}function o(e,t){return[e[0]^t[0],e[1]^t[1],e[2]^t[2],e[3]^t[3]]}var s=new e(16);s.fill(0),t.exports=r,r.prototype.ghash=function(e){for(var t=-1;++t0;e--)a[e]=a[e]>>>1|(1&a[e-1])<<31;a[0]=a[0]>>>1,r&&(a[0]=a[0]^225<<24)}this.state=n(s)},r.prototype.update=function(t){this.cache=e.concat([this.cache,t]);for(var r;this.cache.length>=16;)r=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(r)},r.prototype["final"]=function(t,r){return this.cache.length&&this.ghash(e.concat([this.cache,s],16)),this.ghash(n([0,t,0,r])),this.state};var c=Math.pow(2,32)}).call(this,e("buffer").Buffer)},{buffer:11}],23:[function(e,t,r){r["aes-128-ecb"]={cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},r["aes-192-ecb"]={cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},r["aes-256-ecb"]={cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},r["aes-128-cbc"]={cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},r["aes-192-cbc"]={cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},r["aes-256-cbc"]={cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},r.aes128=r["aes-128-cbc"],r.aes192=r["aes-192-cbc"],r.aes256=r["aes-256-cbc"],r["aes-128-cfb"]={cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},r["aes-192-cfb"]={cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},r["aes-256-cfb"]={cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"},r["aes-128-cfb8"]={cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},r["aes-192-cfb8"]={cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},r["aes-256-cfb8"]={cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},r["aes-128-cfb1"]={cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},r["aes-192-cfb1"]={cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},r["aes-256-cfb1"]={cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},r["aes-128-ofb"]={cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},r["aes-192-ofb"]={cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},r["aes-256-ofb"]={cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},r["aes-128-ctr"]={cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},r["aes-192-ctr"]={cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},r["aes-256-ctr"]={cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},r["aes-128-gcm"]={cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},r["aes-192-gcm"]={cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},r["aes-256-gcm"]={cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}},{}],24:[function(e,t,r){var i=e("buffer-xor");r.encrypt=function(e,t){var r=i(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var n=e._cipher.decryptBlock(t);return i(n,r)}},{"buffer-xor":31}],25:[function(e,t,r){(function(t){function i(e,r,i){var a=r.length,o=n(r,e._cache);return e._cache=e._cache.slice(a),e._prev=t.concat([e._prev,i?r:o]),o}var n=e("buffer-xor");r.encrypt=function(e,r,n){for(var a,o=new t("");r.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=new t("")),!(e._cache.length<=r.length)){o=t.concat([o,i(e,r,n)]);break}a=e._cache.length,o=t.concat([o,i(e,r.slice(0,a),n)]),r=r.slice(a)}return o}}).call(this,e("buffer").Buffer)},{buffer:11,"buffer-xor":31}],26:[function(e,t,r){(function(e){function t(e,t,r){for(var n,a,o,s=-1,c=8,f=0;++s>s%8,e._prev=i(e._prev,r?a:o);return f}function i(t,r){var i=t.length,n=-1,a=new e(t.length);for(t=e.concat([t,new e([r])]);++n>7;return a}r.encrypt=function(r,i,n){for(var a=i.length,o=new e(a),s=-1;++sa;++a)n[a]=t[a]^r[a];return n}}).call(this,e("buffer").Buffer)},{buffer:11}],32:[function(e,t,r){(function(r){function i(e){n.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this["final"]=this._finalOrDigest,this._decoder=null,this._encoding=null}var n=e("stream").Transform,a=e("inherits"),o=e("string_decoder").StringDecoder;t.exports=i,a(i,n),i.prototype.update=function(e,t,i){"string"==typeof e&&(e=new r(e,t));var n=this._update(e);return this.hashMode?this:(i&&(n=this._toString(n,i)),n)},i.prototype._transform=function(e,t,r){var i;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(n){i=n}finally{r(i)}},i.prototype._flush=function(e){var t;try{this.push(this._final())}catch(r){t=r}finally{e(t)}},i.prototype._finalOrDigest=function(e){var t=this._final()||new r("");return e&&(t=this._toString(t,e,!0)),t},i.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var i=this._decoder.write(e);return r&&(i+=this._decoder.end()),i}}).call(this,e("buffer").Buffer)},{buffer:11,inherits:202,stream:219,string_decoder:220}],33:[function(e,t,r){(function(r){function i(e,t,o,s){return this instanceof i?(a.call(this),this._cipher=new n.AES(t),this._prev=new r(o.length),this._cache=new r(""),this._secCache=new r(""),this._decrypt=s,o.copy(this._prev),void(this._mode=e)):new i(e,t,o)}var n=e("./aes"),a=e("cipher-base"),o=e("inherits");o(i,a),t.exports=i,i.prototype._update=function(e){return this._mode.encrypt(this,e,this._decrypt)},i.prototype._final=function(){this._cipher.scrub()}}).call(this,e("buffer").Buffer)},{"./aes":17,buffer:11,"cipher-base":32,inherits:202}],34:[function(e,t,r){(function(r){function i(e){n.call(this);var t,i=e.mode.toLowerCase(),a=s[i];t=e.decrypt?"decrypt":"encrypt";var o=e.key;("des-ede"===i||"des-ede-cbc"===i)&&(o=r.concat([o,o.slice(0,8)]));var c=e.iv;this._des=a.create({key:o,iv:c,type:t})}var n=e("cipher-base"),a=e("des.js"),o=e("inherits"),s={"des-ede3-cbc":a.CBC.instantiate(a.EDE),"des-ede3":a.EDE,"des-ede-cbc":a.CBC.instantiate(a.EDE),"des-ede":a.EDE,"des-cbc":a.CBC.instantiate(a.DES),"des-ecb":a.DES};s.des=s["des-cbc"],s.des3=s["des-ede3-cbc"],t.exports=i,o(i,n),i.prototype._update=function(e){return new r(this._des.update(e))},i.prototype._final=function(){return new r(this._des["final"]())}}).call(this,e("buffer").Buffer)},{buffer:11,"cipher-base":36,"des.js":37,inherits:202}],35:[function(e,t,r){r["des-ecb"]={key:8,iv:0},r["des-cbc"]=r.des={key:8,iv:8},r["des-ede3-cbc"]=r.des3={key:24,iv:8},r["des-ede3"]={key:24,iv:0},r["des-ede-cbc"]={key:16,iv:8},r["des-ede"]={key:16,iv:0}},{}],36:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{buffer:11,dup:32,inherits:202,stream:219,string_decoder:220}],37:[function(e,t,r){"use strict";r.utils=e("./des/utils"),r.Cipher=e("./des/cipher"),r.DES=e("./des/des"),r.CBC=e("./des/cbc"),r.EDE=e("./des/ede")},{"./des/cbc":38,"./des/cipher":39,"./des/des":40,"./des/ede":41,"./des/utils":42}],38:[function(e,t,r){"use strict";function i(e){a.equal(e.length,8,"Invalid IV length"),this.iv=new Array(8);for(var t=0;ti;i++)this.buffer[this.bufferOff+i]=e[t+i];return this.bufferOff+=r,r},i.prototype._flushBuffer=function(e,t){return this._update(this.buffer,0,e,t),this.bufferOff=0,this.blockSize},i.prototype._updateEncrypt=function(e){var t=0,r=0,i=(this.bufferOff+e.length)/this.blockSize|0,n=new Array(i*this.blockSize);0!==this.bufferOff&&(t+=this._buffer(e,t),this.bufferOff===this.buffer.length&&(r+=this._flushBuffer(n,r)));for(var a=e.length-(e.length-t)%this.blockSize;a>t;t+=this.blockSize)this._update(e,t,n,r),r+=this.blockSize;for(;t0;i--)t+=this._buffer(e,t),r+=this._flushBuffer(n,r);return t+=this._buffer(e,t),n},i.prototype["final"]=function(e){var t;e&&(t=this.update(e));var r;return r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=c.r28shl(r,o),i=c.r28shl(i,o),c.pc2(r,i,e.keys,n)}},n.prototype._update=function(e,t,r,i){var n=this._desState,a=c.readUInt32BE(e,t),o=c.readUInt32BE(e,t+4);c.ip(a,o,n.tmp,0),a=n.tmp[0],o=n.tmp[1],"encrypt"===this.type?this._encrypt(n,a,o,n.tmp,0):this._decrypt(n,a,o,n.tmp,0),a=n.tmp[0],o=n.tmp[1],c.writeUInt32BE(r,a,i),c.writeUInt32BE(r,o,i+4)},n.prototype._pad=function(e,t){for(var r=e.length-t,i=t;i>>0,a=l}c.rip(o,a,i,n)},n.prototype._decrypt=function(e,t,r,i,n){for(var a=r,o=t,s=e.keys.length-2;s>=0;s-=2){var f=e.keys[s],u=e.keys[s+1];c.expand(a,e.tmp,0),f^=e.tmp[0],u^=e.tmp[1];var d=c.substitute(f,u),h=c.permute(d),l=a;a=(o^h)>>>0,o=l}c.rip(a,o,i,n)}},{"../des":37,inherits:202,"minimalistic-assert":43}],41:[function(e,t,r){"use strict";function i(e,t){a.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),n=t.slice(16,24);"encrypt"===e?this.ciphers=[f.create({type:"encrypt",key:r}),f.create({type:"decrypt",key:i}),f.create({type:"encrypt",key:n})]:this.ciphers=[f.create({type:"decrypt",key:n}),f.create({type:"encrypt",key:i}),f.create({type:"decrypt",key:r})]}function n(e){c.call(this,e);var t=new i(this.type,this.options.key);this._edeState=t}var a=e("minimalistic-assert"),o=e("inherits"),s=e("../des"),c=s.Cipher,f=s.DES;o(n,c),t.exports=n,n.create=function(e){return new n(e)},n.prototype._update=function(e,t,r,i){var n=this._edeState;n.ciphers[0]._update(e,t,r,i),n.ciphers[1]._update(r,i,r,i),n.ciphers[2]._update(r,i,r,i)},n.prototype._pad=f.prototype._pad,n.prototype._unpad=f.prototype._unpad},{"../des":37,inherits:202,"minimalistic-assert":43}],42:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){var r=e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t];return r>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,i){for(var n=0,a=0,o=6;o>=0;o-=2){for(var s=0;24>=s;s+=8)n<<=1,n|=t>>>s+o&1;for(var s=0;24>=s;s+=8)n<<=1,n|=e>>>s+o&1}for(var o=6;o>=0;o-=2){for(var s=1;25>=s;s+=8)a<<=1,a|=t>>>s+o&1;for(var s=1;25>=s;s+=8)a<<=1,a|=e>>>s+o&1}r[i+0]=n>>>0,r[i+1]=a>>>0},r.rip=function(e,t,r,i){for(var n=0,a=0,o=0;4>o;o++)for(var s=24;s>=0;s-=8)n<<=1,n|=t>>>s+o&1,n<<=1,n|=e>>>s+o&1;for(var o=4;8>o;o++)for(var s=24;s>=0;s-=8)a<<=1,a|=t>>>s+o&1,a<<=1,a|=e>>>s+o&1;r[i+0]=n>>>0,r[i+1]=a>>>0},r.pc1=function(e,t,r,i){for(var n=0,a=0,o=7;o>=5;o--){for(var s=0;24>=s;s+=8)n<<=1,n|=t>>s+o&1;for(var s=0;24>=s;s+=8)n<<=1,n|=e>>s+o&1}for(var s=0;24>=s;s+=8)n<<=1,n|=t>>s+o&1;for(var o=1;3>=o;o++){for(var s=0;24>=s;s+=8)a<<=1,a|=t>>s+o&1;for(var s=0;24>=s;s+=8)a<<=1,a|=e>>s+o&1}for(var s=0;24>=s;s+=8)a<<=1,a|=e>>s+o&1;r[i+0]=n>>>0,r[i+1]=a>>>0},r.r28shl=function(e,t){return e<>>28-t};var i=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,n){for(var a=0,o=0,s=i.length>>>1,c=0;s>c;c++)a<<=1,a|=e>>>i[c]&1;for(var c=s;c>>i[c]&1;r[n+0]=a>>>0,r[n+1]=o>>>0},r.expand=function(e,t,r){var i=0,n=0;i=(1&e)<<5|e>>>27;for(var a=23;a>=15;a-=4)i<<=6,i|=e>>>a&63;for(var a=11;a>=3;a-=4)n|=e>>>a&63,n<<=6;n|=(31&e)<<1|e>>>31,t[r+0]=i>>>0,t[r+1]=n>>>0};var n=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,i=0;4>i;i++){var a=e>>>18-6*i&63,o=n[64*i+a];r<<=4,r|=o}for(var i=0;4>i;i++){var a=t>>>18-6*i&63,o=n[256+64*i+a];r<<=4,r|=o}return r>>>0};var a=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>a[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var i=e.toString(2);i.lengtha;a+=r)n.push(i.slice(a,a+r));return n.join(" ")}},{}],43:[function(e,t,r){function i(e,t){if(!e)throw new Error(t||"Assertion failed")}t.exports=i,i.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},{}],44:[function(e,t,r){(function(r){function i(e,t,i,a){r.isBuffer(e)||(e=new r(e,"binary")),t&&!r.isBuffer(t)&&(t=new r(t,"binary")),i/=8,a=a||0;for(var o,s,c=0,f=0,u=new r(i),d=new r(a),h=0,l=[];;){if(h++>0&&l.push(o),l.push(e),t&&l.push(t),o=n(r.concat(l)),l=[],s=0,i>0)for(;;){if(0===i)break;if(s===o.length)break;u[c++]=o[s],i--,s++}if(a>0&&s!==o.length)for(;;){if(0===a)break;if(s===o.length)break;d[f++]=o[s],a--,s++}if(0===i&&0===a)break}for(s=0;sa;a++){var o=e.charCodeAt(a)-48;i<<=4,i|=o>=49&&54>=o?o-49+10:o>=17&&22>=o?o-17+10:15&o}return i}function o(e,t,r,i){for(var n=0,a=Math.min(e.length,r),o=t;a>o;o++){var s=e.charCodeAt(o)-48;n*=i,n+=s>=49?s-49+10:s>=17?s-17+10:s}return n}function s(e,t){this.name=e,this.p=new n(t,16),this.n=this.p.bitLength(),this.k=new n(1).ishln(this.n).isub(this.p),this.tmp=this._tmp()}function c(){s.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function f(){s.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function u(){s.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function d(){s.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function h(e){if("string"==typeof e){var t=n._prime(e);this.m=t.p,this.prime=t}else this.m=e,this.prime=null}function l(e){h.call(this,e),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).ishln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv.sign=!0,this.minv=this.minv.mod(this.r)}"object"==typeof e?e.exports=n:t.BN=n,n.BN=n,n.wordSize=26,n.prototype._init=function(e,t,i){if("number"==typeof e)return this._initNumber(e,t,i);if("object"==typeof e)return this._initArray(e,t,i);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&36>=t),e=e.toString().replace(/\s+/g,"");var n=0;"-"===e[0]&&n++,16===t?this._parseHex(e,n):this._parseBase(e,t,n),"-"===e[0]&&(this.sign=!0),this.strip(),"le"===i&&this._initArray(this.toArray(),t,i)},n.prototype._initNumber=function(e,t,i){0>e&&(this.sign=!0,e=-e),67108864>e?(this.words=[67108863&e],this.length=1):4503599627370496>e?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(9007199254740992>e),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),t,i)},n.prototype._initArray=function(e,t,i){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3){var s=e[n]|e[n-1]<<8|e[n-2]<<16;this.words[o]|=s<>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}else if("le"===i)for(var n=0,o=0;n>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}return this.strip()},n.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6){var o=a(e,r,r+6);this.words[n]|=o<>>26-i&4194303,i+=24,i>=26&&(i-=26,n++)}if(r+6!==t){var o=a(e,t,r+6);this.words[n]|=o<>>26-i&4194303}this.strip()},n.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var i=0,n=1;67108863>=n;n*=t)i++;i--,n=n/t|0;for(var a=e.length-r,s=a%i,c=Math.min(a,a-s)+r,f=0,u=r;c>u;u+=i)f=o(e,u,u+i,t),this.imuln(n),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(0!==s){for(var d=1,f=o(e,u,e.length,t),u=0;s>u;u++)d*=t;this.imuln(d),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}},n.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},n.prototype.inspect=function(){return(this.red?""};var p=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],m=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(e,t){if(e=e||10,16===e||"hex"===e){for(var i="",n=0,t=0|t||1,a=0,o=0;o>>24-n&16777215,i=0!==a||o!==this.length-1?p[6-c.length]+c+i:c+i,n+=2,n>=26&&(n-=26,o--)}for(0!==a&&(i=a.toString(16)+i);i.length%t!==0;)i="0"+i;return this.sign&&(i="-"+i),i}if(e===(0|e)&&e>=2&&36>=e){var f=b[e],u=m[e],i="",d=this.clone();for(d.sign=!1;0!==d.cmpn(0);){var h=d.modn(u).toString(e);d=d.idivn(u),i=0!==d.cmpn(0)?p[f-h.length]+h+i:h+i}return 0===this.cmpn(0)&&(i="0"+i),this.sign&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toArray=function(e){this.strip();var t=new Array(this.byteLength());t[0]=0;var r=this.clone();if("le"!==e)for(var i=0;0!==r.cmpn(0);i++){var n=r.andln(255);r.ishrn(8),t[t.length-i-1]=n}else for(var i=0;0!==r.cmpn(0);i++){var n=r.andln(255);r.ishrn(8),t[i]=n}return t},Math.clz32?n.prototype._countBits=function(e){return 32-Math.clz32(e)}:n.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},n.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0===(8191&t)&&(r+=13,t>>>=13),0===(127&t)&&(r+=7,t>>>=7),0===(15&t)&&(r+=4,t>>>=4),0===(3&t)&&(r+=2,t>>>=2),0===(1&t)&&r++,r},n.prototype.bitLength=function(){var e=0,t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},n.prototype.iand=function(e){this.sign=this.sign&&e.sign;var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},n.prototype.ixor=function(e){this.sign=this.sign||e.sign;var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var i=0;ie.length?this.clone().ixor(e):e.clone().ixor(this)},n.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);for(var i=e/26|0,n=e%26;this.length<=i;)this.words[this.length++]=0;return t?this.words[i]=this.words[i]|1<e.length?(r=this,i=e):(r=e,i=this);for(var n=0,a=0;a>>26}for(;0!==n&&a>>26}if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;ae.length?this.clone().iadd(e):e.clone().iadd(this)},n.prototype.isub=function(e){if(e.sign){e.sign=!1;var t=this.iadd(e);return e.sign=!0,t._normSign()}if(this.sign)return this.sign=!1,this.iadd(e),this.sign=!0,this._normSign();var r=this.cmp(e);if(0===r)return this.sign=!1,this.length=1,this.words[0]=0,this;var i,n;r>0?(i=this,n=e):(i=e,n=this);for(var a=0,o=0;o>26,this.words[o]=67108863&t}for(;0!==a&&o>26,this.words[o]=67108863&t}if(0===a&&o>>26,a=67108863&r,o=Math.min(i,e.length-1),s=Math.max(0,i-this.length+1);o>=s;s++){var c=i-s,f=0|this.words[c],u=0|e.words[s],d=f*u,h=67108863&d;n=n+(d/67108864|0)|0,h=h+a|0,a=67108863&h,n=n+(h>>>26)|0}t.words[i]=a,r=n}return 0!==r?t.words[i]=r:t.length--,t.strip()},n.prototype._bigMulTo=function(e,t){t.sign=e.sign!==this.sign,t.length=this.length+e.length;for(var r=0,i=0,n=0;n=c;c++){var f=n-c,u=0|this.words[f],d=0|e.words[c],h=u*d,l=67108863&h;a=a+(h/67108864|0)|0,l=l+o|0,o=67108863&l,a=a+(l>>>26)|0,i+=a>>>26,a&=67108863}t.words[n]=o,r=a,a=i}return 0!==r?t.words[n]=r:t.length--,t.strip()},n.prototype.mulTo=function(e,t){var r;return r=this.length+e.length<63?this._smallMulTo(e,t):this._bigMulTo(e,t)},n.prototype.mul=function(e){var t=new n(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},n.prototype.imul=function(e){if(0===this.cmpn(0)||0===e.cmpn(0))return this.words[0]=0,this.length=1,this;var t=this.length,r=e.length;this.sign=e.sign!==this.sign,this.length=this.length+e.length,this.words[this.length-1]=0;for(var i=this.length-2;i>=0;i--){for(var n=0,a=0,o=Math.min(i,r-1),s=Math.max(0,i-t+1);o>=s;s++){var c=i-s,f=this.words[c],u=e.words[s],d=f*u,h=67108863&d;n+=d/67108864|0,h+=a,a=67108863&h,n+=h>>>26}this.words[i]=a,this.words[i+1]+=n,n=0}for(var n=0,c=1;c>>26}return this.strip()},n.prototype.imuln=function(e){r("number"==typeof e);for(var t=0,i=0;i>=26,t+=n/67108864|0,t+=a>>>26,this.words[i]=67108863&a}return 0!==t&&(this.words[i]=t,this.length++),this},n.prototype.muln=function(e){return this.clone().imuln(e)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.mul(this)},n.prototype.ishln=function(e){r("number"==typeof e&&e>=0);var t=e%26,i=(e-t)/26,n=67108863>>>26-t<<26-t;if(0!==t){for(var a=0,o=0;o>>26-t}a&&(this.words[o]=a,this.length++)}if(0!==i){for(var o=this.length-1;o>=0;o--)this.words[o+i]=this.words[o];for(var o=0;i>o;o++)this.words[o]=0;this.length+=i}return this.strip()},n.prototype.ishrn=function(e,t,i){r("number"==typeof e&&e>=0);var n;n=t?(t-t%26)/26:0;var a=e%26,o=Math.min((e-a)/26,this.length),s=67108863^67108863>>>a<f;f++)c.words[f]=this.words[f];c.length=o}if(0===o);else if(this.length>o){this.length-=o;for(var f=0;f=0&&(0!==u||f>=n);f--){var d=this.words[f];this.words[f]=u<<26-a|d>>>a,u=d&s}return c&&0!==u&&(c.words[c.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},n.prototype.shln=function(e){return this.clone().ishln(e)},n.prototype.shrn=function(e){return this.clone().ishrn(e)},n.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,i=(e-t)/26,n=1<=0);var t=e%26,i=(e-t)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!==t&&i++,this.length=Math.min(i,this.length),0!==t){var n=67108863^67108863>>>t<e?this.isubn(-e):this.sign?1===this.length&&this.words[0]=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},n.prototype.isubn=function(e){if(r("number"==typeof e),0>e)return this.iaddn(-e);if(this.sign)return this.sign=!1,this.iaddn(e),this.sign=!0,this;this.words[0]-=e;for(var t=0;t>26)-(f/67108864|0),this.words[n+i]=67108863&c}for(;n>26,this.words[n+i]=67108863&c}if(0===s)return this.strip();r(-1===s),s=0;for(var n=0;n>26,this.words[n]=67108863&c}return this.sign=!0,this.strip()},n.prototype._wordDiv=function(e,t){var r=this.length-e.length,i=this.clone(),a=e,o=a.words[a.length-1],s=this._countBits(o);r=26-s,0!==r&&(a=a.shln(r),i.ishln(r),o=a.words[a.length-1]);var c,f=i.length-a.length;if("mod"!==t){c=new n(null),c.length=f+1,c.words=new Array(c.length);for(var u=0;u=0;h--){var l=67108864*i.words[a.length+h]+i.words[a.length+h-1];for(l=Math.min(l/o|0,67108863),i._ishlnsubmul(a,l,h);i.sign;)l--,i.sign=!1,i._ishlnsubmul(a,1,h),0!==i.cmpn(0)&&(i.sign=!i.sign);c&&(c.words[h]=l)}return c&&c.strip(),i.strip(),"div"!==t&&0!==r&&i.ishrn(r),{div:c?c:null,mod:i}},n.prototype.divmod=function(e,t){if(r(0!==e.cmpn(0)),this.sign&&!e.sign){var i,a,o=this.neg().divmod(e,t);return"mod"!==t&&(i=o.div.neg()),"div"!==t&&(a=0===o.mod.cmpn(0)?o.mod:e.sub(o.mod)),{div:i,mod:a}}if(!this.sign&&e.sign){var i,o=this.divmod(e.neg(),t);return"mod"!==t&&(i=o.div.neg()),{div:i,mod:o.mod}}return this.sign&&e.sign?this.neg().divmod(e.neg(),t):e.length>this.length||this.cmp(e)<0?{div:new n(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new n(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new n(this.modn(e.words[0]))}:this._wordDiv(e,t)},n.prototype.div=function(e){return this.divmod(e,"div").div},n.prototype.mod=function(e){return this.divmod(e,"mod").mod},n.prototype.divRound=function(e){var t=this.divmod(e);if(0===t.mod.cmpn(0))return t.div;var r=t.div.sign?t.mod.isub(e):t.mod,i=e.shrn(1),n=e.andln(1),a=r.cmp(i);return 0>a||1===n&&0===a?t.div:t.div.sign?t.div.isubn(1):t.div.iaddn(1)},n.prototype.modn=function(e){r(67108863>=e);for(var t=(1<<26)%e,i=0,n=this.length-1;n>=0;n--)i=(t*i+this.words[n])%e;return i},n.prototype.idivn=function(e){r(67108863>=e);for(var t=0,i=this.length-1;i>=0;i--){var n=this.words[i]+67108864*t;this.words[i]=n/e|0,t=n%e}return this.strip()},n.prototype.divn=function(e){return this.clone().idivn(e)},n.prototype.egcd=function(e){r(!e.sign),r(0!==e.cmpn(0));var t=this,i=e.clone();t=t.sign?t.mod(e):t.clone();for(var a=new n(1),o=new n(0),s=new n(0),c=new n(1),f=0;t.isEven()&&i.isEven();)t.ishrn(1),i.ishrn(1),++f;for(var u=i.clone(),d=t.clone();0!==t.cmpn(0);){for(;t.isEven();)t.ishrn(1),a.isEven()&&o.isEven()?(a.ishrn(1),o.ishrn(1)):(a.iadd(u).ishrn(1),o.isub(d).ishrn(1));for(;i.isEven();)i.ishrn(1),s.isEven()&&c.isEven()?(s.ishrn(1),c.ishrn(1)):(s.iadd(u).ishrn(1),c.isub(d).ishrn(1));t.cmp(i)>=0?(t.isub(i),a.isub(s),o.isub(c)):(i.isub(t),s.isub(a),c.isub(o))}return{a:s,b:c,gcd:i.ishln(f)}},n.prototype._invmp=function(e){r(!e.sign),r(0!==e.cmpn(0));var t=this,i=e.clone();t=t.sign?t.mod(e):t.clone();for(var a=new n(1),o=new n(0),s=i.clone();t.cmpn(1)>0&&i.cmpn(1)>0;){for(;t.isEven();)t.ishrn(1),a.isEven()?a.ishrn(1):a.iadd(s).ishrn(1);for(;i.isEven();)i.ishrn(1),o.isEven()?o.ishrn(1):o.iadd(s).ishrn(1);t.cmp(i)>=0?(t.isub(i),a.isub(o)):(i.isub(t),o.isub(a))}return 0===t.cmpn(1)?a:o},n.prototype.gcd=function(e){if(0===this.cmpn(0))return e.clone();if(0===e.cmpn(0))return this.clone();var t=this.clone(),r=e.clone();t.sign=!1,r.sign=!1;for(var i=0;t.isEven()&&r.isEven();i++)t.ishrn(1),r.ishrn(1);for(;;){for(;t.isEven();)t.ishrn(1);for(;r.isEven();)r.ishrn(1);var n=t.cmp(r);if(0>n){var a=t;t=r,r=a}else if(0===n||0===r.cmpn(1))break;t.isub(r)}return r.ishln(i)},n.prototype.invm=function(e){return this.egcd(e).a.mod(e)},n.prototype.isEven=function(){return 0===(1&this.words[0])},n.prototype.isOdd=function(){return 1===(1&this.words[0])},n.prototype.andln=function(e){return this.words[0]&e},n.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,i=(e-t)/26,n=1<a;a++)this.words[a]=0;return this.words[i]|=n,this.length=i+1,this}for(var o=n,a=i;0!==o&&a>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.cmpn=function(e){var t=0>e;if(t&&(e=-e),this.sign&&!t)return-1;if(!this.sign&&t)return 1;e&=67108863,this.strip();var r;if(this.length>1)r=1;else{var i=this.words[0];r=i===e?0:e>i?-1:1}return this.sign&&(r=-r),r},n.prototype.cmp=function(e){if(this.sign&&!e.sign)return-1;if(!this.sign&&e.sign)return 1;var t=this.ucmp(e);return this.sign?-t:t},n.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length=0;r--){var i=this.words[r],n=e.words[r];if(i!==n){n>i?t=-1:i>n&&(t=1);break}}return t},n.red=function(e){return new h(e)},n.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),e.convertTo(this)._forceRed(e)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(e){return this.red=e,this},n.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},n.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},n.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},n.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},n.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},n.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},n.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},n.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};s.prototype._tmp=function(){var e=new n(null);return e.words=new Array(Math.ceil(this.n/13)),e},s.prototype.ireduce=function(e){var t,r=e;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),t=r.bitLength();while(t>this.n);var i=t0?r.isub(this.p):r.strip(),r},s.prototype.split=function(e,t){e.ishrn(this.n,0,t)},s.prototype.imulK=function(e){return e.imul(this.k)},i(c,s),c.prototype.split=function(e,t){for(var r=4194303,i=Math.min(e.length,9),n=0;i>n;n++)t.words[n]=e.words[n];if(t.length=i,e.length<=9)return e.words[0]=0,void(e.length=1);var a=e.words[9];t.words[t.length++]=a&r;for(var n=10;n>>22,a=o}e.words[n-10]=a>>>22,e.length-=9},c.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t,r=0,i=0;i>>=26,e.words[r]=n,t=i}return 0!==t&&(e.words[e.length++]=t),e},n._prime=function v(e){if(g[e])return g[e];var v;if("k256"===e)v=new c;else if("p224"===e)v=new f;else if("p192"===e)v=new u;else{if("p25519"!==e)throw new Error("Unknown prime "+e);v=new d}return g[e]=v,v},h.prototype._verify1=function(e){r(!e.sign,"red works only with positives"),r(e.red,"red works only with red numbers")},h.prototype._verify2=function(e,t){r(!e.sign&&!t.sign,"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},h.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.mod(this.m)._forceRed(this)},h.prototype.neg=function(e){var t=e.clone();return t.sign=!t.sign,t.iadd(this.m)._forceRed(this)},h.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},h.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},h.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},h.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},h.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.shln(t))},h.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},h.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},h.prototype.isqr=function(e){return this.imul(e,e)},h.prototype.sqr=function(e){return this.mul(e,e)},h.prototype.sqrt=function(e){if(0===e.cmpn(0))return e.clone();var t=this.m.andln(3);if(r(t%2===1),3===t){var i=this.m.add(new n(1)).ishrn(2),a=this.pow(e,i);return a}for(var o=this.m.subn(1),s=0;0!==o.cmpn(0)&&0===o.andln(1);)s++,o.ishrn(1);r(0!==o.cmpn(0));var c=new n(1).toRed(this),f=c.redNeg(),u=this.m.subn(1).ishrn(1),d=this.m.bitLength();for(d=new n(2*d*d).toRed(this);0!==this.pow(d,u).cmp(f);)d.redIAdd(f);for(var h=this.pow(d,o),a=this.pow(e,o.addn(1).ishrn(1)),l=this.pow(e,o),p=s;0!==l.cmp(c);){for(var b=l,m=0;0!==b.cmp(c);m++)b=b.redSqr();r(p>m);var g=this.pow(h,new n(1).ishln(p-m-1));a=a.redMul(g),h=g.redSqr(),l=l.redMul(h),p=m}return a},h.prototype.invm=function(e){var t=e._invmp(this.m);return t.sign?(t.sign=!1,this.imod(t).redNeg()):this.imod(t)},h.prototype.pow=function(e,t){var r=[];if(0===t.cmpn(0))return new n(1);for(var i=t.clone();0!==i.cmpn(0);)r.push(i.andln(1)),i.ishrn(1);for(var a=e,o=0;o=0?a=n.isub(this.m):n.cmpn(0)<0&&(a=n.iadd(this.m)),a._forceRed(this)},l.prototype.mul=function(e,t){if(0===e.cmpn(0)||0===t.cmpn(0))return new n(0)._forceRed(this);var r=e.mul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(i).ishrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},l.prototype.invm=function(e){var t=this.imod(e._invmp(this.m).mul(this.r2));return t._forceRed(this)}}("undefined"==typeof t||t,this)},{}],49:[function(e,t,r){(function(r){function i(e){var t=a(e),r=t.toRed(o.mont(e.modulus)).redPow(new o(e.publicExponent)).fromRed();return{blinder:r,unblinder:t.invm(e.modulus)}}function n(e,t){var n=i(t),a=t.modulus.byteLength(),s=(o.mont(t.modulus),new o(e).mul(n.blinder).mod(t.modulus)),c=s.toRed(o.mont(t.prime1)),f=s.toRed(o.mont(t.prime2)),u=t.coefficient,d=t.prime1,h=t.prime2,l=c.redPow(t.exponent1),p=f.redPow(t.exponent2);l=l.fromRed(),p=p.fromRed();var b=l.isub(p).imul(u).mod(d);b.imul(h),p.iadd(b);var m=new r(p.imul(n.unblinder).mod(t.modulus).toArray());if(m.length=0||!r.mod(e.prime1)||!r.mod(e.prime2);)r=new o(s(t));return r}var o=e("bn.js"),s=e("randombytes");t.exports=n,n.getr=a}).call(this,e("buffer").Buffer)},{"bn.js":48,buffer:11,randombytes:200}],50:[function(e,t,r){"use strict";var i=r;i.version=e("../package.json").version,i.utils=e("./elliptic/utils"),i.rand=e("brorand"),i.hmacDRBG=e("./elliptic/hmac-drbg"),i.curve=e("./elliptic/curve"),i.curves=e("./elliptic/curves"),i.ec=e("./elliptic/ec")},{"../package.json":70,"./elliptic/curve":53,"./elliptic/curves":56,"./elliptic/ec":57,"./elliptic/hmac-drbg":60,"./elliptic/utils":62,brorand:63}],51:[function(e,t,r){"use strict";function i(e,t){this.type=e,this.p=new a(t.p,16),this.red=t.prime?a.red(t.prime):a.mont(this.p),this.zero=new a(0).toRed(this.red),this.one=new a(1).toRed(this.red),this.two=new a(2).toRed(this.red),this.n=t.n&&new a(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4)}function n(e,t){this.curve=e,this.type=t,this.precomputed=null}var a=e("bn.js"),o=e("../../elliptic"),s=o.utils.getNAF,c=o.utils.getJSF,f=o.utils.assert;t.exports=i,i.prototype.point=function(){throw new Error("Not implemented")},i.prototype.validate=function(){throw new Error("Not implemented")},i.prototype._fixedNafMul=function(e,t){f(e.precomputed);var r=e._getDoubles(),i=s(t,1),n=(1<=o;t--)c=(c<<1)+i[t];a.push(c)}for(var u=this.jpoint(null,null,null),d=this.jpoint(null,null,null),h=n;h>0;h--){for(var o=0;o=0;c--){for(var t=0;c>=0&&0===a[c];c--)t++;if(c>=0&&t++,o=o.dblp(t),0>c)break;var u=a[c];f(0!==u),o="affine"===e.type?u>0?o.mixedAdd(n[u-1>>1]):o.mixedAdd(n[-u-1>>1].neg()):u>0?o.add(n[u-1>>1]):o.add(n[-u-1>>1].neg())}return"affine"===e.type?o.toP():o},i.prototype._wnafMulAdd=function(e,t,r,i){for(var n=this._wnafT1,a=this._wnafT2,o=this._wnafT3,f=0,u=0;i>u;u++){var d=t[u],h=d._getNAFPoints(e);n[u]=h.wnd,a[u]=h.points}for(var u=i-1;u>=1;u-=2){var l=u-1,p=u;if(1===n[l]&&1===n[p]){var b=[t[l],null,null,t[p]];0===t[l].y.cmp(t[p].y)?(b[1]=t[l].add(t[p]),b[2]=t[l].toJ().mixedAdd(t[p].neg())):0===t[l].y.cmp(t[p].y.redNeg())?(b[1]=t[l].toJ().mixedAdd(t[p]),b[2]=t[l].add(t[p].neg())):(b[1]=t[l].toJ().mixedAdd(t[p]),b[2]=t[l].toJ().mixedAdd(t[p].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],g=c(r[l],r[p]);f=Math.max(g[0].length,f),o[l]=new Array(f),o[p]=new Array(f);for(var v=0;f>v;v++){var y=0|g[0][v],w=0|g[1][v];o[l][v]=m[3*(y+1)+(w+1)],o[p][v]=0,a[l]=b}}else o[l]=s(r[l],n[l]),o[p]=s(r[p],n[p]),f=Math.max(o[l].length,f),f=Math.max(o[p].length,f)}for(var _=this.jpoint(null,null,null),S=this._wnafT4,u=f;u>=0;u--){for(var k=0;u>=0;){for(var E=!0,v=0;i>v;v++)S[v]=0|o[v][u],0!==S[v]&&(E=!1);if(!E)break;k++,u--}if(u>=0&&k++,_=_.dblp(k),0>u)break;for(var v=0;i>v;v++){var d,x=S[v];0!==x&&(x>0?d=a[v][x-1>>1]:0>x&&(d=a[v][-x-1>>1].neg()),_="affine"===d.type?_.mixedAdd(d):_.add(d))}}for(var u=0;i>u;u++)a[u]=null;return _.toP()},i.BasePoint=n,n.prototype.validate=function(){return this.curve.validate(this)},n.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},n.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1},n.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;t>n;n+=e){for(var a=0;e>a;a++)i=i.dbl();r.push(i)}return{step:e,points:r}},n.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],r=(1<n;n++)t[n]=t[n-1].add(i);return{wnd:e,points:t}},n.prototype._getBeta=function(){return null},n.prototype.dblp=function(e){for(var t=this,r=0;e>r;r++)t=t.dbl();return t}},{"../../elliptic":50,"bn.js":48}],52:[function(e,t,r){"use strict";function i(e){this.twisted=1!==(0|e.a),this.mOneA=this.twisted&&-1===(0|e.a),this.extended=this.mOneA,f.call(this,"edwards",e),this.a=new s(e.a,16).mod(this.red.m).toRed(this.red),this.c=new s(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new s(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),u(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1===(0|e.c)}function n(e,t,r,i,n){f.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===i?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new s(t,16),this.y=new s(r,16),this.z=i?new s(i,16):this.curve.one,this.t=n&&new s(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}var a=e("../curve"),o=e("../../elliptic"),s=e("bn.js"),c=e("inherits"),f=a.base,u=o.utils.assert;c(i,f),t.exports=i,i.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},i.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},i.prototype.jpoint=function(e,t,r,i){return this.point(e,t,r,i)},i.prototype.pointFromX=function(e,t){t=new s(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr(),i=this.c2.redSub(this.a.redMul(r)),n=this.one.redSub(this.c2.redMul(this.d).redMul(r)),o=i.redMul(n.redInvm()).redSqrt(),c=o.fromRed().isOdd();return(e&&!c||!e&&c)&&(o=o.redNeg()),this.point(t,o,a.one)},i.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),i=t.redMul(this.a).redAdd(r),n=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===i.cmp(n)},c(n,f.BasePoint),i.prototype.pointFromJSON=function(e){return n.fromJSON(this,e)},i.prototype.point=function(e,t,r,i){return new n(this,e,t,r,i)},n.fromJSON=function(e,t){return new n(e,t[0],t[1],t[2])},n.prototype.inspect=function(){return this.isInfinity()?"":""},n.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},n.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(e),n=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),a=i.redAdd(t),o=a.redSub(r),s=i.redSub(t),c=n.redMul(o),f=a.redMul(s),u=n.redMul(s),d=o.redMul(a);return this.curve.point(c,f,d,u)},n.prototype._projDbl=function(){var e,t,r,i=this.x.redAdd(this.y).redSqr(),n=this.x.redSqr(),a=this.y.redSqr();if(this.curve.twisted){var o=this.curve._mulA(n),s=o.redAdd(a);if(this.zOne)e=i.redSub(n).redSub(a).redMul(s.redSub(this.curve.two)),t=s.redMul(o.redSub(a)),r=s.redSqr().redSub(s).redSub(s);else{var c=this.z.redSqr(),f=s.redSub(c).redISub(c);e=i.redSub(n).redISub(a).redMul(f),t=s.redMul(o.redSub(a)),r=s.redMul(f)}}else{var o=n.redAdd(a),c=this.curve._mulC(this.c.redMul(this.z)).redSqr(),f=o.redSub(c).redSub(c);e=this.curve._mulC(i.redISub(o)).redMul(f),t=this.curve._mulC(o).redMul(n.redISub(a)),r=o.redMul(f)}return this.curve.point(e,t,r)},n.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},n.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),i=this.t.redMul(this.curve.dd).redMul(e.t),n=this.z.redMul(e.z.redAdd(e.z)),a=r.redSub(t),o=n.redSub(i),s=n.redAdd(i),c=r.redAdd(t),f=a.redMul(o),u=s.redMul(c),d=a.redMul(c),h=o.redMul(s);return this.curve.point(f,u,h,d)},n.prototype._projAdd=function(e){var t,r,i=this.z.redMul(e.z),n=i.redSqr(),a=this.x.redMul(e.x),o=this.y.redMul(e.y),s=this.curve.d.redMul(a).redMul(o),c=n.redSub(s),f=n.redAdd(s),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(a).redISub(o),d=i.redMul(c).redMul(u);return this.curve.twisted?(t=i.redMul(f).redMul(o.redSub(this.curve._mulA(a))),r=c.redMul(f)):(t=i.redMul(f).redMul(o.redSub(a)),r=this.curve._mulC(c).redMul(f)),this.curve.point(d,t,r)},n.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},n.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},n.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2)},n.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},n.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},n.prototype.getX=function(){return this.normalize(),this.x.fromRed()},n.prototype.getY=function(){return this.normalize(),this.y.fromRed()},n.prototype.toP=n.prototype.normalize,n.prototype.mixedAdd=n.prototype.add},{"../../elliptic":50,"../curve":53,"bn.js":48,inherits:202}],53:[function(e,t,r){"use strict";var i=r;i.base=e("./base"),i["short"]=e("./short"),i.mont=e("./mont"),i.edwards=e("./edwards")},{"./base":51,"./edwards":52,"./mont":54,"./short":55}],54:[function(e,t,r){"use strict";function i(e){c.call(this,"mont",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.i4=new o(4).toRed(this.red).redInvm(),this.two=new o(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function n(e,t,r){c.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new o(t,16),this.z=new o(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}var a=e("../curve"),o=e("bn.js"),s=e("inherits"),c=a.base;s(i,c),t.exports=i,i.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),i=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t),n=i.redSqrt();return 0===n.redSqr().cmp(i)},s(n,c.BasePoint),i.prototype.point=function(e,t){return new n(this,e,t)},i.prototype.pointFromJSON=function(e){return n.fromJSON(this,e)},n.prototype.precompute=function(){},n.fromJSON=function(e,t){return new n(e,t[0],t[1]||e.one)},n.prototype.inspect=function(){return this.isInfinity()?"":""},n.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},n.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),r=this.x.redSub(this.z),i=r.redSqr(),n=t.redSub(i),a=t.redMul(i),o=n.redMul(i.redAdd(this.curve.a24.redMul(n)));return this.curve.point(a,o)},n.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},n.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=e.x.redAdd(e.z),a=e.x.redSub(e.z),o=a.redMul(r),s=n.redMul(i),c=t.z.redMul(o.redAdd(s).redSqr()),f=t.x.redMul(o.redISub(s).redSqr());return this.curve.point(c,f)},n.prototype.mul=function(e){for(var t=e.clone(),r=this,i=this.curve.point(null,null),n=this,a=[];0!==t.cmpn(0);t.ishrn(1))a.push(t.andln(1));for(var o=a.length-1;o>=0;o--)0===a[o]?(r=r.diffAdd(i,n),i=i.dbl()):(i=r.diffAdd(i,n),r=r.dbl());return i},n.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},n.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},n.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../curve":53,"bn.js":48,inherits:202}],55:[function(e,t,r){"use strict";function i(e){u.call(this,"short",e),this.a=new c(e.a,16).toRed(this.red),this.b=new c(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function n(e,t,r,i){u.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new c(t,16),this.y=new c(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function a(e,t,r,i){u.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new c(0)):(this.x=new c(t,16),this.y=new c(r,16),this.z=new c(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}var o=e("../curve"),s=e("../../elliptic"),c=e("bn.js"),f=e("inherits"),u=o.base,d=s.utils.assert; +f(i,u),t.exports=i,i.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new c(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);t=i[0].cmp(i[1])<0?i[0]:i[1],t=t.toRed(this.red)}if(e.lambda)r=new c(e.lambda,16);else{var n=this._getEndoRoots(this.n);0===this.g.mul(n[0]).x.cmp(this.g.x.redMul(t))?r=n[0]:(r=n[1],d(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}var a;return a=e.basis?e.basis.map(function(e){return{a:new c(e.a,16),b:new c(e.b,16)}}):this._getEndoBasis(r),{beta:t,lambda:r,basis:a}}},i.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:c.mont(e),r=new c(2).toRed(t).redInvm(),i=r.redNeg(),n=new c(3).toRed(t).redNeg().redSqrt().redMul(r),a=i.redAdd(n).fromRed(),o=i.redSub(n).fromRed();return[a,o]},i.prototype._getEndoBasis=function(e){for(var t,r,i,n,a,o,s,f,u,d=this.n.shrn(Math.floor(this.n.bitLength()/2)),h=e,l=this.n.clone(),p=new c(1),b=new c(0),m=new c(0),g=new c(1),v=0;0!==h.cmpn(0);){var y=l.div(h);f=l.sub(y.mul(h)),u=m.sub(y.mul(p));var w=g.sub(y.mul(b));if(!i&&f.cmp(d)<0)t=s.neg(),r=p,i=f.neg(),n=u;else if(i&&2===++v)break;s=f,l=h,h=f,m=p,p=u,g=b,b=w}a=f.neg(),o=u;var _=i.sqr().add(n.sqr()),S=a.sqr().add(o.sqr());return S.cmp(_)>=0&&(a=t,o=r),i.sign&&(i=i.neg(),n=n.neg()),a.sign&&(a=a.neg(),o=o.neg()),[{a:i,b:n},{a:a,b:o}]},i.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],i=t[1],n=i.b.mul(e).divRound(this.n),a=r.b.neg().mul(e).divRound(this.n),o=n.mul(r.a),s=a.mul(i.a),c=n.mul(r.b),f=a.mul(i.b),u=e.sub(o).sub(s),d=c.add(f).neg();return{k1:u,k2:d}},i.prototype.pointFromX=function(e,t){t=new c(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt(),n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(t,i)},i.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,i=this.a.redMul(t),n=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},i.prototype._endoWnafMulAdd=function(e,t){for(var r=this._endoWnafT1,i=this._endoWnafT2,n=0;nf;f++)r[f]=null,i[f]=null;return c},f(n,u.BasePoint),i.prototype.point=function(e,t,r){return new n(this,e,t,r)},i.prototype.pointFromJSON=function(e,t){return n.fromJSON(this,e,t)},n.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var r=this.curve,i=function(e){return r.point(e.x.redMul(r.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(i)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(i)}}}return t}},n.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},n.fromJSON=function(e,t,r){function i(t){return e.point(t[0],t[1],r)}"string"==typeof t&&(t=JSON.parse(t));var n=e.point(t[0],t[1],r);if(!t[2])return n;var a=t[2];return n.precomputed={beta:null,doubles:a.doubles&&{step:a.doubles.step,points:[n].concat(a.doubles.points.map(i))},naf:a.naf&&{wnd:a.naf.wnd,points:[n].concat(a.naf.points.map(i))}},n},n.prototype.inspect=function(){return this.isInfinity()?"":""},n.prototype.isInfinity=function(){return this.inf},n.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},n.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),i=e.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(i),a=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,o)},n.prototype.getX=function(){return this.x.fromRed()},n.prototype.getY=function(){return this.y.fromRed()},n.prototype.mul=function(e){return e=new c(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},n.prototype.mulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},n.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},n.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,i=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return t},n.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e},f(a,u.BasePoint),i.prototype.jpoint=function(e,t,r){return new a(this,e,t,r)},a.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(r,i)},a.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},a.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(t),n=e.x.redMul(r),a=this.y.redMul(t.redMul(e.z)),o=e.y.redMul(r.redMul(this.z)),s=i.redSub(n),c=a.redSub(o);if(0===s.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),u=f.redMul(s),d=i.redMul(f),h=c.redSqr().redIAdd(u).redISub(d).redISub(d),l=c.redMul(d.redISub(h)).redISub(a.redMul(u)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(h,l,p)},a.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,i=e.x.redMul(t),n=this.y,a=e.y.redMul(t).redMul(this.z),o=r.redSub(i),s=n.redSub(a);if(0===o.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=o.redSqr(),f=c.redMul(o),u=r.redMul(c),d=s.redSqr().redIAdd(f).redISub(u).redISub(u),h=s.redMul(u.redISub(d)).redISub(n.redMul(f)),l=this.z.redMul(o);return this.curve.jpoint(d,h,l)},a.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;e>r;r++)t=t.dbl();return t}for(var i=this.curve.a,n=this.curve.tinv,a=this.x,o=this.y,s=this.z,c=s.redSqr().redSqr(),f=o.redAdd(o),r=0;e>r;r++){var u=a.redSqr(),d=f.redSqr(),h=d.redSqr(),l=u.redAdd(u).redIAdd(u).redIAdd(i.redMul(c)),p=a.redMul(d),b=l.redSqr().redISub(p.redAdd(p)),m=p.redISub(b),g=l.redMul(m);g=g.redIAdd(g).redISub(h);var v=f.redMul(s);e>r+1&&(c=c.redMul(h)),a=b,s=v,f=g}return this.curve.jpoint(a,f.redMul(n),s)},a.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},a.prototype._zeroDbl=function(){var e,t,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),a=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(a);o=o.redIAdd(o);var s=i.redAdd(i).redIAdd(i),c=s.redSqr().redISub(o).redISub(o),f=a.redIAdd(a);f=f.redIAdd(f),f=f.redIAdd(f),e=c,t=s.redMul(o.redISub(c)).redISub(f),r=this.y.redAdd(this.y)}else{var u=this.x.redSqr(),d=this.y.redSqr(),h=d.redSqr(),l=this.x.redAdd(d).redSqr().redISub(u).redISub(h);l=l.redIAdd(l);var p=u.redAdd(u).redIAdd(u),b=p.redSqr(),m=h.redIAdd(h);m=m.redIAdd(m),m=m.redIAdd(m),e=b.redISub(l).redISub(l),t=p.redMul(l.redISub(e)).redISub(m),r=this.y.redMul(this.z),r=r.redIAdd(r)}return this.curve.jpoint(e,t,r)},a.prototype._threeDbl=function(){var e,t,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),a=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(a);o=o.redIAdd(o);var s=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),c=s.redSqr().redISub(o).redISub(o);e=c;var f=a.redIAdd(a);f=f.redIAdd(f),f=f.redIAdd(f),t=s.redMul(o.redISub(c)).redISub(f),r=this.y.redAdd(this.y)}else{var u=this.z.redSqr(),d=this.y.redSqr(),h=this.x.redMul(d),l=this.x.redSub(u).redMul(this.x.redAdd(u));l=l.redAdd(l).redIAdd(l);var p=h.redIAdd(h);p=p.redIAdd(p);var b=p.redAdd(p);e=l.redSqr().redISub(b),r=this.y.redAdd(this.z).redSqr().redISub(d).redISub(u);var m=d.redSqr();m=m.redIAdd(m),m=m.redIAdd(m),m=m.redIAdd(m),t=l.redMul(p.redISub(e)).redISub(m)}return this.curve.jpoint(e,t,r)},a.prototype._dbl=function(){var e=this.curve.a,t=this.x,r=this.y,i=this.z,n=i.redSqr().redSqr(),a=t.redSqr(),o=r.redSqr(),s=a.redAdd(a).redIAdd(a).redIAdd(e.redMul(n)),c=t.redAdd(t);c=c.redIAdd(c);var f=c.redMul(o),u=s.redSqr().redISub(f.redAdd(f)),d=f.redISub(u),h=o.redSqr();h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var l=s.redMul(d).redISub(h),p=r.redAdd(r).redMul(i);return this.curve.jpoint(u,l,p)},a.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr(),i=t.redSqr(),n=e.redAdd(e).redIAdd(e),a=n.redSqr(),o=this.x.redAdd(t).redSqr().redISub(e).redISub(i);o=o.redIAdd(o),o=o.redAdd(o).redIAdd(o),o=o.redISub(a);var s=o.redSqr(),c=i.redIAdd(i);c=c.redIAdd(c),c=c.redIAdd(c),c=c.redIAdd(c);var f=n.redIAdd(o).redSqr().redISub(a).redISub(s).redISub(c),u=t.redMul(f);u=u.redIAdd(u),u=u.redIAdd(u);var d=this.x.redMul(s).redISub(u);d=d.redIAdd(d),d=d.redIAdd(d);var h=this.y.redMul(f.redMul(c.redISub(f)).redISub(o.redMul(s)));h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var l=this.z.redAdd(o).redSqr().redISub(r).redISub(s);return this.curve.jpoint(d,h,l)},a.prototype.mul=function(e,t){return e=new c(e,t),this.curve._wnafMul(this,e)},a.prototype.eq=function(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),r=e.z.redSqr();if(0!==this.x.redMul(r).redISub(e.x.redMul(t)).cmpn(0))return!1;var i=t.redMul(this.z),n=r.redMul(e.z);return 0===this.y.redMul(n).redISub(e.y.redMul(i)).cmpn(0)},a.prototype.inspect=function(){return this.isInfinity()?"":""},a.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":50,"../curve":53,"bn.js":48,inherits:202}],56:[function(e,t,r){"use strict";function i(e){"short"===e.type?this.curve=new s.curve["short"](e):"edwards"===e.type?this.curve=new s.curve.edwards(e):this.curve=new s.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,c(this.g.validate(),"Invalid curve"),c(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function n(e,t){Object.defineProperty(a,e,{configurable:!0,enumerable:!0,get:function(){var r=new i(t);return Object.defineProperty(a,e,{configurable:!0,enumerable:!0,value:r}),r}})}var a=r,o=e("hash.js"),s=e("../elliptic"),c=s.utils.assert;a.PresetCurve=i,n("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),n("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),n("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),n("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"0",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),n("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var f;try{f=e("./precomputed/secp256k1")}catch(u){f=void 0}n("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",f]})},{"../elliptic":50,"./precomputed/secp256k1":61,"hash.js":64}],57:[function(e,t,r){"use strict";function i(e){return this instanceof i?("string"==typeof e&&(s(a.curves.hasOwnProperty(e),"Unknown curve "+e),e=a.curves[e]),e instanceof a.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.shrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),void(this.hash=e.hash||e.curve.hash)):new i(e)}var n=e("bn.js"),a=e("../../elliptic"),o=a.utils,s=o.assert,c=e("./key"),f=e("./signature");t.exports=i,i.prototype.keyPair=function(e){return new c(this,e)},i.prototype.keyFromPrivate=function(e,t){return c.fromPrivate(this,e,t)},i.prototype.keyFromPublic=function(e,t){return c.fromPublic(this,e,t)},i.prototype.genKeyPair=function(e){e||(e={});for(var t=new a.hmacDRBG({hash:this.hash,pers:e.pers,entropy:e.entropy||a.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new n(2));;){var o=new n(t.generate(r));if(!(o.cmp(i)>0))return o.iaddn(1),this.keyFromPrivate(o)}},i.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.shrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},i.prototype.sign=function(e,t,r,i){"object"==typeof r&&(i=r,r=null),i||(i={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var o=this.n.byteLength(),s=t.getPrivate().toArray(),c=s.length;21>c;c++)s.unshift(0);for(var u=e.toArray(),c=u.length;o>c;c++)u.unshift(0);for(var d=new a.hmacDRBG({hash:this.hash,entropy:s,nonce:u}),h=this.n.sub(new n(1));;){var l=new n(d.generate(this.n.byteLength()));if(l=this._truncateToN(l,!0),!(l.cmpn(1)<=0||l.cmp(h)>=0)){var p=this.g.mul(l);if(!p.isInfinity()){var b=p.getX(),m=b.mod(this.n);if(0!==m.cmpn(0)){var g=l.invm(this.n).mul(m.mul(t.getPrivate()).iadd(e)).mod(this.n);if(0!==g.cmpn(0)){i.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g));var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(m)?2:0);return new f({r:m,s:g,recoveryParam:v})}}}}}},i.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i),t=new f(t,"hex");var a=t.r,o=t.s;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var s=o.invm(this.n),c=s.mul(e).mod(this.n),u=s.mul(a).mod(this.n),d=this.g.mulAdd(c,r.getPublic(),u);return d.isInfinity()?!1:0===d.getX().mod(this.n).cmp(a)},i.prototype.recoverPubKey=function(e,t,r,i){s((3&r)===r,"The recovery param is more than two bits"),t=new f(t,i);var a=this.n,o=new n(e),c=t.r,u=t.s,d=1&r,h=r>>1;if(c.cmp(this.curve.p.mod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");c=this.curve.pointFromX(d,c);var l=o.neg().mod(a),p=t.r.invm(a);return c.mul(u).add(this.g.mul(l)).mul(p)},i.prototype.getKeyRecoveryParam=function(e,t,r,i){if(t=new f(t,i),null!==t.recoveryParam)return t.recoveryParam;for(var n=0;4>n;n++){var a=this.recoverPubKey(e,t,n);if(a.eq(r))return n}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":50,"./key":58,"./signature":59,"bn.js":48}],58:[function(e,t,r){"use strict";function i(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var n=e("bn.js"),a=e("../../elliptic"),o=a.utils;t.exports=i,i.fromPublic=function(e,t,r){return t instanceof i?t:new i(e,{pub:t,pubEnc:r})},i.fromPrivate=function(e,t,r){return t instanceof i?t:new i(e,{priv:t,privEnc:r})},i.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},i.prototype.getPublic=function(e,t){if(this.pub||(this.pub=this.ec.g.mul(this.priv)),"string"==typeof e&&(t=e,e=null),!t)return this.pub;for(var r=this.ec.curve.p.byteLength(),i=this.pub.getX().toArray(),n=i.length;r>n;n++)i.unshift(0);var a;if("mont"!==this.ec.curve.type)if(e)a=[this.pub.getY().isEven()?2:3].concat(i);else{for(var s=this.pub.getY().toArray(),n=s.length;r>n;n++)s.unshift(0);var a=[4].concat(i,s)}else a=i;return o.encode(a,t)},i.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},i.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.mod(this.ec.curve.n)},i.prototype._importPublic=function(e,t){return e.x||e.y?void(this.pub=this.ec.curve.point(e.x,e.y)):(e=o.toArray(e,t),"mont"!==this.ec.curve.type?this._importPublicShort(e):this._importPublicMont(e))},i.prototype._importPublicShort=function(e){var t=this.ec.curve.p.byteLength();4===e[0]&&e.length-1===2*t?this.pub=this.ec.curve.point(e.slice(1,1+t),e.slice(1+t,1+2*t)):2!==e[0]&&3!==e[0]||e.length-1!==t||(this.pub=this.ec.curve.pointFromX(3===e[0],e.slice(1,1+t)))},i.prototype._importPublicMont=function(e){this.pub=this.ec.curve.point(e,1)},i.prototype.derive=function(e){return e.mul(this.priv).getX()},i.prototype.sign=function(e){return this.ec.sign(e,this)},i.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},i.prototype.inspect=function(){return""}},{"../../elliptic":50,"bn.js":48}],59:[function(e,t,r){"use strict";function i(e,t){return e instanceof i?e:void(this._importDER(e,t)||(s(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),null!==e.recoveryParam?this.recoveryParam=e.recoveryParam:this.recoveryParam=null))}var n=e("bn.js"),a=e("../../elliptic"),o=a.utils,s=o.assert;t.exports=i,i.prototype._importDER=function(e,t){if(e=o.toArray(e,t),e.length<6||48!==e[0]||2!==e[2])return!1;var r=e[1];if(1+r>e.length)return!1;var i=e[3];if(i>=128)return!1;if(4+i+2>=e.length)return!1;if(2!==e[4+i])return!1;var a=e[5+i];return a>=128?!1:4+i+2+a>e.length?!1:(this.r=new n(e.slice(4,4+i)),this.s=new n(e.slice(4+i+2,4+i+2+a)),this.recoveryParam=null,!0)},i.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r));var i=t.length+r.length+4,n=[48,i,2,t.length];return n=n.concat(t,[2,r.length],r),o.encode(n,e)}},{"../../elliptic":50,"bn.js":48}],60:[function(e,t,r){"use strict";function i(e){if(!(this instanceof i))return new i(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this.reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=o.toArray(e.entropy,e.entropyEnc),r=o.toArray(e.nonce,e.nonceEnc),n=o.toArray(e.pers,e.persEnc);s(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}var n=e("hash.js"),a=e("../elliptic"),o=a.utils,s=o.assert;t.exports=i,i.prototype._init=function(e,t,r){var i=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this.reseed=1},i.prototype.generate=function(e,t,r,i){if(this.reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(i=r,r=t,t=null),r&&(r=o.toArray(r,i),this._update(r));for(var n=[];n.length>8,o=255&n;a?r.push(a,o):r.push(o)}return r}function n(e){return 1===e.length?"0"+e:e}function a(e){for(var t="",r=0;r=0;){var a;if(n.isOdd()){var o=n.andln(i-1);a=o>(i>>1)-1?(i>>1)-o:o,n.isubn(a)}else a=0;r.push(a);for(var s=0!==n.cmpn(0)&&0===n.andln(i-1)?t+1:1,c=1;s>c;c++)r.push(0);n.ishrn(s)}return r}function s(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var i=0,n=0;e.cmpn(-i)>0||t.cmpn(-n)>0;){var a=e.andln(3)+i&3,o=t.andln(3)+n&3;3===a&&(a=-1),3===o&&(o=-1);var s;if(0===(1&a))s=0;else{var c=e.andln(7)+i&7;s=3!==c&&5!==c||2!==o?a:-a}r[0].push(s);var f;if(0===(1&o))f=0;else{var c=t.andln(7)+n&7;f=3!==c&&5!==c||2!==a?o:-o}r[1].push(f),2*i===s+1&&(i=1-i),2*n===f+1&&(n=1-n),e.ishrn(1),t.ishrn(1)}return r}var c=r;c.assert=function(e,t){if(!e)throw new Error(t||"Assertion failed")},c.toArray=i,c.zero2=n,c.toHex=a,c.encode=function(e,t){return"hex"===t?a(e):e},c.getNAF=o,c.getJSF=s},{}],63:[function(e,t,r){function i(e){this.rand=e}var n;if(t.exports=function(e){return n||(n=new i(null)),n.generate(e)},t.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},"object"==typeof window)window.crypto&&window.crypto.getRandomValues?i.prototype._rand=function(e){var t=new Uint8Array(e);return window.crypto.getRandomValues(t),t}:window.msCrypto&&window.msCrypto.getRandomValues?i.prototype._rand=function(e){var t=new Uint8Array(e);return window.msCrypto.getRandomValues(t),t}:i.prototype._rand=function(){throw new Error("Not implemented yet")};else try{var a=e("crypto");i.prototype._rand=function(e){return a.randomBytes(e)}}catch(o){i.prototype._rand=function(e){for(var t=new Uint8Array(e),r=0;r=this._delta8){e=this.pending;var r=e.length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=a.join32(e,0,e.length-r,this.endian);for(var i=0;in;n++)i[n]=0;if(e<<=3,"big"===this.endian){for(var a=8;a>>24&255,i[n++]=e>>>16&255,i[n++]=e>>>8&255,i[n++]=255&e}else{i[n++]=255&e,i[n++]=e>>>8&255,i[n++]=e>>>16&255,i[n++]=e>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0;for(var a=8;athis.blockSize&&(e=(new this.Hash).update(e).digest()),o(e.length<=this.blockSize);for(var t=e.length;t=e?t^r^i:31>=e?t&r|~t&i:47>=e?(t|~r)^i:63>=e?t&i|r&~i:t^(r|~i)}function a(e){return 15>=e?0:31>=e?1518500249:47>=e?1859775393:63>=e?2400959708:2840853838}function o(e){return 15>=e?1352829926:31>=e?1548603684:47>=e?1836072691:63>=e?2053994217:0}var s=e("../hash"),c=s.utils,f=c.rotl32,u=c.sum32,d=c.sum32_3,h=c.sum32_4,l=s.common.BlockHash;c.inherits(i,l),r.ripemd160=i,i.blockSize=512,i.outSize=160,i.hmacStrength=192,i.padLength=64,i.prototype._update=function(e,t){for(var r=this.h[0],i=this.h[1],s=this.h[2],c=this.h[3],l=this.h[4],v=r,y=i,w=s,_=c,S=l,k=0;80>k;k++){var E=u(f(h(r,n(k,i,s,c),e[p[k]+t],a(k)),m[k]),l);r=l,l=c,c=f(s,10),s=i,i=E,E=u(f(h(v,n(79-k,y,w,_),e[b[k]+t],o(k)),g[k]),S),v=S,S=_,_=f(w,10),w=y,y=E}E=d(this.h[1],s,_),this.h[1]=d(this.h[2],c,S),this.h[2]=d(this.h[3],l,v),this.h[3]=d(this.h[4],r,y),this.h[4]=d(this.h[0],i,w),this.h[0]=E},i.prototype._digest=function(e){return"hex"===e?c.toHex32(this.h,"little"):c.split32(this.h,"little")};var p=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],b=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],m=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],g=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},{"../hash":64}],68:[function(e,t,r){function i(){return this instanceof i?(V.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=X,void(this.W=new Array(64))):new i}function n(){return this instanceof n?(i.call(this),void(this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])):new n}function a(){return this instanceof a?(V.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=J,void(this.W=new Array(160))):new a}function o(){return this instanceof o?(a.call(this),void(this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428])):new o}function s(){return this instanceof s?(V.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],void(this.W=new Array(80))):new s}function c(e,t,r){return e&t^~e&r}function f(e,t,r){return e&t^e&r^t&r}function u(e,t,r){return e^t^r}function d(e){return R(e,2)^R(e,13)^R(e,22)}function h(e){return R(e,6)^R(e,11)^R(e,25)}function l(e){return R(e,7)^R(e,18)^e>>>3}function p(e){return R(e,17)^R(e,19)^e>>>10}function b(e,t,r,i){return 0===e?c(t,r,i):1===e||3===e?u(t,r,i):2===e?f(t,r,i):void 0}function m(e,t,r,i,n,a){var o=e&r^~e&n;return 0>o&&(o+=4294967296),o}function g(e,t,r,i,n,a){var o=t&i^~t&a;return 0>o&&(o+=4294967296),o}function v(e,t,r,i,n,a){var o=e&r^e&n^r&n;return 0>o&&(o+=4294967296),o}function y(e,t,r,i,n,a){var o=t&i^t&a^i&a;return 0>o&&(o+=4294967296),o}function w(e,t){var r=L(e,t,28),i=L(t,e,2),n=L(t,e,7),a=r^i^n;return 0>a&&(a+=4294967296),a}function _(e,t){var r=D(e,t,28),i=D(t,e,2),n=D(t,e,7),a=r^i^n;return 0>a&&(a+=4294967296),a}function S(e,t){var r=L(e,t,14),i=L(e,t,18),n=L(t,e,9),a=r^i^n;return 0>a&&(a+=4294967296),a}function k(e,t){var r=D(e,t,14),i=D(e,t,18),n=D(t,e,9),a=r^i^n;return 0>a&&(a+=4294967296),a}function E(e,t){var r=L(e,t,1),i=L(e,t,8),n=T(e,t,7),a=r^i^n;return 0>a&&(a+=4294967296),a}function x(e,t){var r=D(e,t,1),i=D(e,t,8),n=U(e,t,7),a=r^i^n;return 0>a&&(a+=4294967296),a}function A(e,t){var r=L(e,t,19),i=L(t,e,29),n=T(e,t,6),a=r^i^n;return 0>a&&(a+=4294967296),a}function j(e,t){var r=D(e,t,19),i=D(t,e,29),n=U(e,t,6),a=r^i^n;return 0>a&&(a+=4294967296),a}var B=e("../hash"),I=B.utils,z=I.assert,R=I.rotr32,M=I.rotl32,q=I.sum32,C=I.sum32_4,P=I.sum32_5,L=I.rotr64_hi,D=I.rotr64_lo,T=I.shr64_hi,U=I.shr64_lo,O=I.sum64,N=I.sum64_hi,K=I.sum64_lo,F=I.sum64_4_hi,H=I.sum64_4_lo,Y=I.sum64_5_hi,W=I.sum64_5_lo,V=B.common.BlockHash,X=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],J=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],G=[1518500249,1859775393,2400959708,3395469782];I.inherits(i,V),r.sha256=i,i.blockSize=512,i.outSize=256,i.hmacStrength=192,i.padLength=64,i.prototype._update=function(e,t){for(var r=this.W,i=0;16>i;i++)r[i]=e[t+i];for(;ii;i++)r[i]=e[t+i];for(;ii;i++)r[i]=e[t+i];for(;i>8,o=255&n;a?r.push(a,o):r.push(o)}else for(var i=0;i>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24;return t>>>0}function o(e,t){for(var r="",i=0;i>>0}return a}function u(e,t){for(var r=new Array(4*e.length),i=0,n=0;i>>24,r[n+1]=a>>>16&255,r[n+2]=a>>>8&255,r[n+3]=255&a):(r[n+3]=a>>>24,r[n+2]=a>>>16&255,r[n+1]=a>>>8&255,r[n]=255&a)}return r}function d(e,t){return e>>>t|e<<32-t}function h(e,t){return e<>>32-t}function l(e,t){return e+t>>>0}function p(e,t,r){return e+t+r>>>0}function b(e,t,r,i){return e+t+r+i>>>0}function m(e,t,r,i,n){return e+t+r+i+n>>>0}function g(e,t){if(!e)throw new Error(t||"Assertion failed")}function v(e,t,r,i){var n=e[t],a=e[t+1],o=i+a>>>0,s=(i>o?1:0)+r+n;e[t]=s>>>0,e[t+1]=o}function y(e,t,r,i){var n=t+i>>>0,a=(t>n?1:0)+e+r;return a>>>0}function w(e,t,r,i){var n=t+i;return n>>>0}function _(e,t,r,i,n,a,o,s){var c=0,f=t;f=f+i>>>0,c+=t>f?1:0,f=f+a>>>0,c+=a>f?1:0,f=f+s>>>0,c+=s>f?1:0;var u=e+r+n+o+c;return u>>>0}function S(e,t,r,i,n,a,o,s){var c=t+i+a+s;return c>>>0}function k(e,t,r,i,n,a,o,s,c,f){var u=0,d=t;d=d+i>>>0,u+=t>d?1:0,d=d+a>>>0,u+=a>d?1:0,d=d+s>>>0,u+=s>d?1:0,d=d+f>>>0,u+=f>d?1:0;var h=e+r+n+o+c+u;return h>>>0}function E(e,t,r,i,n,a,o,s,c,f){var u=t+i+a+s+f;return u>>>0}function x(e,t,r){var i=t<<32-r|e>>>r;return i>>>0}function A(e,t,r){var i=e<<32-r|t>>>r;return i>>>0}function j(e,t,r){return e>>>r}function B(e,t,r){var i=e<<32-r|t>>>r;return i>>>0}var I=r,z=e("inherits");I.toArray=i,I.toHex=n,I.htonl=a,I.toHex32=o,I.zero2=s,I.zero8=c,I.join32=f,I.split32=u,I.rotr32=d,I.rotl32=h,I.sum32=l,I.sum32_3=p,I.sum32_4=b,I.sum32_5=m,I.assert=g,I.inherits=z,r.sum64=v,r.sum64_hi=y,r.sum64_lo=w,r.sum64_4_hi=_,r.sum64_4_lo=S,r.sum64_5_hi=k,r.sum64_5_lo=E,r.rotr64_hi=x,r.rotr64_lo=A,r.shr64_hi=j,r.shr64_lo=B},{inherits:202}],70:[function(e,t,r){t.exports={name:"elliptic",version:"3.1.0",description:"EC cryptography",main:"lib/elliptic.js",scripts:{test:"make lint && mocha --reporter=spec test/*-test.js"},repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},keywords:["EC","Elliptic","curve","Cryptography"],author:{name:"Fedor Indutny",email:"fedor@indutny.com"},license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{browserify:"^3.44.2",jscs:"^1.11.3",jshint:"^2.6.0",mocha:"^2.1.0","uglify-js":"^2.4.13"},dependencies:{"bn.js":"^2.0.3",brorand:"^1.0.1","hash.js":"^1.0.0",inherits:"^2.0.1"},gitHead:"d86cd2a8178f7e7cecbd6dd92eea084e2ab44c13",_id:"elliptic@3.1.0",_shasum:"c21682ef762769b56a74201609105da11d5f60cc",_from:"elliptic@>=3.0.0 <4.0.0",_npmVersion:"2.11.0",_nodeVersion:"2.2.1",_npmUser:{name:"indutny",email:"fedor@indutny.com"},maintainers:[{name:"indutny",email:"fedor@indutny.com"}],dist:{shasum:"c21682ef762769b56a74201609105da11d5f60cc",tarball:"http://registry.npmjs.org/elliptic/-/elliptic-3.1.0.tgz"},directories:{},_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-3.1.0.tgz"}},{}],71:[function(e,t,r){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],72:[function(e,t,r){var i=e("asn1.js"),n=i.define("RSAPrivateKey",function(){this.seq().obj(this.key("version")["int"](),this.key("modulus")["int"](),this.key("publicExponent")["int"](),this.key("privateExponent")["int"](),this.key("prime1")["int"](),this.key("prime2")["int"](),this.key("exponent1")["int"](),this.key("exponent2")["int"](),this.key("coefficient")["int"]())});r.RSAPrivateKey=n;var a=i.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus")["int"](),this.key("publicExponent")["int"]())});r.RSAPublicKey=a;var o=i.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())});r.PublicKey=o;var s=i.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p")["int"](),this.key("q")["int"](),this.key("g")["int"]()).optional())}),c=i.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version")["int"](),this.key("algorithm").use(s),this.key("subjectPrivateKey").octstr())});r.PrivateKey=c;var f=i.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters")["int"]())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=f;var u=i.define("DSAPrivateKey",function(){this.seq().obj(this.key("version")["int"](),this.key("p")["int"](),this.key("q")["int"](),this.key("g")["int"](),this.key("pub_key")["int"](),this.key("priv_key")["int"]())});r.DSAPrivateKey=u,r.DSAparam=i.define("DSAparam",function(){this["int"]()});var d=i.define("ECPrivateKey",function(){this.seq().obj(this.key("version")["int"](),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(h),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=d;var h=i.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=i.define("signature",function(){this.seq().obj(this.key("r")["int"](),this.key("s")["int"]())})},{"asn1.js":75}],73:[function(e,t,r){(function(r){var i=/Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\r?\n\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n/m,n=/^-----BEGIN (.*) KEY-----\r?\n/m,a=/^-----BEGIN (.*) KEY-----\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n-----END \1 KEY-----$/m,o=e("evp_bytestokey"),s=e("browserify-aes");t.exports=function(e,t){var c,f=e.toString(),u=f.match(i);if(u){var d="aes"+u[1],h=new r(u[2],"hex"),l=new r(u[3].replace(/\r?\n/g,""),"base64"),p=o(t,h.slice(0,8),parseInt(u[1],10)).key,b=[],m=s.createDecipheriv(d,p,h);b.push(m.update(l)),b.push(m["final"]()),c=r.concat(b)}else{var g=f.match(a);c=new r(g[2].replace(/\r?\n/g,""),"base64")}var v=f.match(n)[1]+" KEY";return{tag:v,data:c}}}).call(this,e("buffer").Buffer)},{"browserify-aes":92,buffer:11,evp_bytestokey:107}],74:[function(e,t,r){(function(r){function i(e){var t;"object"!=typeof e||r.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=new r(e));var i,o,c=s(e,t),f=c.tag,u=c.data;switch(f){case"PUBLIC KEY":switch(o=a.PublicKey.decode(u,"der"),i=o.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return a.RSAPublicKey.decode(o.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return o.subjectPrivateKey=o.subjectPublicKey,{type:"ec",data:o};case"1.2.840.10040.4.1":return o.algorithm.params.pub_key=a.DSAparam.decode(o.subjectPublicKey.data,"der"),{type:"dsa",data:o.algorithm.params};default:throw new Error("unknown key id "+i)}throw new Error("unknown key type "+f);case"ENCRYPTED PRIVATE KEY":u=a.EncryptedPrivateKey.decode(u,"der"),u=n(u,t);case"PRIVATE KEY":switch(o=a.PrivateKey.decode(u,"der"),i=o.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return a.RSAPrivateKey.decode(o.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:o.algorithm.curve,privateKey:a.ECPrivateKey.decode(o.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return o.algorithm.params.priv_key=a.DSAparam.decode(o.subjectPrivateKey,"der"),{type:"dsa",params:o.algorithm.params};default:throw new Error("unknown key id "+i)}throw new Error("unknown key type "+f);case"RSA PUBLIC KEY":return a.RSAPublicKey.decode(u,"der");case"RSA PRIVATE KEY":return a.RSAPrivateKey.decode(u,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:a.DSAPrivateKey.decode(u,"der")};case"EC PRIVATE KEY":return u=a.ECPrivateKey.decode(u,"der"),{curve:u.parameters.value,privateKey:u.privateKey};default:throw new Error("unknown key type "+f)}}function n(e,t){var i=e.algorithm.decrypt.kde.kdeparams.salt,n=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),a=o[e.algorithm.decrypt.cipher.algo.join(".")],s=e.algorithm.decrypt.cipher.iv,u=e.subjectPrivateKey,d=parseInt(a.split("-")[1],10)/8,h=f.pbkdf2Sync(t,i,n,d),l=c.createDecipheriv(a,h,s),p=[];return p.push(l.update(u)),p.push(l["final"]()),r.concat(p)}var a=e("./asn1"),o=e("./aesid.json"),s=e("./fixProc"),c=e("browserify-aes"),f=e("pbkdf2");t.exports=i,i.signature=a.signature}).call(this,e("buffer").Buffer)},{"./aesid.json":71,"./asn1":72,"./fixProc":73,"browserify-aes":92,buffer:11,pbkdf2:154}],75:[function(e,t,r){var i=r;i.bignum=e("bn.js"),i.define=e("./asn1/api").define,i.base=e("./asn1/base"),i.constants=e("./asn1/constants"),i.decoders=e("./asn1/decoders"),i.encoders=e("./asn1/encoders")},{"./asn1/api":76,"./asn1/base":78,"./asn1/constants":82,"./asn1/decoders":84,"./asn1/encoders":87,"bn.js":48}],76:[function(e,t,r){function i(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}var n=e("../asn1"),a=e("inherits"),o=r;o.define=function(e,t){return new i(e,t)},i.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(i){r=function(e){this._initNamed(e)}}return a(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},i.prototype._getDecoder=function(e){return this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},i.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},i.prototype._getEncoder=function(e){return this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},i.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":75,inherits:202,vm:221}],77:[function(e,t,r){function i(e,t){return o.call(this,t),s.isBuffer(e)?(this.base=e,this.offset=0,void(this.length=e.length)):void this.error("Input not Buffer")}function n(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof n||(e=new n(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(e>=0&&255>=e))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=s.byteLength(e);else{if(!s.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}var a=e("inherits"),o=e("../base").Reporter,s=e("buffer").Buffer;a(i,o),r.DecoderBuffer=i,i.prototype.save=function(){return{offset:this.offset,reporter:o.prototype.save.call(this)}},i.prototype.restore=function(e){var t=new i(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,o.prototype.restore.call(this,e.reporter),t},i.prototype.isEmpty=function(){return this.offset===this.length},i.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},i.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new i(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},i.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=n,n.prototype.join=function(e,t){return e||(e=new s(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):s.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},{"../base":78,buffer:11,inherits:202}],78:[function(e,t,r){var i=r;i.Reporter=e("./reporter").Reporter,i.DecoderBuffer=e("./buffer").DecoderBuffer,i.EncoderBuffer=e("./buffer").EncoderBuffer,i.Node=e("./node")},{"./buffer":77,"./node":79,"./reporter":80}],79:[function(e,t,r){function i(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r["default"]=null,r.explicit=null,r.implicit=null,r.parent||(r.children=[],this._wrap())}var n=e("../base").Reporter,a=e("../base").EncoderBuffer,o=e("minimalistic-assert"),s=["seq","seqof","set","setof","octstr","bitstr","objid","bool","gentime","utctime","null_","enum","int","ia5str","utf8str"],c=["key","obj","use","optional","explicit","implicit","def","choice","any"].concat(s),f=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];t.exports=i;var u=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit"];i.prototype.clone=function(){var e=this._baseState,t={};u.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},i.prototype._wrap=function(){var e=this._baseState;c.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},i.prototype._init=function(e){var t=this._baseState;o(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),o.equal(t.children.length,1,"Root node can have only one child")},i.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(o(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(o(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var i=e[r];t[i]=r}),t}))},f.forEach(function(e){i.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),s.forEach(function(e){i.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return o(null===t.tag),t.tag=e,this._useArgs(r),this}}),i.prototype.use=function(e){var t=this._baseState;return o(null===t.use),t.use=e,this},i.prototype.optional=function(){var e=this._baseState;return e.optional=!0,this},i.prototype.def=function(e){var t=this._baseState;return o(null===t["default"]),t["default"]=e,t.optional=!0,this},i.prototype.explicit=function(e){var t=this._baseState;return o(null===t.explicit&&null===t.implicit),t.explicit=e,this},i.prototype.implicit=function(e){var t=this._baseState;return o(null===t.explicit&&null===t.implicit),t.implicit=e,this},i.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},i.prototype.key=function(e){var t=this._baseState;return o(null===t.key),t.key=e,this},i.prototype.any=function(){var e=this._baseState;return e.any=!0,this},i.prototype.choice=function(e){var t=this._baseState;return o(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},i.prototype._decode=function(e){var t=this._baseState;if(null===t.parent)return e.wrapResult(t.children[0]._decode(e));var r,i=t["default"],n=!0;if(null!==t.key&&(r=e.enterKey(t.key)),t.optional){var a=null;if(null!==t.explicit?a=t.explicit:null!==t.implicit?a=t.implicit:null!==t.tag&&(a=t.tag),null!==a||t.any){if(n=this._peekTag(e,a,t.any),e.isError(n))return n}else{var o=e.save();try{null===t.choice?this._decodeGeneric(t.tag,e):this._decodeChoice(e), +n=!0}catch(s){n=!1}e.restore(o)}}var c;if(t.obj&&n&&(c=e.enterObject()),n){if(null!==t.explicit){var f=this._decodeTag(e,t.explicit);if(e.isError(f))return f;e=f}if(null===t.use&&null===t.choice){if(t.any)var o=e.save();var u=this._decodeTag(e,null!==t.implicit?t.implicit:t.tag,t.any);if(e.isError(u))return u;t.any?i=e.raw(o):e=u}if(i=t.any?i:null===t.choice?this._decodeGeneric(t.tag,e):this._decodeChoice(e),e.isError(i))return i;if(!t.any&&null===t.choice&&null!==t.children){var d=t.children.some(function(t){t._decode(e)});if(d)return err}}return t.obj&&n&&(i=e.leaveObject(c)),null===t.key||null===i&&n!==!0||e.leaveKey(r,t.key,i),i},i.prototype._decodeGeneric=function(e,t){var r=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,r.args[0]):"octstr"===e||"bitstr"===e?this._decodeStr(t,e):"ia5str"===e||"utf8str"===e?this._decodeStr(t,e):"objid"===e&&r.args?this._decodeObjid(t,r.args[0],r.args[1]):"objid"===e?this._decodeObjid(t,null,null):"gentime"===e||"utctime"===e?this._decodeTime(t,e):"null_"===e?this._decodeNull(t):"bool"===e?this._decodeBool(t):"int"===e||"enum"===e?this._decodeInt(t,r.args&&r.args[0]):null!==r.use?this._getUse(r.use,t._reporterState.obj)._decode(t):t.error("unknown tag: "+e)},i.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),o(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},i.prototype._decodeChoice=function(e){var t=this._baseState,r=null,i=!1;return Object.keys(t.choice).some(function(n){var a=e.save(),o=t.choice[n];try{var s=o._decode(e);if(e.isError(s))return!1;r={type:n,value:s},i=!0}catch(c){return e.restore(a),!1}return!0},this),i?r:e.error("Choice not matched")},i.prototype._createEncoderBuffer=function(e){return new a(e,this.reporter)},i.prototype._encode=function(e,t,r){var i=this._baseState;if(null===i["default"]||i["default"]!==e){var n=this._encodeValue(e,t,r);if(void 0!==n&&!this._skipDefault(n,t,r))return n}},i.prototype._encodeValue=function(e,t,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);var a=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i["default"])return;e=i["default"]}var o=null,s=!1;if(i.any)a=this._createEncoderBuffer(e);else if(i.choice)a=this._encodeChoice(e,t);else if(i.children)o=i.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var i=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var n=r._encode(e[r._baseState.key],t,e);return t.leaveKey(i),n},this).filter(function(e){return e}),o=this._createEncoderBuffer(o);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var c=this.clone();c._baseState.implicit=null,o=this._createEncoderBuffer(e.map(function(r){var i=this._baseState;return this._getUse(i.args[0],e)._encode(r,t)},c))}else null!==i.use?a=this._getUse(i.use,r)._encode(e,t):(o=this._encodePrimitive(i.tag,e),s=!0);var a;if(!i.any&&null===i.choice){var f=null!==i.implicit?i.implicit:i.tag,u=null===i.implicit?"universal":"context";null===f?null===i.use&&t.error("Tag could be ommited only for .use()"):null===i.use&&(a=this._encodeComposite(f,s,u,o))}return null!==i.explicit&&(a=this._encodeComposite(i.explicit,!1,"context",a)),a},i.prototype._encodeChoice=function(e,t){var r=this._baseState,i=r.choice[e.type];return i||o(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),i._encode(e.value,t)},i.prototype._encodePrimitive=function(e,t){var r=this._baseState;if("octstr"===e||"bitstr"===e||"ia5str"===e)return this._encodeStr(t,e);if("utf8str"===e)return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);throw new Error("Unsupported tag: "+e)}},{"../base":78,"minimalistic-assert":89}],80:[function(e,t,r){function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function n(e,t){this.path=e,this.rethrow(t)}var a=e("inherits");r.Reporter=i,i.prototype.isError=function(e){return e instanceof n},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.leaveKey=function(e,t,r){var i=this._reporterState;i.path=i.path.slice(0,e-1),null!==i.obj&&(i.obj[t]=r)},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){var t,r=this._reporterState,i=e instanceof n;if(t=i?e:new n(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return i||r.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},a(n,Error),n.prototype.rethrow=function(e){return this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace(this,n),this}},{inherits:202}],81:[function(e,t,r){var i=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=i._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=i._reverse(r.tag)},{"../constants":82}],82:[function(e,t,r){var i=r;i._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r=0|r);var i=e[r];t[i]=r}),t},i.der=e("./der")},{"./der":81}],83:[function(e,t,r){function i(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new n,this.tree._init(e.body)}function n(e){f.Node.call(this,"der",e)}function a(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var i=d.tagClass[r>>6],n=0===(32&r);if(31===(31&r)){var a=r;for(r=0;128===(128&a);){if(a=e.readUInt8(t),e.isError(a))return a;r<<=7,r|=127&a}}else r&=31;var o=d.tag[r];return{cls:i,primitive:n,tag:r,tagStr:o}}function o(e,t,r){var i=e.readUInt8(r);if(e.isError(i))return i;if(!t&&128===i)return null;if(0===(128&i))return i;var n=127&i;if(n>=4)return e.error("length octect is too long");i=0;for(var a=0;n>a;a++){i<<=8;var o=e.readUInt8(r);if(e.isError(o))return o;i|=o}return i}var s=e("inherits"),c=e("../../asn1"),f=c.base,u=c.bignum,d=c.constants.der;t.exports=i,i.prototype.decode=function(e,t){return e instanceof f.DecoderBuffer||(e=new f.DecoderBuffer(e,t)),this.tree._decode(e,t)},s(n,f.Node),n.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;var i=e.save(),n=a(e,'Failed to peek tag: "'+t+'"');return e.isError(n)?n:(e.restore(i),n.tag===t||n.tagStr===t||r)},n.prototype._decodeTag=function(e,t,r){var i=a(e,'Failed to decode tag of "'+t+'"');if(e.isError(i))return i;var n=o(e,i.primitive,'Failed to get length of "'+t+'"');if(e.isError(n))return n;if(!r&&i.tag!==t&&i.tagStr!==t&&i.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(i.primitive||null!==n)return e.skip(n,'Failed to match body of: "'+t+'"');var s=e.save(),c=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(c)?c:(n=e.offset-s.offset,e.restore(s),e.skip(n,'Failed to match body of: "'+t+'"'))},n.prototype._skipUntilEnd=function(e,t){for(;;){var r=a(e,t);if(e.isError(r))return r;var i=o(e,r.primitive,t);if(e.isError(i))return i;var n;if(n=r.primitive||null!==i?e.skip(i):this._skipUntilEnd(e,t),e.isError(n))return n;if("end"===r.tagStr)break}},n.prototype._decodeList=function(e,t,r){for(var i=[];!e.isEmpty();){var n=this._peekTag(e,"end");if(e.isError(n))return n;var a=r.decode(e,"der");if(e.isError(a)&&n)break;i.push(a)}return i},n.prototype._decodeStr=function(e,t){if("octstr"===t)return e.raw();if("bitstr"===t){var r=e.readUInt8();return e.isError(r)?r:{unused:r,data:e.raw()}}return"ia5str"===t||"utf8str"===t?e.raw().toString():this.error("Decoding of string type: "+t+" unsupported")},n.prototype._decodeObjid=function(e,t,r){for(var i=[],n=0;!e.isEmpty();){var a=e.readUInt8();n<<=7,n|=127&a,0===(128&a)&&(i.push(n),n=0)}128&a&&i.push(n);var o=i[0]/40|0,s=i[0]%40;return r?result=i:result=[o,s].concat(i.slice(1)),t&&(result=t[result.join(" ")]),result},n.prototype._decodeTime=function(e,t){var r=e.raw().toString();if("gentime"===t)var i=0|r.slice(0,4),n=0|r.slice(4,6),a=0|r.slice(6,8),o=0|r.slice(8,10),s=0|r.slice(10,12),c=0|r.slice(12,14);else{if("utctime"!==t)return this.error("Decoding "+t+" time is not supported yet");var i=0|r.slice(0,2),n=0|r.slice(2,4),a=0|r.slice(4,6),o=0|r.slice(6,8),s=0|r.slice(8,10),c=0|r.slice(10,12);i=70>i?2e3+i:1900+i}return Date.UTC(i,n-1,a,o,s,c,0)},n.prototype._decodeNull=function(e){return null},n.prototype._decodeBool=function(e){var t=e.readUInt8();return e.isError(t)?t:0!==t},n.prototype._decodeInt=function(e,t){var r=e.raw(),i=new u(r);return t&&(i=t[i.toString(10)]||i),i},n.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree}},{"../../asn1":75,inherits:202}],84:[function(e,t,r){var i=r;i.der=e("./der"),i.pem=e("./pem")},{"./der":83,"./pem":85}],85:[function(e,t,r){function i(e){o.call(this,e),this.enc="pem"}var n=e("inherits"),a=e("buffer").Buffer,o=(e("../../asn1"),e("./der"));n(i,o),t.exports=i,i.prototype.decode=function(e,t){for(var r=e.toString().split(/[\r\n]+/g),i=t.label.toUpperCase(),n=/^-----(BEGIN|END) ([^-]+)-----$/,s=-1,c=-1,f=0;fe?"0"+e:e}function o(e,t,r,i){var n;if("seqof"===e?e="seq":"setof"===e&&(e="set"),d.tagByName.hasOwnProperty(e))n=d.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return i.error("Unknown tag: "+e);n=e}return n>=31?i.error("Multi-octet tag encoding unsupported"):(t||(n|=32),n|=d.tagClassByName[r||"universal"]<<6)}var s=e("inherits"),c=e("buffer").Buffer,f=e("../../asn1"),u=f.base,d=(f.bignum,f.constants.der);t.exports=i,i.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},s(n,u.Node),n.prototype._encodeComposite=function(e,t,r,i){var n=o(e,t,r,this.reporter);if(i.length<128){var a=new c(2);return a[0]=n,a[1]=i.length,this._createEncoderBuffer([a,i])}for(var s=1,f=i.length;f>=256;f>>=8)s++;var a=new c(2+s);a[0]=n,a[1]=128|s;for(var f=1+s,u=i.length;u>0;f--,u>>=8)a[f]=255&u;return this._createEncoderBuffer([a,i])},n.prototype._encodeStr=function(e,t){return"octstr"===t?this._createEncoderBuffer(e):"bitstr"===t?this._createEncoderBuffer([0|e.unused,e.data]):"ia5str"===t||"utf8str"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported")},n.prototype._encodeObjid=function(e,t,r){if("string"==typeof e){if(!t)return this.reporter.error("string objid given, but no values map found");if(!t.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=t[e].split(/[\s\.]+/g);for(var i=0;i=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}for(var n=0,i=0;i=128;a>>=7)n++}for(var o=new c(n),s=o.length-1,i=e.length-1;i>=0;i--){var a=e[i];for(o[s--]=127&a;(a>>=7)>0;)o[s--]=128|127&a}return this._createEncoderBuffer(o)},n.prototype._encodeTime=function(e,t){var r,i=new Date(e);return"gentime"===t?r=[a(i.getFullYear()),a(i.getUTCMonth()+1),a(i.getUTCDate()),a(i.getUTCHours()),a(i.getUTCMinutes()),a(i.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[a(i.getFullYear()%100),a(i.getUTCMonth()+1),a(i.getUTCDate()),a(i.getUTCHours()),a(i.getUTCMinutes()),a(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},n.prototype._encodeNull=function(){return this._createEncoderBuffer("")},n.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!c.isBuffer(e)){var r=e.toArray();e.sign===!1&&128&r[0]&&r.unshift(0),e=new c(r)}if(c.isBuffer(e)){var i=e.length;0===e.length&&i++;var n=new c(i);return e.copy(n),0===e.length&&(n[0]=0),this._createEncoderBuffer(n)}if(128>e)return this._createEncoderBuffer(e);if(256>e)return this._createEncoderBuffer([0,e]);for(var i=1,a=e;a>=256;a>>=8)i++;for(var n=new Array(i),a=n.length-1;a>=0;a--)n[a]=255&e,e>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(new c(n))},n.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},n.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},n.prototype._skipDefault=function(e,t,r){var i,n=this._baseState;if(null===n["default"])return!1;var a=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n["default"],t,r).join()),a.length!==n.defaultBuffer.length)return!1;for(i=0;i0&&r.ishrn(i),r}function f(e,t){e=c(e,t),e=e.mod(t);var i=new r(e.toArray());if(i.lengthh&&(b=1),c=Math.min(e.length,d.length),e.length!==d.length&&(b=1),l=-1;++l=t)throw new Error("invalid sig")}var s=e("./curves"),c=e("elliptic"),f=e("parse-asn1"),u=e("bn.js"),d=c.ec;t.exports=i}).call(this,e("buffer").Buffer)},{"./curves":47,"bn.js":48,buffer:11,elliptic:50,"parse-asn1":74}],110:[function(e,t,r){(function(r){function i(e){this.curveType=s[e],this.curveType||(this.curveType={name:e}),this.curve=new a.ec(this.curveType.name),this.keys=void 0}function n(e,t,i){Array.isArray(e)||(e=e.toArray());var n=new r(e);if(i&&n.length>5]|=128<>>9<<4)+14]=t;for(var r=1732584193,i=-271733879,n=-1732584194,u=271733878,d=0;d>16)+(t>>16)+(r>>16);return i<<16|65535&r}function u(e,t){return e<>>32-t}var d=e("./helpers");t.exports=function(e){return d.hash(e,i,16)}},{"./helpers":134}],136:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{buffer:11,dup:32,inherits:202,stream:219,string_decoder:220}],137:[function(e,t,r){(function(e){function r(e){for(var t=[],r=0,i=0;r>>5]|=e[r]<<24-i%32;return t}function i(e){for(var t=[],r=0;r<32*e.length;r+=8)t.push(e[r>>>5]>>>24-r%32&255);return t}function n(e,t,r){for(var i=0;16>i;i++){var n=r+i,d=t[n];t[n]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}var v,y,w,_,S,k,E,x,A,j;k=v=e[0],E=y=e[1],x=w=e[2],A=_=e[3],j=S=e[4];var B;for(i=0;80>i;i+=1)B=v+t[r+h[i]]|0,B+=16>i?a(y,w,_)+m[0]:32>i?o(y,w,_)+m[1]:48>i?s(y,w,_)+m[2]:64>i?c(y,w,_)+m[3]:f(y,w,_)+m[4],B=0|B,B=u(B,p[i]),B=B+S|0,v=S,S=_,_=u(w,10),w=y,y=B,B=k+t[r+l[i]]|0,B+=16>i?f(E,x,A)+g[0]:32>i?c(E,x,A)+g[1]:48>i?s(E,x,A)+g[2]:64>i?o(E,x,A)+g[3]:a(E,x,A)+g[4],B=0|B,B=u(B,b[i]),B=B+j|0,k=j,j=A,A=u(x,10),x=E,E=B;B=e[1]+w+A|0,e[1]=e[2]+_+j|0,e[2]=e[3]+S+k|0,e[3]=e[4]+v+E|0,e[4]=e[0]+y+x|0,e[0]=B}function a(e,t,r){return e^t^r}function o(e,t,r){return e&t|~e&r}function s(e,t,r){return(e|~t)^r}function c(e,t,r){return e&r|t&~r}function f(e,t,r){return e^(t|~r)}function u(e,t){return e<>>32-t}function d(t){var a=[1732584193,4023233417,2562383102,271733878,3285377520];"string"==typeof t&&(t=new e(t,"utf8"));var o=r(t),s=8*t.length,c=8*t.length;o[s>>>5]|=128<<24-s%32,o[(s+64>>>9<<4)+14]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8);for(var f=0;ff;f++){var u=a[f];a[f]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var d=i(a);return new e(d)}var h=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],l=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],p=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],b=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],m=[0,1518500249,1859775393,2400959708,2840853838],g=[1352829926,1548603684,1836072691,2053994217,0];t.exports=d}).call(this,e("buffer").Buffer)},{buffer:11}],138:[function(e,t,r){(function(e){function r(t,r){this._block=new e(t),this._finalSize=r,this._blockSize=t,this._len=0,this._s=0}r.prototype.update=function(t,r){ +"string"==typeof t&&(r=r||"utf8",t=new e(t,r));for(var i=this._len+=t.length,n=this._s||0,a=0,o=this._block;i>n;){for(var s=Math.min(t.length,a+this._blockSize-n%this._blockSize),c=s-a,f=0;c>f;f++)o[n%this._blockSize+f]=t[f+a];n+=c,a+=c,n%this._blockSize===0&&this._update(o)}return this._s=n,this},r.prototype.digest=function(e){var t=8*this._len;this._block[this._len%this._blockSize]=128,this._block.fill(0,this._len%this._blockSize+1),t%(8*this._blockSize)>=8*this._finalSize&&(this._update(this._block),this._block.fill(0)),this._block.writeInt32BE(t,this._blockSize-4);var r=this._update(this._block)||this._hash();return e?r.toString(e):r},r.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=r}).call(this,e("buffer").Buffer)},{buffer:11}],139:[function(e,t,r){var r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t};r.sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":140,"./sha1":141,"./sha224":142,"./sha256":143,"./sha384":144,"./sha512":145}],140:[function(e,t,r){(function(r){function i(){this.init(),this._w=s,o.call(this,64,56)}function n(e,t){return e<>>32-t}var a=e("inherits"),o=e("./hash"),s=new Array(80);a(i,o),i.prototype.init=function(){return this._a=1732584193,this._b=-271733879,this._c=-1732584194,this._d=271733878,this._e=-1009589776,this},i.prototype._update=function(e){function t(){return a[d-3]^a[d-8]^a[d-14]^a[d-16]}function r(e,t){a[d]=e;var r=n(o,5)+t+u+e+i;u=f,f=c,c=n(s,30),s=o,o=r,d++}var i,a=this._w,o=this._a,s=this._b,c=this._c,f=this._d,u=this._e,d=0;for(i=1518500249;16>d;)r(e.readInt32BE(4*d),s&c|~s&f);for(;20>d;)r(t(),s&c|~s&f);for(i=1859775393;40>d;)r(t(),s^c^f);for(i=-1894007588;60>d;)r(t(),s&c|s&f|c&f);for(i=-899497514;80>d;)r(t(),s^c^f);this._a=o+this._a|0,this._b=s+this._b|0,this._c=c+this._c|0,this._d=f+this._d|0,this._e=u+this._e|0},i.prototype._hash=function(){var e=new r(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=i}).call(this,e("buffer").Buffer)},{"./hash":138,buffer:11,inherits:202}],141:[function(e,t,r){(function(r){function i(){this.init(),this._w=s,o.call(this,64,56)}function n(e,t){return e<>>32-t}var a=e("inherits"),o=e("./hash"),s=new Array(80);a(i,o),i.prototype.init=function(){return this._a=1732584193,this._b=-271733879,this._c=-1732584194,this._d=271733878,this._e=-1009589776,this},i.prototype._update=function(e){function t(){return n(a[d-3]^a[d-8]^a[d-14]^a[d-16],1)}function r(e,t){a[d]=e;var r=n(o,5)+t+u+e+i;u=f,f=c,c=n(s,30),s=o,o=r,d++}var i,a=this._w,o=this._a,s=this._b,c=this._c,f=this._d,u=this._e,d=0;for(i=1518500249;16>d;)r(e.readInt32BE(4*d),s&c|~s&f);for(;20>d;)r(t(),s&c|~s&f);for(i=1859775393;40>d;)r(t(),s^c^f);for(i=-1894007588;60>d;)r(t(),s&c|s&f|c&f);for(i=-899497514;80>d;)r(t(),s^c^f);this._a=o+this._a|0,this._b=s+this._b|0,this._c=c+this._c|0,this._d=f+this._d|0,this._e=u+this._e|0},i.prototype._hash=function(){var e=new r(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=i}).call(this,e("buffer").Buffer)},{"./hash":138,buffer:11,inherits:202}],142:[function(e,t,r){(function(r){function i(){this.init(),this._w=s,o.call(this,64,56)}var n=e("inherits"),a=e("./sha256"),o=e("./hash"),s=new Array(64);n(i,a),i.prototype.init=function(){return this._a=-1056596264,this._b=914150663,this._c=812702999,this._d=-150054599,this._e=-4191439,this._f=1750603025,this._g=1694076839,this._h=-1090891868,this},i.prototype._hash=function(){var e=new r(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=i}).call(this,e("buffer").Buffer)},{"./hash":138,"./sha256":143,buffer:11,inherits:202}],143:[function(e,t,r){(function(r){function i(){this.init(),this._w=l,d.call(this,64,56)}function n(e,t,r){return r^e&(t^r)}function a(e,t,r){return e&t|r&(e|t)}function o(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function s(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function c(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function f(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}var u=e("inherits"),d=e("./hash"),h=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],l=new Array(64);u(i,d),i.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this},i.prototype._update=function(e){function t(){return f(i[y-2])+i[y-7]+c(i[y-15])+i[y-16]}function r(e){i[y]=e;var t=v+s(b)+n(b,m,g)+h[y]+e,r=o(u)+a(u,d,l);v=g,g=m,m=b,b=p+t,p=l,l=d,d=u,u=t+r,y++}for(var i=this._w,u=0|this._a,d=0|this._b,l=0|this._c,p=0|this._d,b=0|this._e,m=0|this._f,g=0|this._g,v=0|this._h,y=0;16>y;)r(e.readInt32BE(4*y));for(;64>y;)r(t());this._a=u+this._a|0,this._b=d+this._b|0,this._c=l+this._c|0,this._d=p+this._d|0,this._e=b+this._e|0,this._f=m+this._f|0,this._g=g+this._g|0,this._h=v+this._h|0},i.prototype._hash=function(){var e=new r(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=i}).call(this,e("buffer").Buffer)},{"./hash":138,buffer:11,inherits:202}],144:[function(e,t,r){(function(r){function i(){this.init(),this._w=s,o.call(this,128,112)}var n=e("inherits"),a=e("./sha512"),o=e("./hash"),s=new Array(160);n(i,a),i.prototype.init=function(){return this._a=-876896931,this._b=1654270250,this._c=-1856437926,this._d=355462360,this._e=1731405415,this._f=-1900787065,this._g=-619958771,this._h=1203062813,this._al=-1056596264,this._bl=914150663,this._cl=812702999,this._dl=-150054599,this._el=-4191439,this._fl=1750603025,this._gl=1694076839,this._hl=-1090891868,this},i.prototype._hash=function(){function e(e,r,i){t.writeInt32BE(e,i),t.writeInt32BE(r,i+4)}var t=new r(48);return e(this._a,this._al,0),e(this._b,this._bl,8),e(this._c,this._cl,16),e(this._d,this._dl,24),e(this._e,this._el,32),e(this._f,this._fl,40),t},t.exports=i}).call(this,e("buffer").Buffer)},{"./hash":138,"./sha512":145,buffer:11,inherits:202}],145:[function(e,t,r){(function(r){function i(){this.init(),this._w=b,l.call(this,128,112)}function n(e,t,r){return r^e&(t^r)}function a(e,t,r){return e&t|r&(e|t)}function o(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function s(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function c(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function f(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function u(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function d(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}var h=e("inherits"),l=e("./hash"),p=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],b=new Array(160);h(i,l),i.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this._al=-205731576,this._bl=-2067093701,this._cl=-23791573,this._dl=1595750129,this._el=-1377402159,this._fl=725511199,this._gl=-79577749,this._hl=327033209,this},i.prototype._update=function(e){function t(){var e=l[M-30],t=l[M-30+1],r=c(e,t),n=f(t,e);e=l[M-4],t=l[M-4+1];var a=u(e,t),o=d(t,e),s=l[M-14],p=l[M-14+1],b=l[M-32],m=l[M-32+1];h=n+p,i=r+s+(n>>>0>h>>>0?1:0),h+=o,i=i+a+(o>>>0>h>>>0?1:0),h+=m,i=i+b+(m>>>0>h>>>0?1:0)}function r(){l[M]=i,l[M+1]=h;var e=a(b,m,g),t=a(k,E,x),r=o(b,k),c=o(k,b),f=s(y,j),u=s(j,y),d=p[M],q=p[M+1],C=n(y,w,_),P=n(j,B,I),L=z+u,D=S+f+(z>>>0>L>>>0?1:0);L+=P,D=D+C+(P>>>0>L>>>0?1:0),L+=q,D=D+d+(q>>>0>L>>>0?1:0),L+=h,D=D+i+(h>>>0>L>>>0?1:0);var T=c+t,U=r+e+(c>>>0>T>>>0?1:0);S=_,z=I,_=w,I=B,w=y,B=j,j=A+L|0,y=v+D+(A>>>0>j>>>0?1:0)|0,v=g,A=x,g=m,x=E,m=b,E=k,k=L+T|0,b=D+U+(L>>>0>k>>>0?1:0)|0,R++,M+=2}for(var i,h,l=this._w,b=0|this._a,m=0|this._b,g=0|this._c,v=0|this._d,y=0|this._e,w=0|this._f,_=0|this._g,S=0|this._h,k=0|this._al,E=0|this._bl,x=0|this._cl,A=0|this._dl,j=0|this._el,B=0|this._fl,I=0|this._gl,z=0|this._hl,R=0,M=0;16>R;)i=e.readInt32BE(4*M),h=e.readInt32BE(4*M+4),r();for(;80>R;)t(),r();this._al=this._al+k|0,this._bl=this._bl+E|0,this._cl=this._cl+x|0,this._dl=this._dl+A|0,this._el=this._el+j|0,this._fl=this._fl+B|0,this._gl=this._gl+I|0,this._hl=this._hl+z|0,this._a=this._a+b+(this._al>>>0>>0?1:0)|0,this._b=this._b+m+(this._bl>>>0>>0?1:0)|0,this._c=this._c+g+(this._cl>>>0>>0?1:0)|0,this._d=this._d+v+(this._dl>>>0>>0?1:0)|0,this._e=this._e+y+(this._el>>>0>>0?1:0)|0,this._f=this._f+w+(this._fl>>>0>>0?1:0)|0,this._g=this._g+_+(this._gl>>>0>>0?1:0)|0,this._h=this._h+S+(this._hl>>>0>>0?1:0)|0},i.prototype._hash=function(){function e(e,r,i){t.writeInt32BE(e,i),t.writeInt32BE(r,i+4)}var t=new r(64);return e(this._a,this._al,0),e(this._b,this._bl,8),e(this._c,this._cl,16),e(this._d,this._dl,24),e(this._e,this._el,32),e(this._f,this._fl,40),e(this._g,this._gl,48),e(this._h,this._hl,56),t},t.exports=i}).call(this,e("buffer").Buffer)},{"./hash":138,buffer:11,inherits:202}],146:[function(e,t,r){(function(r){"use strict";function i(e,t){o.call(this),e=e.toLowerCase(),"string"==typeof t&&(t=new r(t));var i="sha512"===e||"sha384"===e?128:64;this._alg=e,this._key=t,t.length>i?t=n(e).update(t).digest():t.lengthf;f++)a[f]=54^t[f],c[f]=92^t[f];this._hash=n(e).update(a)}var n=e("create-hash/browser"),a=e("inherits"),o=e("stream").Transform,s=new r(128);s.fill(0),a(i,o),i.prototype.update=function(e,t){return this._hash.update(e,t),this},i.prototype._transform=function(e,t,r){this._hash.update(e),r()},i.prototype._flush=function(e){this.push(this.digest()),e()},i.prototype.digest=function(e){var t=this._hash.digest();return n(this._alg).update(this._opad).update(t).digest(e)},t.exports=function(e,t){return new i(e,t)}}).call(this,e("buffer").Buffer)},{buffer:11,"create-hash/browser":133,inherits:202,stream:219}],147:[function(e,t,r){(function(t){function i(e){var r=new t(o[e].prime,"hex"),i=new t(o[e].gen,"hex");return new s(r,i)}function n(e,r,i,n){return(t.isBuffer(r)||"string"==typeof r&&-1===["hex","binary","base64"].indexOf(r))&&(n=i,i=r,r=void 0),r=r||"binary",n=n||"binary",i=i||new t([2]),t.isBuffer(i)||(i=new t(i,n)),"number"==typeof e?new s(a(e,i),i,!0):(t.isBuffer(e)||(e=new t(e,r)),new s(e,i,!0))}var a=e("./lib/generatePrime"),o=e("./lib/primes"),s=e("./lib/dh");r.DiffieHellmanGroup=r.createDiffieHellmanGroup=r.getDiffieHellman=i,r.createDiffieHellman=r.DiffieHellman=n}).call(this,e("buffer").Buffer)},{"./lib/dh":148,"./lib/generatePrime":149,"./lib/primes":150,buffer:11}],148:[function(e,t,r){(function(r){function i(e,t){return t=t||"utf8",r.isBuffer(e)||(e=new r(e,t)),this._pub=new f(e),this}function n(e,t){return t=t||"utf8",r.isBuffer(e)||(e=new r(e,t)),this._priv=new f(e),this}function a(e,t){var r=t.toString("hex"),i=[r,e.toString(16)].join("_");if(i in y)return y[i];var n=0;if(e.isEven()||!g.simpleSieve||!g.fermatTest(e)||!d.test(e))return n+=1,n+="02"===r||"05"===r?8:4,y[i]=n,n;d.test(e.shrn(1))||(n+=2);var a;switch(r){case"02":e.mod(h).cmp(l)&&(n+=8);break;case"05":a=e.mod(p),a.cmp(b)&&a.cmp(m)&&(n+=8);break;default:n+=4}return y[i]=n,n}function o(e,t){try{Object.defineProperty(e,"verifyError",{enumerable:!0,value:t,writable:!1})}catch(r){e.verifyError=t}}function s(e,t,r){this.setGenerator(t),this.__prime=new f(e),this._prime=f.mont(this.__prime),this._primeLen=e.length,this._pub=void 0,this._priv=void 0,r?(this.setPublicKey=i,this.setPrivateKey=n,o(this,a(this.__prime,t))):o(this,8)}function c(e,t){var i=new r(e.toArray());return t?i.toString(t):i}var f=e("bn.js"),u=e("miller-rabin"),d=new u,h=new f(24),l=new f(11),p=new f(10),b=new f(3),m=new f(7),g=e("./generatePrime"),v=e("randombytes");t.exports=s;var y={};s.prototype.generateKeys=function(){return this._priv||(this._priv=new f(v(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},s.prototype.computeSecret=function(e){e=new f(e),e=e.toRed(this._prime);var t=e.redPow(this._priv).fromRed(),i=new r(t.toArray()),n=this.getPrime();if(i.lengthi;i+=2){for(var n=Math.ceil(Math.sqrt(i)),a=0;r>a&&t[a]<=n&&i%t[a]!==0;a++);r!==a&&t[a]<=n||(t[r++]=i)}return S=t,t}function n(e){for(var t=i(),r=0;re;)r.ishrn(1);if(r.isEven()&&r.iadd(h),r.testn(1)||r.iadd(l),t.cmp(l))if(t.cmp(p))o={major:[w],minor:[l]};else{for(rem=r.mod(g);rem.cmp(v);)r.iadd(w),rem=r.mod(g);o={major:[w,b],minor:[l,m]}}else{for(;r.mod(f).cmp(y);)r.iadd(w);o={major:[f],minor:[_]}}return r}if(16>e)return new c(2===t||5===t?[140,123]:[140,39]);t=new c(t);for(var i,o,u=r(e),S=u.shrn(1);;){for(;u.bitLength()>e;)u=r(e),S=u.shrn(1);if(i++,n(S)&&n(u)&&a(S)&&a(u)&&d.test(S)&&d.test(u))return u;u.iadd(o.major[i%o.major.length]),S.iadd(o.minor[i%o.minor.length])}}var s=e("randombytes");t.exports=o,o.simpleSieve=n,o.fermatTest=a;var c=e("bn.js"),f=new c(24),u=e("miller-rabin"),d=new u,h=new c(1),l=new c(2),p=new c(5),b=new c(16),m=new c(8),g=new c(10),v=new c(3),y=(new c(7),new c(11)),w=new c(4),_=new c(12),S=null},{"bn.js":151,"miller-rabin":152,randombytes:200}],150:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],151:[function(e,t,r){arguments[4][48][0].apply(r,arguments)},{dup:48}],152:[function(e,t,r){function i(e){this.rand=e||new a.Rand}var n=e("bn.js"),a=e("brorand");t.exports=i,i.create=function(e){return new i(e)},i.prototype._rand=function(e){var t=e.bitLength(),r=this.rand.generate(Math.ceil(t/8));r[0]|=3;var i=7&t;return 0!==i&&(r[r.length-1]>>=7-i),new n(r)},i.prototype.test=function(e,t,r){var i=e.bitLength(),a=n.mont(e),o=new n(1).toRed(a);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),c=s.subn(1),f=0;!s.testn(f);f++);for(var u=e.shrn(f),d=s.toRed(a),h=!0;t>0;t--){var l=this._rand(c);r&&r(l);var p=l.toRed(a).redPow(u);if(0!==p.cmp(o)&&0!==p.cmp(d)){for(var b=1;f>b;b++){if(p=p.redSqr(),0===p.cmp(o))return!1;if(0===p.cmp(d))break}if(b===f)return!1}}return h},i.prototype.getDivisor=function(e,t){var r=e.bitLength(),i=n.mont(e),a=new n(1).toRed(i);t||(t=Math.max(1,r/48|0));for(var o=e.subn(1),s=o.subn(1),c=0;!o.testn(c);c++);for(var f=e.shrn(c),u=o.toRed(i);t>0;t--){var d=this._rand(s),h=e.gcd(d);if(0!==h.cmpn(1))return h;var l=d.toRed(i).redPow(f);if(0!==l.cmp(a)&&0!==l.cmp(u)){for(var p=1;c>p;p++){if(l=l.redSqr(),0===l.cmp(a))return l.fromRed().subn(1).gcd(e);if(0===l.cmp(u))break}if(p===c)return l=l.redSqr(),l.fromRed().subn(1).gcd(e)}}return!1}},{"bn.js":151,brorand:153}],153:[function(e,t,r){arguments[4][63][0].apply(r,arguments)},{dup:63}],154:[function(e,t,r){(function(t){function i(e,t,r,i,a,o){if("function"==typeof a&&(o=a,a=void 0),"function"!=typeof o)throw new Error("No callback provided to pbkdf2");var s=n(e,t,r,i,a);setTimeout(function(){o(void 0,s)})}function n(e,r,i,n,s){if("number"!=typeof i)throw new TypeError("Iterations not a number");if(0>i)throw new TypeError("Bad iterations");if("number"!=typeof n)throw new TypeError("Key length not a number");if(0>n||n>o)throw new TypeError("Bad key length");s=s||"sha1",t.isBuffer(e)||(e=new t(e,"binary")),t.isBuffer(r)||(r=new t(r,"binary"));var c,f=1,u=new t(n),d=new t(r.length+4);r.copy(d,0,0,r.length);for(var h,l,p=1;f>=p;p++){d.writeUInt32BE(p,r.length);var b=a(s,e).update(d).digest();c||(c=b.length,l=new t(c),f=Math.ceil(n/c),h=n-(f-1)*c),b.copy(l,0,0,c);for(var m=1;i>m;m++){b=a(s,e).update(b).digest();for(var g=0;c>g;g++)l[g]^=b[g]}var v=(p-1)*c,y=p===f?h:c;l.copy(u,v,0,y)}return u}var a=e("create-hmac"),o=Math.pow(2,30)-1;r.pbkdf2=i,r.pbkdf2Sync=n}).call(this,e("buffer").Buffer)},{buffer:11,"create-hmac":146}],155:[function(e,t,r){r.publicEncrypt=e("./publicEncrypt"),r.privateDecrypt=e("./privateDecrypt"),r.privateEncrypt=function(e,t){return r.publicEncrypt(e,t,!0)},r.publicDecrypt=function(e,t){return r.privateDecrypt(e,t,!0)}},{"./privateDecrypt":196,"./publicEncrypt":197}],156:[function(e,t,r){(function(r){function i(e){var t=new r(4);return t.writeUInt32BE(e,0),t}var n=e("create-hash");t.exports=function(e,t){for(var a,o=new r(""),s=0;o.length=t.length){a++;break}var o=t.slice(2,n-1);t.slice(n-1,n);if(("0002"!==i.toString("hex")&&!r||"0001"!==i.toString("hex")&&r)&&a++,o.length<8&&a++,a)throw new Error("decryption error");return t.slice(n)}function a(e,t){e=new r(e),t=new r(t);var i=0,n=e.length;e.length!==t.length&&(i++,n=Math.min(e.length,t.length));for(var a=-1;++ad||new f(t).cmp(c.modulus)>=0)throw new Error("decryption error");var l;l=a?h(new f(t),c):u(t,c);var p=new r(d-l.length);if(p.fill(0),l=r.concat([p,l],d),4===s)return i(c,l);if(1===s)return n(c,l,a);if(3===s)return l;throw new Error("unknown padding")}}).call(this,e("buffer").Buffer)},{"./mgf":156,"./withPublic":198,"./xor":199,"bn.js":157,"browserify-rsa":158,buffer:11,"create-hash":133,"parse-asn1":162}],197:[function(e,t,r){(function(r){function i(e,t){var i=e.modulus.byteLength(),n=t.length,a=c("sha1").update(new r("")).digest(),o=a.length,h=2*o;if(n>i-h-2)throw new Error("message too long");var l=new r(i-n-h-2);l.fill(0);var p=i-o-1,b=s(o),m=u(r.concat([a,l,new r([1]),t],p),f(b,p)),g=u(b,f(m,o));return new d(r.concat([new r([0]),g,m],i))}function n(e,t,i){var n=t.length,o=e.modulus.byteLength();if(n>o-11)throw new Error("message too long");var s;return i?(s=new r(o-n-3),s.fill(255)):s=a(o-n-3),new d(r.concat([new r([0,i?1:2]),s,new r([0]),t],o))}function a(e,t){for(var i,n=new r(e),a=0,o=s(2*e),c=0;e>a;)c===o.length&&(o=s(2*e),c=0),i=o[c++],i&&(n[a++]=i);return n}var o=e("parse-asn1"),s=e("randombytes"),c=e("create-hash"),f=e("./mgf"),u=e("./xor"),d=e("bn.js"),h=e("./withPublic"),l=e("browserify-rsa");t.exports=function(e,t,r){var a;a=e.padding?e.padding:r?1:4;var s,c=o(e);if(4===a)s=i(c,t);else if(1===a)s=n(c,t,r);else{if(3!==a)throw new Error("unknown padding");if(s=new d(t),s.cmp(c.modulus)>=0)throw new Error("data too long for modulus")}return r?l(s,c):h(s,c)}}).call(this,e("buffer").Buffer)},{"./mgf":156,"./withPublic":198,"./xor":199,"bn.js":157,"browserify-rsa":158,buffer:11,"create-hash":133,"parse-asn1":162,randombytes:200}],198:[function(e,t,r){(function(r){function i(e,t){return new r(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}var n=e("bn.js");t.exports=i}).call(this,e("buffer").Buffer)},{"bn.js":157,buffer:11}],199:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,i=-1;++ie||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},i.prototype.emit=function(e){var t,r,i,a,c,f;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[e],s(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,a=new Array(i-1),c=1;i>c;c++)a[c-1]=arguments[c];r.apply(this,a)}else if(o(r)){for(i=arguments.length,a=new Array(i-1),c=1;i>c;c++)a[c-1]=arguments[c];for(f=r.slice(),i=f.length,c=0;i>c;c++)f[c].apply(this,a)}return!0},i.prototype.addListener=function(e,t){var r;if(!n(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,n(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned){var r;r=s(this._maxListeners)?i.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},i.prototype.on=i.prototype.addListener,i.prototype.once=function(e,t){function r(){this.removeListener(e,r),i||(i=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var i=!1;return r.listener=t,this.on(e,r),this},i.prototype.removeListener=function(e,t){var r,i,a,s;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],a=r.length,i=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-->0;)if(r[s]===t||r[s].listener&&r[s].listener===t){i=s;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},i.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],n(r))this.removeListener(e,r);else for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},i.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},i.listenerCount=function(e,t){var r;return r=e._events&&e._events[t]?n(e._events[t])?1:e._events[t].length:0}},{}],202:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],203:[function(e,t,r){t.exports=function(e){return!(null==e||!(e._isBuffer||e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)))}},{}],204:[function(e,t,r){t.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},{}],205:[function(e,t,r){function i(){u=!1,s.length?f=s.concat(f):d=-1,f.length&&n()}function n(){if(!u){var e=setTimeout(i);u=!0;for(var t=f.length;t;){for(s=f,f=[];++d1)for(var r=1;r0)if(t.ended&&!n){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&n){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else!t.decoder||n||i||(r=t.decoder.write(r)),n||(t.reading=!1),t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&d(e)),l(e,t);else n||(t.reading=!1);return o(t)}function o(e){return!e.ended&&(e.needReadable||e.length=q)e=q;else{e--;for(var t=1;32>t;t<<=1)e|=e>>t;e++}return e}function c(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=s(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function f(e,t){var r=null;return j.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function u(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,d(e)}}function d(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(R("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?x(h,e):h(e))}function h(e){R("emit readable"),e.emit("readable"),y(e)}function l(e,t){t.readingMore||(t.readingMore=!0,x(p,e,t))}function p(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=n)r=a?i.join(""):j.concat(i,n),i.length=0;else if(ef&&e>c;f++){var s=i[0],d=Math.min(e-c,s.length);a?r+=s.slice(0,d):s.copy(r,c,0,d),d0)throw new Error("endReadable called on non-empty stream");t.endEmitted||(t.ended=!0,x(S,t,e))}function S(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function k(e,t){for(var r=0,i=e.length;i>r;r++)t(e[r],r)}function E(e,t){for(var r=0,i=e.length;i>r;r++)if(e[r]===t)return r;return-1}t.exports=n;var x=e("process-nextick-args"),A=e("isarray"),j=e("buffer").Buffer;n.ReadableState=i;var B=e("events").EventEmitter;B.listenerCount||(B.listenerCount=function(e,t){return e.listeners(t).length});var I;!function(){try{I=e("stream")}catch(t){}finally{I||(I=e("events").EventEmitter)}}();var j=e("buffer").Buffer,z=e("core-util-is");z.inherits=e("inherits");var R=e("util");R=R&&R.debuglog?R.debuglog("stream"):function(){};var M;z.inherits(n,I),n.prototype.push=function(e,t){var r=this._readableState;return r.objectMode||"string"!=typeof e||(t=t||r.defaultEncoding,t!==r.encoding&&(e=new j(e,t),t="")),a(this,r,e,t,!1)},n.prototype.unshift=function(e){var t=this._readableState;return a(this,t,e,"",!0)},n.prototype.isPaused=function(){return this._readableState.flowing===!1},n.prototype.setEncoding=function(t){return M||(M=e("string_decoder/").StringDecoder),this._readableState.decoder=new M(t),this._readableState.encoding=t,this};var q=8388608;n.prototype.read=function(e){R("read",e);var t=this._readableState,r=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return R("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?_(this):d(this),null;if(e=c(e,t),0===e&&t.ended)return 0===t.length&&_(this),null;var i=t.needReadable;R("need readable",i),(0===t.length||t.length-e0?w(e,t):null,null===n&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),r!==e&&t.ended&&0===t.length&&_(this),null!==n&&this.emit("data",n),n},n.prototype._read=function(e){this.emit("error",new Error("not implemented"))},n.prototype.pipe=function(e,t){function i(e){R("onunpipe"),e===d&&a()}function n(){R("onend"),e.end()}function a(){R("cleanup"),e.removeListener("close",c),e.removeListener("finish",f),e.removeListener("drain",m),e.removeListener("error",s),e.removeListener("unpipe",i),d.removeListener("end",n),d.removeListener("end",a),d.removeListener("data",o),!h.awaitDrain||e._writableState&&!e._writableState.needDrain||m()}function o(t){R("ondata");var r=e.write(t);!1===r&&(R("false write response, pause",d._readableState.awaitDrain),d._readableState.awaitDrain++,d.pause())}function s(t){R("onerror",t),u(),e.removeListener("error",s),0===B.listenerCount(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",f),u()}function f(){R("onfinish"),e.removeListener("close",c),u()}function u(){R("unpipe"),d.unpipe(e)}var d=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,R("pipe count=%d opts=%j",h.pipesCount,t);var l=(!t||t.end!==!1)&&e!==r.stdout&&e!==r.stderr,p=l?n:a;h.endEmitted?x(p):d.once("end",p),e.on("unpipe",i);var m=b(d);return e.on("drain",m),d.on("data",o),e._events&&e._events.error?A(e._events.error)?e._events.error.unshift(s):e._events.error=[s,e._events.error]:e.on("error",s),e.once("close",c),e.once("finish",f),e.emit("pipe",d),h.flowing||(R("pipe resume"),d.resume()),e},n.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var n=0;i>n;n++)r[n].emit("unpipe",this);return this}var n=E(t.pipes,e);return-1===n?this:(t.pipes.splice(n,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},n.prototype.on=function(e,t){var r=I.prototype.on.call(this,e,t);if("data"===e&&!1!==this._readableState.flowing&&this.resume(),"readable"===e&&this.readable){var i=this._readableState;i.readableListening||(i.readableListening=!0,i.emittedReadable=!1,i.needReadable=!0,i.reading?i.length&&d(this,i):x(m,this))}return r},n.prototype.addListener=n.prototype.on,n.prototype.resume=function(){var e=this._readableState;return e.flowing||(R("resume"),e.flowing=!0,g(this,e)),this},n.prototype.pause=function(){return R("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(R("pause"),this._readableState.flowing=!1,this.emit("pause")),this},n.prototype.wrap=function(e){var t=this._readableState,r=!1,i=this;e.on("end",function(){if(R("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&i.push(e)}i.push(null)}),e.on("data",function(n){if(R("wrapped data"),t.decoder&&(n=t.decoder.write(n)),(!t.objectMode||null!==n&&void 0!==n)&&(t.objectMode||n&&n.length)){var a=i.push(n);a||(r=!0,e.pause())}});for(var n in e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));var a=["error","close","destroy","pause","resume"];return k(a,function(t){e.on(t,i.emit.bind(i,t))}),i._read=function(t){R("wrapped _read",t),r&&(r=!1,e.resume())},i},n._fromList=w}).call(this,e("_process"))},{"./_stream_duplex":207,_process:205,buffer:11,"core-util-is":212,events:201,inherits:202,isarray:204,"process-nextick-args":213,"string_decoder/":220,util:10}],210:[function(e,t,r){"use strict";function i(e){this.afterTransform=function(t,r){return n(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function n(e,t,r){var i=e._transformState;i.transforming=!1;var n=i.writecb;if(!n)return e.emit("error",new Error("no writecb in Transform class"));i.writechunk=null,i.writecb=null,null!==r&&void 0!==r&&e.push(r),n&&n(t);var a=e._readableState;a.reading=!1,(a.needReadable||a.length-1))throw new TypeError("Unknown encoding: "+e);this._writableState.defaultEncoding=e},o.prototype._write=function(e,t,r){r(new Error("not implemented"))},o.prototype._writev=null,o.prototype.end=function(e,t,r){var i=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||_(this,i,r)}},{"./_stream_duplex":207,buffer:11,"core-util-is":212,events:201,inherits:202,"process-nextick-args":213,"util-deprecate":214}],212:[function(e,t,r){(function(e){function t(e){return Array.isArray(e)}function i(e){return"boolean"==typeof e}function n(e){return null===e}function a(e){return null==e}function o(e){return"number"==typeof e}function s(e){return"string"==typeof e}function c(e){return"symbol"==typeof e}function f(e){return void 0===e}function u(e){return d(e)&&"[object RegExp]"===g(e)}function d(e){return"object"==typeof e&&null!==e}function h(e){return d(e)&&"[object Date]"===g(e)}function l(e){return d(e)&&("[object Error]"===g(e)||e instanceof Error)}function p(e){return"function"==typeof e}function b(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function m(t){return e.isBuffer(t)}function g(e){return Object.prototype.toString.call(e)}r.isArray=t,r.isBoolean=i,r.isNull=n,r.isNullOrUndefined=a,r.isNumber=o,r.isString=s,r.isSymbol=c,r.isUndefined=f,r.isRegExp=u,r.isObject=d,r.isDate=h,r.isError=l,r.isFunction=p,r.isPrimitive=b,r.isBuffer=m}).call(this,{isBuffer:e("../../../../insert-module-globals/node_modules/is-buffer/index.js")})},{"../../../../insert-module-globals/node_modules/is-buffer/index.js":203}],213:[function(e,t,r){(function(e){"use strict";function r(t){for(var r=new Array(arguments.length-1),i=0;i=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&56319>=i)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived),t+=e.toString(this.encoding,0,n);var n=t.length-1,i=t.charCodeAt(n);if(i>=55296&&56319>=i){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),e.copy(this.charBuffer,0,0,a),t.substring(0,n)}return t},f.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(2>=t&&r>>4==14){this.charLength=3;break}if(3>=t&&r>>3==30){this.charLength=4;break}}this.charReceived=t},f.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,i=this.charBuffer,n=this.encoding; +t+=i.slice(0,r).toString(n)}return t}},{buffer:11}],221:[function(require,module,exports){function Context(){}var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r>8&255]>h&&(k[t]=i)),i}function i(e,t,r){var i=65280&t,n=S.udata[i]||{},a=n[t];return a?new S(t,a):new S(t,d)}function n(e,t,r){return r?e(t,r):new S(t,null)}function a(e,t,r){var i;if(p>t||t>=p+g&&l>t||t>l+_)return e(t,r);if(t>=p&&p+g>t){var n={},a=(t-p)*v;for(i=0;v>i;++i)n[b+i]=l+y*(i+a);return new S(t,[,,n])}var o=t-l,s=o%y,c=[];if(0!==s)c[0]=[l+o-s,m+s];else for(c[0]=[p+Math.floor(o/w),b+Math.floor(o%w/y)],c[2]={},i=1;y>i;++i)c[2][m+i]=t+i;return new S(t,c)}function o(e,t,r){return 60>t||t>13311&&42607>t?new S(t,d):e(t,r)}function s(e){return M("NFD",e)}function c(e){return M("NFKD",e)}function f(e){return M("NFC",e)}function u(e){return M("NFKC",e)}for(var d=[null,0,{}],h=10,l=44032,p=4352,b=4449,m=4519,g=19,v=21,y=28,w=v*y,_=g*w,S=function(e,t){this.codepoint=e,this.feature=t},k={},E=[],x=0;255>=x;++x)E[x]=0;var A=[o,r,n,a,i];S.fromCharCode=A.reduceRight(function(e,t){return function(r,i){return t(e,r,i)}},null),S.isHighSurrogate=function(e){return e>=55296&&56319>=e},S.isLowSurrogate=function(e){return e>=56320&&57343>=e},S.prototype.prepFeature=function(){this.feature||(this.feature=S.fromCharCode(this.codepoint,!0).feature)},S.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var e=this.codepoint-65536;return String.fromCharCode(Math.floor(e/1024)+55296,e%1024+56320)},S.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},S.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},S.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},S.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},S.prototype.getComposite=function(e){if(this.prepFeature(),!this.feature[2])return null;var t=this.feature[2][e.codepoint];return t?S.fromCharCode(t):null};var j=function(e){this.str=e,this.cursor=0};j.prototype.next=function(){if(this.str&&this.cursor0;--r){var i=this.resBuf[r-1],n=i.getCanonicalClass();if(e>=n)break}this.resBuf.splice(r,0,t)}while(0!==e);return this.resBuf.shift()};var z=function(e){this.it=e,this.procBuf=[],this.resBuf=[],this.lastClass=null};z.prototype.next=function(){for(;0===this.resBuf.length;){var e=this.it.next();if(!e){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=e.getCanonicalClass(),this.procBuf.push(e);else{var t=this.procBuf[0],r=t.getComposite(e),i=e.getCanonicalClass();r&&(this.lastClass"},e.exports=n;var d=t("./script")}).call(this,t("buffer").Buffer)},{"./crypto/hash":8,"./encoding/base58check":13,"./errors":17,"./networks":22,"./publickey":25,"./script":26,"./util/js":44,"./util/preconditions":45,buffer:48,lodash:297}],2:[function(t,e,r){(function(r){"use strict";function n(t){return this instanceof n?(i.extend(this,n._from(t)),this):new n(t)}var i=t("lodash"),s=t("./blockheader"),o=t("../crypto/bn"),a=t("../util/buffer"),f=t("../encoding/bufferreader"),u=t("../encoding/bufferwriter"),c=t("../crypto/hash"),h=t("../transaction"),d=t("../util/preconditions");n.MAX_BLOCK_SIZE=1e6,n._from=function(t){var e={};if(a.isBuffer(t))e=n._fromBufferReader(f(t));else{if(!i.isObject(t))throw new TypeError("Unrecognized argument for Block");e=n._fromObject(t)}return e},n._fromObject=function(t){var e=[];t.transactions.forEach(function(t){t instanceof h?e.push(t):e.push(h().fromObject(t))});var r={header:s.fromObject(t.header),transactions:e};return r},n.fromObject=function(t){var e=n._fromObject(t);return new n(e)},n._fromBufferReader=function(t){var e={};d.checkState(!t.finished(),"No block data received"),e.header=s.fromBufferReader(t);var r=t.readVarintNum();e.transactions=[];for(var n=0;r>n;n++)e.transactions.push(h().fromBufferReader(t));return e},n.fromBufferReader=function(t){d.checkArgument(t,"br is required");var e=n._fromBufferReader(t);return new n(e)},n.fromBuffer=function(t){return n.fromBufferReader(new f(t))},n.fromString=function(t){var e=new r(t,"hex");return n.fromBuffer(e)},n.fromRawBlock=function(t){a.isBuffer(t)||(t=new r(t,"binary"));var e=f(t);e.pos=n.Values.START_OF_BLOCK;var i=n._fromBufferReader(e);return new n(i)},n.prototype.toObject=n.prototype.toJSON=function(){var t=[];return this.transactions.forEach(function(e){t.push(e.toObject())}),{header:this.header.toObject(),transactions:t}},n.prototype.toBuffer=function(){return this.toBufferWriter().concat()},n.prototype.toString=function(){return this.toBuffer().toString("hex")},n.prototype.toBufferWriter=function(t){t||(t=new u),t.write(this.header.toBuffer()),t.writeVarintNum(this.transactions.length);for(var e=0;e1;n=Math.floor((n+1)/2)){for(var i=0;n>i;i+=2){var s=Math.min(i+1,n-1),o=r.concat([t[e+i],t[e+s]]);t.push(c.sha256sha256(o))}e+=n}return t},n.prototype.getMerkleRoot=function(){var t=this.getMerkleTree();return t[t.length-1]},n.prototype.validMerkleRoot=function(){var t=new o(this.header.merkleRoot.toString("hex"),"hex"),e=new o(this.getMerkleRoot().toString("hex"),"hex");return 0!==t.cmp(e)?!1:!0},n.prototype._getHash=function(){return this.header._getHash()};var p={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=this.header.id),this._id},set:i.noop};Object.defineProperty(n.prototype,"id",p),Object.defineProperty(n.prototype,"hash",p),n.prototype.inspect=function(){return""},n.Values={START_OF_BLOCK:8,NULL_HASH:new r("0000000000000000000000000000000000000000000000000000000000000000","hex")},e.exports=n}).call(this,t("buffer").Buffer)},{"../crypto/bn":6,"../crypto/hash":8,"../encoding/bufferreader":14,"../encoding/bufferwriter":15,"../transaction":29,"../util/buffer":43,"../util/preconditions":45,"./blockheader":3,buffer:48,lodash:297}],3:[function(t,e,r){(function(r){"use strict";var n=t("lodash"),i=t("../crypto/bn"),s=t("../util/buffer"),o=t("../encoding/bufferreader"),a=t("../encoding/bufferwriter"),f=t("../crypto/hash"),u=(t("../util/js"),t("../util/preconditions")),c=486604799,h=function p(t){if(!(this instanceof p))return new p(t);var e=p._from(t);return this.version=e.version,this.prevHash=e.prevHash,this.merkleRoot=e.merkleRoot,this.time=e.time,this.timestamp=e.time,this.bits=e.bits,this.nonce=e.nonce,e.hash&&u.checkState(this.hash===e.hash,"Argument object hash property does not match block hash."),this};h._from=function(t){var e={};if(s.isBuffer(t))e=h._fromBufferReader(o(t));else{if(!n.isObject(t))throw new TypeError("Unrecognized argument for BlockHeader");e=h._fromObject(t)}return e},h._fromObject=function(t){u.checkArgument(t,"data is required");var e=t.prevHash,i=t.merkleRoot;n.isString(t.prevHash)&&(e=s.reverse(new r(t.prevHash,"hex"))),n.isString(t.merkleRoot)&&(i=s.reverse(new r(t.merkleRoot,"hex")));var o={hash:t.hash,version:t.version,prevHash:e,merkleRoot:i,time:t.time,timestamp:t.time,bits:t.bits,nonce:t.nonce};return o},h.fromObject=function(t){var e=h._fromObject(t);return new h(e)},h.fromRawBlock=function(t){s.isBuffer(t)||(t=new r(t,"binary"));var e=o(t);e.pos=h.Constants.START_OF_HEADER;var n=h._fromBufferReader(e);return new h(n)},h.fromBuffer=function(t){var e=h._fromBufferReader(o(t));return new h(e)},h.fromString=function(t){var e=new r(t,"hex");return h.fromBuffer(e)},h._fromBufferReader=function(t){var e={};return e.version=t.readUInt32LE(),e.prevHash=t.read(32),e.merkleRoot=t.read(32),e.time=t.readUInt32LE(),e.bits=t.readUInt32LE(),e.nonce=t.readUInt32LE(),e},h.fromBufferReader=function(t){var e=h._fromBufferReader(t);return new h(e)},h.prototype.toObject=h.prototype.toJSON=function(){return{hash:this.hash,version:this.version,prevHash:s.reverse(this.prevHash).toString("hex"),merkleRoot:s.reverse(this.merkleRoot).toString("hex"),time:this.time,bits:this.bits,nonce:this.nonce}},h.prototype.toBuffer=function(){return this.toBufferWriter().concat()},h.prototype.toString=function(){return this.toBuffer().toString("hex")},h.prototype.toBufferWriter=function(t){return t||(t=new a),t.writeUInt32LE(this.version),t.write(this.prevHash),t.write(this.merkleRoot),t.writeUInt32LE(this.time),t.writeUInt32LE(this.bits),t.writeUInt32LE(this.nonce),t},h.prototype.getTargetDifficulty=function(t){t=t||this.bits;for(var e=new i(16777215&t),r=8*((t>>>24)-3);r-- >0;)e=e.mul(new i(2));return e},h.prototype.getDifficulty=function(){var t=this.getTargetDifficulty(c).mul(new i(Math.pow(10,8))),e=this.getTargetDifficulty(),r=t.div(e).toString(10),n=r.length-8;return r=r.slice(0,n)+"."+r.slice(n),parseFloat(r)},h.prototype._getHash=function(){var t=this.toBuffer();return f.sha256sha256(t)};var d={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=o(this._getHash()).readReverse().toString("hex")),this._id},set:n.noop};Object.defineProperty(h.prototype,"id",d),Object.defineProperty(h.prototype,"hash",d),h.prototype.validTimestamp=function(){var t=Math.round((new Date).getTime()/1e3);return this.time>t+h.Constants.MAX_TIME_OFFSET?!1:!0},h.prototype.validProofOfWork=function(){var t=new i(this.id,"hex"),e=this.getTargetDifficulty();return t.cmp(e)>0?!1:!0},h.prototype.inspect=function(){return""},h.Constants={START_OF_HEADER:8,MAX_TIME_OFFSET:7200,LARGEST_HASH:new i("10000000000000000000000000000000000000000000000000000000000000000","hex")},e.exports=h}).call(this,t("buffer").Buffer)},{"../crypto/bn":6,"../crypto/hash":8,"../encoding/bufferreader":14,"../encoding/bufferwriter":15,"../util/buffer":43,"../util/js":44,"../util/preconditions":45,buffer:48,lodash:297}],4:[function(t,e,r){e.exports=t("./block"),e.exports.BlockHeader=t("./blockheader"),e.exports.MerkleBlock=t("./merkleblock")},{"./block":2,"./blockheader":3,"./merkleblock":5}],5:[function(t,e,r){(function(r){"use strict";function n(t){if(!(this instanceof n))return new n(t);var e={};if(o.isBuffer(t))e=n._fromBufferReader(a(t));else{if(!i.isObject(t))throw new TypeError("Unrecognized argument for MerkleBlock");var r;r=t.header instanceof s?t.header:s.fromObject(t.header),e={header:r,numTransactions:t.numTransactions,hashes:t.hashes,flags:t.flags}}return i.extend(this,e),this._flagBitsUsed=0,this._hashesUsed=0,this}var i=t("lodash"),s=t("./blockheader"),o=t("../util/buffer"),a=t("../encoding/bufferreader"),f=t("../encoding/bufferwriter"),u=t("../crypto/hash"),c=(t("../util/js"),t("../transaction")),h=t("../util/preconditions");n.fromBuffer=function(t){return n.fromBufferReader(a(t))},n.fromBufferReader=function(t){return new n(n._fromBufferReader(t))},n.prototype.toBuffer=function(){return this.toBufferWriter().concat()},n.prototype.toBufferWriter=function(t){t||(t=new f),t.write(this.header.toBuffer()),t.writeUInt32LE(this.numTransactions),t.writeVarintNum(this.hashes.length);for(var e=0;ethis.numTransactions)return!1;if(8*this.flags.length8*this.flags.length)return null;var i=this.flags[n.flagBitsUsed>>3]>>>(7&n.flagBitsUsed++)&1;if(0!==t&&i){var s=this._traverseMerkleTree(t-1,2*e,n),o=s;return 2*e+1=this.hashes.length)return null;var a=this.hashes[n.hashesUsed++];return 0===t&&i&&n.txs.push(a),new r(a,"hex")},n.prototype._calcTreeWidth=function(t){return this.numTransactions+(1<>t},n.prototype._calcTreeHeight=function(){for(var t=0;this._calcTreeWidth(t)>1;)t++;return t},n.prototype.hasTransaction=function(t){h.checkArgument(!i.isUndefined(t),"tx cannot be undefined"),h.checkArgument(t instanceof c||"string"==typeof t,'Invalid tx given, tx must be a "string" or "Transaction"');var e=t;t instanceof c&&(e=o.reverse(new r(t.id,"hex")).toString("hex"));var n=[],s=this._calcTreeHeight();return this._traverseMerkleTree(s,0,{txs:n}),-1!==n.indexOf(e)},n._fromBufferReader=function(t){h.checkState(!t.finished(),"No merkleblock data received");var e={};e.header=s.fromBufferReader(t),e.numTransactions=t.readUInt32LE();var r=t.readVarintNum();e.hashes=[];for(var n=0;r>n;n++)e.hashes.push(t.read(32).toString("hex"));var i=t.readVarintNum();for(e.flags=[],n=0;i>n;n++)e.flags.push(t.readUInt8());return e},n.fromObject=function(t){return new n(t)},e.exports=n}).call(this,t("buffer").Buffer)},{"../crypto/hash":8,"../encoding/bufferreader":14,"../encoding/bufferwriter":15,"../transaction":29,"../util/buffer":43,"../util/js":44,"../util/preconditions":45,"./blockheader":3,buffer:48,lodash:297}],6:[function(t,e,r){(function(r){"use strict";var n=t("bn.js"),i=t("../util/preconditions"),s=t("lodash"),o=function(t){for(var e=new r(t.length),n=0;nt.size?e=n.trim(e,s):s0&&0===(127&t[t.length-1])&&(t.length<=1||0===(128&t[t.length-2])))throw new Error("non-minimally encoded script number");return n.fromSM(t,{endian:"little"})},n.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})},n.prototype.gt=function(t){return this.cmp(t)>0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.lt=function(t){return this.cmp(t)<0},n.trim=function(t,e){return t.slice(e-t.length,t.length)},n.pad=function(t,e,n){for(var i=new r(n),s=0;ss;s++)i[s]=0;return i},e.exports=n}).call(this,t("buffer").Buffer)},{"../util/preconditions":45,"bn.js":272,buffer:48,lodash:297}],7:[function(t,e,r){(function(r){"use strict";var n=t("./bn"),i=t("./point"),s=t("./signature"),o=t("../publickey"),a=t("./random"),f=t("./hash"),u=t("../util/buffer"),c=t("lodash"),h=t("../util/preconditions"),d=function p(t){return this instanceof p?void(t&&this.set(t)):new p(t)};d.prototype.set=function(t){return this.hashbuf=t.hashbuf||this.hashbuf,this.endian=t.endian||this.endian,this.privkey=t.privkey||this.privkey,this.pubkey=t.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),this.sig=t.sig||this.sig,this.k=t.k||this.k,this.verified=t.verified||this.verified,this},d.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()},d.prototype.calci=function(){for(var t=0;4>t;t++){this.sig.i=t;var e;try{e=this.toPublicKey()}catch(r){console.error(r);continue}if(e.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")},d.fromString=function(t){var e=JSON.parse(t);return new d(e)},d.prototype.randomK=function(){var t,e=i.getN();do t=n.fromBuffer(a.getRandomBuffer(32));while(!t.lt(e)||!t.gt(n.Zero));return this.k=t,this},d.prototype.deterministicK=function(t){c.isUndefined(t)&&(t=0);var e=new r(32);e.fill(1);var s=new r(32);s.fill(0);var o=this.privkey.bn.toBuffer({size:32});s=f.sha256hmac(r.concat([e,new r([0]),o,this.hashbuf]),s),e=f.sha256hmac(e,s),s=f.sha256hmac(r.concat([e,new r([1]),o,this.hashbuf]),s),e=f.sha256hmac(e,s),e=f.sha256hmac(e,s);for(var a=n.fromBuffer(e),u=i.getN(),h=0;t>h||!a.lt(u)||!a.gt(n.Zero);h++)s=f.sha256hmac(r.concat([e,new r([0])]),s),e=f.sha256hmac(e,s),e=f.sha256hmac(e,s),a=n.fromBuffer(e);return this.k=a,this},d.prototype.toPublicKey=function(){var t=this.sig.i;h.checkArgument(0===t||1===t||2===t||3===t,new Error("i must be equal to 0, 1, 2, or 3"));var e=n.fromBuffer(this.hashbuf),r=this.sig.r,s=this.sig.s,a=1&t,f=t>>1,u=i.getN(),c=i.getG(),d=f?r.add(u):r,p=i.fromX(a,d),l=p.mul(u);if(!l.isInfinity())throw new Error("nR is not a valid curve point");var b=e.neg().mod(u),g=r.invm(u),m=p.mul(s).add(c.mul(b)).mul(g),y=o.fromPoint(m,this.sig.compressed);return y},d.prototype.sigError=function(){if(!u.isBuffer(this.hashbuf)||32!==this.hashbuf.length)return"hashbuf must be a 32 byte buffer";var t=this.sig.r,e=this.sig.s;if(!(t.gt(n.Zero)&&t.lt(i.getN())&&e.gt(n.Zero)&&e.lt(i.getN())))return"r and s not in range";var r=n.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),s=i.getN(),o=e.invm(s),a=o.mul(r).mod(s),f=o.mul(t).mod(s),c=i.getG().mulAdd(a,this.pubkey.point,f);return c.isInfinity()?"p is infinity":0!==c.getX().mod(s).cmp(t)?"Invalid signature":!1},d.toLowS=function(t){return t.gt(n.fromBuffer(new r("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(t=i.getN().sub(t)),t},d.prototype._findSignature=function(t,e){var r,s,o,a,f=i.getN(),u=i.getG(),c=0;do(!this.k||c>0)&&this.deterministicK(c),c++,r=this.k,s=u.mul(r),o=s.x.mod(f),a=r.invm(f).mul(e.add(t.mul(o))).mod(f);while(o.cmp(n.Zero)<=0||a.cmp(n.Zero)<=0);return a=d.toLowS(a),{s:a,r:o}},d.prototype.sign=function(){var t=this.hashbuf,e=this.privkey,r=e.bn;h.checkState(t&&e&&r,new Error("invalid parameters")),h.checkState(u.isBuffer(t)&&32===t.length,new Error("hashbuf must be a 32 byte buffer"));var i=n.fromBuffer(t,this.endian?{endian:this.endian}:void 0),o=this._findSignature(r,i);return o.compressed=this.pubkey.compressed,this.sig=new s(o),this},d.prototype.signRandomK=function(){return this.randomK(),this.sign()},d.prototype.toString=function(){var t={};return this.hashbuf&&(t.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(t.privkey=this.privkey.toString()),this.pubkey&&(t.pubkey=this.pubkey.toString()),this.sig&&(t.sig=this.sig.toString()),this.k&&(t.k=this.k.toString()),JSON.stringify(t)},d.prototype.verify=function(){return this.sigError()?this.verified=!1:this.verified=!0,this},d.sign=function(t,e,r){return d().set({hashbuf:t,endian:r,privkey:e}).sign().sig},d.verify=function(t,e,r,n){return d().set({hashbuf:t,endian:n,sig:e,pubkey:r}).verify().verified},e.exports=d}).call(this,t("buffer").Buffer)},{"../publickey":25,"../util/buffer":43,"../util/preconditions":45,"./bn":6,"./hash":8,"./point":9,"./random":10,"./signature":11,buffer:48,lodash:297}],8:[function(t,e,r){(function(r){"use strict";var n=t("sha512"),i=t("crypto"),s=t("../util/buffer"),o=t("../util/preconditions"),a=e.exports;a.sha1=function(t){return o.checkArgument(s.isBuffer(t)),i.createHash("sha1").update(t).digest()},a.sha1.blocksize=512,a.sha256=function(t){return o.checkArgument(s.isBuffer(t)),i.createHash("sha256").update(t).digest()},a.sha256.blocksize=512,a.sha256sha256=function(t){return o.checkArgument(s.isBuffer(t)),a.sha256(a.sha256(t))},a.ripemd160=function(t){return o.checkArgument(s.isBuffer(t)),i.createHash("ripemd160").update(t).digest()},a.sha256ripemd160=function(t){return o.checkArgument(s.isBuffer(t)),a.ripemd160(a.sha256(t))},a.sha512=function(t){o.checkArgument(s.isBuffer(t));var e=n(t);return new r(e)},a.sha512.blocksize=1024,a.hmac=function(t,e,n){o.checkArgument(s.isBuffer(e)),o.checkArgument(s.isBuffer(n)),o.checkArgument(t.blocksize);var i=t.blocksize/8;if(n.length>i)n=t(n);else if(i>n){var a=new r(i);a.fill(0),n.copy(a),n=a}var f=new r(i);f.fill(92);var u=new r(i);u.fill(54);for(var c=new r(i),h=new r(i),d=0;i>d;d++)c[d]=f[d]^n[d],h[d]=u[d]^n[d];return t(r.concat([c,t(r.concat([h,e]))]))},a.sha256hmac=function(t,e){return a.hmac(a.sha256,t,e)},a.sha512hmac=function(t,e){return a.hmac(a.sha512,t,e)}}).call(this,t("buffer").Buffer)},{"../util/buffer":43,"../util/preconditions":45,buffer:48,crypto:52,sha512:300}],9:[function(t,e,r){(function(r){"use strict";var n=t("./bn"),i=t("../util/buffer"),s=t("elliptic").curves.secp256k1,o=s.curve.point.bind(s.curve),a=s.curve.pointFromX.bind(s.curve),f=function(t,e,r){var n=o(t,e,r);return n.validate(),n};f.prototype=Object.getPrototypeOf(s.curve.point()),f.fromX=function(t,e){var r=a(t,e);return r.validate(),r},f.getG=function(){return s.curve.g},f.getN=function(){return new n(s.curve.n.toArray())},f.prototype._getX=f.prototype.getX,f.prototype.getX=function(){return new n(this._getX().toArray())},f.prototype._getY=f.prototype.getY,f.prototype.getY=function(){return new n(this._getY().toArray())},f.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");if(0===this.getX().cmp(n.Zero)||0===this.getY().cmp(n.Zero))throw new Error("Invalid x,y value for curve, cannot equal 0.");var t=a(this.getY().isOdd(),this.getX());if(0!==t.y.cmp(this.y))throw new Error("Invalid y value for curve.");var e=this.getX().gt(n.Minus1)&&this.getX().lt(f.getN()),r=this.getY().gt(n.Minus1)&&this.getY().lt(f.getN());if(!e||!r)throw new Error("Point does not lie on the curve");if(!this.mul(f.getN()).isInfinity())throw new Error("Point times N must be infinity");return this},f.pointToCompressed=function(t){var e,n=t.getX().toBuffer({size:32}),s=t.getY().toBuffer({size:32}),o=s[s.length-1]%2;return e=new r(o?[3]:[2]),i.concat([e,n])},e.exports=f}).call(this,t("buffer").Buffer)},{"../util/buffer":43,"./bn":6,buffer:48,elliptic:275}],10:[function(t,e,r){(function(r,n){"use strict";function i(){}i.getRandomBuffer=function(t){return r.browser?i.getRandomBufferBrowser(t):i.getRandomBufferNode(t)},i.getRandomBufferNode=function(e){var r=t("crypto");return r.randomBytes(e)},i.getRandomBufferBrowser=function(t){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");if(window.crypto&&window.crypto.getRandomValues)var e=window.crypto;else{if(!window.msCrypto||!window.msCrypto.getRandomValues)throw new Error("window.crypto.getRandomValues not available");var e=window.msCrypto}var r=new Uint8Array(t);e.getRandomValues(r);var i=new n(r);return i},i.getPseudoRandomBuffer=function(t){for(var e,r=4294967296,i=new n(t),s=0;t>=s;s++){var o=Math.floor(s/4),a=s-4*o;0===a?(e=Math.random()*r,i[s]=255&e):i[s]=255&(e>>>=8)}return i},e.exports=i}).call(this,t("_process"),t("buffer").Buffer)},{_process:247,buffer:48,crypto:52}],11:[function(t,e,r){(function(r){"use strict";var n=t("./bn"),i=t("lodash"),s=t("../util/preconditions"),o=t("../util/buffer"),a=t("../util/js"),f=function u(t,e){if(!(this instanceof u))return new u(t,e);if(t instanceof n)this.set({r:t,s:e});else if(t){var r=t;this.set(r)}};f.prototype.set=function(t){return this.r=t.r||this.r||void 0,this.s=t.s||this.s||void 0,this.i="undefined"!=typeof t.i?t.i:this.i,this.compressed="undefined"!=typeof t.compressed?t.compressed:this.compressed,this.nhashtype=t.nhashtype||this.nhashtype||void 0,this},f.fromCompact=function(t){s.checkArgument(o.isBuffer(t),"Argument is expected to be a Buffer");var e=new f,r=!0,i=t.slice(0,1)[0]-27-4;0>i&&(r=!1,i+=4);var a=t.slice(1,33),u=t.slice(33,65);return s.checkArgument(0===i||1===i||2===i||3===i,new Error("i must be 0, 1, 2, or 3")),s.checkArgument(32===a.length,new Error("r must be 32 bytes")),s.checkArgument(32===u.length,new Error("s must be 32 bytes")),e.compressed=r,e.i=i,e.r=n.fromBuffer(a),e.s=n.fromBuffer(u),e},f.fromDER=f.fromBuffer=function(t,e){var r=f.parseDER(t,e),n=new f;return n.r=r.r,n.s=r.s,n},f.fromTxFormat=function(t){var e=t.readUInt8(t.length-1),r=t.slice(0,t.length-1),n=new f.fromDER(r,!1);return n.nhashtype=e,n},f.fromString=function(t){var e=new r(t,"hex");return f.fromDER(e)},f.parseDER=function(t,e){s.checkArgument(o.isBuffer(t),new Error("DER formatted signature should be a buffer")),i.isUndefined(e)&&(e=!0);var r=t[0];s.checkArgument(48===r,new Error("Header byte should be 0x30"));var a=t[1],f=t.slice(2).length;s.checkArgument(!e||a===f,new Error("Length byte should length of what follows")),a=f>a?a:f;var u=t[2];s.checkArgument(2===u,new Error("Integer byte for r should be 0x02"));var c=t[3],h=t.slice(4,4+c),d=n.fromBuffer(h),p=0===t[4]?!0:!1;s.checkArgument(c===h.length,new Error("Length of r incorrect"));var l=t[4+c+0];s.checkArgument(2===l,new Error("Integer byte for s should be 0x02"));var b=t[4+c+1],g=t.slice(4+c+2,4+c+2+b),m=n.fromBuffer(g),y=0===t[4+c+2+2]?!0:!1;s.checkArgument(b===g.length,new Error("Length of s incorrect"));var v=4+c+2+b;s.checkArgument(a===v-2,new Error("Length of signature incorrect"));var _={header:r,length:a,rheader:u,rlength:c,rneg:p,rbuf:h,r:d,sheader:l,slength:b,sneg:y,sbuf:g,s:m};return _},f.prototype.toCompact=function(t,e){if(t="number"==typeof t?t:this.i,e="boolean"==typeof e?e:this.compressed,0!==t&&1!==t&&2!==t&&3!==t)throw new Error("i must be equal to 0, 1, 2, or 3");var n=t+27+4;e===!1&&(n-=4);var i=new r([n]),s=this.r.toBuffer({size:32}),o=this.s.toBuffer({size:32});return r.concat([i,s,o])},f.prototype.toBuffer=f.prototype.toDER=function(){var t=this.r.toBuffer(),e=this.s.toBuffer(),n=128&t[0]?!0:!1,i=128&e[0]?!0:!1,s=n?r.concat([new r([0]),t]):t,o=i?r.concat([new r([0]),e]):e,a=s.length,f=o.length,u=2+a+2+f,c=2,h=2,d=48,p=r.concat([new r([d,u,c,a]),s,new r([h,f]),o]);return p},f.prototype.toString=function(){var t=this.toDER();return t.toString("hex")},f.isTxDER=function(t){if(t.length<9)return!1;if(t.length>73)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-3)return!1;var e=t[3];if(5+e>=t.length)return!1;var r=t[5+e];if(e+r+7!==t.length)return!1;var n=t.slice(4);if(2!==t[2])return!1;if(0===e)return!1;if(128&n[0])return!1;if(e>1&&0===n[0]&&!(128&n[1]))return!1;var i=t.slice(6+e);return 2!==t[6+e-2]?!1:0===r?!1:128&i[0]?!1:r>1&&0===i[0]&&!(128&i[1])?!1:!0},f.prototype.hasLowS=function(){return this.s.lt(new n(1))||this.s.gt(new n("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex"))?!1:!0},f.prototype.hasDefinedHashtype=function(){if(!a.isNaturalNumber(this.nhashtype))return!1;var t=this.nhashtype&~f.SIGHASH_ANYONECANPAY;return tf.SIGHASH_SINGLE?!1:!0},f.prototype.toTxFormat=function(){var t=this.toDER(),e=new r(1);return e.writeUInt8(this.nhashtype,0),r.concat([t,e])},f.SIGHASH_ALL=1,f.SIGHASH_NONE=2,f.SIGHASH_SINGLE=3,f.SIGHASH_ANYONECANPAY=128,e.exports=f}).call(this,t("buffer").Buffer)},{"../util/buffer":43,"../util/js":44,"../util/preconditions":45,"./bn":6,buffer:48,lodash:297}],12:[function(t,e,r){(function(r){"use strict";var n=t("lodash"),i=t("bs58"),s=t("buffer"),o="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),a=function f(t){if(!(this instanceof f))return new f(t);if(r.isBuffer(t)){var e=t;this.fromBuffer(e)}else if("string"==typeof t){var n=t;this.fromString(n)}else t&&this.set(t)};a.validCharacters=function(t){return s.Buffer.isBuffer(t)&&(t=t.toString()),n.all(n.map(t,function(t){return n.contains(o,t)}))},a.prototype.set=function(t){return this.buf=t.buf||this.buf||void 0,this},a.encode=function(t){if(!s.Buffer.isBuffer(t))throw new Error("Input should be a buffer");return i.encode(t)},a.decode=function(t){if("string"!=typeof t)throw new Error("Input should be a string");return new r(i.decode(t))},a.prototype.fromBuffer=function(t){ +return this.buf=t,this},a.prototype.fromString=function(t){var e=a.decode(t);return this.buf=e,this},a.prototype.toBuffer=function(){return this.buf},a.prototype.toString=function(){return a.encode(this.buf)},e.exports=a}).call(this,t("buffer").Buffer)},{bs58:273,buffer:48,lodash:297}],13:[function(t,e,r){(function(r){"use strict";var n=t("lodash"),i=t("./base58"),s=t("buffer"),o=t("../crypto/hash").sha256sha256,a=function f(t){if(!(this instanceof f))return new f(t);if(r.isBuffer(t)){var e=t;this.fromBuffer(e)}else if("string"==typeof t){var n=t;this.fromString(n)}else t&&this.set(t)};a.prototype.set=function(t){return this.buf=t.buf||this.buf||void 0,this},a.validChecksum=function(t,e){return n.isString(t)&&(t=new s.Buffer(i.decode(t))),n.isString(e)&&(e=new s.Buffer(i.decode(e))),e||(e=t.slice(-4),t=t.slice(0,-4)),a.checksum(t).toString("hex")===e.toString("hex")},a.decode=function(t){if("string"!=typeof t)throw new Error("Input must be a string");var e=new r(i.decode(t));if(e.length<4)throw new Error("Input string too short");var n=e.slice(0,-4),s=e.slice(-4),a=o(n),f=a.slice(0,4);if(s.toString("hex")!==f.toString("hex"))throw new Error("Checksum mismatch");return n},a.checksum=function(t){return o(t).slice(0,4)},a.encode=function(t){if(!r.isBuffer(t))throw new Error("Input must be a buffer");var e=new r(t.length+4),n=a.checksum(t);return t.copy(e),n.copy(e,t.length),i.encode(e)},a.prototype.fromBuffer=function(t){return this.buf=t,this},a.prototype.fromString=function(t){var e=a.decode(t);return this.buf=e,this},a.prototype.toBuffer=function(){return this.buf},a.prototype.toString=function(){return a.encode(this.buf)},e.exports=a}).call(this,t("buffer").Buffer)},{"../crypto/hash":8,"./base58":12,buffer:48,lodash:297}],14:[function(t,e,r){(function(r){"use strict";var n=t("lodash"),i=t("../util/preconditions"),s=t("../util/buffer"),o=t("../crypto/bn"),a=function f(t){if(!(this instanceof f))return new f(t);if(!n.isUndefined(t))if(r.isBuffer(t))this.set({buf:t});else if(n.isString(t))this.set({buf:new r(t,"hex")});else{if(!n.isObject(t))throw new TypeError("Unrecognized argument for BufferReader");var e=t;this.set(e)}};a.prototype.set=function(t){return this.buf=t.buf||this.buf||void 0,this.pos=t.pos||this.pos||0,this},a.prototype.eof=function(){return this.pos>=this.buf.length},a.prototype.finished=a.prototype.eof,a.prototype.read=function(t){i.checkArgument(!n.isUndefined(t),"Must specify a length");var e=this.buf.slice(this.pos,this.pos+t);return this.pos=this.pos+t,e},a.prototype.readAll=function(){var t=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,t},a.prototype.readUInt8=function(){var t=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,t},a.prototype.readUInt16BE=function(){var t=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,t},a.prototype.readUInt16LE=function(){var t=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,t},a.prototype.readUInt32BE=function(){var t=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,t},a.prototype.readUInt32LE=function(){var t=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,t},a.prototype.readUInt64BEBN=function(){var t=this.buf.slice(this.pos,this.pos+8),e=o.fromBuffer(t);return this.pos=this.pos+8,e},a.prototype.readUInt64LEBN=function(){var t,e=this.buf.readUInt32LE(this.pos),r=this.buf.readUInt32LE(this.pos+4),n=4294967296*r+e;if(9007199254740991>=n)t=new o(n);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);t=new o(i,10,"le")}return this.pos=this.pos+8,t},a.prototype.readVarintNum=function(){var t=this.readUInt8();switch(t){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var e=this.readUInt64LEBN(),r=e.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return t}},a.prototype.readVarLengthBuffer=function(){var t=this.readVarintNum(),e=this.read(t);return i.checkState(e.length===t,"Invalid length while reading varlength buffer. Expected to read: "+t+" and read "+e.length),e},a.prototype.readVarintBuf=function(){var t=this.buf.readUInt8(this.pos);switch(t){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}},a.prototype.readVarintBN=function(){var t=this.readUInt8();switch(t){case 253:return new o(this.readUInt16LE());case 254:return new o(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new o(t)}},a.prototype.reverse=function(){for(var t=new r(this.buf.length),e=0;et?(e=new r(1),e.writeUInt8(t,0)):65536>t?(e=new r(3),e.writeUInt8(253,0),e.writeUInt16LE(t,1)):4294967296>t?(e=new r(5),e.writeUInt8(254,0),e.writeUInt32LE(t,1)):(e=new r(9),e.writeUInt8(255,0),e.writeInt32LE(-1&t,1),e.writeUInt32LE(Math.floor(t/4294967296),5)),e},s.varintBufBN=function(t){var e=void 0,n=t.toNumber();if(253>n)e=new r(1),e.writeUInt8(n,0);else if(65536>n)e=new r(3),e.writeUInt8(253,0),e.writeUInt16LE(n,1);else if(4294967296>n)e=new r(5),e.writeUInt8(254,0),e.writeUInt32LE(n,1);else{var i=new s;i.writeUInt8(255),i.writeUInt64LEBN(t);var e=i.concat()}return e},e.exports=s}).call(this,t("buffer").Buffer)},{"../util/buffer":43,assert:46,buffer:48}],16:[function(t,e,r){(function(r){"use strict";var n=t("./bufferwriter"),i=t("./bufferreader"),s=t("../crypto/bn"),o=function a(t){if(!(this instanceof a))return new a(t);if(r.isBuffer(t))this.buf=t;else if("number"==typeof t){var e=t;this.fromNumber(e)}else if(t instanceof s){var n=t;this.fromBN(n)}else if(t){var i=t;this.set(i)}};o.prototype.set=function(t){return this.buf=t.buf||this.buf,this},o.prototype.fromString=function(t){return this.set({buf:new r(t,"hex")}),this},o.prototype.toString=function(){return this.buf.toString("hex")},o.prototype.fromBuffer=function(t){return this.buf=t,this},o.prototype.fromBufferReader=function(t){return this.buf=t.readVarintBuf(),this},o.prototype.fromBN=function(t){return this.buf=n().writeVarintBN(t).concat(),this},o.prototype.fromNumber=function(t){return this.buf=n().writeVarintNum(t).concat(),this},o.prototype.toBuffer=function(){return this.buf},o.prototype.toBN=function(){return i(this.buf).readVarintBN()},o.prototype.toNumber=function(){return i(this.buf).readVarintNum()},e.exports=o}).call(this,t("buffer").Buffer)},{"../crypto/bn":6,"./bufferreader":14,"./bufferwriter":15,buffer:48}],17:[function(t,e,r){"use strict";function n(t,e){return t.replace("{0}",e[0]).replace("{1}",e[1]).replace("{2}",e[2])}var i=t("lodash"),s=function(t,e){var r=function(){if(i.isString(e.message))this.message=n(e.message,arguments);else{if(!i.isFunction(e.message))throw new Error("Invalid error definition for "+e.name);this.message=e.message.apply(null,arguments)}this.stack=this.message+"\n"+(new Error).stack};return r.prototype=Object.create(t.prototype),r.prototype.name=t.prototype.name+e.name,t[e.name]=r,e.errors&&o(r,e.errors),r},o=function(t,e){i.each(e,function(e){s(t,e)})},a=function(t,e){return o(t,e),t},f={};f.Error=function(){this.message="Internal error",this.stack=this.message+"\n"+(new Error).stack},f.Error.prototype=Object.create(Error.prototype),f.Error.prototype.name="bitcore.Error";var u=t("./spec");a(f.Error,u),e.exports=f.Error,e.exports.extend=function(t){return s(f.Error,t)}},{"./spec":18,lodash:297}],18:[function(t,e,r){"use strict";var n="http://bitcore.io/";e.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+n+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]},{}],19:[function(t,e,r){"use strict";e.exports={_cache:{},_count:0,_eraseIndex:0,_usedList:{},_usedIndex:{},_CACHE_SIZE:5e3,get:function(t,e,r){r=!!r;var n=t+"/"+e+"/"+r;return this._cache[n]?(this._cacheHit(n),this._cache[n]):void 0},set:function(t,e,r,n){r=!!r;var i=t+"/"+e+"/"+r;this._cache[i]=n,this._cacheHit(i)},_cacheHit:function(t){this._usedIndex[t]&&delete this._usedList[this._usedIndex[t]],this._usedList[this._count]=t,this._usedIndex[t]=this._count,this._count++,this._cacheRemove()},_cacheRemove:function(){for(;this._eraseIndex=0&&t=n.Hardened?!0:e,tI*S)throw new y.InvalidEntropyArgument.TooMuchEntropy(t);var i=h.sha512hmac(t,new s.Buffer("Bitcoin seed"));return new n({network:d.get(e)||d.defaultNetwork,depth:0,parentFingerPrint:0,childIndex:0,privateKey:i.slice(0,32),chainCode:i.slice(32,64)})},n.prototype._calcHDPublicKey=function(){if(!this._hdPublicKey){var e=t("./hdpublickey");this._hdPublicKey=new e(this)}},n.prototype._buildFromBuffers=function(t){n._validateBufferArguments(t),_.defineImmutable(this,{_buffers:t});var e=[t.version,t.depth,t.parentFingerPrint,t.childIndex,t.chainCode,v.emptyBuffer(1),t.privateKey],i=s.Buffer.concat(e);if(t.checksum&&t.checksum.length){if(t.checksum.toString()!==c.checksum(i).toString())throw new m.InvalidB58Checksum(i)}else t.checksum=c.checksum(i);var o,a=d.get(v.integerFromBuffer(t.version));o=c.encode(s.Buffer.concat(e)),t.xprivkey=new r(o);var u=new b(f.fromBuffer(t.privateKey),a),p=u.toPublicKey(),l=n.ParentFingerPrintSize,g=h.sha256ripemd160(p.toBuffer()).slice(0,l);return _.defineImmutable(this,{xprivkey:o,network:a,depth:v.integerFromSingleByteBuffer(t.depth),privateKey:u,publicKey:p,fingerPrint:g}),this._hdPublicKey=null,Object.defineProperty(this,"hdPublicKey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey}}),Object.defineProperty(this,"xpubkey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey.xpubkey}}),this},n._validateBufferArguments=function(t){var e=function(e,r){var n=t[e];i(v.isBuffer(n),e+" argument is not a buffer"),i(n.length===r,e+" has not the expected size: found "+n.length+", expected "+r)};e("version",n.VersionSize),e("depth",n.DepthSize),e("parentFingerPrint",n.ParentFingerPrintSize),e("childIndex",n.ChildIndexSize),e("chainCode",n.ChainCodeSize),e("privateKey",n.PrivateKeySize),t.checksum&&t.checksum.length&&e("checksum",n.CheckSumSize)},n.prototype.toString=function(){return this.xprivkey},n.prototype.inspect=function(){return""},n.prototype.toObject=n.prototype.toJSON=function(){return{network:d.get(v.integerFromBuffer(this._buffers.version),"xprivkey").name,depth:v.integerFromSingleByteBuffer(this._buffers.depth),fingerPrint:v.integerFromBuffer(this.fingerPrint),parentFingerPrint:v.integerFromBuffer(this._buffers.parentFingerPrint),childIndex:v.integerFromBuffer(this._buffers.childIndex),chainCode:v.bufferToHex(this._buffers.chainCode),privateKey:this.privateKey.toBuffer().toString("hex"),checksum:v.integerFromBuffer(this._buffers.checksum),xprivkey:this.xprivkey}},n.fromBuffer=function(t){return new n(t.toString())},n.prototype.toBuffer=function(){return v.copy(this._buffers.xprivkey)},n.DefaultDepth=0,n.DefaultFingerprint=0,n.DefaultChildIndex=0,n.Hardened=2147483648,n.MaxIndex=2*n.Hardened,n.RootElementAlias=["m","M","m'","M'"],n.VersionSize=4,n.DepthSize=1,n.ParentFingerPrintSize=4,n.ChildIndexSize=4,n.ChainCodeSize=32,n.PrivateKeySize=32,n.CheckSumSize=4,n.DataLength=78,n.SerializedByteSize=82,n.VersionStart=0,n.VersionEnd=n.VersionStart+n.VersionSize,n.DepthStart=n.VersionEnd,n.DepthEnd=n.DepthStart+n.DepthSize,n.ParentFingerPrintStart=n.DepthEnd,n.ParentFingerPrintEnd=n.ParentFingerPrintStart+n.ParentFingerPrintSize,n.ChildIndexStart=n.ParentFingerPrintEnd,n.ChildIndexEnd=n.ChildIndexStart+n.ChildIndexSize,n.ChainCodeStart=n.ChildIndexEnd,n.ChainCodeEnd=n.ChainCodeStart+n.ChainCodeSize,n.PrivateKeyStart=n.ChainCodeEnd+1,n.PrivateKeyEnd=n.PrivateKeyStart+n.PrivateKeySize,n.ChecksumStart=n.PrivateKeyEnd,n.ChecksumEnd=n.ChecksumStart+n.CheckSumSize,i(n.ChecksumEnd===n.SerializedByteSize),e.exports=n}).call(this,t("buffer").Buffer)},{"./crypto/bn":6,"./crypto/hash":8,"./crypto/point":9,"./crypto/random":10,"./encoding/base58":12,"./encoding/base58check":13,"./errors":17,"./hdkeycache":19,"./hdpublickey":21,"./networks":22,"./privatekey":24,"./util/buffer":43,"./util/js":44,"./util/preconditions":45,assert:46,buffer:48,lodash:297}],21:[function(t,e,r){(function(r){"use strict";function n(t){if(t instanceof n)return t;if(!(this instanceof n))return new n(t);if(t){if(i.isString(t)||_.isBuffer(t)){var e=n.getSerializedError(t);if(e){if(_.isBuffer(t)&&!n.getSerializedError(t.toString()))return this._buildFromSerialized(t.toString());if(e instanceof m.ArgumentIsPrivateExtended)return new c(t).hdPublicKey;throw e}return this._buildFromSerialized(t)}if(i.isObject(t))return t instanceof c?this._buildFromPrivate(t):this._buildFromObject(t);throw new m.UnrecognizedArgument(t)}throw new m.MustSupplyArgument}var i=t("lodash"),s=t("./util/preconditions"),o=t("./crypto/bn"),a=t("./encoding/base58"),f=t("./encoding/base58check"),u=t("./crypto/hash"),c=t("./hdprivatekey"),h=t("./hdkeycache"),d=t("./networks"),p=t("./crypto/point"),l=t("./publickey"),b=t("./errors"),g=b,m=b.HDPublicKey,y=t("assert"),v=t("./util/js"),_=t("./util/buffer");n.isValidPath=function(t){if(i.isString(t)){var e=c._getDerivationIndexes(t);return null!==e&&i.all(e,n.isValidPath)}return i.isNumber(t)?t>=0&&t=n.Hardened||e)throw new m.InvalidIndexCantDeriveHardened;if(0>t)throw new m.InvalidPath(t);var r=h.get(this.xpubkey,t,!1);if(r)return r;var i=_.integerAsBuffer(t),s=_.concat([this.publicKey.toBuffer(),i]),a=u.sha512hmac(s,this._buffers.chainCode),f=o.fromBuffer(a.slice(0,32),{size:32}),c=a.slice(32,64),d=l.fromPoint(p.getG().mul(f).add(this.publicKey.point)),b=new n({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:t,chainCode:c,publicKey:d});return h.set(this.xpubkey,t,!1,b),b},n.prototype._deriveFromString=function(t){if(i.contains(t,"'"))throw new m.InvalidIndexCantDeriveHardened;if(!n.isValidPath(t))throw new m.InvalidPath(t);var e=c._getDerivationIndexes(t),r=e.reduce(function(t,e){return t._deriveWithNumber(e)},this);return r},n.isValidSerialized=function(t,e){return i.isNull(n.getSerializedError(t,e))},n.getSerializedError=function(t,e){if(!i.isString(t)&&!_.isBuffer(t))return new m.UnrecognizedArgument("expected buffer or string");if(!a.validCharacters(t))return new g.InvalidB58Char("(unknown)",t);try{t=f.decode(t)}catch(r){return new g.InvalidB58Checksum(t)}if(t.length!==n.DataSize)return new m.InvalidLength(t);if(!i.isUndefined(e)){var s=n._validateNetwork(t,e);if(s)return s}var o=_.integerFromBuffer(t.slice(0,4));return o===d.livenet.xprivkey||o===d.testnet.xprivkey?new m.ArgumentIsPrivateExtended:null},n._validateNetwork=function(t,e){var r=d.get(e);if(!r)return new g.InvalidNetworkArgument(e);var i=t.slice(n.VersionStart,n.VersionEnd);return _.integerFromBuffer(i)!==r.xpubkey?new g.InvalidNetwork(i):null},n.prototype._buildFromPrivate=function(t){var e=i.clone(t._buffers),r=p.getG().mul(o.fromBuffer(e.privateKey));return e.publicKey=p.pointToCompressed(r),e.version=_.integerAsBuffer(d.get(_.integerFromBuffer(e.version)).xpubkey),e.privateKey=void 0,e.checksum=void 0,e.xprivkey=void 0,this._buildFromBuffers(e)},n.prototype._buildFromObject=function(t){var e={version:t.network?_.integerAsBuffer(d.get(t.network).xpubkey):t.version,depth:i.isNumber(t.depth)?_.integerAsSingleByteBuffer(t.depth):t.depth,parentFingerPrint:i.isNumber(t.parentFingerPrint)?_.integerAsBuffer(t.parentFingerPrint):t.parentFingerPrint,childIndex:i.isNumber(t.childIndex)?_.integerAsBuffer(t.childIndex):t.childIndex,chainCode:i.isString(t.chainCode)?_.hexToBuffer(t.chainCode):t.chainCode,publicKey:i.isString(t.publicKey)?_.hexToBuffer(t.publicKey):_.isBuffer(t.publicKey)?t.publicKey:t.publicKey.toBuffer(),checksum:i.isNumber(t.checksum)?_.integerAsBuffer(t.checksum):t.checksum};return this._buildFromBuffers(e)},n.prototype._buildFromSerialized=function(t){var e=f.decode(t),r={version:e.slice(n.VersionStart,n.VersionEnd),depth:e.slice(n.DepthStart,n.DepthEnd),parentFingerPrint:e.slice(n.ParentFingerPrintStart,n.ParentFingerPrintEnd),childIndex:e.slice(n.ChildIndexStart,n.ChildIndexEnd),chainCode:e.slice(n.ChainCodeStart,n.ChainCodeEnd),publicKey:e.slice(n.PublicKeyStart,n.PublicKeyEnd),checksum:e.slice(n.ChecksumStart,n.ChecksumEnd),xpubkey:t};return this._buildFromBuffers(r)},n.prototype._buildFromBuffers=function(t){n._validateBufferArguments(t),v.defineImmutable(this,{_buffers:t});var e=[t.version,t.depth,t.parentFingerPrint,t.childIndex,t.chainCode,t.publicKey],i=_.concat(e),s=f.checksum(i);if(t.checksum&&t.checksum.length){if(t.checksum.toString("hex")!==s.toString("hex"))throw new g.InvalidB58Checksum(i,s)}else t.checksum=s;var o,a=d.get(_.integerFromBuffer(t.version));o=f.encode(_.concat(e)),t.xpubkey=new r(o);var c=new l(t.publicKey,{network:a}),h=n.ParentFingerPrintSize,p=u.sha256ripemd160(c.toBuffer()).slice(0,h);return v.defineImmutable(this,{xpubkey:o,network:a,depth:_.integerFromSingleByteBuffer(t.depth),publicKey:c,fingerPrint:p}),this},n._validateBufferArguments=function(t){var e=function(e,r){var n=t[e];y(_.isBuffer(n),e+" argument is not a buffer, it's "+typeof n),y(n.length===r,e+" has not the expected size: found "+n.length+", expected "+r)};e("version",n.VersionSize),e("depth",n.DepthSize),e("parentFingerPrint",n.ParentFingerPrintSize),e("childIndex",n.ChildIndexSize),e("chainCode",n.ChainCodeSize),e("publicKey",n.PublicKeySize),t.checksum&&t.checksum.length&&e("checksum",n.CheckSumSize)},n.fromString=function(t){return s.checkArgument(i.isString(t),"No valid string was provided"),new n(t)},n.fromObject=function(t){return s.checkArgument(i.isObject(t),"No valid argument was provided"),new n(t)},n.prototype.toString=function(){return this.xpubkey},n.prototype.inspect=function(){return""},n.prototype.toObject=n.prototype.toJSON=function(){return{network:d.get(_.integerFromBuffer(this._buffers.version)).name,depth:_.integerFromSingleByteBuffer(this._buffers.depth),fingerPrint:_.integerFromBuffer(this.fingerPrint),parentFingerPrint:_.integerFromBuffer(this._buffers.parentFingerPrint),childIndex:_.integerFromBuffer(this._buffers.childIndex),chainCode:_.bufferToHex(this._buffers.chainCode),publicKey:this.publicKey.toString(),checksum:_.integerFromBuffer(this._buffers.checksum),xpubkey:this.xpubkey}},n.fromBuffer=function(t){return new n(t)},n.prototype.toBuffer=function(){return _.copy(this._buffers.xpubkey)},n.Hardened=2147483648,n.RootElementAlias=["m","M"],n.VersionSize=4,n.DepthSize=1,n.ParentFingerPrintSize=4,n.ChildIndexSize=4,n.ChainCodeSize=32,n.PublicKeySize=33,n.CheckSumSize=4,n.DataSize=78,n.SerializedByteSize=82,n.VersionStart=0,n.VersionEnd=n.VersionStart+n.VersionSize,n.DepthStart=n.VersionEnd,n.DepthEnd=n.DepthStart+n.DepthSize,n.ParentFingerPrintStart=n.DepthEnd,n.ParentFingerPrintEnd=n.ParentFingerPrintStart+n.ParentFingerPrintSize,n.ChildIndexStart=n.ParentFingerPrintEnd,n.ChildIndexEnd=n.ChildIndexStart+n.ChildIndexSize,n.ChainCodeStart=n.ChildIndexEnd,n.ChainCodeEnd=n.ChainCodeStart+n.ChainCodeSize,n.PublicKeyStart=n.ChainCodeEnd,n.PublicKeyEnd=n.PublicKeyStart+n.PublicKeySize,n.ChecksumStart=n.PublicKeyEnd,n.ChecksumEnd=n.ChecksumStart+n.CheckSumSize,y(n.PublicKeyEnd===n.DataSize),y(n.ChecksumEnd===n.SerializedByteSize),e.exports=n}).call(this,t("buffer").Buffer)},{"./crypto/bn":6,"./crypto/hash":8,"./crypto/point":9,"./encoding/base58":12,"./encoding/base58check":13,"./errors":17,"./hdkeycache":19,"./hdprivatekey":20,"./networks":22,"./publickey":25,"./util/buffer":43,"./util/js":44,"./util/preconditions":45,assert:46,buffer:48,lodash:297}],22:[function(t,e,r){"use strict";function n(){}function i(t,e){if(~d.indexOf(t))return t;{if(!e)return p[t];u.isArray(e)||(e=[e]);var r=function(e){return d[n][e]===t};for(var n in d)if(u.any(e,r))return d[n]}}function s(t){var e=new n;return h.defineImmutable(e,{name:t.name,alias:t.alias,pubkeyhash:t.pubkeyhash,privatekey:t.privatekey,scripthash:t.scripthash,xpubkey:t.xpubkey,xprivkey:t.xprivkey}),t.networkMagic&&h.defineImmutable(e,{networkMagic:c.integerAsBuffer(t.networkMagic)}),t.port&&h.defineImmutable(e,{port:t.port}),t.dnsSeeds&&h.defineImmutable(e,{dnsSeeds:t.dnsSeeds}),u.each(e,function(t){u.isUndefined(t)||u.isObject(t)||(p[t]=e)}),d.push(e),e}function o(t){for(var e=0;e=0&&16>=t,"Invalid Argument: n must be between 0 and 16"),0===t?n("OP_0"):new n(n.map.OP_1+t-1)},n.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},n.reverseMap=[];for(var f in n.map)n.reverseMap[n.map[f]]=f;i.extend(n,n.map),n.isSmallIntOp=function(t){return t instanceof n&&(t=t.toNumber()),t===n.map.OP_0||t>=n.map.OP_1&&t<=n.map.OP_16},n.prototype.inspect=function(){return""},e.exports=n}).call(this,t("buffer").Buffer)},{"./util/buffer":43,"./util/js":44,"./util/preconditions":45,buffer:48,lodash:297}],24:[function(t,e,r){(function(r){"use strict";function n(t,e){if(!(this instanceof n))return new n(t,e);if(t instanceof n)return t;var r=this._classifyArguments(t,e);if(!r.bn||0===r.bn.cmp(new a(0)))throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(c.getN()))throw new TypeError("Number must be less than N");if("undefined"==typeof r.network)throw new TypeError('Must specify the network ("livenet" or "testnet")');return f.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}var i=t("lodash"),s=t("./address"),o=t("./encoding/base58check"),a=t("./crypto/bn"),f=t("./util/js"),u=t("./networks"),c=t("./crypto/point"),h=t("./publickey"),d=t("./crypto/random"),p=t("./util/preconditions");n.prototype._classifyArguments=function(t,e){var s={compressed:!0,network:e?u.get(e):u.defaultNetwork};if(i.isUndefined(t)||i.isNull(t))s.bn=n._getRandomBN();else if(t instanceof a)s.bn=t;else if(t instanceof r||t instanceof Uint8Array)s=n._transformBuffer(t,e);else if(t.bn&&t.network)s=n._transformObject(t);else if(!e&&u.get(t))s.bn=n._getRandomBN(),s.network=u.get(t);else{if("string"!=typeof t)throw new TypeError("First argument is an unrecognized data type.");f.isHexa(t)?s.bn=new a(new r(t,"hex")):s=n._transformWIF(t,e)}return s},n._getRandomBN=function(){var t,e;do{var r=d.getRandomBuffer(32);e=a.fromBuffer(r),t=e.lt(c.getN())}while(!t);return e},n._transformBuffer=function(t,e){var r={};if(32===t.length)return n._transformBNBuffer(t,e);if(r.network=u.get(t[0],"privatekey"),!r.network)throw new Error("Invalid network");if(e&&r.network!==u.get(e))throw new TypeError("Private key network mismatch");if(34===t.length&&1===t[33])r.compressed=!0;else{if(33!==t.length)throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");r.compressed=!1}return r.bn=a.fromBuffer(t.slice(1,33)),r},n._transformBNBuffer=function(t,e){var r={};return r.network=u.get(e)||u.defaultNetwork,r.bn=a.fromBuffer(t),r.compressed=!1,r},n._transformWIF=function(t,e){return n._transformBuffer(o.decode(t),e)},n.fromBuffer=function(t,e){return new n(t,e)},n._transformObject=function(t){var e=new a(t.bn,"hex"),r=u.get(t.network);return{bn:e,network:r,compressed:t.compressed}},n.fromString=n.fromWIF=function(t){return p.checkArgument(i.isString(t),"First argument is expected to be a string."),new n(t)},n.fromObject=function(t){return p.checkArgument(i.isObject(t),"First argument is expected to be an object."),new n(t)},n.fromRandom=function(t){var e=n._getRandomBN();return new n(e,t)},n.getValidationError=function(t,e){var r;try{new n(t,e)}catch(i){r=i}return r},n.isValid=function(t,e){return t?!n.getValidationError(t,e):!1},n.prototype.toString=function(){return this.toBuffer().toString("hex")},n.prototype.toWIF=function(){var t,e=this.network,n=this.compressed;return t=n?r.concat([new r([e.privatekey]),this.bn.toBuffer({size:32}),new r([1])]):r.concat([new r([e.privatekey]),this.bn.toBuffer({size:32})]),o.encode(t)},n.prototype.toBigNumber=function(){return this.bn},n.prototype.toBuffer=function(){return this.bn.toBuffer()},n.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=h.fromPrivateKey(this)),this._pubkey},n.prototype.toAddress=function(t){var e=this.toPublicKey();return s.fromPublicKey(e,t||this.network)},n.prototype.toObject=n.prototype.toJSON=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}},n.prototype.inspect=function(){var t=this.compressed?"":", uncompressed";return""},e.exports=n}).call(this,t("buffer").Buffer)},{"./address":1,"./crypto/bn":6,"./crypto/point":9,"./crypto/random":10,"./encoding/base58check":13,"./networks":22,"./publickey":25,"./util/js":44,"./util/preconditions":45,buffer:48,lodash:297}],25:[function(t,e,r){(function(r){"use strict";function n(t,e){if(!(this instanceof n))return new n(t,e);if(c.checkArgument(t,"First argument is required, please include public key data."),t instanceof n)return t;e=e||{};var r=this._classifyArgs(t,e);return r.point.validate(),a.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||f.defaultNetwork}),this}var i=t("./crypto/bn"),s=t("./crypto/point"),o=t("./crypto/hash"),a=t("./util/js"),f=t("./networks"),u=t("lodash"),c=t("./util/preconditions");n.prototype._classifyArgs=function(t,e){var i={compressed:u.isUndefined(e.compressed)||e.compressed};if(t instanceof s)i.point=t;else if(t.x&&t.y)i=n._transformObject(t);else if("string"==typeof t)i=n._transformDER(new r(t,"hex"));else if(n._isBuffer(t))i=n._transformDER(t);else{if(!n._isPrivateKey(t))throw new TypeError("First argument is an unrecognized data format.");i=n._transformPrivateKey(t)}return i.network||(i.network=u.isUndefined(e.network)?void 0:f.get(e.network)),i},n._isPrivateKey=function(e){var r=t("./privatekey");return e instanceof r},n._isBuffer=function(t){return t instanceof r||t instanceof Uint8Array},n._transformPrivateKey=function(t){c.checkArgument(n._isPrivateKey(t),"Must be an instance of PrivateKey");var e={};return e.point=s.getG().mul(t.bn),e.compressed=t.compressed,e.network=t.network,e},n._transformDER=function(t,e){c.checkArgument(n._isBuffer(t),"Must be a hex buffer of DER encoded public key");var r={};e=u.isUndefined(e)?!0:e;var o,a,f,h;if(4!==t[0]&&(e||6!==t[0]&&7!==t[0]))if(3===t[0])f=t.slice(1),o=new i(f),r=n._transformX(!0,o),r.compressed=!0;else{if(2!==t[0])throw new TypeError("Invalid DER format public key");f=t.slice(1),o=new i(f),r=n._transformX(!1,o),r.compressed=!0}else{if(f=t.slice(1,33),h=t.slice(33,65),32!==f.length||32!==h.length||65!==t.length)throw new TypeError("Length of x and y must be 32 bytes");o=new i(f),a=new i(h),r.point=new s(o,a),r.compressed=!1}return r},n._transformX=function(t,e){c.checkArgument("boolean"==typeof t,"Must specify whether y is odd or not (true or false)");var r={};return r.point=s.fromX(t,e),r},n._transformObject=function(t){var e=new i(t.x,"hex"),r=new i(t.y,"hex"),o=new s(e,r);return new n(o,{compressed:t.compressed})},n.fromPrivateKey=function(t){c.checkArgument(n._isPrivateKey(t),"Must be an instance of PrivateKey");var e=n._transformPrivateKey(t);return new n(e.point,{compressed:e.compressed,network:e.network})},n.fromDER=n.fromBuffer=function(t,e){c.checkArgument(n._isBuffer(t),"Must be a hex buffer of DER encoded public key");var r=n._transformDER(t,e);return new n(r.point,{compressed:r.compressed})},n.fromPoint=function(t,e){return c.checkArgument(t instanceof s,"First argument must be an instance of Point."),new n(t,{compressed:e})},n.fromString=function(t,e){var i=new r(t,e||"hex"),s=n._transformDER(i);return new n(s.point,{compressed:s.compressed})},n.fromX=function(t,e){var r=n._transformX(t,e);return new n(r.point,{compressed:r.compressed})},n.getValidationError=function(t){var e;try{new n(t)}catch(r){e=r}return e},n.isValid=function(t){return!n.getValidationError(t)},n.prototype.toObject=n.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}},n.prototype.toBuffer=n.prototype.toDER=function(){var t,e=this.point.getX(),n=this.point.getY(),i=e.toBuffer({size:32}),s=n.toBuffer({size:32});if(this.compressed){var o=s[s.length-1]%2;return t=new r(o?[3]:[2]),r.concat([t,i])}return t=new r([4]),r.concat([t,i,s])},n.prototype._getID=function(){return o.sha256ripemd160(this.toBuffer())},n.prototype.toAddress=function(e){var r=t("./address");return r.fromPublicKey(this,e||this.network)},n.prototype.toString=function(){return this.toDER().toString("hex")},n.prototype.inspect=function(){return""},e.exports=n}).call(this,t("buffer").Buffer)},{"./address":1,"./crypto/bn":6,"./crypto/hash":8,"./crypto/point":9,"./networks":22,"./privatekey":24,"./util/js":44,"./util/preconditions":45,buffer:48,lodash:297}],26:[function(t,e,r){e.exports=t("./script"),e.exports.Interpreter=t("./interpreter")},{"./interpreter":27,"./script":28}],27:[function(t,e,r){(function(r){"use strict";var n=t("lodash"),i=t("./script"),s=t("../opcode"),o=t("../crypto/bn"),a=t("../crypto/hash"),f=t("../crypto/signature"),u=t("../publickey"),c=function h(t){return this instanceof h?void(t?(this.initialize(),this.set(t)):this.initialize()):new h(t)};c.prototype.verify=function(e,r,s,o,a){var f=t("../transaction");n.isUndefined(s)&&(s=new f),n.isUndefined(o)&&(o=0),n.isUndefined(a)&&(a=0),this.set({script:e,tx:s,nin:o,flags:a});var u;if(0!==(a&c.SCRIPT_VERIFY_SIGPUSHONLY)&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;a&c.SCRIPT_VERIFY_P2SH&&(u=this.stack.slice());var h=this.stack;if(this.initialize(),this.set({script:r,stack:h,tx:s,nin:o,flags:a}),!this.evaluate())return!1;if(0===this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var d=this.stack[this.stack.length-1];if(!c.castToBool(d))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(a&c.SCRIPT_VERIFY_P2SH&&r.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(0===u.length)throw new Error("internal error - stack copy empty");var p=u[u.length-1],l=i.fromBuffer(p);return u.pop(),this.initialize(),this.set({script:l,stack:u,tx:s,nin:o,flags:a}),this.evaluate()?0===u.length?(this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1):c.castToBool(u[u.length-1])?!0:(this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1):!1}return!0},e.exports=c,c.prototype.initialize=function(t){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},c.prototype.set=function(t){this.script=t.script||this.script,this.tx=t.tx||this.tx,this.nin="undefined"!=typeof t.nin?t.nin:this.nin,this.stack=t.stack||this.stack,this.altstack=t.altack||this.altstack,this.pc="undefined"!=typeof t.pc?t.pc:this.pc,this.pbegincodehash="undefined"!=typeof t.pbegincodehash?t.pbegincodehash:this.pbegincodehash,this.nOpCount="undefined"!=typeof t.nOpCount?t.nOpCount:this.nOpCount,this.vfExec=t.vfExec||this.vfExec,this.errstr=t.errstr||this.errstr,this.flags="undefined"!=typeof t.flags?t.flags:this.flags},c["true"]=new r([1]),c["false"]=new r([]),c.MAX_SCRIPT_ELEMENT_SIZE=520,c.LOCKTIME_THRESHOLD=5e8,c.LOCKTIME_THRESHOLD_BN=new o(c.LOCKTIME_THRESHOLD),c.SCRIPT_VERIFY_NONE=0,c.SCRIPT_VERIFY_P2SH=1,c.SCRIPT_VERIFY_STRICTENC=2,c.SCRIPT_VERIFY_DERSIG=4,c.SCRIPT_VERIFY_LOW_S=8,c.SCRIPT_VERIFY_NULLDUMMY=16,c.SCRIPT_VERIFY_SIGPUSHONLY=32,c.SCRIPT_VERIFY_MINIMALDATA=64,c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,c.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,c.castToBool=function(t){for(var e=0;e1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(e){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+e,!1}return this.vfExec.length>0?(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1):!0},c.prototype.checkLockTime=function(t){return this.tx.nLockTime=c.LOCKTIME_THRESHOLD&&t.gte(c.LOCKTIME_THRESHOLD_BN)?t.gt(new o(this.tx.nLockTime))?!1:this.tx.inputs[this.nin].isFinal()?!0:!1:!1},c.prototype.step=function(){var t,e,r,h,d,p,l,b,g,m,y,v,_,w,S,I,k,E=0!==(this.flags&c.SCRIPT_VERIFY_MINIMALDATA),A=-1===this.vfExec.indexOf(!1),x=this.script.chunks[this.pc];this.pc++;var P=x.opcodenum;if(n.isUndefined(P))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(x.buf&&x.buf.length>c.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(P>s.OP_16&&++this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(P===s.OP_CAT||P===s.OP_SUBSTR||P===s.OP_LEFT||P===s.OP_RIGHT||P===s.OP_INVERT||P===s.OP_AND||P===s.OP_OR||P===s.OP_XOR||P===s.OP_2MUL||P===s.OP_2DIV||P===s.OP_MUL||P===s.OP_DIV||P===s.OP_MOD||P===s.OP_LSHIFT||P===s.OP_RSHIFT)return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(A&&P>=0&&P<=s.OP_PUSHDATA4){if(E&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(x.buf){if(x.len!==x.buf.length)throw new Error("Length of push value not equal to length of data");this.stack.push(x.buf)}else this.stack.push(c["false"])}else if(A||s.OP_IF<=P&&P<=s.OP_ENDIF)switch(P){case s.OP_1NEGATE:case s.OP_1:case s.OP_2:case s.OP_3:case s.OP_4:case s.OP_5:case s.OP_6:case s.OP_7:case s.OP_8:case s.OP_9:case s.OP_10:case s.OP_11:case s.OP_12:case s.OP_13:case s.OP_14:case s.OP_15:case s.OP_16:d=P-(s.OP_1-1),t=new o(d).toScriptNumBuffer(),this.stack.push(t);break;case s.OP_NOP:break;case s.OP_NOP2:case s.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&c.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var O=o.fromScriptNumBuffer(this.stack[this.stack.length-1],E,5);if(O.lt(new o(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(O))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case s.OP_NOP1:case s.OP_NOP3:case s.OP_NOP4:case s.OP_NOP5:case s.OP_NOP6:case s.OP_NOP7:case s.OP_NOP8:case s.OP_NOP9:case s.OP_NOP10:if(this.flags&c.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case s.OP_IF:case s.OP_NOTIF:if(I=!1,A){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;t=this.stack.pop(),I=c.castToBool(t),P===s.OP_NOTIF&&(I=!I)}this.vfExec.push(I);break;case s.OP_ELSE:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case s.OP_ENDIF:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case s.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(t=this.stack[this.stack.length-1],I=c.castToBool(t),!I)return this.errstr="SCRIPT_ERR_VERIFY",!1;this.stack.pop();break;case s.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case s.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case s.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case s.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case s.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;e=this.stack[this.stack.length-2],r=this.stack[this.stack.length-1],this.stack.push(e),this.stack.push(r);break;case s.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;e=this.stack[this.stack.length-3],r=this.stack[this.stack.length-2];var B=this.stack[this.stack.length-1];this.stack.push(e),this.stack.push(r),this.stack.push(B);break;case s.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;e=this.stack[this.stack.length-4],r=this.stack[this.stack.length-3],this.stack.push(e),this.stack.push(r);break;case s.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;h=this.stack.splice(this.stack.length-6,2),this.stack.push(h[0]),this.stack.push(h[1]);break;case s.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;h=this.stack.splice(this.stack.length-4,2),this.stack.push(h[0]),this.stack.push(h[1]);break;case s.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;t=this.stack[this.stack.length-1],I=c.castToBool(t),I&&this.stack.push(t);break;case s.OP_DEPTH:t=new o(this.stack.length).toScriptNumBuffer(),this.stack.push(t);break;case s.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case s.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-1]);break;case s.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case s.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-2]);break;case s.OP_PICK:case s.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(t=this.stack[this.stack.length-1],b=o.fromScriptNumBuffer(t,E),d=b.toNumber(),this.stack.pop(),0>d||d>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;t=this.stack[this.stack.length-d-1],P===s.OP_ROLL&&this.stack.splice(this.stack.length-d-1,1),this.stack.push(t);break;case s.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack[this.stack.length-3],l=this.stack[this.stack.length-2];var M=this.stack[this.stack.length-1];this.stack[this.stack.length-3]=l,this.stack[this.stack.length-2]=M,this.stack[this.stack.length-1]=p;break;case s.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack[this.stack.length-2],l=this.stack[this.stack.length-1],this.stack[this.stack.length-2]=l,this.stack[this.stack.length-1]=p;break;case s.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,this.stack[this.stack.length-1]);break;case s.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;b=new o(this.stack[this.stack.length-1].length),this.stack.push(b.toScriptNumBuffer());break;case s.OP_EQUAL:case s.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;e=this.stack[this.stack.length-2],r=this.stack[this.stack.length-1];var R=e.toString("hex")===r.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(R?c["true"]:c["false"]),P===s.OP_EQUALVERIFY){if(!R)return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;this.stack.pop()}break;case s.OP_1ADD:case s.OP_1SUB:case s.OP_NEGATE:case s.OP_ABS:case s.OP_NOT:case s.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(t=this.stack[this.stack.length-1],b=o.fromScriptNumBuffer(t,E),P){case s.OP_1ADD:b=b.add(o.One);break;case s.OP_1SUB:b=b.sub(o.One);break;case s.OP_NEGATE:b=b.neg();break;case s.OP_ABS:b.cmp(o.Zero)<0&&(b=b.neg());break;case s.OP_NOT:b=new o((0===b.cmp(o.Zero))+0);break;case s.OP_0NOTEQUAL:b=new o((0!==b.cmp(o.Zero))+0)}this.stack.pop(),this.stack.push(b.toScriptNumBuffer());break;case s.OP_ADD:case s.OP_SUB:case s.OP_BOOLAND:case s.OP_BOOLOR:case s.OP_NUMEQUAL:case s.OP_NUMEQUALVERIFY:case s.OP_NUMNOTEQUAL:case s.OP_LESSTHAN:case s.OP_GREATERTHAN:case s.OP_LESSTHANOREQUAL:case s.OP_GREATERTHANOREQUAL:case s.OP_MIN:case s.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(g=o.fromScriptNumBuffer(this.stack[this.stack.length-2],E),m=o.fromScriptNumBuffer(this.stack[this.stack.length-1],E),b=new o(0),P){case s.OP_ADD:b=g.add(m);break;case s.OP_SUB:b=g.sub(m);break;case s.OP_BOOLAND:b=new o((0!==g.cmp(o.Zero)&&0!==m.cmp(o.Zero))+0);break;case s.OP_BOOLOR:b=new o((0!==g.cmp(o.Zero)||0!==m.cmp(o.Zero))+0);break;case s.OP_NUMEQUAL:b=new o((0===g.cmp(m))+0);break;case s.OP_NUMEQUALVERIFY:b=new o((0===g.cmp(m))+0);break;case s.OP_NUMNOTEQUAL:b=new o((0!==g.cmp(m))+0);break;case s.OP_LESSTHAN:b=new o((g.cmp(m)<0)+0);break;case s.OP_GREATERTHAN:b=new o((g.cmp(m)>0)+0);break;case s.OP_LESSTHANOREQUAL:b=new o((g.cmp(m)<=0)+0);break;case s.OP_GREATERTHANOREQUAL:b=new o((g.cmp(m)>=0)+0);break;case s.OP_MIN:b=g.cmp(m)<0?g:m;break;case s.OP_MAX:b=g.cmp(m)>0?g:m}if(this.stack.pop(),this.stack.pop(),this.stack.push(b.toScriptNumBuffer()),P===s.OP_NUMEQUALVERIFY){if(!c.castToBool(this.stack[this.stack.length-1]))return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;this.stack.pop()}break;case s.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;g=o.fromScriptNumBuffer(this.stack[this.stack.length-3],E),m=o.fromScriptNumBuffer(this.stack[this.stack.length-2],E);var T=o.fromScriptNumBuffer(this.stack[this.stack.length-1],E);I=m.cmp(g)<=0&&g.cmp(T)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(I?c["true"]:c["false"]);break;case s.OP_RIPEMD160:case s.OP_SHA1:case s.OP_SHA256:case s.OP_HASH160:case s.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;t=this.stack[this.stack.length-1];var C;P===s.OP_RIPEMD160?C=a.ripemd160(t):P===s.OP_SHA1?C=a.sha1(t):P===s.OP_SHA256?C=a.sha256(t):P===s.OP_HASH160?C=a.sha256ripemd160(t):P===s.OP_HASH256&&(C=a.sha256sha256(t)),this.stack.pop(),this.stack.push(C);break;case s.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case s.OP_CHECKSIG:case s.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=this.stack[this.stack.length-2],v=this.stack[this.stack.length-1],_=(new i).set({chunks:this.script.chunks.slice(this.pbegincodehash)});var N=(new i).add(y);if(_.findAndDelete(N),!this.checkSignatureEncoding(y)||!this.checkPubkeyEncoding(v))return!1;try{w=f.fromTxFormat(y),S=u.fromBuffer(v,!1),k=this.tx.verifySignature(w,S,this.nin,_)}catch(j){k=!1}if(this.stack.pop(),this.stack.pop(),this.stack.push(k?c["true"]:c["false"]),P===s.OP_CHECKSIGVERIFY){if(!k)return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;this.stack.pop()}break;case s.OP_CHECKMULTISIG:case s.OP_CHECKMULTISIGVERIFY:var U=1;if(this.stack.lengthL||L>20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=L,this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var D=++U;if(U+=L,this.stack.lengthz||z>L)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var F=++U;if(U+=z,this.stack.lengthK;K++)y=this.stack[this.stack.length-F-K],_.findAndDelete((new i).add(y));for(k=!0;k&&z>0;){if(y=this.stack[this.stack.length-F],v=this.stack[this.stack.length-D],!this.checkSignatureEncoding(y)||!this.checkPubkeyEncoding(v))return!1;var H;try{w=f.fromTxFormat(y),S=u.fromBuffer(v,!1),H=this.tx.verifySignature(w,S,this.nin,_)}catch(j){H=!1}H&&(F++,z--),D++,L--,z>L&&(k=!1)}for(;U-- >1;)this.stack.pop();if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&c.SCRIPT_VERIFY_NULLDUMMY&&this.stack[this.stack.length-1].length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(k?c["true"]:c["false"]),P===s.OP_CHECKMULTISIGVERIFY){if(!k)return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;this.stack.pop()}break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}}).call(this,t("buffer").Buffer)},{"../crypto/bn":6,"../crypto/hash":8,"../crypto/signature":11,"../opcode":23,"../publickey":25,"../transaction":29,"./script":28,buffer:48,lodash:297}],28:[function(t,e,r){(function(r){"use strict";var n=t("../address"),i=t("../encoding/bufferreader"),s=t("../encoding/bufferwriter"),o=t("../crypto/hash"),a=t("../opcode"),f=t("../publickey"),u=t("../crypto/signature"),c=t("../networks"),h=t("../util/preconditions"),d=t("lodash"),p=t("../errors"),l=t("buffer"),b=t("../util/buffer"),g=t("../util/js"),m=function y(t){return this instanceof y?(this.chunks=[],b.isBuffer(t)?y.fromBuffer(t):t instanceof n?y.fromAddress(t):t instanceof y?y.fromBuffer(t.toBuffer()):"string"==typeof t?y.fromString(t):void("undefined"!=typeof t&&this.set(t))):new y(t)};m.prototype.set=function(t){return this.chunks=t.chunks||this.chunks,this},m.fromBuffer=function(t){var e=new m;e.chunks=[];for(var r=new i(t);!r.finished();)try{var n,s,o=r.readUInt8();o>0&&o0&&f0&&(i=n?i+" "+t.buf.toString("hex"):i+" "+t.len+" 0x"+t.buf.toString("hex"));else if("undefined"!=typeof a.reverseMap[r])i=i+" "+a(r).toString();else{ +var s=r.toString(16);s.length%2!==0&&(s="0"+s),i=n?i+" "+s:i+" 0x"+s}return i},m.prototype.toASM=function(){for(var t="",e=0;e"},m.prototype.isPublicKeyHashOut=function(){return!(5!==this.chunks.length||this.chunks[0].opcodenum!==a.OP_DUP||this.chunks[1].opcodenum!==a.OP_HASH160||!this.chunks[2].buf||20!==this.chunks[2].buf.length||this.chunks[3].opcodenum!==a.OP_EQUALVERIFY||this.chunks[4].opcodenum!==a.OP_CHECKSIG)},m.prototype.isPublicKeyHashIn=function(){if(2===this.chunks.length){var t=this.chunks[0].buf,e=this.chunks[1].buf;if(t&&t.length&&48===t[0]&&e&&e.length){var r=e[0];if((4===r||6===r||7===r)&&65===e.length)return!0;if((3===r||2===r)&&33===e.length)return!0}}return!1},m.prototype.getPublicKey=function(){return h.checkState(this.isPublicKeyOut(),"Can't retreive PublicKey from a non-PK output"),this.chunks[0].buf},m.prototype.getPublicKeyHash=function(){return h.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf},m.prototype.isPublicKeyOut=function(){if(2===this.chunks.length&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===a.OP_CHECKSIG){var t=this.chunks[0].buf,e=t[0],r=!1;if(4!==e&&6!==e&&7!==e||65!==t.length?3!==e&&2!==e||33!==t.length||(r=!0):r=!0,r)return f.isValid(t)}return!1},m.prototype.isPublicKeyIn=function(){if(1===this.chunks.length){var t=this.chunks[0].buf;if(t&&t.length&&48===t[0])return!0}return!1},m.prototype.isScriptHashOut=function(){var t=this.toBuffer();return 23===t.length&&t[0]===a.OP_HASH160&&20===t[1]&&t[t.length-1]===a.OP_EQUAL},m.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var t=this.chunks[this.chunks.length-1],e=t.buf;if(!e)return!1;var r;try{r=m.fromBuffer(e)}catch(n){if(n instanceof p.Script.InvalidBuffer)return!1;throw n}var i=r.classify();return i!==m.types.UNKNOWN},m.prototype.isMultisigOut=function(){return this.chunks.length>3&&a.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(t){return t.buf&&b.isBuffer(t.buf)})&&a.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===a.OP_CHECKMULTISIG},m.prototype.isMultisigIn=function(){return this.chunks.length>=2&&0===this.chunks[0].opcodenum&&this.chunks.slice(1,this.chunks.length).every(function(t){return t.buf&&b.isBuffer(t.buf)&&u.isTxDER(t.buf)})},m.prototype.isDataOut=function(){return this.chunks.length>=1&&this.chunks[0].opcodenum===a.OP_RETURN&&(1===this.chunks.length||2===this.chunks.length&&this.chunks[1].buf&&this.chunks[1].buf.length<=m.OP_RETURN_STANDARD_SIZE&&this.chunks[1].length===this.chunks.len)},m.prototype.getData=function(){if(this.isDataOut()||this.isScriptHashOut())return new r(d.isUndefined(this.chunks[1])?0:this.chunks[1].buf);if(this.isPublicKeyHashOut())return new r(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")},m.prototype.isPushOnly=function(){return d.every(this.chunks,function(t){return t.opcodenum<=a.OP_16})},m.types={},m.types.UNKNOWN="Unknown",m.types.PUBKEY_OUT="Pay to public key",m.types.PUBKEY_IN="Spend from public key",m.types.PUBKEYHASH_OUT="Pay to public key hash",m.types.PUBKEYHASH_IN="Spend from public key hash",m.types.SCRIPTHASH_OUT="Pay to script hash",m.types.SCRIPTHASH_IN="Spend from script hash",m.types.MULTISIG_OUT="Pay to multisig",m.types.MULTISIG_IN="Spend from multisig",m.types.DATA_OUT="Data push",m.OP_RETURN_STANDARD_SIZE=80,m.identifiers={},m.identifiers.PUBKEY_OUT=m.prototype.isPublicKeyOut,m.identifiers.PUBKEY_IN=m.prototype.isPublicKeyIn,m.identifiers.PUBKEYHASH_OUT=m.prototype.isPublicKeyHashOut,m.identifiers.PUBKEYHASH_IN=m.prototype.isPublicKeyHashIn,m.identifiers.MULTISIG_OUT=m.prototype.isMultisigOut,m.identifiers.MULTISIG_IN=m.prototype.isMultisigIn,m.identifiers.SCRIPTHASH_OUT=m.prototype.isScriptHashOut,m.identifiers.SCRIPTHASH_IN=m.prototype.isScriptHashIn,m.identifiers.DATA_OUT=m.prototype.isDataOut,m.prototype.classify=function(){for(var t in m.identifiers)if(m.identifiers[t].bind(this)())return m.types[t];return m.types.UNKNOWN},m.prototype.isStandard=function(){return this.classify()!==m.types.UNKNOWN},m.prototype.prepend=function(t){return this._addByType(t,!0),this},m.prototype.equals=function(t){if(h.checkState(t instanceof m,"Must provide another script"),this.chunks.length!==t.chunks.length)return!1;var e;for(e=0;e=0&&n=1&&r[0]<=16?n===a.OP_1+(r[0]-1):1===r.length&&129===r[0]?n===a.OP_1NEGATE:r.length<=75?n===r.length:r.length<=255?n===a.OP_PUSHDATA1:r.length<=65535?n===a.OP_PUSHDATA2:!0:!0},m.prototype._decodeOP_N=function(t){if(t===a.OP_0)return 0;if(t>=a.OP_1&&t<=a.OP_16)return t-(a.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(t))},m.prototype.getSignatureOperationsCount=function(t){t=d.isUndefined(t)?!0:t;var e=this,r=0,n=a.OP_INVALIDOPCODE;return d.each(e.chunks,function(i){var s=i.opcodenum;s==a.OP_CHECKSIG||s==a.OP_CHECKSIGVERIFY?r++:(s==a.OP_CHECKMULTISIG||s==a.OP_CHECKMULTISIGVERIFY)&&(r+=t&&n>=a.OP_1&&n<=a.OP_16?e._decodeOP_N(n):20),n=s}),r},e.exports=m}).call(this,t("buffer").Buffer)},{"../address":1,"../crypto/hash":8,"../crypto/signature":11,"../encoding/bufferreader":14,"../encoding/bufferwriter":15,"../errors":17,"../networks":22,"../opcode":23,"../publickey":25,"../util/buffer":43,"../util/js":44,"../util/preconditions":45,buffer:48,lodash:297}],29:[function(t,e,r){e.exports=t("./transaction"),e.exports.Input=t("./input"),e.exports.Output=t("./output"),e.exports.UnspentOutput=t("./unspentoutput"),e.exports.Signature=t("./signature"),e.exports.Sighash=t("./sighash")},{"./input":30,"./output":36,"./sighash":37,"./signature":38,"./transaction":39,"./unspentoutput":40}],30:[function(t,e,r){e.exports=t("./input"),e.exports.PublicKey=t("./publickey"),e.exports.PublicKeyHash=t("./publickeyhash"),e.exports.MultiSig=t("./multisig.js"),e.exports.MultiSigScriptHash=t("./multisigscripthash.js")},{"./input":31,"./multisig.js":32,"./multisigscripthash.js":33,"./publickey":34,"./publickeyhash":35}],31:[function(t,e,r){"use strict";function n(t){return this instanceof n?t?this._fromObject(t):void 0:new n(t)}var i=t("lodash"),s=t("../../util/preconditions"),o=t("../../errors"),a=t("../../encoding/bufferwriter"),f=t("buffer"),u=t("../../util/buffer"),c=t("../../util/js"),h=t("../../script"),d=t("../sighash"),p=t("../output"),l=4294967295,b=0;n.DEFAULT_SEQNUMBER=l,n.DEFAULT_LOCKTIME_SEQNUMBER=b,Object.defineProperty(n.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new h(this._scriptBuffer),this._script._isInput=!0),this._script)}}),n.fromObject=function(t){s.checkArgument(i.isObject(t));var e=new n;return e._fromObject(t)},n.prototype._fromObject=function(t){var e;if(e=i.isString(t.prevTxId)&&c.isHexa(t.prevTxId)?new f.Buffer(t.prevTxId,"hex"):t.prevTxId,this.output=t.output?t.output instanceof p?t.output:new p(t.output):void 0,this.prevTxId=e||t.txidbuf,this.outputIndex=i.isUndefined(t.outputIndex)?t.txoutnum:t.outputIndex,this.sequenceNumber=i.isUndefined(t.sequenceNumber)?i.isUndefined(t.seqnum)?l:t.seqnum:t.sequenceNumber,i.isUndefined(t.script)&&i.isUndefined(t.scriptBuffer))throw new o.Transaction.Input.MissingScript;return this.setScript(t.scriptBuffer||t.script),this},n.prototype.toObject=n.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t},n.fromBufferReader=function(t){var e=new n;return e.prevTxId=t.readReverse(32),e.outputIndex=t.readUInt32LE(),e._scriptBuffer=t.readVarLengthBuffer(),e.sequenceNumber=t.readUInt32LE(),e},n.prototype.toBufferWriter=function(t){t||(t=new a),t.writeReverse(this.prevTxId),t.writeUInt32LE(this.outputIndex);var e=this._scriptBuffer;return t.writeVarintNum(e.length),t.write(e),t.writeUInt32LE(this.sequenceNumber),t},n.prototype.setScript=function(t){if(this._script=null,t instanceof h)this._script=t,this._script._isInput=!0,this._scriptBuffer=t.toBuffer();else if(c.isHexa(t))this._scriptBuffer=new f.Buffer(t,"hex");else if(i.isString(t))this._script=new h(t),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else{if(!u.isBuffer(t))throw new TypeError("Invalid argument type: script");this._scriptBuffer=new f.Buffer(t)}return this},n.prototype.getSignatures=function(){throw new o.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))},n.prototype.isFullySigned=function(){throw new o.AbstractMethodInvoked("Input#isFullySigned")},n.prototype.isFinal=function(){return 4294967295!==this.sequenceNumber},n.prototype.addSignature=function(){throw new o.AbstractMethodInvoked("Input#addSignature")},n.prototype.clearSignatures=function(){throw new o.AbstractMethodInvoked("Input#clearSignatures")},n.prototype.isValidSignature=function(t,e){return e.signature.nhashtype=e.sigtype,d.verify(t,e.signature,e.publicKey,e.inputIndex,this.output.script)},n.prototype.isNull=function(){return"0000000000000000000000000000000000000000000000000000000000000000"===this.prevTxId.toString("hex")&&4294967295===this.outputIndex},n.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length},e.exports=n},{"../../encoding/bufferwriter":15,"../../errors":17,"../../script":26,"../../util/buffer":43,"../../util/js":44,"../../util/preconditions":45,"../output":36,"../sighash":37,buffer:48,lodash:297}],32:[function(t,e,r){"use strict";function n(t,e,r,n){o.apply(this,arguments);var s=this;e=e||t.publicKeys,r=r||t.threshold,n=n||t.signatures,this.publicKeys=i.sortBy(e,function(t){return t.toString("hex")}),f.checkState(u.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},i.each(this.publicKeys,function(t,e){s.publicKeyIndex[t.toString()]=e}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}var i=t("lodash"),s=t("inherits"),o=(t("../transaction"),t("./input")),a=t("../output"),f=t("../../util/preconditions"),u=t("../../script"),c=t("../../crypto/signature"),h=t("../sighash"),d=(t("../../publickey"),t("../../util/buffer")),p=t("../signature");s(n,o),n.prototype.toObject=function(){var t=o.prototype.toObject.apply(this,arguments);return t.threshold=this.threshold,t.publicKeys=i.map(this.publicKeys,function(t){return t.toString()}),t.signatures=this._serializeSignatures(),t},n.prototype._deserializeSignatures=function(t){return i.map(t,function(t){return t?new p(t):void 0})},n.prototype._serializeSignatures=function(){return i.map(this.signatures,function(t){return t?t.toObject():void 0})},n.prototype.getSignatures=function(t,e,r,n){f.checkState(this.output instanceof a),n=n||c.SIGHASH_ALL;var s=this,o=[];return i.each(this.publicKeys,function(i){i.toString()===e.publicKey.toString()&&o.push(new p({publicKey:e.publicKey,prevTxId:s.prevTxId,outputIndex:s.outputIndex,inputIndex:r,signature:h.sign(t,e,n,r,s.output.script),sigtype:n}))}),o},n.prototype.addSignature=function(t,e){return f.checkState(!this.isFullySigned(),"All needed signatures have already been added"),f.checkArgument(!i.isUndefined(this.publicKeyIndex[e.publicKey.toString()]),"Signature has no matching public key"),f.checkState(this.isValidSignature(t,e)),this.signatures[this.publicKeyIndex[e.publicKey.toString()]]=e,this._updateScript(),this},n.prototype._updateScript=function(){return this.setScript(u.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},n.prototype._createSignatures=function(){return i.map(i.filter(this.signatures,function(t){return!i.isUndefined(t)}),function(t){return d.concat([t.signature.toDER(),d.integerAsSingleByteBuffer(t.sigtype)])})},n.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},n.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},n.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},n.prototype.countSignatures=function(){return i.reduce(this.signatures,function(t,e){return t+!!e},0)},n.prototype.publicKeysWithoutSignature=function(){var t=this;return i.filter(this.publicKeys,function(e){return!t.signatures[t.publicKeyIndex[e.toString()]]})},n.prototype.isValidSignature=function(t,e){return e.signature.nhashtype=e.sigtype,h.verify(t,e.signature,e.publicKey,e.inputIndex,this.output.script)},n.normalizeSignatures=function(t,e,r,n,i){return i.map(function(i){var s=null;return n=n.filter(function(n){if(s)return!0;var o=new p({signature:c.fromTxFormat(n),publicKey:i,prevTxId:e.prevTxId,outputIndex:e.outputIndex,inputIndex:r,sigtype:c.SIGHASH_ALL});o.signature.nhashtype=o.sigtype;var a=h.verify(t,o.signature,o.publicKey,o.inputIndex,e.output.script);return a?(s=o,!1):!0}),s?s:null})},n.OPCODES_SIZE=1,n.SIGNATURE_SIZE=73,n.prototype._estimateSize=function(){return n.OPCODES_SIZE+this.threshold*n.SIGNATURE_SIZE},e.exports=n},{"../../crypto/signature":11,"../../publickey":25,"../../script":26,"../../util/buffer":43,"../../util/preconditions":45,"../output":36,"../sighash":37,"../signature":38,"../transaction":39,"./input":31,inherits:296,lodash:297}],33:[function(t,e,r){"use strict";function n(t,e,r,n){o.apply(this,arguments);var s=this;e=e||t.publicKeys,r=r||t.threshold,n=n||t.signatures,this.publicKeys=i.sortBy(e,function(t){return t.toString("hex")}),this.redeemScript=u.buildMultisigOut(this.publicKeys,r),f.checkState(u.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},i.each(this.publicKeys,function(t,e){s.publicKeyIndex[t.toString()]=e}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}var i=t("lodash"),s=t("inherits"),o=t("./input"),a=t("../output"),f=t("../../util/preconditions"),u=t("../../script"),c=t("../../crypto/signature"),h=t("../sighash"),d=(t("../../publickey"),t("../../util/buffer")),p=t("../signature");s(n,o),n.prototype.toObject=function(){var t=o.prototype.toObject.apply(this,arguments);return t.threshold=this.threshold,t.publicKeys=i.map(this.publicKeys,function(t){return t.toString()}),t.signatures=this._serializeSignatures(),t},n.prototype._deserializeSignatures=function(t){return i.map(t,function(t){return t?new p(t):void 0})},n.prototype._serializeSignatures=function(){return i.map(this.signatures,function(t){return t?t.toObject():void 0})},n.prototype.getSignatures=function(t,e,r,n){f.checkState(this.output instanceof a),n=n||c.SIGHASH_ALL;var s=this,o=[];return i.each(this.publicKeys,function(i){i.toString()===e.publicKey.toString()&&o.push(new p({publicKey:e.publicKey,prevTxId:s.prevTxId,outputIndex:s.outputIndex,inputIndex:r,signature:h.sign(t,e,n,r,s.redeemScript),sigtype:n}))}),o},n.prototype.addSignature=function(t,e){return f.checkState(!this.isFullySigned(),"All needed signatures have already been added"),f.checkArgument(!i.isUndefined(this.publicKeyIndex[e.publicKey.toString()]),"Signature has no matching public key"),f.checkState(this.isValidSignature(t,e)),this.signatures[this.publicKeyIndex[e.publicKey.toString()]]=e,this._updateScript(),this},n.prototype._updateScript=function(){return this.setScript(u.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this},n.prototype._createSignatures=function(){return i.map(i.filter(this.signatures,function(t){return!i.isUndefined(t)}),function(t){return d.concat([t.signature.toDER(),d.integerAsSingleByteBuffer(t.sigtype)])})},n.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},n.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},n.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},n.prototype.countSignatures=function(){return i.reduce(this.signatures,function(t,e){return t+!!e},0)},n.prototype.publicKeysWithoutSignature=function(){var t=this;return i.filter(this.publicKeys,function(e){return!t.signatures[t.publicKeyIndex[e.toString()]]})},n.prototype.isValidSignature=function(t,e){return e.signature.nhashtype=e.sigtype,h.verify(t,e.signature,e.publicKey,e.inputIndex,this.redeemScript)},n.OPCODES_SIZE=7,n.SIGNATURE_SIZE=74,n.PUBKEY_SIZE=34,n.prototype._estimateSize=function(){return n.OPCODES_SIZE+this.threshold*n.SIGNATURE_SIZE+this.publicKeys.length*n.PUBKEY_SIZE},e.exports=n},{"../../crypto/signature":11,"../../publickey":25,"../../script":26,"../../util/buffer":43,"../../util/preconditions":45,"../output":36,"../sighash":37,"../signature":38,"./input":31,inherits:296,lodash:297}],34:[function(t,e,r){"use strict";function n(){o.apply(this,arguments)}var i=t("inherits"),s=t("../../util/preconditions"),o=(t("../../util/buffer"),t("./input")),a=t("../output"),f=t("../sighash"),u=t("../../script"),c=t("../../crypto/signature"),h=t("../signature");i(n,o),n.prototype.getSignatures=function(t,e,r,n){s.checkState(this.output instanceof a),n=n||c.SIGHASH_ALL;var i=e.toPublicKey();return i.toString()===this.output.script.getPublicKey().toString("hex")?[new h({publicKey:i,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:f.sign(t,e,n,r,this.output.script),sigtype:n})]:[]},n.prototype.addSignature=function(t,e){return s.checkState(this.isValidSignature(t,e),"Signature is invalid"),this.setScript(u.buildPublicKeyIn(e.signature.toDER(),e.sigtype)),this},n.prototype.clearSignatures=function(){return this.setScript(u.empty()),this},n.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},n.SCRIPT_MAX_SIZE=73,n.prototype._estimateSize=function(){return n.SCRIPT_MAX_SIZE},e.exports=n},{"../../crypto/signature":11,"../../script":26,"../../util/buffer":43,"../../util/preconditions":45,"../output":36,"../sighash":37,"../signature":38,"./input":31,inherits:296}],35:[function(t,e,r){"use strict";function n(){f.apply(this,arguments)}var i=t("inherits"),s=t("../../util/preconditions"),o=t("../../util/buffer"),a=t("../../crypto/hash"),f=t("./input"),u=t("../output"),c=t("../sighash"),h=t("../../script"),d=t("../../crypto/signature"),p=t("../signature");i(n,f),n.prototype.getSignatures=function(t,e,r,n,i){return s.checkState(this.output instanceof u),i=i||a.sha256ripemd160(e.publicKey.toBuffer()),n=n||d.SIGHASH_ALL,o.equals(i,this.output.script.getPublicKeyHash())?[new p({publicKey:e.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:c.sign(t,e,n,r,this.output.script),sigtype:n})]:[]},n.prototype.addSignature=function(t,e){return s.checkState(this.isValidSignature(t,e),"Signature is invalid"),this.setScript(h.buildPublicKeyHashIn(e.publicKey,e.signature.toDER(),e.sigtype)),this},n.prototype.clearSignatures=function(){return this.setScript(h.empty()),this},n.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()},n.SCRIPT_MAX_SIZE=107,n.prototype._estimateSize=function(){return n.SCRIPT_MAX_SIZE},e.exports=n},{"../../crypto/hash":8,"../../crypto/signature":11,"../../script":26,"../../util/buffer":43,"../../util/preconditions":45,"../output":36,"../sighash":37,"../signature":38,"./input":31,inherits:296}],36:[function(t,e,r){"use strict";function n(t){if(!(this instanceof n))return new n(t);if(!i.isObject(t))throw new TypeError("Unrecognized argument for Output");if(this.satoshis=t.satoshis,a.isBuffer(t.script))this._scriptBuffer=t.script;else{var e;e=i.isString(t.script)&&f.isHexa(t.script)?new o.Buffer(t.script,"hex"):t.script,this.setScript(e)}}var i=t("lodash"),s=t("../crypto/bn"),o=t("buffer"),a=t("../util/buffer"),f=t("../util/js"),u=t("../encoding/bufferwriter"),c=t("../script"),h=t("../util/preconditions"),d=t("../errors"),p=9007199254740991;Object.defineProperty(n.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}}),Object.defineProperty(n.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(t){t instanceof s?(this._satoshisBN=t,this._satoshis=t.toNumber()):i.isString(t)?(this._satoshis=parseInt(t),this._satoshisBN=s.fromNumber(this._satoshis)):(h.checkArgument(f.isNaturalNumber(t),"Output satoshis is not a natural number"),this._satoshisBN=s.fromNumber(t),this._satoshis=t),h.checkState(f.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),n.prototype.invalidSatoshis=function(){return this._satoshis>p?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0?"transaction txout negative":!1},n.prototype.toObject=n.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t},n.fromObject=function(t){return new n(t)},n.prototype.setScriptFromBuffer=function(t){this._scriptBuffer=t;try{this._script=c.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(e){if(!(e instanceof d.Script.InvalidBuffer))throw e;this._script=null}},n.prototype.setScript=function(t){if(t instanceof c)this._scriptBuffer=t.toBuffer(),this._script=t,this._script._isOutput=!0;else if(i.isString(t))this._script=c.fromString(t),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else{if(!a.isBuffer(t))throw new TypeError("Invalid argument type: script");this.setScriptFromBuffer(t)}return this},n.prototype.inspect=function(){var t;return t=this.script?this.script.inspect():this._scriptBuffer.toString("hex"),""},n.fromBufferReader=function(t){var e={};e.satoshis=t.readUInt64LEBN();var r=t.readVarintNum();return 0!==r?e.script=t.read(r):e.script=new o.Buffer([]),new n(e)},n.prototype.toBufferWriter=function(t){t||(t=new u),t.writeUInt64LEBN(this._satoshisBN);var e=this._scriptBuffer;return t.writeVarintNum(e.length),t.write(e),t},e.exports=n},{"../crypto/bn":6,"../encoding/bufferwriter":15,"../errors":17,"../script":26,"../util/buffer":43,"../util/js":44,"../util/preconditions":45,buffer:48,lodash:297}],37:[function(t,e,r){(function(r){"use strict";function n(t,e,r,n,i){var s=y(t,r,n,i),o=p.sign(s,e,"little").set({nhashtype:r});return o}function i(t,e,r,n,i){l.checkArgument(!b.isUndefined(t)),l.checkArgument(!b.isUndefined(e)&&!b.isUndefined(e.nhashtype));var s=y(t,e.nhashtype,n,i);return p.verify(s,e,r,"little")}var s=t("buffer"),o=t("../crypto/signature"),a=t("../script"),f=t("./output"),u=t("../encoding/bufferreader"),c=t("../encoding/bufferwriter"),h=t("../crypto/bn"),d=t("../crypto/hash"),p=t("../crypto/ecdsa"),l=t("../util/preconditions"),b=t("lodash"),g="0000000000000000000000000000000000000000000000000000000000000001",m="ffffffffffffffff",y=function(e,n,i,p){var l,b=t("./transaction"),y=t("./input"),v=b.shallowCopy(e);for(p=new a(p),p.removeCodeseparators(),l=0;l=v.outputs.length)return new r(g,"hex");for(v.outputs.length=i+1,l=0;i>l;l++)v.outputs[l]=new f({satoshis:h.fromBuffer(new s.Buffer(m,"hex")),script:a.empty()})}n&o.SIGHASH_ANYONECANPAY&&(v.inputs=[v.inputs[i]]);var _=(new c).write(v.toBuffer()).writeInt32LE(n).toBuffer(),w=d.sha256sha256(_);return w=new u(w).readReverse()};e.exports={sighash:y,sign:n,verify:i}}).call(this,t("buffer").Buffer)},{"../crypto/bn":6,"../crypto/ecdsa":7,"../crypto/hash":8,"../crypto/signature":11,"../encoding/bufferreader":14,"../encoding/bufferwriter":15,"../script":26,"../util/preconditions":45,"./input":30,"./output":36,"./transaction":39,buffer:48,lodash:297}],38:[function(t,e,r){(function(r){"use strict";function n(t){if(!(this instanceof n))return new n(t);if(t instanceof n)return t;if(i.isObject(t))return this._fromObject(t);throw new c.InvalidArgument("TransactionSignatures must be instantiated from an object")}var i=t("lodash"),s=t("../util/preconditions"),o=t("inherits"),a=t("../util/buffer"),f=t("../util/js"),u=t("../publickey"),c=t("../errors"),h=t("../crypto/signature");o(n,h),n.prototype._fromObject=function(t){return this._checkObjectArgs(t),this.publicKey=new u(t.publicKey),this.prevTxId=a.isBuffer(t.prevTxId)?t.prevTxId:new r(t.prevTxId,"hex"),this.outputIndex=t.outputIndex,this.inputIndex=t.inputIndex,this.signature=t.signature instanceof h?t.signature:a.isBuffer(t.signature)?h.fromBuffer(t.signature):h.fromString(t.signature),this.sigtype=t.sigtype,this},n.prototype._checkObjectArgs=function(t){s.checkArgument(u(t.publicKey),"publicKey"),s.checkArgument(!i.isUndefined(t.inputIndex),"inputIndex"),s.checkArgument(!i.isUndefined(t.outputIndex),"outputIndex"),s.checkState(i.isNumber(t.inputIndex),"inputIndex must be a number"),s.checkState(i.isNumber(t.outputIndex),"outputIndex must be a number"),s.checkArgument(t.signature,"signature"),s.checkArgument(t.prevTxId,"prevTxId"),s.checkState(t.signature instanceof h||a.isBuffer(t.signature)||f.isHexa(t.signature),"signature must be a buffer or hexa value"),s.checkState(a.isBuffer(t.prevTxId)||f.isHexa(t.prevTxId),"prevTxId must be a buffer or hexa value"),s.checkArgument(t.sigtype,"sigtype"),s.checkState(i.isNumber(t.sigtype),"sigtype must be a number")},n.prototype.toObject=n.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}},n.fromObject=function(t){return s.checkArgument(t),new n(t)},e.exports=n}).call(this,t("buffer").Buffer)},{"../crypto/signature":11,"../errors":17, +"../publickey":25,"../util/buffer":43,"../util/js":44,"../util/preconditions":45,buffer:48,inherits:296,lodash:297}],39:[function(t,e,r){(function(r){"use strict";function n(t){if(!(this instanceof n))return new n(t);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,t){if(t instanceof n)return n.shallowCopy(t);if(c.isHexa(t))this.fromString(t);else if(u.isBuffer(t))this.fromBuffer(t);else{if(!i.isObject(t))throw new f.InvalidArgument("Must provide an object or string to deserialize a transaction");this.fromObject(t)}}else this._newTransaction()}var i=t("lodash"),s=t("../util/preconditions"),o=t("buffer"),a=r.compare||t("buffer-compare"),f=t("../errors"),u=t("../util/buffer"),c=t("../util/js"),h=t("../encoding/bufferreader"),d=t("../encoding/bufferwriter"),p=t("../crypto/hash"),l=t("../crypto/signature"),b=t("./sighash"),g=t("../address"),m=t("./unspentoutput"),y=t("./input"),v=y.PublicKeyHash,_=y.PublicKey,w=y.MultiSigScriptHash,S=y.MultiSig,I=t("./output"),k=t("../script"),E=t("../privatekey"),A=t("../crypto/bn"),x=1,P=0,O=1e6;n.DUST_AMOUNT=546,n.FEE_SECURITY_MARGIN=15,n.MAX_MONEY=21e14,n.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8,n.NLOCKTIME_MAX_VALUE=4294967295,n.FEE_PER_KB=1e4,n.CHANGE_OUTPUT_MAX_SIZE=62,n.MAXIMUM_EXTRA_SIZE=26,n.shallowCopy=function(t){var e=new n(t.toBuffer());return e};var B={configurable:!1,enumerable:!0,get:function(){return new h(this._getHash()).readReverse().toString("hex")}};Object.defineProperty(n.prototype,"hash",B),Object.defineProperty(n.prototype,"id",B);var M={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(n.prototype,"inputAmount",M),M.get=function(){return this._getOutputAmount()},Object.defineProperty(n.prototype,"outputAmount",M),n.prototype._getHash=function(){return p.sha256sha256(this.toBuffer())},n.prototype.serialize=function(t){return!0===t||t&&t.disableAll?this.uncheckedSerialize():this.checkedSerialize(t)},n.prototype.uncheckedSerialize=n.prototype.toString=function(){return this.toBuffer().toString("hex")},n.prototype.checkedSerialize=function(t){var e=this.getSerializationError(t);if(e)throw e.message+=" Use Transaction#uncheckedSerialize if you want to skip security checks. See http://bitcore.io/guide/transaction.html#Serialization for more info.",e;return this.uncheckedSerialize()},n.prototype.invalidSatoshis=function(){for(var t=!1,e=0;er?t.disableMoreOutputThanInput||(e=new f.Transaction.InvalidOutputAmountSum):e=this._hasFeeError(t,r),e||this._hasDustOutputs(t)||this._isMissingSignatures(t)},n.prototype._hasFeeError=function(t,e){if(!i.isUndefined(this._fee)&&this._fee!==e)return new f.Transaction.FeeError.Different("Unspent value is "+e+" but specified fee is "+this._fee);if(!t.disableLargeFees){var r=Math.floor(n.FEE_SECURITY_MARGIN*this._estimateFee());if(e>r)return this._missingChange()?new f.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new f.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+e)}if(!t.disableSmallFees){var s=Math.ceil(this._estimateFee()/n.FEE_SECURITY_MARGIN);if(s>e)return new f.Transaction.FeeError.TooSmall("expected more than "+s+" but got "+e)}},n.prototype._missingChange=function(){return!this._changeScript},n.prototype._hasDustOutputs=function(t){if(!t.disableDustOutputs){var e,r;for(e in this.outputs)if(r=this.outputs[e],r.satoshis"},n.prototype.toBuffer=function(){var t=new d;return this.toBufferWriter(t).toBuffer()},n.prototype.toBufferWriter=function(t){return t.writeUInt32LE(this.version),t.writeVarintNum(this.inputs.length),i.each(this.inputs,function(e){e.toBufferWriter(t)}),t.writeVarintNum(this.outputs.length),i.each(this.outputs,function(e){e.toBufferWriter(t)}),t.writeUInt32LE(this.nLockTime),t},n.prototype.fromBuffer=function(t){var e=new h(t);return this.fromBufferReader(e)},n.prototype.fromBufferReader=function(t){s.checkArgument(!t.finished(),"No transaction data received");var e,r,n;for(this.version=t.readUInt32LE(),r=t.readVarintNum(),e=0;r>e;e++){var i=y.fromBufferReader(t);this.inputs.push(i)}for(n=t.readVarintNum(),e=0;n>e;e++)this.outputs.push(I.fromBufferReader(t));return this.nLockTime=t.readUInt32LE(),this},n.prototype.toObject=n.prototype.toJSON=function(){var t=[];this.inputs.forEach(function(e){t.push(e.toObject())});var e=[];this.outputs.forEach(function(t){e.push(t.toObject())});var r={hash:this.hash,version:this.version,inputs:t,outputs:e,nLockTime:this.nLockTime};return this._changeScript&&(r.changeScript=this._changeScript.toString()),i.isUndefined(this._changeIndex)||(r.changeIndex=this._changeIndex),i.isUndefined(this._fee)||(r.fee=this._fee),r},n.prototype.fromObject=function(t){s.checkArgument(i.isObject(t)||t instanceof n);var e,r=this;return e=t instanceof n?e.toObject():t,i.each(e.inputs,function(t){if(!t.output||!t.output.script)return void r.uncheckedAddInput(new y(t));var e,n=new k(t.output.script);if(n.isPublicKeyHashOut())e=new y.PublicKeyHash(t);else if(n.isScriptHashOut()&&t.publicKeys&&t.threshold)e=new y.MultiSigScriptHash(t,t.publicKeys,t.threshold,t.signatures);else{if(!n.isPublicKeyOut())throw new f.Transaction.Input.UnsupportedScript(t.output.script);e=new y.PublicKey(t)}r.addInput(e)}),i.each(e.outputs,function(t){r.addOutput(new I(t))}),e.changeIndex&&(this._changeIndex=e.changeIndex),e.changeScript&&(this._changeScript=new k(e.changeScript)),e.fee&&(this._fee=e.fee),this.nLockTime=e.nLockTime,this.version=e.version,this._checkConsistency(t),this},n.prototype._checkConsistency=function(t){i.isUndefined(this._changeIndex)||(s.checkState(this._changeScript),s.checkState(this.outputs[this._changeIndex]),s.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString())),t&&t.hash&&s.checkState(t.hash===this.hash,"Hash in object does not match transaction hash")},n.prototype.lockUntilDate=function(t){if(s.checkArgument(t),i.isNumber(t)&&t=n.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new f.Transaction.BlockHeightTooHigh;if(0>t)throw new f.Transaction.NLockTimeOutOfRange;for(var e=0;e0?(this._changeIndex=this.outputs.length,this._addOutput(new I({script:this._changeScript,satoshis:r}))):this._changeIndex=void 0}},n.prototype.getFee=function(){return this.isCoinbase()?0:i.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee},n.prototype._estimateFee=function(){var t=this._estimateSize(),e=this._getUnspentValue();return n._estimateFee(t,e,this._feePerKb)},n.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()},n.prototype._clearSignatures=function(){i.each(this.inputs,function(t){t.clearSignatures()})},n._estimateFee=function(t,e,r){var i=Math.ceil(t/1e3)*(r||n.FEE_PER_KB);return e>i&&(t+=n.CHANGE_OUTPUT_MAX_SIZE),Math.ceil(t/1e3)*(r||n.FEE_PER_KB)},n.prototype._estimateSize=function(){var t=n.MAXIMUM_EXTRA_SIZE;return i.each(this.inputs,function(e){t+=e._estimateSize()}),i.each(this.outputs,function(e){t+=e.script.toBuffer().length+9}),t},n.prototype._removeOutput=function(t){var e=this.outputs[t];this.outputs=i.without(this.outputs,e),this._outputAmount=void 0},n.prototype.removeOutput=function(t){this._removeOutput(t),this._updateChangeOutput()},n.prototype.sort=function(){return this.sortInputs(function(t){var e=Array.prototype.concat.apply([],t);return e.sort(function(t,e){return a(t.prevTxId,e.prevTxId)||t.outputIndex-e.outputIndex}),e}),this.sortOutputs(function(t){var e=Array.prototype.concat.apply([],t);return e.sort(function(t,e){return t.satoshis-e.satoshis||a(t.script.toBuffer(),e.script.toBuffer())}),e}),this},n.prototype.shuffleOutputs=function(){return this.sortOutputs(i.shuffle)},n.prototype.sortOutputs=function(t){var e=t(this.outputs);return this._newOutputOrder(e)},n.prototype.sortInputs=function(t){return this.inputs=t(this.inputs),this._clearSignatures(),this},n.prototype._newOutputOrder=function(t){var e=this.outputs.length!==t.length||0!==i.difference(this.outputs,t).length;if(e)throw new f.Transaction.InvalidSorting;if(!i.isUndefined(this._changeIndex)){var r=this.outputs[this._changeIndex];this._changeIndex=i.findIndex(t,r)}return this.outputs=t,this},n.prototype.removeInput=function(t,e){var r;if(r=!e&&i.isNumber(t)?t:i.findIndex(this.inputs,function(r){return r.prevTxId.toString("hex")===t&&r.outputIndex===e}),0>r||r>=this.inputs.length)throw new f.Transaction.InvalidIndex(r,this.inputs.length);var n=this.inputs[r];this.inputs=i.without(this.inputs,n),this._inputAmount=void 0,this._updateChangeOutput()},n.prototype.sign=function(t,e){s.checkState(this.hasAllUtxoInfo());var r=this;return i.isArray(t)?(i.each(t,function(t){r.sign(t,e)}),this):(i.each(this.getSignatures(t,e),function(t){r.applySignature(t)}),this)},n.prototype.getSignatures=function(t,e){t=new E(t),e=e||l.SIGHASH_ALL;var r=this,n=[],s=p.sha256ripemd160(t.publicKey.toBuffer());return i.each(this.inputs,function(o,a){i.each(o.getSignatures(r,t,a,e,s),function(t){n.push(t)})}),n},n.prototype.applySignature=function(t){return this.inputs[t.inputIndex].addSignature(this,t),this},n.prototype.isFullySigned=function(){return i.each(this.inputs,function(t){if(t.isFullySigned===y.prototype.isFullySigned)throw new f.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),i.all(i.map(this.inputs,function(t){return t.isFullySigned()}))},n.prototype.isValidSignature=function(t){var e=this;if(this.inputs[t.inputIndex].isValidSignature===y.prototype.isValidSignature)throw new f.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[t.inputIndex].isValidSignature(e,t)},n.prototype.verifySignature=function(t,e,r,n){return b.verify(this,t,e,r,n)},n.prototype.verify=function(){if(0===this.inputs.length)return"transaction txins empty";if(0===this.outputs.length)return"transaction txouts empty";for(var t=new A(0),e=0;eO)return"transaction over the maximum block size";var s={};for(e=0;e100)return"coinbase transaction script size invalid"}else for(e=0;e64)throw new Error("Invalid TXID in object",t);var c=i.isUndefined(t.vout)?t.outputIndex:t.vout;if(!i.isNumber(c))throw new Error("Invalid outputIndex, received "+c);s.checkArgument(!i.isUndefined(t.scriptPubKey)||!i.isUndefined(t.script),"Must provide the scriptPubKey for that output!");var h=new a(t.scriptPubKey||t.script);s.checkArgument(!i.isUndefined(t.amount)||!i.isUndefined(t.satoshis),"Must provide an amount for the output");var d=i.isUndefined(t.amount)?t.satoshis:new u.fromBTC(t.amount).toSatoshis();s.checkArgument(i.isNumber(d),"Amount must be a number"),o.defineImmutable(this,{address:e,txId:r,outputIndex:c,script:h,satoshis:d})}var i=t("lodash"),s=t("../util/preconditions"),o=t("../util/js"),a=t("../script"),f=t("../address"),u=t("../unit");n.prototype.inspect=function(){return""},n.prototype.toString=function(){return this.txId+":"+this.outputIndex},n.fromObject=function(t){return new n(t)},n.prototype.toObject=n.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:u.fromSatoshis(this.satoshis).toBTC()}},e.exports=n},{"../address":1,"../script":26,"../unit":41,"../util/js":44,"../util/preconditions":45,lodash:297}],41:[function(t,e,r){"use strict";function n(t,e){if(!(this instanceof n))return new n(t,e);if(i.isNumber(e)){if(0>=e)throw new s.Unit.InvalidRate(e);t/=e,e=n.BTC}this._value=this._from(t,e);var r=this,o=function(t){Object.defineProperty(r,t,{get:function(){return r.to(t)},enumerable:!0})};Object.keys(a).forEach(o)}var i=t("lodash"),s=t("./errors"),o=t("./util/preconditions"),a={BTC:[1e8,8],mBTC:[1e5,5],uBTC:[100,2],bits:[100,2],satoshis:[1,0]};Object.keys(a).forEach(function(t){n[t]=t}),n.fromObject=function(t){return o.checkArgument(i.isObject(t),"Argument is expected to be an object"),new n(t.amount,t.code)},n.fromBTC=function(t){return new n(t,n.BTC)},n.fromMillis=n.fromMilis=function(t){return new n(t,n.mBTC)},n.fromMicros=n.fromBits=function(t){return new n(t,n.bits)},n.fromSatoshis=function(t){return new n(t,n.satoshis)},n.fromFiat=function(t,e){return new n(t,e)},n.prototype._from=function(t,e){if(!a[e])throw new s.Unit.UnknownCode(e);return parseInt((t*a[e][0]).toFixed())},n.prototype.to=function(t){if(i.isNumber(t)){if(0>=t)throw new s.Unit.InvalidRate(t);return parseFloat((this.BTC*t).toFixed(2))}if(!a[t])throw new s.Unit.UnknownCode(t);var e=this._value/a[t][0];return parseFloat(e.toFixed(a[t][1]))},n.prototype.toBTC=function(){return this.to(n.BTC)},n.prototype.toMillis=n.prototype.toMilis=function(){return this.to(n.mBTC)},n.prototype.toMicros=n.prototype.toBits=function(){return this.to(n.bits)},n.prototype.toSatoshis=function(){return this.to(n.satoshis)},n.prototype.atRate=function(t){return this.to(t)},n.prototype.toString=function(){return this.satoshis+" satoshis"},n.prototype.toObject=n.prototype.toJSON=function(){return{amount:this.BTC,code:n.BTC}},n.prototype.inspect=function(){return""},e.exports=n},{"./errors":17,"./util/preconditions":45,lodash:297}],42:[function(t,e,r){"use strict";var n=t("lodash"),i=t("url"),s=t("./address"),o=t("./unit"),a=function(t,e){if(!(this instanceof a))return new a(t,e);if(this.extras={},this.knownParams=e||[],this.address=this.network=this.amount=this.message=null,"string"==typeof t){var r=a.parse(t);r.amount&&(r.amount=this._parseAmount(r.amount)),this._fromObject(r)}else{if("object"!=typeof t)throw new TypeError("Unrecognized data format.");this._fromObject(t)}};a.fromString=function(t){if("string"!=typeof t)throw new TypeError("Expected a string");return new a(t)},a.fromObject=function(t){return new a(t)},a.isValid=function(t,e){try{new a(t,e)}catch(r){return!1}return!0},a.parse=function(t){var e=i.parse(t,!0);if("bitcoin:"!==e.protocol)throw new TypeError("Invalid bitcoin URI");var r=/[^:]*:\/?\/?([^?]*)/.exec(t);return e.query.address=r&&r[1]||void 0,e.query},a.Members=["address","amount","message","label","r"],a.prototype._fromObject=function(t){if(!s.isValid(t.address))throw new TypeError("Invalid bitcoin address");this.address=new s(t.address),this.network=this.address.network,this.amount=t.amount;for(var e in t)if("address"!==e&&"amount"!==e){if(/^req-/.exec(e)&&-1===this.knownParams.indexOf(e))throw Error("Unknown required argument "+e);var r=a.Members.indexOf(e)>-1?this:this.extras;r[e]=t[e]}},a.prototype._parseAmount=function(t){if(t=Number(t),isNaN(t))throw new TypeError("Invalid amount");return o.fromBTC(t).toSatoshis()},a.prototype.toObject=a.prototype.toJSON=function(){for(var t={},e=0;e"},e.exports=a},{"./address":1,"./unit":41,lodash:297,url:267}],43:[function(t,e,r){(function(r){"use strict";function n(t,e){if(t.length!==e.length)return!1;for(var r=t.length,n=0;r>n;n++)if(t[n]!==e[n])return!1;return!0}var i=t("buffer"),s=t("assert"),o=t("./js"),a=t("./preconditions");e.exports={fill:function(t,e){a.checkArgumentType(t,"Buffer","buffer"),a.checkArgumentType(e,"number","value");for(var r=t.length,n=0;r>n;n++)t[n]=e;return t},copy:function(t){var e=new r(t.length);return t.copy(e),e},isBuffer:function(t){return i.Buffer.isBuffer(t)||t instanceof Uint8Array},emptyBuffer:function(t){a.checkArgumentType(t,"number","bytes");for(var e=new i.Buffer(t),r=0;t>r;r++)e.write("\x00",r);return e},concat:i.Buffer.concat,equals:n,equal:n,integerAsSingleByteBuffer:function(t){return a.checkArgumentType(t,"number","integer"),new i.Buffer([255&t])},integerAsBuffer:function(t){a.checkArgumentType(t,"number","integer");var e=[];return e.push(t>>24&255),e.push(t>>16&255),e.push(t>>8&255),e.push(255&t),new r(e)},integerFromBuffer:function(t){return a.checkArgumentType(t,"Buffer","buffer"),t[0]<<24|t[1]<<16|t[2]<<8|t[3]},integerFromSingleByteBuffer:function(t){return a.checkArgumentType(t,"Buffer","buffer"),t[0]},bufferToHex:function(t){return a.checkArgumentType(t,"Buffer","buffer"),t.toString("hex")},reverse:function(t){for(var e=new i.Buffer(t.length),r=0;r=0}}},{lodash:297}],45:[function(t,e,r){"use strict";var n=t("../errors"),i=t("lodash");e.exports={checkState:function(t,e){if(!t)throw new n.InvalidState(e)},checkArgument:function(t,e,r,i){if(!t)throw new n.InvalidArgument(e,r,i)},checkArgumentType:function(e,r,s){if(s=s||"(unknown name)",i.isString(r)){if("Buffer"===r){var o=t("./buffer");if(!o.isBuffer(e))throw new n.InvalidArgumentType(e,r,s)}else if(typeof e!==r)throw new n.InvalidArgumentType(e,r,s)}else if(!(e instanceof r))throw new n.InvalidArgumentType(e,r.name,s)}}},{"../errors":17,"./buffer":43,lodash:297}],46:[function(t,e,r){function n(t,e){return p.isUndefined(e)?""+e:p.isNumber(e)&&!isFinite(e)?e.toString():p.isFunction(e)||p.isRegExp(e)?e.toString():e}function i(t,e){return p.isString(t)?t.length=0;s--)if(o[s]!=a[s])return!1;for(s=o.length-1;s>=0;s--)if(i=o[s],!f(t[i],e[i]))return!1;return!0}function h(t,e){return t&&e?"[object RegExp]"==Object.prototype.toString.call(e)?e.test(t):t instanceof e?!0:e.call({},t)===!0?!0:!1:!1}function d(t,e,r,n){var i;p.isString(r)&&(n=r,r=null);try{e()}catch(s){i=s}if(n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&o(i,r,"Missing expected exception"+n),!t&&h(i,r)&&o(i,r,"Got unwanted exception"+n),t&&i&&r&&!h(i,r)||!t&&i)throw i}var p=t("util/"),l=Array.prototype.slice,b=Object.prototype.hasOwnProperty,g=e.exports=a;g.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=s(this),this.generatedMessage=!0);var e=t.stackStartFunction||o;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,i=e.name,a=n.indexOf("\n"+i);if(a>=0){var f=n.indexOf("\n",a+1);n=n.substring(f+1)}this.stack=n}}},p.inherits(g.AssertionError,Error),g.fail=o,g.ok=a,g.equal=function(t,e,r){t!=e&&o(t,e,r,"==",g.equal)},g.notEqual=function(t,e,r){t==e&&o(t,e,r,"!=",g.notEqual)},g.deepEqual=function(t,e,r){f(t,e)||o(t,e,r,"deepEqual",g.deepEqual)},g.notDeepEqual=function(t,e,r){f(t,e)&&o(t,e,r,"notDeepEqual",g.notDeepEqual)},g.strictEqual=function(t,e,r){t!==e&&o(t,e,r,"===",g.strictEqual)},g.notStrictEqual=function(t,e,r){t===e&&o(t,e,r,"!==",g.notStrictEqual)},g["throws"]=function(t,e,r){d.apply(this,[!0].concat(l.call(arguments)))},g.doesNotThrow=function(t,e){d.apply(this,[!1].concat(l.call(arguments)))},g.ifError=function(t){if(t)throw t};var m=Object.keys||function(t){var e=[];for(var r in t)b.call(t,r)&&e.push(r);return e}},{"util/":269}],47:[function(t,e,r){},{}],48:[function(t,e,r){(function(e){"use strict";function n(){function t(){}try{var e=new Uint8Array(1);return e.foo=function(){return 42},e.constructor=t,42===e.foo()&&e.constructor===t&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(r){return!1}}function i(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t){return this instanceof s?(s.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?o(this,t):"string"==typeof t?a(this,t,arguments.length>1?arguments[1]:"utf8"):f(this,t)):arguments.length>1?new s(t,arguments[1]):new s(t)}function o(t,e){if(t=b(t,0>e?0:0|g(e)),!s.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;r++)t[r]=0;return t}function a(t,e,r){("string"!=typeof r||""===r)&&(r="utf8");var n=0|y(e,r);return t=b(t,n),t.write(e,r),t}function f(t,e){if(s.isBuffer(e))return u(t,e);if(J(e))return c(t,e);if(null==e)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(e.buffer instanceof ArrayBuffer)return h(t,e);if(e instanceof ArrayBuffer)return d(t,e)}return e.length?p(t,e):l(t,e)}function u(t,e){var r=0|g(e.length);return t=b(t,r),e.copy(t,0,0,r),t}function c(t,e){var r=0|g(e.length);t=b(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function h(t,e){var r=0|g(e.length);t=b(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function d(t,e){return s.TYPED_ARRAY_SUPPORT?(e.byteLength,t=s._augment(new Uint8Array(e))):t=h(t,new Uint8Array(e)),t}function p(t,e){var r=0|g(e.length);t=b(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function l(t,e){var r,n=0;"Buffer"===e.type&&J(e.data)&&(r=e.data,n=0|g(r.length)),t=b(t,n);for(var i=0;n>i;i+=1)t[i]=255&r[i];return t}function b(t,e){s.TYPED_ARRAY_SUPPORT?(t=s._augment(new Uint8Array(e)),t.__proto__=s.prototype):(t.length=e,t._isBuffer=!0);var r=0!==e&&e<=s.poolSize>>>1;return r&&(t.parent=Z),t}function g(t){if(t>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function m(t,e){if(!(this instanceof m))return new m(t,e);var r=new s(t,e);return delete r.parent,r}function y(t,e){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(t).length;default:if(n)return H(t).length;e=(""+e).toLowerCase(),n=!0}}function v(t,e,r){var n=!1;if(e=0|e,r=void 0===r||r===1/0?this.length:0|r,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return M(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return O(this,e,r);case"binary":return B(this,e,r);case"base64":return A(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function _(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var s=e.length;if(s%2!==0)throw new Error("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;n>o;o++){var a=parseInt(e.substr(2*o,2),16);if(isNaN(a))throw new Error("Invalid hex string");t[r+o]=a}return o}function w(t,e,r,n){return G(H(e,t.length-r),t,r,n)}function S(t,e,r,n){return G(q(e),t,r,n)}function I(t,e,r,n){return S(t,e,r,n)}function k(t,e,r,n){return G(Y(e),t,r,n)}function E(t,e,r,n){return G(V(e,t.length-r),t,r,n)}function A(t,e,r){return 0===e&&r===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;r>i;){var s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(r>=i+a){var f,u,c,h;switch(a){case 1:128>s&&(o=s);break;case 2:f=t[i+1],128===(192&f)&&(h=(31&s)<<6|63&f,h>127&&(o=h));break;case 3:f=t[i+1],u=t[i+2],128===(192&f)&&128===(192&u)&&(h=(15&s)<<12|(63&f)<<6|63&u,h>2047&&(55296>h||h>57343)&&(o=h));break;case 4:f=t[i+1],u=t[i+2],c=t[i+3],128===(192&f)&&128===(192&u)&&128===(192&c)&&(h=(15&s)<<18|(63&f)<<12|(63&u)<<6|63&c,h>65535&&1114112>h&&(o=h))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296), +o=56320|1023&o),n.push(o),i+=a}return P(n)}function P(t){var e=t.length;if(Q>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Q));return r}function O(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function B(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function M(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",s=e;r>s;s++)i+=K(t[s]);return i}function R(t,e,r){for(var n=t.slice(e,r),i="",s=0;st)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>i||o>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range")}function N(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-r,2);s>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function j(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-r,4);s>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function U(t,e,r,n,i,s){if(e>i||s>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function L(t,e,r,n,i){return i||U(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,i){return i||U(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(t,e,r,n,52,8),r+8}function z(t){if(t=F(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function F(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function K(t){return 16>t?"0"+t.toString(16):t.toString(16)}function H(t,e){e=e||1/0;for(var r,n=t.length,i=null,s=[],o=0;n>o;o++){if(r=t.charCodeAt(o),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,128>r){if((e-=1)<0)break;s.push(r)}else if(2048>r){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function q(t){for(var e=[],r=0;r>8,i=r%256,s.push(i),s.push(n);return s}function Y(t){return W.toByteArray(z(t))}function G(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}var W=t("base64-js"),X=t("ieee754"),J=t("isarray");r.Buffer=s,r.SlowBuffer=m,r.INSPECT_MAX_BYTES=50,s.poolSize=8192;var Z={};s.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),s.TYPED_ARRAY_SUPPORT?(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array):(s.prototype.length=void 0,s.prototype.parent=void 0),s.isBuffer=function(t){return!(null==t||!t._isBuffer)},s.compare=function(t,e){if(!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);o>i&&t[i]===e[i];)++i;return i!==o&&(r=t[i],n=e[i]),n>r?-1:r>n?1:0},s.isEncoding=function(t){switch(String(t).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}},s.concat=function(t,e){if(!J(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new s(0);var r;if(void 0===e)for(e=0,r=0;r0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},s.prototype.compare=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:s.compare(this,t)},s.prototype.indexOf=function(t,e){function r(t,e,r){for(var n=-1,i=0;r+i2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,e);if(s.isBuffer(t))return r(this,t,e);if("number"==typeof t)return s.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):r(this,[t],e);throw new TypeError("val must be string, number or Buffer")},s.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},s.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},s.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite(e))e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var i=n;n=e,e=0|r,r=i}var s=this.length-e;if((void 0===r||r>s)&&(r=s),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return w(this,t,e,r);case"ascii":return S(this,t,e,r);case"binary":return I(this,t,e,r);case"base64":return k(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var n;if(s.TYPED_ARRAY_SUPPORT)n=s._augment(this.subarray(t,e));else{var i=e-t;n=new s(i,void 0);for(var o=0;i>o;o++)n[o]=this[o+t]}return n.length&&(n.parent=this.parent||this),n},s.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||T(t,e,this.length);for(var n=this[t],i=1,s=0;++s0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return e||T(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||T(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||T(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||T(t,e,this.length);for(var n=this[t],i=1,s=0;++s=i&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||T(t,e,this.length);for(var n=e,i=1,s=this[t+--n];n>0&&(i*=256);)s+=this[t+--n]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*e)),s},s.prototype.readInt8=function(t,e){return e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||T(t,4,this.length),X.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||T(t,4,this.length),X.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||T(t,8,this.length),X.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||T(t,8,this.length),X.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){t=+t,e=0|e,r=0|r,n||C(this,t,e,r,Math.pow(2,8*r),0);var i=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+i]=t/s&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||C(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||C(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||C(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||C(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):j(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||C(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);C(this,t,e,r,i-1,-i)}var s=0,o=1,a=0>t?1:0;for(this[e]=255&t;++s>0)-a&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);C(this,t,e,r,i-1,-i)}var s=r-1,o=1,a=0>t?1:0;for(this[e+s]=255&t;--s>=0&&(o*=256);)this[e+s]=(t/o>>0)-a&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||C(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||C(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||C(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||C(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):j(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||C(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-er&&n>e)for(i=o-1;i>=0;i--)t[i+e]=this[i+r];else if(1e3>o||!s.TYPED_ARRAY_SUPPORT)for(i=0;o>i;i++)t[i+e]=this[i+r];else t._set(this.subarray(r,r+o),e);return o},s.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new RangeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=H(t.toString()),s=i.length;for(n=e;r>n;n++)this[n]=i[n%s]}return this}},s.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(s.TYPED_ARRAY_SUPPORT)return new s(this).buffer;for(var t=new Uint8Array(this.length),e=0,r=t.length;r>e;e+=1)t[e]=this[e];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var $=s.prototype;s._augment=function(t){return t.constructor=s,t._isBuffer=!0,t._set=t.set,t.get=$.get,t.set=$.set,t.write=$.write,t.toString=$.toString,t.toLocaleString=$.toString,t.toJSON=$.toJSON,t.equals=$.equals,t.compare=$.compare,t.indexOf=$.indexOf,t.copy=$.copy,t.slice=$.slice,t.readUIntLE=$.readUIntLE,t.readUIntBE=$.readUIntBE,t.readUInt8=$.readUInt8,t.readUInt16LE=$.readUInt16LE,t.readUInt16BE=$.readUInt16BE,t.readUInt32LE=$.readUInt32LE,t.readUInt32BE=$.readUInt32BE,t.readIntLE=$.readIntLE,t.readIntBE=$.readIntBE,t.readInt8=$.readInt8,t.readInt16LE=$.readInt16LE,t.readInt16BE=$.readInt16BE,t.readInt32LE=$.readInt32LE,t.readInt32BE=$.readInt32BE,t.readFloatLE=$.readFloatLE,t.readFloatBE=$.readFloatBE,t.readDoubleLE=$.readDoubleLE,t.readDoubleBE=$.readDoubleBE,t.writeUInt8=$.writeUInt8,t.writeUIntLE=$.writeUIntLE,t.writeUIntBE=$.writeUIntBE,t.writeUInt16LE=$.writeUInt16LE,t.writeUInt16BE=$.writeUInt16BE,t.writeUInt32LE=$.writeUInt32LE,t.writeUInt32BE=$.writeUInt32BE,t.writeIntLE=$.writeIntLE,t.writeIntBE=$.writeIntBE,t.writeInt8=$.writeInt8,t.writeInt16LE=$.writeInt16LE,t.writeInt16BE=$.writeInt16BE,t.writeInt32LE=$.writeInt32LE,t.writeInt32BE=$.writeInt32BE,t.writeFloatLE=$.writeFloatLE,t.writeFloatBE=$.writeFloatBE,t.writeDoubleLE=$.writeDoubleLE,t.writeDoubleBE=$.writeDoubleBE,t.fill=$.fill,t.inspect=$.inspect,t.toArrayBuffer=$.toArrayBuffer,t};var tt=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":49,ieee754:50,isarray:51}],49:[function(t,e,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===o||e===h?62:e===a||e===d?63:f>e?-1:f+10>e?e-f+26+26:c+26>e?e-c:u+26>e?e-u+26:void 0}function r(t){function r(t){u[h++]=t}var n,i,o,a,f,u;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var c=t.length;f="="===t.charAt(c-2)?2:"="===t.charAt(c-1)?1:0,u=new s(3*t.length/4-f),o=f>0?t.length-4:t.length;var h=0;for(n=0,i=0;o>n;n+=4,i+=3)a=e(t.charAt(n))<<18|e(t.charAt(n+1))<<12|e(t.charAt(n+2))<<6|e(t.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===f?(a=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&a)):1===f&&(a=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(a>>8&255),r(255&a)),u}function i(t){function e(t){return n.charAt(t)}function r(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,s,o,a=t.length%3,f="";for(i=0,o=t.length-a;o>i;i+=3)s=(t[i]<<16)+(t[i+1]<<8)+t[i+2],f+=r(s);switch(a){case 1:s=t[t.length-1],f+=e(s>>2),f+=e(s<<4&63),f+="==";break;case 2:s=(t[t.length-2]<<8)+t[t.length-1],f+=e(s>>10),f+=e(s>>4&63),f+=e(s<<2&63),f+="="}return f}var s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="+".charCodeAt(0),a="/".charCodeAt(0),f="0".charCodeAt(0),u="a".charCodeAt(0),c="A".charCodeAt(0),h="-".charCodeAt(0),d="_".charCodeAt(0);t.toByteArray=r,t.fromByteArray=i}("undefined"==typeof r?this.base64js={}:r)},{}],50:[function(t,e,r){r.read=function(t,e,r,n,i){var s,o,a=8*i-n-1,f=(1<>1,c=-7,h=r?i-1:0,d=r?-1:1,p=t[e+h];for(h+=d,s=p&(1<<-c)-1,p>>=-c,c+=a;c>0;s=256*s+t[e+h],h+=d,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+h],h+=d,c-=8);if(0===s)s=1-u;else{if(s===f)return o?NaN:(p?-1:1)*(1/0);o+=Math.pow(2,n),s-=u}return(p?-1:1)*o*Math.pow(2,s-n)},r.write=function(t,e,r,n,i,s){var o,a,f,u=8*s-i-1,c=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,l=n?1:-1,b=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-o))<1&&(o--,f*=2),e+=o+h>=1?d/f:d*Math.pow(2,1-h),e*f>=2&&(o++,f/=2),o+h>=c?(a=0,o=c):o+h>=1?(a=(e*f-1)*Math.pow(2,i),o+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&a,p+=l,a/=256,i-=8);for(o=o<0;t[r+p]=255&o,p+=l,o/=256,u-=8);t[r+p-l]|=128*b}},{}],51:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],52:[function(t,e,r){"use strict";r.randomBytes=r.rng=r.pseudoRandomBytes=r.prng=t("randombytes"),r.createHash=r.Hash=t("create-hash"),r.createHmac=r.Hmac=t("create-hmac");var n=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(Object.keys(t("browserify-sign/algos")));r.getHashes=function(){return n};var i=t("pbkdf2");r.pbkdf2=i.pbkdf2,r.pbkdf2Sync=i.pbkdf2Sync;var s=t("browserify-cipher");["Cipher","createCipher","Cipheriv","createCipheriv","Decipher","createDecipher","Decipheriv","createDecipheriv","getCiphers","listCiphers"].forEach(function(t){r[t]=s[t]});var o=t("diffie-hellman");["DiffieHellmanGroup","createDiffieHellmanGroup","getDiffieHellman","createDiffieHellman","DiffieHellman"].forEach(function(t){r[t]=o[t]});var a=t("browserify-sign");["createSign","Sign","createVerify","Verify"].forEach(function(t){r[t]=a[t]}),r.createECDH=t("create-ecdh");var f=t("public-encrypt");["publicEncrypt","privateEncrypt","publicDecrypt","privateDecrypt"].forEach(function(t){r[t]=f[t]}),["createCredentials"].forEach(function(t){r[t]=function(){throw new Error(["sorry, "+t+" is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))}})},{"browserify-cipher":53,"browserify-sign":83,"browserify-sign/algos":82,"create-ecdh":150,"create-hash":176,"create-hmac":189,"diffie-hellman":190,pbkdf2:197,"public-encrypt":198,randombytes:243}],53:[function(t,e,r){function n(t,e){var r,n;if(t=t.toLowerCase(),d[t])r=d[t].key,n=d[t].iv;else{if(!h[t])throw new TypeError("invalid suite type");r=8*h[t].key,n=h[t].iv}var i=f(e,!1,r,n);return s(t,i.key,i.iv)}function i(t,e){var r,n;if(t=t.toLowerCase(),d[t])r=d[t].key,n=d[t].iv;else{if(!h[t])throw new TypeError("invalid suite type");r=8*h[t].key,n=h[t].iv}var i=f(e,!1,r,n);return o(t,i.key,i.iv)}function s(t,e,r){if(t=t.toLowerCase(),d[t])return u.createCipheriv(t,e,r);if(h[t])return new c({key:e,iv:r,mode:t});throw new TypeError("invalid suite type")}function o(t,e,r){if(t=t.toLowerCase(),d[t])return u.createDecipheriv(t,e,r);if(h[t])return new c({key:e,iv:r,mode:t,decrypt:!0});throw new TypeError("invalid suite type")}function a(){return Object.keys(h).concat(u.getCiphers())}var f=t("evp_bytestokey"),u=t("browserify-aes/browser"),c=t("browserify-des"),h=t("browserify-des/modes"),d=t("browserify-aes/modes");r.createCipher=r.Cipher=n,r.createCipheriv=r.Cipheriv=s,r.createDecipher=r.Decipher=i,r.createDecipheriv=r.Decipheriv=o,r.listCiphers=r.getCiphers=a},{"browserify-aes/browser":56,"browserify-aes/modes":60,"browserify-des":71,"browserify-des/modes":72,evp_bytestokey:81}],54:[function(t,e,r){(function(t){function e(t){var e,r;return e=t>a||0>t?(r=Math.abs(t)%a,0>t?a-r:r):t}function n(t){for(var e=0;et;e=++t)128>e?r.push(e<<1):r.push(e<<1^283);return r}(),i=0,f=0,e=u=0;256>u;e=++u)r=f^f<<1^f<<2^f<<3^f<<4,r=r>>>8^255&r^99,this.SBOX[i]=r,this.INV_SBOX[r]=i,s=t[i],o=t[s],a=t[o],n=257*t[r]^16843008*r,this.SUB_MIX[0][i]=n<<24|n>>>8,this.SUB_MIX[1][i]=n<<16|n>>>16,this.SUB_MIX[2][i]=n<<8|n>>>24,this.SUB_MIX[3][i]=n,n=16843009*a^65537*o^257*s^16843008*i,this.INV_SUB_MIX[0][r]=n<<24|n>>>8,this.INV_SUB_MIX[1][r]=n<<16|n>>>16,this.INV_SUB_MIX[2][r]=n<<8|n>>>24,this.INV_SUB_MIX[3][r]=n,0===i?i=f=1:(i=s^t[t[t[a^s]]],f^=t[t[f]]);return!0};var f=new i;o.blockSize=16,o.prototype.blockSize=o.blockSize,o.keySize=32,o.prototype.keySize=o.keySize,o.prototype._doReset=function(){var t,e,r,n,i,s;for(r=this._key,e=r.length,this._nRounds=e+6,i=4*(this._nRounds+1),this._keySchedule=[],n=0;i>n;n++)this._keySchedule[n]=e>n?r[n]:(s=this._keySchedule[n-1],n%e===0?(s=s<<8|s>>>24,s=f.SBOX[s>>>24]<<24|f.SBOX[s>>>16&255]<<16|f.SBOX[s>>>8&255]<<8|f.SBOX[255&s],s^=f.RCON[n/e|0]<<24):e>6&&n%e===4?s=f.SBOX[s>>>24]<<24|f.SBOX[s>>>16&255]<<16|f.SBOX[s>>>8&255]<<8|f.SBOX[255&s]:void 0,this._keySchedule[n-e]^s);for(this._invKeySchedule=[],t=0;i>t;t++)n=i-t,s=this._keySchedule[n-(t%4?0:4)],this._invKeySchedule[t]=4>t||4>=n?s:f.INV_SUB_MIX[0][f.SBOX[s>>>24]]^f.INV_SUB_MIX[1][f.SBOX[s>>>16&255]]^f.INV_SUB_MIX[2][f.SBOX[s>>>8&255]]^f.INV_SUB_MIX[3][f.SBOX[255&s]];return!0},o.prototype.encryptBlock=function(e){e=s(new t(e));var r=this._doCryptBlock(e,this._keySchedule,f.SUB_MIX,f.SBOX),n=new t(16);return n.writeUInt32BE(r[0],0),n.writeUInt32BE(r[1],4),n.writeUInt32BE(r[2],8),n.writeUInt32BE(r[3],12),n},o.prototype.decryptBlock=function(e){e=s(new t(e));var r=[e[3],e[1]];e[1]=r[0],e[3]=r[1];var n=this._doCryptBlock(e,this._invKeySchedule,f.INV_SUB_MIX,f.INV_SBOX),i=new t(16);return i.writeUInt32BE(n[0],0),i.writeUInt32BE(n[3],4),i.writeUInt32BE(n[2],8),i.writeUInt32BE(n[1],12),i},o.prototype.scrub=function(){n(this._keySchedule),n(this._invKeySchedule),n(this._key)},o.prototype._doCryptBlock=function(t,r,n,i){var s,o,a,f,u,c,h,d,p;o=t[0]^r[0],a=t[1]^r[1],f=t[2]^r[2],u=t[3]^r[3],s=4;for(var l=1;l>>24]^n[1][a>>>16&255]^n[2][f>>>8&255]^n[3][255&u]^r[s++],h=n[0][a>>>24]^n[1][f>>>16&255]^n[2][u>>>8&255]^n[3][255&o]^r[s++],d=n[0][f>>>24]^n[1][u>>>16&255]^n[2][o>>>8&255]^n[3][255&a]^r[s++],p=n[0][u>>>24]^n[1][o>>>16&255]^n[2][a>>>8&255]^n[3][255&f]^r[s++],o=c,a=h,f=d,u=p;return c=(i[o>>>24]<<24|i[a>>>16&255]<<16|i[f>>>8&255]<<8|i[255&u])^r[s++],h=(i[a>>>24]<<24|i[f>>>16&255]<<16|i[u>>>8&255]<<8|i[255&o])^r[s++],d=(i[f>>>24]<<24|i[u>>>16&255]<<16|i[o>>>8&255]<<8|i[255&a])^r[s++],p=(i[u>>>24]<<24|i[o>>>16&255]<<16|i[a>>>8&255]<<8|i[255&f])^r[s++],[e(c),e(h),e(d),e(p)]},r.AES=o}).call(this,t("buffer").Buffer)},{buffer:48}],55:[function(t,e,r){(function(r){function n(t,e,i,a){if(!(this instanceof n))return new n(t,e,i);o.call(this),this._finID=r.concat([i,new r([0,0,0,1])]),i=r.concat([i,new r([0,0,0,2])]),this._cipher=new s.AES(e),this._prev=new r(i.length),this._cache=new r(""),this._secCache=new r(""),this._decrypt=a,this._alen=0,this._len=0,i.copy(this._prev),this._mode=t;var u=new r(4);u.fill(0),this._ghash=new f(this._cipher.encryptBlock(u)),this._authTag=null,this._called=!1}function i(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=-1;++ie&&(e=new r(e),e.fill(0),this._ghash.update(e))}this._called=!0;var n=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(n),this._len+=t.length,n},n.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=u(this._ghash["final"](8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt){if(i(t,this._authTag))throw new Error("Unsupported state or unable to authenticate data")}else this._authTag=t;this._cipher.scrub()},n.prototype.getAuthTag=function(){if(!this._decrypt&&r.isBuffer(this._authTag))return this._authTag;throw new Error("Attempting to get auth tag in unsupported state")},n.prototype.setAuthTag=function(t){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=t},n.prototype.setAAD=function(t){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(t),this._alen+=t.length}}).call(this,t("buffer").Buffer)},{"./aes":54,"./ghash":59,buffer:48,"buffer-xor":68,"cipher-base":69,inherits:296}],56:[function(t,e,r){function n(){return Object.keys(o)}var i=t("./encrypter");r.createCipher=r.Cipher=i.createCipher,r.createCipheriv=r.Cipheriv=i.createCipheriv;var s=t("./decrypter");r.createDecipher=r.Decipher=s.createDecipher,r.createDecipheriv=r.Decipheriv=s.createDecipheriv;var o=t("./modes");r.listCiphers=r.getCiphers=n},{"./decrypter":57,"./encrypter":58,"./modes":60}],57:[function(t,e,r){(function(e){function n(t,r,s){return this instanceof n?(u.call(this),this._cache=new i,this._last=void 0,this._cipher=new f.AES(r),this._prev=new e(s.length),s.copy(this._prev),this._mode=t,void(this._autopadding=!0)):new n(t,r,s)}function i(){return this instanceof i?void(this.cache=new e("")):new i}function s(t){for(var e=t[15],r=-1;++r16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},i.prototype.flush=function(){return this.cache.length?this.cache:void 0};var b={ECB:t("./modes/ecb"),CBC:t("./modes/cbc"),CFB:t("./modes/cfb"),CFB8:t("./modes/cfb8"),CFB1:t("./modes/cfb1"),OFB:t("./modes/ofb"),CTR:t("./modes/ctr"),GCM:t("./modes/ctr")};r.createDecipher=a,r.createDecipheriv=o}).call(this,t("buffer").Buffer)},{"./aes":54,"./authCipher":55,"./modes":60,"./modes/cbc":61,"./modes/cfb":62,"./modes/cfb1":63,"./modes/cfb8":64,"./modes/ctr":65,"./modes/ecb":66,"./modes/ofb":67,"./streamCipher":70,buffer:48,"cipher-base":69,evp_bytestokey:81,inherits:296}],58:[function(t,e,r){(function(e){function n(t,r,s){return this instanceof n?(f.call(this),this._cache=new i,this._cipher=new a.AES(r),this._prev=new e(s.length),s.copy(this._prev),this._mode=t,void(this._autopadding=!0)):new n(t,r,s)}function i(){return this instanceof i?void(this.cache=new e("")):new i}function s(t,r,i){var s=c[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof i&&(i=new e(i)),"string"==typeof r&&(r=new e(r)),r.length!==s.key/8)throw new TypeError("invalid key length "+r.length);if(i.length!==s.iv)throw new TypeError("invalid iv length "+i.length);return"stream"===s.type?new d(l[s.mode],r,i):"auth"===s.type?new p(l[s.mode],r,i):new n(l[s.mode],r,i)}function o(t,e){var r=c[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=h(e,!1,r.key,r.iv);return s(t,n.key,n.iv)}var a=t("./aes"),f=t("cipher-base"),u=t("inherits"),c=t("./modes"),h=t("evp_bytestokey"),d=t("./streamCipher"),p=t("./authCipher");u(n,f),n.prototype._update=function(t){this._cache.add(t);for(var r,n,i=[];r=this._cache.get();)n=this._mode.encrypt(this,r),i.push(n);return e.concat(i)},n.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if("10101010101010101010101010101010"!==t.toString("hex"))throw this._cipher.scrub(),new Error("data not multiple of block length")},n.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},i.prototype.add=function(t){this.cache=e.concat([this.cache,t])},i.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},i.prototype.flush=function(){for(var t=16-this.cache.length,r=new e(t),n=-1;++nf||0>t?(r=Math.abs(t)%f,0>t?f-r:r):t}function o(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]}var a=new t(16);a.fill(0),e.exports=r,r.prototype.ghash=function(t){for(var e=-1;++e0;t--)s[t]=s[t]>>>1|(1&s[t-1])<<31;s[0]=s[0]>>>1,r&&(s[0]=s[0]^225<<24)}this.state=i(a)},r.prototype.update=function(e){this.cache=t.concat([this.cache,e]);for(var r;this.cache.length>=16;)r=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(r)},r.prototype["final"]=function(e,r){return this.cache.length&&this.ghash(t.concat([this.cache,a],16)),this.ghash(i([0,e,0,r])),this.state};var f=Math.pow(2,32)}).call(this,t("buffer").Buffer)},{buffer:48}],60:[function(t,e,r){r["aes-128-ecb"]={cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},r["aes-192-ecb"]={cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},r["aes-256-ecb"]={cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},r["aes-128-cbc"]={cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},r["aes-192-cbc"]={cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},r["aes-256-cbc"]={cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},r.aes128=r["aes-128-cbc"],r.aes192=r["aes-192-cbc"],r.aes256=r["aes-256-cbc"],r["aes-128-cfb"]={cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},r["aes-192-cfb"]={cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},r["aes-256-cfb"]={cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"}, +r["aes-128-cfb8"]={cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},r["aes-192-cfb8"]={cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},r["aes-256-cfb8"]={cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},r["aes-128-cfb1"]={cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},r["aes-192-cfb1"]={cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},r["aes-256-cfb1"]={cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},r["aes-128-ofb"]={cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},r["aes-192-ofb"]={cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},r["aes-256-ofb"]={cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},r["aes-128-ctr"]={cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},r["aes-192-ctr"]={cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},r["aes-256-ctr"]={cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},r["aes-128-gcm"]={cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},r["aes-192-gcm"]={cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},r["aes-256-gcm"]={cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}},{}],61:[function(t,e,r){var n=t("buffer-xor");r.encrypt=function(t,e){var r=n(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev},r.decrypt=function(t,e){var r=t._prev;t._prev=e;var i=t._cipher.decryptBlock(e);return n(i,r)}},{"buffer-xor":68}],62:[function(t,e,r){(function(e){function n(t,r,n){var s=r.length,o=i(r,t._cache);return t._cache=t._cache.slice(s),t._prev=e.concat([t._prev,n?r:o]),o}var i=t("buffer-xor");r.encrypt=function(t,r,i){for(var s,o=new e("");r.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=new e("")),!(t._cache.length<=r.length)){o=e.concat([o,n(t,r,i)]);break}s=t._cache.length,o=e.concat([o,n(t,r.slice(0,s),i)]),r=r.slice(s)}return o}}).call(this,t("buffer").Buffer)},{buffer:48,"buffer-xor":68}],63:[function(t,e,r){(function(t){function e(t,e,r){for(var i,s,o,a=-1,f=8,u=0;++a>a%8,t._prev=n(t._prev,r?s:o);return u}function n(e,r){var n=e.length,i=-1,s=new t(e.length);for(e=t.concat([e,new t([r])]);++i>7;return s}r.encrypt=function(r,n,i){for(var s=n.length,o=new t(s),a=-1;++as;++s)i[s]=e[s]^r[s];return i}}).call(this,t("buffer").Buffer)},{buffer:48}],69:[function(t,e,r){(function(r){function n(t){i.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this["final"]=this._finalOrDigest,this._decoder=null,this._encoding=null}var i=t("stream").Transform,s=t("inherits"),o=t("string_decoder").StringDecoder;e.exports=n,s(n,i),n.prototype.update=function(t,e,n){"string"==typeof t&&(t=new r(t,e));var i=this._update(t);return this.hashMode?this:(n&&(i=this._toString(i,n)),i)},n.prototype.setAutoPadding=function(){},n.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},n.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},n.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},n.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(i){n=i}finally{r(n)}},n.prototype._flush=function(t){var e;try{this.push(this._final())}catch(r){e=r}finally{t(e)}},n.prototype._finalOrDigest=function(t){var e=this._final()||new r("");return t&&(e=this._toString(e,t,!0)),e},n.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n}}).call(this,t("buffer").Buffer)},{buffer:48,inherits:296,stream:265,string_decoder:266}],70:[function(t,e,r){(function(r){function n(t,e,o,a){return this instanceof n?(s.call(this),this._cipher=new i.AES(e),this._prev=new r(o.length),this._cache=new r(""),this._secCache=new r(""),this._decrypt=a,o.copy(this._prev),void(this._mode=t)):new n(t,e,o)}var i=t("./aes"),s=t("cipher-base"),o=t("inherits");o(n,s),e.exports=n,n.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)},n.prototype._final=function(){this._cipher.scrub()}}).call(this,t("buffer").Buffer)},{"./aes":54,buffer:48,"cipher-base":69,inherits:296}],71:[function(t,e,r){(function(r){function n(t){i.call(this);var e,n=t.mode.toLowerCase(),s=a[n];e=t.decrypt?"decrypt":"encrypt";var o=t.key;("des-ede"===n||"des-ede-cbc"===n)&&(o=r.concat([o,o.slice(0,8)]));var f=t.iv;this._des=s.create({key:o,iv:f,type:e})}var i=t("cipher-base"),s=t("des.js"),o=t("inherits"),a={"des-ede3-cbc":s.CBC.instantiate(s.EDE),"des-ede3":s.EDE,"des-ede-cbc":s.CBC.instantiate(s.EDE),"des-ede":s.EDE,"des-cbc":s.CBC.instantiate(s.DES),"des-ecb":s.DES};a.des=a["des-cbc"],a.des3=a["des-ede3-cbc"],e.exports=n,o(n,i),n.prototype._update=function(t){return new r(this._des.update(t))},n.prototype._final=function(){return new r(this._des["final"]())}}).call(this,t("buffer").Buffer)},{buffer:48,"cipher-base":73,"des.js":74,inherits:296}],72:[function(t,e,r){r["des-ecb"]={key:8,iv:0},r["des-cbc"]=r.des={key:8,iv:8},r["des-ede3-cbc"]=r.des3={key:24,iv:8},r["des-ede3"]={key:24,iv:0},r["des-ede-cbc"]={key:16,iv:8},r["des-ede"]={key:16,iv:0}},{}],73:[function(t,e,r){arguments[4][69][0].apply(r,arguments)},{buffer:48,dup:69,inherits:296,stream:265,string_decoder:266}],74:[function(t,e,r){"use strict";r.utils=t("./des/utils"),r.Cipher=t("./des/cipher"),r.DES=t("./des/des"),r.CBC=t("./des/cbc"),r.EDE=t("./des/ede")},{"./des/cbc":75,"./des/cipher":76,"./des/des":77,"./des/ede":78,"./des/utils":79}],75:[function(t,e,r){"use strict";function n(t){s.equal(t.length,8,"Invalid IV length"),this.iv=new Array(8);for(var e=0;en;n++)this.buffer[this.bufferOff+n]=t[e+n];return this.bufferOff+=r,r},n.prototype._flushBuffer=function(t,e){return this._update(this.buffer,0,t,e),this.bufferOff=0,this.blockSize},n.prototype._updateEncrypt=function(t){var e=0,r=0,n=(this.bufferOff+t.length)/this.blockSize|0,i=new Array(n*this.blockSize);0!==this.bufferOff&&(e+=this._buffer(t,e),this.bufferOff===this.buffer.length&&(r+=this._flushBuffer(i,r)));for(var s=t.length-(t.length-e)%this.blockSize;s>e;e+=this.blockSize)this._update(t,e,i,r),r+=this.blockSize;for(;e0;n--)e+=this._buffer(t,e),r+=this._flushBuffer(i,r);return e+=this._buffer(t,e),i},n.prototype["final"]=function(t){var e;t&&(e=this.update(t));var r;return r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},n.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];r=f.r28shl(r,o),n=f.r28shl(n,o),f.pc2(r,n,t.keys,i)}},i.prototype._update=function(t,e,r,n){var i=this._desState,s=f.readUInt32BE(t,e),o=f.readUInt32BE(t,e+4);f.ip(s,o,i.tmp,0),s=i.tmp[0],o=i.tmp[1],"encrypt"===this.type?this._encrypt(i,s,o,i.tmp,0):this._decrypt(i,s,o,i.tmp,0),s=i.tmp[0],o=i.tmp[1],f.writeUInt32BE(r,s,n),f.writeUInt32BE(r,o,n+4)},i.prototype._pad=function(t,e){for(var r=t.length-e,n=e;n>>0,s=p}f.rip(o,s,n,i)},i.prototype._decrypt=function(t,e,r,n,i){for(var s=r,o=e,a=t.keys.length-2;a>=0;a-=2){var u=t.keys[a],c=t.keys[a+1];f.expand(s,t.tmp,0),u^=t.tmp[0],c^=t.tmp[1];var h=f.substitute(u,c),d=f.permute(h),p=s;s=(o^d)>>>0,o=p}f.rip(s,o,n,i)}},{"../des":74,inherits:296,"minimalistic-assert":80}],78:[function(t,e,r){"use strict";function n(t,e){s.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),n=e.slice(8,16),i=e.slice(16,24);"encrypt"===t?this.ciphers=[u.create({type:"encrypt",key:r}),u.create({type:"decrypt",key:n}),u.create({type:"encrypt",key:i})]:this.ciphers=[u.create({type:"decrypt",key:i}),u.create({type:"encrypt",key:n}),u.create({type:"decrypt",key:r})]}function i(t){f.call(this,t);var e=new n(this.type,this.options.key);this._edeState=e}var s=t("minimalistic-assert"),o=t("inherits"),a=t("../des"),f=a.Cipher,u=a.DES;o(i,f),e.exports=i,i.create=function(t){return new i(t)},i.prototype._update=function(t,e,r,n){var i=this._edeState;i.ciphers[0]._update(t,e,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},i.prototype._pad=u.prototype._pad,i.prototype._unpad=u.prototype._unpad},{"../des":74,inherits:296,"minimalistic-assert":80}],79:[function(t,e,r){"use strict";r.readUInt32BE=function(t,e){var r=t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e];return r>>>0},r.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},r.ip=function(t,e,r,n){for(var i=0,s=0,o=6;o>=0;o-=2){for(var a=0;24>=a;a+=8)i<<=1,i|=e>>>a+o&1;for(var a=0;24>=a;a+=8)i<<=1,i|=t>>>a+o&1}for(var o=6;o>=0;o-=2){for(var a=1;25>=a;a+=8)s<<=1,s|=e>>>a+o&1;for(var a=1;25>=a;a+=8)s<<=1,s|=t>>>a+o&1}r[n+0]=i>>>0,r[n+1]=s>>>0},r.rip=function(t,e,r,n){for(var i=0,s=0,o=0;4>o;o++)for(var a=24;a>=0;a-=8)i<<=1,i|=e>>>a+o&1,i<<=1,i|=t>>>a+o&1;for(var o=4;8>o;o++)for(var a=24;a>=0;a-=8)s<<=1,s|=e>>>a+o&1,s<<=1,s|=t>>>a+o&1;r[n+0]=i>>>0,r[n+1]=s>>>0},r.pc1=function(t,e,r,n){for(var i=0,s=0,o=7;o>=5;o--){for(var a=0;24>=a;a+=8)i<<=1,i|=e>>a+o&1;for(var a=0;24>=a;a+=8)i<<=1,i|=t>>a+o&1}for(var a=0;24>=a;a+=8)i<<=1,i|=e>>a+o&1;for(var o=1;3>=o;o++){for(var a=0;24>=a;a+=8)s<<=1,s|=e>>a+o&1;for(var a=0;24>=a;a+=8)s<<=1,s|=t>>a+o&1}for(var a=0;24>=a;a+=8)s<<=1,s|=t>>a+o&1;r[n+0]=i>>>0,r[n+1]=s>>>0},r.r28shl=function(t,e){return t<>>28-e};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(t,e,r,i){for(var s=0,o=0,a=n.length>>>1,f=0;a>f;f++)s<<=1,s|=t>>>n[f]&1;for(var f=a;f>>n[f]&1;r[i+0]=s>>>0,r[i+1]=o>>>0},r.expand=function(t,e,r){var n=0,i=0;n=(1&t)<<5|t>>>27;for(var s=23;s>=15;s-=4)n<<=6,n|=t>>>s&63;for(var s=11;s>=3;s-=4)i|=t>>>s&63,i<<=6;i|=(31&t)<<1|t>>>31,e[r+0]=n>>>0,e[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(t,e){for(var r=0,n=0;4>n;n++){var s=t>>>18-6*n&63,o=i[64*n+s];r<<=4,r|=o}for(var n=0;4>n;n++){var s=e>>>18-6*n&63,o=i[256+64*n+s];r<<=4,r|=o}return r>>>0};var s=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(t){for(var e=0,r=0;r>>s[r]&1;return e>>>0},r.padSplit=function(t,e,r){for(var n=t.toString(2);n.lengths;s+=r)i.push(n.slice(s,s+r));return i.join(" ")}},{}],80:[function(t,e,r){function n(t,e){if(!t)throw new Error(e||"Assertion failed")}e.exports=n,n.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)}},{}],81:[function(t,e,r){(function(r){function n(t,e,n,s){r.isBuffer(t)||(t=new r(t,"binary")),e&&!r.isBuffer(e)&&(e=new r(e,"binary")),n/=8,s=s||0;for(var o,a,f=0,u=0,c=new r(n),h=new r(s),d=0,p=[];;){if(d++>0&&p.push(o),p.push(t),e&&p.push(e),o=i(r.concat(p)),p=[],a=0,n>0)for(;;){if(0===n)break;if(a===o.length)break;c[f++]=o[a],n--,a++}if(s>0&&a!==o.length)for(;;){if(0===s)break;if(a===o.length)break;h[u++]=o[a],s--,a++}if(0===n&&0===s)break}for(a=0;as;s++){var o=t.charCodeAt(s)-48;n<<=4,n|=o>=49&&54>=o?o-49+10:o>=17&&22>=o?o-17+10:15&o}return n}function a(t,e,r,n){for(var i=0,s=Math.min(t.length,r),o=e;s>o;o++){var a=t.charCodeAt(o)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}function f(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}function u(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],s=0|e.words[0],o=i*s,a=67108863&o,f=o/67108864|0;r.words[0]=a;for(var u=1;n>u;u++){for(var c=f>>>26,h=67108863&f,d=Math.min(u,e.length-1),p=Math.max(0,u-t.length+1);d>=p;p++){var l=u-p|0;i=0|t.words[l],s=0|e.words[p],o=i*s+h,c+=o/67108864|0,h=67108863&o}r.words[u]=0|h,f=0|c}return 0!==f?r.words[u]=0|f:r.length--,r.strip()}function c(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,s=0;s=u;u++){var c=s-u,h=0|t.words[c],d=0|e.words[u],p=h*d,l=67108863&p;o=o+(p/67108864|0)|0,l=l+a|0,a=67108863&l,o=o+(l>>>26)|0,i+=o>>>26,o&=67108863}r.words[s]=a,n=o,o=i}return 0!==n?r.words[s]=n:r.length--,r.strip()}function h(t,e,r){var n=new d;return n.mulp(t,e,r)}function d(t,e){this.x=t,this.y=e}function p(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function l(){p.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){p.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function g(){p.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function m(){p.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function y(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function v(t){y.call(this,t),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}"object"==typeof e?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var _;try{_=t("buffer").Buffer}catch(w){}s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&36>=e),t=t.toString().replace(/\s+/g,"");var i=0;"-"===t[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initNumber=function(t,e,r){0>t&&(this.negative=1,t=-t),67108864>t?(this.words=[67108863&t],this.length=1):4503599627370496>t?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(9007199254740992>t),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[s]|=o<>>26-a&67108863,a+=24,a>=26&&(a-=26,s++);else if("le"===r)for(i=0,s=0;i>>26-a&67108863,a+=24,a>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=o(t,r,r+6),this.words[n]|=i<>>26-s&4194303,s+=24,s>=26&&(s-=26,n++);r+6!==e&&(i=o(t,e,r+6),this.words[n]|=i<>>26-s&4194303),this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;67108863>=i;i*=e)n++;n--,i=i/e|0;for(var s=t.length-r,o=s%n,f=Math.min(s,s-o)+r,u=0,c=r;f>c;c+=n)u=a(t,c,c+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==o){var h=1;for(u=a(t,c,t.length,e),c=0;o>c;c++)h*=e;this.imuln(h),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}},s.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?""};var S=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],I=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],k=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(t,e){t=t||10,e=0|e||1;var r;if(16===t||"hex"===t){r="";for(var i=0,s=0,o=0;o>>24-i&16777215,r=0!==s||o!==this.length-1?S[6-f.length]+f+r:f+r,i+=2,i>=26&&(i-=26,o--)}for(0!==s&&(r=s.toString(16)+r);r.length%e!==0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&36>=t){var u=I[t],c=k[t];r="";var h=this.clone();for(h.negative=0;!h.isZero();){var d=h.modn(c).toString(t);h=h.idivn(c),r=h.isZero()?d+r:S[u-d.length]+d+r}for(this.isZero()&&(r="0"+r);r.length%e!==0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var t,e=this.bitLength();return 26>=e?t=this.words[0]:52>=e?t=67108864*this.words[1]+this.words[0]:53===e?t=4503599627370496+67108864*this.words[1]+this.words[0]:n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return n("undefined"!=typeof _),new _(this.toArray(t,e))},s.prototype.toArray=function(t,e){var r=this.byteLength(),i=e||Math.max(1,r);n(i>=r,"byte array longer than desired length"),n(i>0,"Requested array length <= 0"),this.strip();var s,o,a="le"===t,f=new Array(i),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),f[o]=s;for(;i>o;o++)f[o]=0}else{for(o=0;i-r>o;o++)f[o]=0;for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),f[i-o-1]=s}return f},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0===(8191&e)&&(r+=13,e>>>=13),0===(127&e)&&(r+=7,e>>>=7),0===(15&e)&&(r+=4,e>>>=4),0===(3&e)&&(r+=2,e>>>=2),0===(1&e)&&r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){n("number"==typeof t&&t>=0);for(var e=0|Math.ceil(t/26),r=t%26;this.length0&&e--;for(var i=0;e>i;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);for(var r=t/26|0,i=t%26;this.length<=r;)this.words[this.length++]=0;return e?this.words[r]=this.words[r]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,s=0;s>>26;for(;0!==i&&s>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r=this.cmp(t);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;var n,i;r>0?(n=this,i=t):(n=t,i=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,p=0|o[1],l=8191&p,b=p>>>13,g=0|o[2],m=8191&g,y=g>>>13,v=0|o[3],_=8191&v,w=v>>>13,S=0|o[4],I=8191&S,k=S>>>13,E=0|o[5],A=8191&E,x=E>>>13,P=0|o[6],O=8191&P,B=P>>>13,M=0|o[7],R=8191&M,T=M>>>13,C=0|o[8],N=8191&C,j=C>>>13,U=0|o[9],L=8191&U,D=U>>>13,z=0|a[0],F=8191&z,K=z>>>13,H=0|a[1],q=8191&H,V=H>>>13,Y=0|a[2],G=8191&Y,W=Y>>>13,X=0|a[3],J=8191&X,Z=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],st=8191&it,ot=it>>>13,at=0|a[7],ft=8191&at,ut=at>>>13,ct=0|a[8],ht=8191&ct,dt=ct>>>13,pt=0|a[9],lt=8191&pt,bt=pt>>>13;r.negative=t.negative^e.negative,r.length=19,n=Math.imul(h,F),i=Math.imul(h,K),i+=Math.imul(d,F),s=Math.imul(d,K);var gt=u+n+((8191&i)<<13);u=s+(i>>>13)+(gt>>>26),gt&=67108863,n=Math.imul(l,F),i=Math.imul(l,K),i+=Math.imul(b,F),s=Math.imul(b,K),n+=Math.imul(h,q),i+=Math.imul(h,V),i+=Math.imul(d,q),s+=Math.imul(d,V);var mt=u+n+((8191&i)<<13);u=s+(i>>>13)+(mt>>>26),mt&=67108863,n=Math.imul(m,F),i=Math.imul(m,K),i+=Math.imul(y,F),s=Math.imul(y,K),n+=Math.imul(l,q),i+=Math.imul(l,V),i+=Math.imul(b,q),s+=Math.imul(b,V),n+=Math.imul(h,G),i+=Math.imul(h,W),i+=Math.imul(d,G),s+=Math.imul(d,W);var yt=u+n+((8191&i)<<13);u=s+(i>>>13)+(yt>>>26),yt&=67108863,n=Math.imul(_,F),i=Math.imul(_,K),i+=Math.imul(w,F),s=Math.imul(w,K),n+=Math.imul(m,q),i+=Math.imul(m,V),i+=Math.imul(y,q),s+=Math.imul(y,V),n+=Math.imul(l,G),i+=Math.imul(l,W),i+=Math.imul(b,G),s+=Math.imul(b,W),n+=Math.imul(h,J),i+=Math.imul(h,Z),i+=Math.imul(d,J),s+=Math.imul(d,Z);var vt=u+n+((8191&i)<<13);u=s+(i>>>13)+(vt>>>26),vt&=67108863,n=Math.imul(I,F),i=Math.imul(I,K),i+=Math.imul(k,F),s=Math.imul(k,K),n+=Math.imul(_,q),i+=Math.imul(_,V),i+=Math.imul(w,q),s+=Math.imul(w,V),n+=Math.imul(m,G),i+=Math.imul(m,W),i+=Math.imul(y,G),s+=Math.imul(y,W),n+=Math.imul(l,J),i+=Math.imul(l,Z),i+=Math.imul(b,J),s+=Math.imul(b,Z),n+=Math.imul(h,$),i+=Math.imul(h,tt),i+=Math.imul(d,$),s+=Math.imul(d,tt);var _t=u+n+((8191&i)<<13);u=s+(i>>>13)+(_t>>>26),_t&=67108863,n=Math.imul(A,F),i=Math.imul(A,K),i+=Math.imul(x,F),s=Math.imul(x,K),n+=Math.imul(I,q),i+=Math.imul(I,V),i+=Math.imul(k,q),s+=Math.imul(k,V),n+=Math.imul(_,G),i+=Math.imul(_,W),i+=Math.imul(w,G),s+=Math.imul(w,W),n+=Math.imul(m,J),i+=Math.imul(m,Z),i+=Math.imul(y,J),s+=Math.imul(y,Z),n+=Math.imul(l,$),i+=Math.imul(l,tt),i+=Math.imul(b,$),s+=Math.imul(b,tt),n+=Math.imul(h,rt),i+=Math.imul(h,nt),i+=Math.imul(d,rt),s+=Math.imul(d,nt);var wt=u+n+((8191&i)<<13);u=s+(i>>>13)+(wt>>>26),wt&=67108863,n=Math.imul(O,F),i=Math.imul(O,K),i+=Math.imul(B,F),s=Math.imul(B,K),n+=Math.imul(A,q),i+=Math.imul(A,V),i+=Math.imul(x,q),s+=Math.imul(x,V),n+=Math.imul(I,G),i+=Math.imul(I,W),i+=Math.imul(k,G),s+=Math.imul(k,W),n+=Math.imul(_,J),i+=Math.imul(_,Z),i+=Math.imul(w,J),s+=Math.imul(w,Z),n+=Math.imul(m,$),i+=Math.imul(m,tt),i+=Math.imul(y,$),s+=Math.imul(y,tt),n+=Math.imul(l,rt),i+=Math.imul(l,nt),i+=Math.imul(b,rt),s+=Math.imul(b,nt),n+=Math.imul(h,st),i+=Math.imul(h,ot),i+=Math.imul(d,st),s+=Math.imul(d,ot);var St=u+n+((8191&i)<<13);u=s+(i>>>13)+(St>>>26),St&=67108863,n=Math.imul(R,F),i=Math.imul(R,K),i+=Math.imul(T,F),s=Math.imul(T,K),n+=Math.imul(O,q),i+=Math.imul(O,V),i+=Math.imul(B,q),s+=Math.imul(B,V),n+=Math.imul(A,G),i+=Math.imul(A,W),i+=Math.imul(x,G),s+=Math.imul(x,W),n+=Math.imul(I,J),i+=Math.imul(I,Z),i+=Math.imul(k,J),s+=Math.imul(k,Z),n+=Math.imul(_,$),i+=Math.imul(_,tt),i+=Math.imul(w,$),s+=Math.imul(w,tt),n+=Math.imul(m,rt),i+=Math.imul(m,nt),i+=Math.imul(y,rt),s+=Math.imul(y,nt),n+=Math.imul(l,st),i+=Math.imul(l,ot),i+=Math.imul(b,st),s+=Math.imul(b,ot),n+=Math.imul(h,ft),i+=Math.imul(h,ut),i+=Math.imul(d,ft),s+=Math.imul(d,ut);var It=u+n+((8191&i)<<13);u=s+(i>>>13)+(It>>>26),It&=67108863,n=Math.imul(N,F),i=Math.imul(N,K),i+=Math.imul(j,F),s=Math.imul(j,K),n+=Math.imul(R,q),i+=Math.imul(R,V),i+=Math.imul(T,q),s+=Math.imul(T,V),n+=Math.imul(O,G),i+=Math.imul(O,W),i+=Math.imul(B,G),s+=Math.imul(B,W),n+=Math.imul(A,J),i+=Math.imul(A,Z),i+=Math.imul(x,J),s+=Math.imul(x,Z),n+=Math.imul(I,$),i+=Math.imul(I,tt),i+=Math.imul(k,$),s+=Math.imul(k,tt),n+=Math.imul(_,rt),i+=Math.imul(_,nt),i+=Math.imul(w,rt),s+=Math.imul(w,nt),n+=Math.imul(m,st),i+=Math.imul(m,ot),i+=Math.imul(y,st),s+=Math.imul(y,ot),n+=Math.imul(l,ft),i+=Math.imul(l,ut),i+=Math.imul(b,ft),s+=Math.imul(b,ut),n+=Math.imul(h,ht),i+=Math.imul(h,dt),i+=Math.imul(d,ht),s+=Math.imul(d,dt);var kt=u+n+((8191&i)<<13);u=s+(i>>>13)+(kt>>>26),kt&=67108863,n=Math.imul(L,F),i=Math.imul(L,K),i+=Math.imul(D,F),s=Math.imul(D,K),n+=Math.imul(N,q),i+=Math.imul(N,V),i+=Math.imul(j,q),s+=Math.imul(j,V),n+=Math.imul(R,G),i+=Math.imul(R,W),i+=Math.imul(T,G),s+=Math.imul(T,W),n+=Math.imul(O,J),i+=Math.imul(O,Z),i+=Math.imul(B,J),s+=Math.imul(B,Z),n+=Math.imul(A,$),i+=Math.imul(A,tt),i+=Math.imul(x,$),s+=Math.imul(x,tt),n+=Math.imul(I,rt),i+=Math.imul(I,nt),i+=Math.imul(k,rt),s+=Math.imul(k,nt),n+=Math.imul(_,st),i+=Math.imul(_,ot),i+=Math.imul(w,st),s+=Math.imul(w,ot),n+=Math.imul(m,ft),i+=Math.imul(m,ut),i+=Math.imul(y,ft),s+=Math.imul(y,ut),n+=Math.imul(l,ht),i+=Math.imul(l,dt),i+=Math.imul(b,ht),s+=Math.imul(b,dt),n+=Math.imul(h,lt),i+=Math.imul(h,bt),i+=Math.imul(d,lt),s+=Math.imul(d,bt);var Et=u+n+((8191&i)<<13);u=s+(i>>>13)+(Et>>>26),Et&=67108863,n=Math.imul(L,q),i=Math.imul(L,V),i+=Math.imul(D,q),s=Math.imul(D,V),n+=Math.imul(N,G),i+=Math.imul(N,W),i+=Math.imul(j,G),s+=Math.imul(j,W),n+=Math.imul(R,J),i+=Math.imul(R,Z),i+=Math.imul(T,J),s+=Math.imul(T,Z),n+=Math.imul(O,$),i+=Math.imul(O,tt),i+=Math.imul(B,$),s+=Math.imul(B,tt),n+=Math.imul(A,rt),i+=Math.imul(A,nt),i+=Math.imul(x,rt),s+=Math.imul(x,nt),n+=Math.imul(I,st),i+=Math.imul(I,ot),i+=Math.imul(k,st),s+=Math.imul(k,ot),n+=Math.imul(_,ft),i+=Math.imul(_,ut),i+=Math.imul(w,ft),s+=Math.imul(w,ut),n+=Math.imul(m,ht),i+=Math.imul(m,dt),i+=Math.imul(y,ht),s+=Math.imul(y,dt),n+=Math.imul(l,lt),i+=Math.imul(l,bt),i+=Math.imul(b,lt),s+=Math.imul(b,bt);var At=u+n+((8191&i)<<13);u=s+(i>>>13)+(At>>>26),At&=67108863,n=Math.imul(L,G),i=Math.imul(L,W),i+=Math.imul(D,G),s=Math.imul(D,W),n+=Math.imul(N,J),i+=Math.imul(N,Z),i+=Math.imul(j,J),s+=Math.imul(j,Z),n+=Math.imul(R,$),i+=Math.imul(R,tt),i+=Math.imul(T,$),s+=Math.imul(T,tt),n+=Math.imul(O,rt),i+=Math.imul(O,nt),i+=Math.imul(B,rt),s+=Math.imul(B,nt),n+=Math.imul(A,st),i+=Math.imul(A,ot),i+=Math.imul(x,st),s+=Math.imul(x,ot),n+=Math.imul(I,ft),i+=Math.imul(I,ut),i+=Math.imul(k,ft),s+=Math.imul(k,ut),n+=Math.imul(_,ht),i+=Math.imul(_,dt),i+=Math.imul(w,ht),s+=Math.imul(w,dt),n+=Math.imul(m,lt),i+=Math.imul(m,bt),i+=Math.imul(y,lt),s+=Math.imul(y,bt);var xt=u+n+((8191&i)<<13);u=s+(i>>>13)+(xt>>>26),xt&=67108863,n=Math.imul(L,J),i=Math.imul(L,Z),i+=Math.imul(D,J),s=Math.imul(D,Z),n+=Math.imul(N,$),i+=Math.imul(N,tt),i+=Math.imul(j,$),s+=Math.imul(j,tt),n+=Math.imul(R,rt),i+=Math.imul(R,nt),i+=Math.imul(T,rt),s+=Math.imul(T,nt),n+=Math.imul(O,st),i+=Math.imul(O,ot),i+=Math.imul(B,st),s+=Math.imul(B,ot),n+=Math.imul(A,ft),i+=Math.imul(A,ut),i+=Math.imul(x,ft),s+=Math.imul(x,ut),n+=Math.imul(I,ht),i+=Math.imul(I,dt),i+=Math.imul(k,ht),s+=Math.imul(k,dt),n+=Math.imul(_,lt),i+=Math.imul(_,bt),i+=Math.imul(w,lt),s+=Math.imul(w,bt);var Pt=u+n+((8191&i)<<13);u=s+(i>>>13)+(Pt>>>26),Pt&=67108863,n=Math.imul(L,$),i=Math.imul(L,tt),i+=Math.imul(D,$),s=Math.imul(D,tt),n+=Math.imul(N,rt),i+=Math.imul(N,nt),i+=Math.imul(j,rt),s+=Math.imul(j,nt),n+=Math.imul(R,st),i+=Math.imul(R,ot),i+=Math.imul(T,st),s+=Math.imul(T,ot),n+=Math.imul(O,ft),i+=Math.imul(O,ut),i+=Math.imul(B,ft),s+=Math.imul(B,ut),n+=Math.imul(A,ht),i+=Math.imul(A,dt),i+=Math.imul(x,ht),s+=Math.imul(x,dt),n+=Math.imul(I,lt),i+=Math.imul(I,bt),i+=Math.imul(k,lt),s+=Math.imul(k,bt);var Ot=u+n+((8191&i)<<13);u=s+(i>>>13)+(Ot>>>26),Ot&=67108863,n=Math.imul(L,rt),i=Math.imul(L,nt),i+=Math.imul(D,rt),s=Math.imul(D,nt),n+=Math.imul(N,st),i+=Math.imul(N,ot),i+=Math.imul(j,st),s+=Math.imul(j,ot),n+=Math.imul(R,ft),i+=Math.imul(R,ut),i+=Math.imul(T,ft),s+=Math.imul(T,ut),n+=Math.imul(O,ht),i+=Math.imul(O,dt),i+=Math.imul(B,ht),s+=Math.imul(B,dt),n+=Math.imul(A,lt),i+=Math.imul(A,bt),i+=Math.imul(x,lt),s+=Math.imul(x,bt);var Bt=u+n+((8191&i)<<13);u=s+(i>>>13)+(Bt>>>26),Bt&=67108863,n=Math.imul(L,st),i=Math.imul(L,ot),i+=Math.imul(D,st),s=Math.imul(D,ot),n+=Math.imul(N,ft),i+=Math.imul(N,ut),i+=Math.imul(j,ft),s+=Math.imul(j,ut),n+=Math.imul(R,ht),i+=Math.imul(R,dt),i+=Math.imul(T,ht),s+=Math.imul(T,dt),n+=Math.imul(O,lt),i+=Math.imul(O,bt),i+=Math.imul(B,lt),s+=Math.imul(B,bt);var Mt=u+n+((8191&i)<<13);u=s+(i>>>13)+(Mt>>>26),Mt&=67108863,n=Math.imul(L,ft),i=Math.imul(L,ut),i+=Math.imul(D,ft),s=Math.imul(D,ut),n+=Math.imul(N,ht),i+=Math.imul(N,dt),i+=Math.imul(j,ht),s+=Math.imul(j,dt),n+=Math.imul(R,lt),i+=Math.imul(R,bt),i+=Math.imul(T,lt),s+=Math.imul(T,bt);var Rt=u+n+((8191&i)<<13);u=s+(i>>>13)+(Rt>>>26),Rt&=67108863,n=Math.imul(L,ht),i=Math.imul(L,dt),i+=Math.imul(D,ht),s=Math.imul(D,dt),n+=Math.imul(N,lt),i+=Math.imul(N,bt),i+=Math.imul(j,lt),s+=Math.imul(j,bt);var Tt=u+n+((8191&i)<<13);u=s+(i>>>13)+(Tt>>>26),Tt&=67108863,n=Math.imul(L,lt),i=Math.imul(L,bt),i+=Math.imul(D,lt),s=Math.imul(D,bt);var Ct=u+n+((8191&i)<<13);return u=s+(i>>>13)+(Ct>>>26),Ct&=67108863,f[0]=gt,f[1]=mt,f[2]=yt,f[3]=vt,f[4]=_t,f[5]=wt,f[6]=St,f[7]=It,f[8]=kt,f[9]=Et,f[10]=At,f[11]=xt,f[12]=Pt,f[13]=Ot,f[14]=Bt,f[15]=Mt,f[16]=Rt,f[17]=Tt,f[18]=Ct,0!==u&&(f[19]=u,r.length++),r};Math.imul||(E=u),s.prototype.mulTo=function(t,e){var r,n=this.length+t.length;return r=10===this.length&&10===t.length?E(this,t,e):63>n?u(this,t,e):1024>n?c(this,t,e):h(this,t,e)},d.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,n=0;t>n;n++)e[n]=this.revBin(n,r,t);return e},d.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;e>i;i++)n|=(1&t)<>=1;return n},d.prototype.permute=function(t,e,r,n,i,s){for(var o=0;s>o;o++)n[o]=e[t[o]],i[o]=r[t[o]]},d.prototype.transform=function(t,e,r,n,i,s){this.permute(s,t,e,r,n,i);for(var o=1;i>o;o<<=1)for(var a=o<<1,f=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),c=0;i>c;c+=a)for(var h=f,d=u,p=0;o>p;p++){var l=r[c+p],b=n[c+p],g=r[c+p+o],m=n[c+p+o],y=h*g-d*m;m=h*m+d*g,g=y,r[c+p]=l+g,n[c+p]=b+m,r[c+p+o]=l-g,n[c+p+o]=b-m,p!==a&&(y=f*h-u*d,d=f*d+u*h,h=y)}},d.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<=r))for(var n=0;r/2>n;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},d.prototype.normalize13b=function(t,e){for(var r=0,n=0;e/2>n;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=67108864>i?0:i/67108864|0}return t},d.prototype.convert13b=function(t,e,r,i){for(var s=0,o=0;e>o;o++)s+=0|t[o],r[2*o]=8191&s,s>>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;i>o;++o)r[o]=0;n(0===s),n(0===(-8192&s))},d.prototype.stub=function(t){for(var e=new Array(t),r=0;t>r;r++)e[r]=0;return e},d.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),s=this.stub(n),o=new Array(n),a=new Array(n),f=new Array(n),u=new Array(n),c=new Array(n),h=new Array(n),d=r.words;d.length=n,this.convert13b(t.words,t.length,o,n),this.convert13b(e.words,e.length,u,n),this.transform(o,s,a,f,n,i),this.transform(u,s,c,h,n,i);for(var p=0;n>p;p++){var l=a[p]*c[p]-f[p]*h[p];f[p]=a[p]*h[p]+f[p]*c[p],a[p]=l}return this.conjugate(a,f,n),this.transform(a,f,d,s,n,i),this.conjugate(d,s,n),this.normalize13b(d,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},s.prototype.mul=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},s.prototype.mulf=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),h(this,t,e)},s.prototype.imul=function(t){return this.clone().mulTo(t,this)},s.prototype.imuln=function(t){n("number"==typeof t);for(var e=0,r=0;r>=26,e+=i/67108864|0,e+=s>>>26,this.words[r]=67108863&s}return 0!==e&&(this.words[r]=e,this.length++),this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=f(t);if(0===e.length)return new s(1);for(var r=this,n=0;n=0);var e,r=t%26,i=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;i>e;e++)this.words[e]=0;this.length+=i}return this.strip()},s.prototype.ishln=function(t){return n(0===this.negative),this.iushln(t)},s.prototype.iushrn=function(t,e,r){n("number"==typeof t&&t>=0);var i;i=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<u;u++)f.words[u]=this.words[u];f.length=o}if(0===o);else if(this.length>o)for(this.length-=o,u=0;u=0&&(0!==c||u>=i);u--){var h=0|this.words[u];this.words[u]=c<<26-s|h>>>s,c=h&a}return f&&0!==c&&(f.words[f.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<t?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(n("number"==typeof t),0>t)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(u/67108864|0),this.words[i+r]=67108863&a}for(;i>26,this.words[i+r]=67108863&a;if(0===f)return this.strip();for(n(-1===f),f=0,i=0;i>26,this.words[i]=67108863&a;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=this.length-t.length,n=this.clone(),i=t,o=0|i.words[i.length-1],a=this._countBits(o);r=26-a,0!==r&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var f,u=n.length-i.length;if("mod"!==e){f=new s(null),f.length=u+1,f.words=new Array(f.length);for(var c=0;c=0;d--){var p=67108864*(0|n.words[i.length+d])+(0|n.words[i.length+d-1]);for(p=Math.min(p/o|0,67108863),n._ishlnsubmul(i,p,d);0!==n.negative;)p--,n.negative=0,n._ishlnsubmul(i,1,d),n.isZero()||(n.negative^=1);f&&(f.words[d]=p)}return f&&f.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:f||null,mod:n}},s.prototype.divmod=function(t,e,r){n(!t.isZero());var i,o,a;return 0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!==(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e)},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),s=r.cmp(n);return 0>s||1===i&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){n(67108863>=t);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r},s.prototype.idivn=function(t){n(67108863>=t);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new s(1),o=new s(0),a=new s(0),f=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var c=r.clone(),h=e.clone();!e.isZero();){for(var d=0,p=1;0===(e.words[0]&p)&&26>d;++d,p<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(c),o.isub(h)),i.iushrn(1),o.iushrn(1);for(var l=0,b=1;0===(r.words[0]&b)&&26>l;++l,b<<=1);if(l>0)for(r.iushrn(l);l-- >0;)(a.isOdd()||f.isOdd())&&(a.iadd(c),f.isub(h)),a.iushrn(1),f.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),o.isub(f)):(r.isub(e),a.isub(i),f.isub(o))}return{a:a,b:f,gcd:r.iushln(u)}},s.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new s(1),o=new s(0),a=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var f=0,u=1;0===(e.words[0]&u)&&26>f;++f,u<<=1);if(f>0)for(e.iushrn(f);f-- >0;)i.isOdd()&&i.iadd(a),i.iushrn(1);for(var c=0,h=1;0===(r.words[0]&h)&&26>c;++c,h<<=1);if(c>0)for(r.iushrn(c);c-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(o)):(r.isub(e),o.isub(i))}var d;return d=0===e.cmpn(1)?i:o,d.cmpn(0)<0&&d.iadd(t),d},s.prototype.gcd=function(t){if(this.isZero())return t.clone();if(t.isZero())return this.clone();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(0>i){var s=e;e=r,r=s}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return 0===(1&this.words[0])},s.prototype.isOdd=function(){return 1===(1&this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<s;s++)this.words[s]=0;return this.words[r]|=i,this.length=r+1,this}var o=i;for(s=r;0!==o&&s>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e=0>t;if(0!==this.negative&&!e)return-1;if(0===this.negative&&e)return 1;this.strip();var r;if(this.length>1)r=1;else{e&&(t=-t),n(67108863>=t,"Number is too big");var i=0|this.words[0];r=i===t?0:t>i?-1:1}return 0!==this.negative&&(r=-r),r},s.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?-e:e},s.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){i>n?e=-1:n>i&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new y(t)},s.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.ushl(this,t)},s.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var A={k256:null,p224:null,p192:null,p25519:null};p.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},p.prototype.ireduce=function(t){var e,r=t;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),e=r.bitLength();while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},p.prototype.split=function(t,e){t.iushrn(this.n,0,e)},p.prototype.imulK=function(t){return t.imul(this.k)},i(l,p),l.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;n>i;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,i=10;i>>22,s=o}t.words[i-10]=s>>>22,t.length-=9},l.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function x(t){if(A[t])return A[t];var x;if("k256"===t)x=new l;else if("p224"===t)x=new b;else if("p192"===t)x=new g;else{if("p25519"!==t)throw new Error("Unknown prime "+t);x=new m}return A[t]=x,x},y.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},y.prototype._verify2=function(t,e){n(0===(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},y.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},y.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},y.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},y.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},y.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},y.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},y.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},y.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},y.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},y.prototype.isqr=function(t){return this.imul(t,t.clone())},y.prototype.sqr=function(t){return this.mul(t,t)},y.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2===1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);n(!i.isZero());var a=new s(1).toRed(this),f=a.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new s(2*c*c).toRed(this);0!==this.pow(c,u).cmp(f);)c.redIAdd(f);for(var h=this.pow(c,i),d=this.pow(t,i.addn(1).iushrn(1)),p=this.pow(t,i),l=o;0!==p.cmp(a);){for(var b=p,g=0;0!==b.cmp(a);g++)b=b.redSqr();n(l>g);var m=this.pow(h,new s(1).iushln(l-g-1));d=d.redMul(m),h=m.redSqr(),p=p.redMul(h),l=g}return d},y.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},y.prototype.pow=function(t,e){if(e.isZero())return new s(1);if(0===e.cmpn(1))return t.clone();var r=4,n=new Array(1<=0;i--){for(var c=e.words[i],h=u-1;h>=0;h--){var d=c>>h&1;o!==n[0]&&(o=this.sqr(o)),0!==d||0!==a?(a<<=1,a|=d,f++,(f===r||0===i&&0===h)&&(o=this.mul(o,n[a]),f=0,a=0)):f=0}u=26}return o},y.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},y.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new v(t)},i(v,y),v.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},v.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},v.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},v.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},v.prototype.invm=function(t){var e=this.imod(t._invmp(this.m).mul(this.r2));return e._forceRed(this)}}("undefined"==typeof e||e,this)},{buffer:47}],86:[function(t,e,r){(function(r){function n(t){var e=s(t),r=e.toRed(o.mont(t.modulus)).redPow(new o(t.publicExponent)).fromRed();return{blinder:r,unblinder:e.invm(t.modulus)}}function i(t,e){var i=n(e),s=e.modulus.byteLength(),a=(o.mont(e.modulus),new o(t).mul(i.blinder).umod(e.modulus)),f=a.toRed(o.mont(e.prime1)),u=a.toRed(o.mont(e.prime2)),c=e.coefficient,h=e.prime1,d=e.prime2,p=f.redPow(e.exponent1),l=u.redPow(e.exponent2);p=p.fromRed(),l=l.fromRed();var b=p.isub(l).imul(c).umod(h);return b.imul(d),l.iadd(b),new r(l.imul(i.unblinder).umod(e.modulus).toArray(!1,s))}function s(t){for(var e=t.modulus.byteLength(),r=new o(a(e));r.cmp(t.modulus)>=0||!r.umod(t.prime1)||!r.umod(t.prime2);)r=new o(a(e));return r}var o=t("bn.js"),a=t("randombytes");e.exports=i,i.getr=s}).call(this,t("buffer").Buffer)},{"bn.js":85,buffer:48,randombytes:243}],87:[function(t,e,r){"use strict";var n=r;n.version=t("../package.json").version,n.utils=t("./elliptic/utils"),n.rand=t("brorand"),n.hmacDRBG=t("./elliptic/hmac-drbg"),n.curve=t("./elliptic/curve"),n.curves=t("./elliptic/curves"),n.ec=t("./elliptic/ec"),n.eddsa=t("./elliptic/eddsa")},{"../package.json":110,"./elliptic/curve":90,"./elliptic/curves":93,"./elliptic/ec":94,"./elliptic/eddsa":97,"./elliptic/hmac-drbg":100,"./elliptic/utils":102,brorand:103}],88:[function(t,e,r){"use strict";function n(t,e){this.type=t,this.p=new s(e.p,16),this.red=e.prime?s.red(e.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=e.n&&new s(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4)}function i(t,e){this.curve=t,this.type=e,this.precomputed=null}var s=t("bn.js"),o=t("../../elliptic"),a=o.utils,f=a.getNAF,u=a.getJSF,c=a.assert;e.exports=n,n.prototype.point=function(){throw new Error("Not implemented")},n.prototype.validate=function(){throw new Error("Not implemented")},n.prototype._fixedNafMul=function(t,e){c(t.precomputed);var r=t._getDoubles(),n=f(e,1),i=(1<=o;e--)a=(a<<1)+n[e];s.push(a)}for(var u=this.jpoint(null,null,null),h=this.jpoint(null,null,null),d=i;d>0;d--){for(var o=0;o=0;a--){for(var e=0;a>=0&&0===s[a];a--)e++; +if(a>=0&&e++,o=o.dblp(e),0>a)break;var u=s[a];c(0!==u),o="affine"===t.type?u>0?o.mixedAdd(i[u-1>>1]):o.mixedAdd(i[-u-1>>1].neg()):u>0?o.add(i[u-1>>1]):o.add(i[-u-1>>1].neg())}return"affine"===t.type?o.toP():o},n.prototype._wnafMulAdd=function(t,e,r,n){for(var i=this._wnafT1,s=this._wnafT2,o=this._wnafT3,a=0,c=0;n>c;c++){var h=e[c],d=h._getNAFPoints(t);i[c]=d.wnd,s[c]=d.points}for(var c=n-1;c>=1;c-=2){var p=c-1,l=c;if(1===i[p]&&1===i[l]){var b=[e[p],null,null,e[l]];0===e[p].y.cmp(e[l].y)?(b[1]=e[p].add(e[l]),b[2]=e[p].toJ().mixedAdd(e[l].neg())):0===e[p].y.cmp(e[l].y.redNeg())?(b[1]=e[p].toJ().mixedAdd(e[l]),b[2]=e[p].add(e[l].neg())):(b[1]=e[p].toJ().mixedAdd(e[l]),b[2]=e[p].toJ().mixedAdd(e[l].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],m=u(r[p],r[l]);a=Math.max(m[0].length,a),o[p]=new Array(a),o[l]=new Array(a);for(var y=0;a>y;y++){var v=0|m[0][y],_=0|m[1][y];o[p][y]=g[3*(v+1)+(_+1)],o[l][y]=0,s[p]=b}}else o[p]=f(r[p],i[p]),o[l]=f(r[l],i[l]),a=Math.max(o[p].length,a),a=Math.max(o[l].length,a)}for(var w=this.jpoint(null,null,null),S=this._wnafT4,c=a;c>=0;c--){for(var I=0;c>=0;){for(var k=!0,y=0;n>y;y++)S[y]=0|o[y][c],0!==S[y]&&(k=!1);if(!k)break;I++,c--}if(c>=0&&I++,w=w.dblp(I),0>c)break;for(var y=0;n>y;y++){var h,E=S[y];0!==E&&(E>0?h=s[y][E-1>>1]:0>E&&(h=s[y][-E-1>>1].neg()),w="affine"===h.type?w.mixedAdd(h):w.add(h))}}for(var c=0;n>c;c++)s[c]=null;return w.toP()},n.BasePoint=i,i.prototype.eq=function(){throw new Error("Not implemented")},i.prototype.validate=function(){return this.curve.validate(this)},n.prototype.decodePoint=function(t,e){t=a.toArray(t,e);var r=this.p.byteLength();if(4===t[0]&&t.length-1===2*r)return this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},i.prototype.encodeCompressed=function(t){return this.encode(t,!0)},i.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},i.prototype.encode=function(t,e){return a.encode(this._encode(e),t)},i.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},i.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return e?e.points.length>=Math.ceil((t.bitLength()+1)/e.step):!1},i.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;e>i;i+=t){for(var s=0;t>s;s++)n=n.dbl();r.push(n)}return{step:t,points:r}},i.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<i;i++)e[i]=e[i-1].add(n);return{wnd:t,points:e}},i.prototype._getBeta=function(){return null},i.prototype.dblp=function(t){for(var e=this,r=0;t>r;r++)e=e.dbl();return e}},{"../../elliptic":87,"bn.js":85}],89:[function(t,e,r){"use strict";function n(t){this.twisted=1!==(0|t.a),this.mOneA=this.twisted&&-1===(0|t.a),this.extended=this.mOneA,u.call(this,"edwards",t),this.a=new a(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new a(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new a(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),c(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1===(0|t.c)}function i(t,e,r,n,i){u.BasePoint.call(this,t,"projective"),null===e&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new a(e,16),this.y=new a(r,16),this.z=n?new a(n,16):this.curve.one,this.t=i&&new a(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}var s=t("../curve"),o=t("../../elliptic"),a=t("bn.js"),f=t("inherits"),u=s.base,c=o.utils.assert;f(n,u),e.exports=n,n.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},n.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},n.prototype.jpoint=function(t,e,r,n){return this.point(t,e,r,n)},n.prototype.pointFromX=function(t,e){t=new a(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr(),n=this.c2.redSub(this.a.redMul(r)),i=this.one.redSub(this.c2.redMul(this.d).redMul(r)),s=n.redMul(i.redInvm()),o=s.redSqrt();if(0!==o.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var f=o.fromRed().isOdd();return(e&&!f||!e&&f)&&(o=o.redNeg()),this.point(t,o)},n.prototype.pointFromY=function(t,e){t=new a(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr(),n=r.redSub(this.one),i=r.redMul(this.d).redAdd(this.one),s=n.redMul(i.redInvm());if(0===s.cmp(this.zero)){if(e)throw new Error("invalid point");return this.point(this.zero,t)}var o=s.redSqrt();if(0!==o.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");return o.isOdd()!==e&&(o=o.redNeg()),this.point(o,t)},n.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),r=t.y.redSqr(),n=e.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(r)));return 0===n.cmp(i)},f(i,u.BasePoint),n.prototype.pointFromJSON=function(t){return i.fromJSON(this,t)},n.prototype.point=function(t,e,r,n){return new i(this,t,e,r,n)},i.fromJSON=function(t,e){return new i(t,e[0],e[1],e[2])},i.prototype.inspect=function(){return this.isInfinity()?"":""},i.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},i.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),s=n.redAdd(e),o=s.redSub(r),a=n.redSub(e),f=i.redMul(o),u=s.redMul(a),c=i.redMul(a),h=o.redMul(s);return this.curve.point(f,u,h,c)},i.prototype._projDbl=function(){var t,e,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),s=this.y.redSqr();if(this.curve.twisted){var o=this.curve._mulA(i),a=o.redAdd(s);if(this.zOne)t=n.redSub(i).redSub(s).redMul(a.redSub(this.curve.two)),e=a.redMul(o.redSub(s)),r=a.redSqr().redSub(a).redSub(a);else{var f=this.z.redSqr(),u=a.redSub(f).redISub(f);t=n.redSub(i).redISub(s).redMul(u),e=a.redMul(o.redSub(s)),r=a.redMul(u)}}else{var o=i.redAdd(s),f=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=o.redSub(f).redSub(f);t=this.curve._mulC(n.redISub(o)).redMul(u),e=this.curve._mulC(o).redMul(i.redISub(s)),r=o.redMul(u)}return this.curve.point(t,e,r)},i.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},i.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),s=r.redSub(e),o=i.redSub(n),a=i.redAdd(n),f=r.redAdd(e),u=s.redMul(o),c=a.redMul(f),h=s.redMul(f),d=o.redMul(a);return this.curve.point(u,c,d,h)},i.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),s=this.x.redMul(t.x),o=this.y.redMul(t.y),a=this.curve.d.redMul(s).redMul(o),f=i.redSub(a),u=i.redAdd(a),c=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(o),h=n.redMul(f).redMul(c);return this.curve.twisted?(e=n.redMul(u).redMul(o.redSub(this.curve._mulA(s))),r=f.redMul(u)):(e=n.redMul(u).redMul(o.redSub(s)),r=this.curve._mulC(f).redMul(u)),this.curve.point(h,e,r)},i.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},i.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},i.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2)},i.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},i.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},i.prototype.getX=function(){return this.normalize(),this.x.fromRed()},i.prototype.getY=function(){return this.normalize(),this.y.fromRed()},i.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},i.prototype.toP=i.prototype.normalize,i.prototype.mixedAdd=i.prototype.add},{"../../elliptic":87,"../curve":90,"bn.js":85,inherits:296}],90:[function(t,e,r){"use strict";var n=r;n.base=t("./base"),n["short"]=t("./short"),n.mont=t("./mont"),n.edwards=t("./edwards")},{"./base":88,"./edwards":89,"./mont":91,"./short":92}],91:[function(t,e,r){"use strict";function n(t){f.call(this,"mont",t),this.a=new o(t.a,16).toRed(this.red),this.b=new o(t.b,16).toRed(this.red),this.i4=new o(4).toRed(this.red).redInvm(),this.two=new o(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function i(t,e,r){f.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new o(e,16),this.z=new o(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}var s=t("../curve"),o=t("bn.js"),a=t("inherits"),f=s.base,u=t("../../elliptic"),c=u.utils;a(n,f),e.exports=n,n.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e),i=n.redSqrt();return 0===i.redSqr().cmp(n)},a(i,f.BasePoint),n.prototype.decodePoint=function(t,e){return this.point(c.toArray(t,e),1)},n.prototype.point=function(t,e){return new i(this,t,e)},n.prototype.pointFromJSON=function(t){return i.fromJSON(this,t)},i.prototype.precompute=function(){},i.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},i.fromJSON=function(t,e){return new i(t,e[0],e[1]||t.one)},i.prototype.inspect=function(){return this.isInfinity()?"":""},i.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},i.prototype.dbl=function(){var t=this.x.redAdd(this.z),e=t.redSqr(),r=this.x.redSub(this.z),n=r.redSqr(),i=e.redSub(n),s=e.redMul(n),o=i.redMul(n.redAdd(this.curve.a24.redMul(i)));return this.curve.point(s,o)},i.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},i.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),s=t.x.redSub(t.z),o=s.redMul(r),a=i.redMul(n),f=e.z.redMul(o.redAdd(a).redSqr()),u=e.x.redMul(o.redISub(a).redSqr());return this.curve.point(f,u)},i.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=this,s=[];0!==e.cmpn(0);e.iushrn(1))s.push(e.andln(1));for(var o=s.length-1;o>=0;o--)0===s[o]?(r=r.diffAdd(n,i),n=n.dbl()):(n=r.diffAdd(n,i),r=r.dbl());return n},i.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},i.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},i.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},i.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":87,"../curve":90,"bn.js":85,inherits:296}],92:[function(t,e,r){"use strict";function n(t){c.call(this,"short",t),this.a=new f(t.a,16).toRed(this.red),this.b=new f(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function i(t,e,r,n){c.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new f(e,16),this.y=new f(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function s(t,e,r,n){c.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new f(0)):(this.x=new f(e,16),this.y=new f(r,16),this.z=new f(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}var o=t("../curve"),a=t("../../elliptic"),f=t("bn.js"),u=t("inherits"),c=o.base,h=a.utils.assert;u(n,c),e.exports=n,n.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new f(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=n[0].cmp(n[1])<0?n[0]:n[1],e=e.toRed(this.red)}if(t.lambda)r=new f(t.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(e))?r=i[0]:(r=i[1],h(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}var s;return s=t.basis?t.basis.map(function(t){return{a:new f(t.a,16),b:new f(t.b,16)}}):this._getEndoBasis(r),{beta:e,lambda:r,basis:s}}},n.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:f.mont(t),r=new f(2).toRed(e).redInvm(),n=r.redNeg(),i=new f(3).toRed(e).redNeg().redSqrt().redMul(r),s=n.redAdd(i).fromRed(),o=n.redSub(i).fromRed();return[s,o]},n.prototype._getEndoBasis=function(t){for(var e,r,n,i,s,o,a,u,c,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=t,p=this.n.clone(),l=new f(1),b=new f(0),g=new f(0),m=new f(1),y=0;0!==d.cmpn(0);){var v=p.div(d);u=p.sub(v.mul(d)),c=g.sub(v.mul(l));var _=m.sub(v.mul(b));if(!n&&u.cmp(h)<0)e=a.neg(),r=l,n=u.neg(),i=c;else if(n&&2===++y)break;a=u,p=d,d=u,g=l,l=c,m=b,b=_}s=u.neg(),o=c;var w=n.sqr().add(i.sqr()),S=s.sqr().add(o.sqr());return S.cmp(w)>=0&&(s=e,o=r),n.negative&&(n=n.neg(),i=i.neg()),s.negative&&(s=s.neg(),o=o.neg()),[{a:n,b:i},{a:s,b:o}]},n.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=i.mul(r.a),a=s.mul(n.a),f=i.mul(r.b),u=s.mul(n.b),c=t.sub(o).sub(a),h=f.add(u).neg();return{k1:c,k2:h}},n.prototype.pointFromX=function(t,e){t=new f(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},n.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},n.prototype._endoWnafMulAdd=function(t,e){for(var r=this._endoWnafT1,n=this._endoWnafT2,i=0;iu;u++)r[u]=null,n[u]=null;return f},u(i,c.BasePoint),n.prototype.point=function(t,e,r){return new i(this,t,e,r)},n.prototype.pointFromJSON=function(t,e){return i.fromJSON(this,t,e)},i.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,n=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(n)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(n)}}}return e}},i.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},i.fromJSON=function(t,e,r){function n(e){return t.point(e[0],e[1],r)}"string"==typeof e&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;var s=e[2];return i.precomputed={beta:null,doubles:s.doubles&&{step:s.doubles.step,points:[i].concat(s.doubles.points.map(n))},naf:s.naf&&{wnd:s.naf.wnd,points:[i].concat(s.naf.points.map(n))}},i},i.prototype.inspect=function(){return this.isInfinity()?"":""},i.prototype.isInfinity=function(){return this.inf},i.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},i.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),s=i.redSqr().redISub(this.x.redAdd(this.x)),o=i.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},i.prototype.getX=function(){return this.x.fromRed()},i.prototype.getY=function(){return this.y.fromRed()},i.prototype.mul=function(t){return t=new f(t,16),this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},i.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},i.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},i.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},i.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var t=this.curve.jpoint(this.x,this.y,this.curve.one);return t},u(s,c.BasePoint),n.prototype.jpoint=function(t,e,r){return new s(this,t,e,r)},s.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},s.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},s.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),f=s.redSub(o);if(0===a.cmpn(0))return 0!==f.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),h=n.redMul(u),d=f.redSqr().redIAdd(c).redISub(h).redISub(h),p=f.redMul(h.redISub(d)).redISub(s.redMul(c)),l=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(d,p,l)},s.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(n),a=i.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=o.redSqr(),u=f.redMul(o),c=r.redMul(f),h=a.redSqr().redIAdd(u).redISub(c).redISub(c),d=a.redMul(c.redISub(h)).redISub(i.redMul(u)),p=this.z.redMul(o);return this.curve.jpoint(h,d,p)},s.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,r=0;t>r;r++)e=e.dbl();return e}for(var n=this.curve.a,i=this.curve.tinv,s=this.x,o=this.y,a=this.z,f=a.redSqr().redSqr(),u=o.redAdd(o),r=0;t>r;r++){var c=s.redSqr(),h=u.redSqr(),d=h.redSqr(),p=c.redAdd(c).redIAdd(c).redIAdd(n.redMul(f)),l=s.redMul(h),b=p.redSqr().redISub(l.redAdd(l)),g=l.redISub(b),m=p.redMul(g);m=m.redIAdd(m).redISub(d);var y=u.redMul(a);t>r+1&&(f=f.redMul(d)),s=b,a=y,u=m}return this.curve.jpoint(s,u.redMul(i),a)},s.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},s.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),s=i.redSqr(),o=this.x.redAdd(i).redSqr().redISub(n).redISub(s);o=o.redIAdd(o);var a=n.redAdd(n).redIAdd(n),f=a.redSqr().redISub(o).redISub(o),u=s.redIAdd(s);u=u.redIAdd(u),u=u.redIAdd(u),t=f,e=a.redMul(o.redISub(f)).redISub(u),r=this.y.redAdd(this.y)}else{var c=this.x.redSqr(),h=this.y.redSqr(),d=h.redSqr(),p=this.x.redAdd(h).redSqr().redISub(c).redISub(d);p=p.redIAdd(p);var l=c.redAdd(c).redIAdd(c),b=l.redSqr(),g=d.redIAdd(d);g=g.redIAdd(g),g=g.redIAdd(g),t=b.redISub(p).redISub(p),e=l.redMul(p.redISub(t)).redISub(g),r=this.y.redMul(this.z),r=r.redIAdd(r)}return this.curve.jpoint(t,e,r)},s.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),s=i.redSqr(),o=this.x.redAdd(i).redSqr().redISub(n).redISub(s);o=o.redIAdd(o);var a=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),f=a.redSqr().redISub(o).redISub(o);t=f;var u=s.redIAdd(s);u=u.redIAdd(u),u=u.redIAdd(u),e=a.redMul(o.redISub(f)).redISub(u),r=this.y.redAdd(this.y)}else{var c=this.z.redSqr(),h=this.y.redSqr(),d=this.x.redMul(h),p=this.x.redSub(c).redMul(this.x.redAdd(c));p=p.redAdd(p).redIAdd(p);var l=d.redIAdd(d);l=l.redIAdd(l);var b=l.redAdd(l);t=p.redSqr().redISub(b),r=this.y.redAdd(this.z).redSqr().redISub(h).redISub(c);var g=h.redSqr();g=g.redIAdd(g),g=g.redIAdd(g),g=g.redIAdd(g),e=p.redMul(l.redISub(t)).redISub(g)}return this.curve.jpoint(t,e,r)},s.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),s=e.redSqr(),o=r.redSqr(),a=s.redAdd(s).redIAdd(s).redIAdd(t.redMul(i)),f=e.redAdd(e);f=f.redIAdd(f);var u=f.redMul(o),c=a.redSqr().redISub(u.redAdd(u)),h=u.redISub(c),d=o.redSqr();d=d.redIAdd(d),d=d.redIAdd(d),d=d.redIAdd(d);var p=a.redMul(h).redISub(d),l=r.redAdd(r).redMul(n);return this.curve.jpoint(c,p,l)},s.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),n=e.redSqr(),i=t.redAdd(t).redIAdd(t),s=i.redSqr(),o=this.x.redAdd(e).redSqr().redISub(t).redISub(n);o=o.redIAdd(o),o=o.redAdd(o).redIAdd(o),o=o.redISub(s);var a=o.redSqr(),f=n.redIAdd(n);f=f.redIAdd(f),f=f.redIAdd(f),f=f.redIAdd(f);var u=i.redIAdd(o).redSqr().redISub(s).redISub(a).redISub(f),c=e.redMul(u);c=c.redIAdd(c),c=c.redIAdd(c);var h=this.x.redMul(a).redISub(c);h=h.redIAdd(h),h=h.redIAdd(h);var d=this.y.redMul(u.redMul(f.redISub(u)).redISub(o.redMul(a)));d=d.redIAdd(d),d=d.redIAdd(d),d=d.redIAdd(d);var p=this.z.redAdd(o).redSqr().redISub(r).redISub(a);return this.curve.jpoint(h,d,p)},s.prototype.mul=function(t,e){return t=new f(t,e),this.curve._wnafMul(this,t)},s.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var n=e.redMul(this.z),i=r.redMul(t.z);return 0===this.y.redMul(i).redISub(t.y.redMul(n)).cmpn(0)},s.prototype.inspect=function(){return this.isInfinity()?"":""},s.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":87,"../curve":90,"bn.js":85,inherits:296}],93:[function(t,e,r){"use strict";function n(t){"short"===t.type?this.curve=new a.curve["short"](t):"edwards"===t.type?this.curve=new a.curve.edwards(t):this.curve=new a.curve.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,f(this.g.validate(),"Invalid curve"),f(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function i(t,e){Object.defineProperty(s,t,{configurable:!0,enumerable:!0,get:function(){var r=new n(e);return Object.defineProperty(s,t,{configurable:!0,enumerable:!0,value:r}),r}})}var s=r,o=t("hash.js"),a=t("../elliptic"),f=a.utils.assert;s.PresetCurve=n,i("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),i("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),i("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),i("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),i("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),i("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"0",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),i("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var u;try{u=t("./precomputed/secp256k1")}catch(c){u=void 0}i("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",u]})},{"../elliptic":87,"./precomputed/secp256k1":101,"hash.js":104}],94:[function(t,e,r){"use strict";function n(t){return this instanceof n?("string"==typeof t&&(a(s.curves.hasOwnProperty(t),"Unknown curve "+t),t=s.curves[t]),t instanceof s.curves.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),void(this.hash=t.hash||t.curve.hash)):new n(t)}var i=t("bn.js"),s=t("../../elliptic"),o=s.utils,a=o.assert,f=t("./key"),u=t("./signature");e.exports=n,n.prototype.keyPair=function(t){return new f(this,t)},n.prototype.keyFromPrivate=function(t,e){return f.fromPrivate(this,t,e)},n.prototype.keyFromPublic=function(t,e){return f.fromPublic(this,t,e)},n.prototype.genKeyPair=function(t){t||(t={});for(var e=new s.hmacDRBG({hash:this.hash,pers:t.pers,entropy:t.entropy||s.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new i(2));;){var o=new i(e.generate(r));if(!(o.cmp(n)>0))return o.iaddn(1),this.keyFromPrivate(o)}},n.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},n.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new i(t,16));for(var o=this.n.byteLength(),a=e.getPrivate().toArray("be",o),f=t.toArray("be",o),c=new s.hmacDRBG({hash:this.hash,entropy:a,nonce:f,pers:n.pers,persEnc:n.persEnc}),h=this.n.sub(new i(1)),d=0;!0;d++){var p=n.k?n.k(d):new i(c.generate(this.n.byteLength()));if(p=this._truncateToN(p,!0),!(p.cmpn(1)<=0||p.cmp(h)>=0)){var l=this.g.mul(p);if(!l.isInfinity()){var b=l.getX(),g=b.umod(this.n);if(0!==g.cmpn(0)){var m=p.invm(this.n).mul(g.mul(e.getPrivate()).iadd(t));if(m=m.umod(this.n),0!==m.cmpn(0)){var y=(l.getY().isOdd()?1:0)|(0!==b.cmp(g)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),y^=1),new u({r:g,s:m,recoveryParam:y})}}}}}},n.prototype.verify=function(t,e,r,n){t=this._truncateToN(new i(t,16)),r=this.keyFromPublic(r,n),e=new u(e,"hex");var s=e.r,o=e.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),f=a.mul(t).umod(this.n),c=a.mul(s).umod(this.n),h=this.g.mulAdd(f,r.getPublic(),c);return h.isInfinity()?!1:0===h.getX().umod(this.n).cmp(s)},n.prototype.recoverPubKey=function(t,e,r,n){a((3&r)===r,"The recovery param is more than two bits"),e=new u(e,n);var s=this.n,o=new i(t),f=e.r,c=e.s,h=1&r,d=r>>1;if(f.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");f=d?this.curve.pointFromX(f.add(this.curve.n),h):this.curve.pointFromX(f,h);var p=s.sub(o),l=e.r.invm(s);return f.mul(c).add(this.g.mul(p)).mul(l)},n.prototype.getKeyRecoveryParam=function(t,e,r,n){ +if(e=new u(e,n),null!==e.recoveryParam)return e.recoveryParam;for(var i=0;4>i;i++){var s;try{s=this.recoverPubKey(t,e,i)}catch(t){continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":87,"./key":95,"./signature":96,"bn.js":85}],95:[function(t,e,r){"use strict";function n(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var i=t("bn.js");e.exports=n,n.fromPublic=function(t,e,r){return e instanceof n?e:new n(t,{pub:e,pubEnc:r})},n.fromPrivate=function(t,e,r){return e instanceof n?e:new n(t,{priv:e,privEnc:r})},n.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},n.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},n.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},n.prototype._importPrivate=function(t,e){this.priv=new i(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},n.prototype._importPublic=function(t,e){return t.x||t.y?void(this.pub=this.ec.curve.point(t.x,t.y)):void(this.pub=this.ec.curve.decodePoint(t,e))},n.prototype.derive=function(t){return t.mul(this.priv).getX()},n.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},n.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},n.prototype.inspect=function(){return""}},{"bn.js":85}],96:[function(t,e,r){"use strict";function n(t,e){return t instanceof n?t:void(this._importDER(t,e)||(h(t.r&&t.s,"Signature without r or s"),this.r=new f(t.r,16),this.s=new f(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam))}function i(){this.place=0}function s(t,e){var r=t[e.place++];if(!(128&r))return r;for(var n=15&r,i=0,s=0,o=e.place;n>s;s++,o++)i<<=8,i|=t[o];return e.place=o,i}function o(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&r>e;)e++;return 0===e?t:t.slice(e)}function a(t,e){if(128>e)return void t.push(e);var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}var f=t("bn.js"),u=t("../../elliptic"),c=u.utils,h=c.assert;e.exports=n,n.prototype._importDER=function(t,e){t=c.toArray(t,e);var r=new i;if(48!==t[r.place++])return!1;var n=s(t,r);if(n+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var o=s(t,r),a=t.slice(r.place,o+r.place);if(r.place+=o,2!==t[r.place++])return!1;var u=s(t,r);if(t.length!==u+r.place)return!1;var h=t.slice(r.place,u+r.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===h[0]&&128&h[1]&&(h=h.slice(1)),this.r=new f(a),this.s=new f(h),this.recoveryParam=null,!0},n.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=o(e),r=o(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];a(n,e.length),n=n.concat(e),n.push(2),a(n,r.length);var i=n.concat(r),s=[48];return a(s,i.length),s=s.concat(i),c.encode(s,t)}},{"../../elliptic":87,"bn.js":85}],97:[function(t,e,r){"use strict";function n(t){if(a("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof n))return new n(t);var t=s.curves[t].curve;this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=i.sha512}var i=t("hash.js"),s=t("../../elliptic"),o=s.utils,a=o.assert,f=o.parseBytes,u=t("./key"),c=t("./signature");e.exports=n,n.prototype.sign=function(t,e){t=f(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),s=this.encodePoint(i),o=this.hashInt(s,r.pubBytes(),t).mul(r.priv()),a=n.add(o).umod(this.curve.n);return this.makeSignature({R:i,S:a,Rencoded:s})},n.prototype.verify=function(t,e,r){t=f(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),s=this.g.mul(e.S()),o=e.R().add(n.pub().mul(i));return o.eq(s)},n.prototype.hashInt=function(){for(var t=this.hash(),e=0;e=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var i=t("hash.js"),s=t("../elliptic"),o=s.utils,a=o.assert;e.exports=n,n.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this.reseed=1},n.prototype.generate=function(t,e,r,n){if(this.reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=o.toArray(r,n),this._update(r));for(var i=[];i.length>8,o=255&i;s?r.push(s,o):r.push(o)}return r}function i(t){return 1===t.length?"0"+t:t}function s(t){for(var e="",r=0;r=0;){var s;if(i.isOdd()){var o=i.andln(n-1);s=o>(n>>1)-1?(n>>1)-o:o,i.isubn(s)}else s=0;r.push(s);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?e+1:1,f=1;a>f;f++)r.push(0);i.iushrn(a)}return r}function a(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n=0,i=0;t.cmpn(-n)>0||e.cmpn(-i)>0;){var s=t.andln(3)+n&3,o=e.andln(3)+i&3;3===s&&(s=-1),3===o&&(o=-1);var a;if(0===(1&s))a=0;else{var f=t.andln(7)+n&7;a=3!==f&&5!==f||2!==o?s:-s}r[0].push(a);var u;if(0===(1&o))u=0;else{var f=e.andln(7)+i&7;u=3!==f&&5!==f||2!==s?o:-o}r[1].push(u),2*n===a+1&&(n=1-n),2*i===u+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r}function f(t,e){var r=e.name,n="_"+r;t.prototype[r]=function(){return void 0!==this[n]?this[n]:this[n]=e.call(this)}}function u(t){return"string"==typeof t?h.toArray(t,"hex"):t}function c(t){return new d(t,"hex","le")}var h=r,d=t("bn.js");h.assert=function(t,e){if(!t)throw new Error(e||"Assertion failed")},h.toArray=n,h.zero2=i,h.toHex=s,h.encode=function(t,e){return"hex"===e?s(t):t},h.getNAF=o,h.getJSF=a,h.cachedProperty=f,h.parseBytes=u,h.intFromLE=c},{"bn.js":85}],103:[function(t,e,r){function n(t){this.rand=t}var i;if(e.exports=function(t){return i||(i=new n(null)),i.generate(t)},e.exports.Rand=n,n.prototype.generate=function(t){return this._rand(t)},"object"==typeof window)window.crypto&&window.crypto.getRandomValues?n.prototype._rand=function(t){var e=new Uint8Array(t);return window.crypto.getRandomValues(e),e}:window.msCrypto&&window.msCrypto.getRandomValues?n.prototype._rand=function(t){var e=new Uint8Array(t);return window.msCrypto.getRandomValues(e),e}:n.prototype._rand=function(){throw new Error("Not implemented yet")};else try{var s=t("crypto");n.prototype._rand=function(t){return s.randomBytes(t)}}catch(o){n.prototype._rand=function(t){for(var e=new Uint8Array(t),r=0;r=this._delta8){t=this.pending;var r=t.length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=s.join32(t,0,t.length-r,this.endian);for(var n=0;ni;i++)n[i]=0;if(t<<=3,"big"===this.endian){for(var s=8;s>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else{n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0;for(var s=8;sthis.blockSize&&(t=(new this.Hash).update(t).digest()),o(t.length<=this.blockSize);for(var e=t.length;e=t?e^r^n:31>=t?e&r|~e&n:47>=t?(e|~r)^n:63>=t?e&n|r&~n:e^(r|~n)}function s(t){return 15>=t?0:31>=t?1518500249:47>=t?1859775393:63>=t?2400959708:2840853838}function o(t){return 15>=t?1352829926:31>=t?1548603684:47>=t?1836072691:63>=t?2053994217:0}var a=t("../hash"),f=a.utils,u=f.rotl32,c=f.sum32,h=f.sum32_3,d=f.sum32_4,p=a.common.BlockHash;f.inherits(n,p),r.ripemd160=n,n.blockSize=512,n.outSize=160,n.hmacStrength=192,n.padLength=64,n.prototype._update=function(t,e){for(var r=this.h[0],n=this.h[1],a=this.h[2],f=this.h[3],p=this.h[4],y=r,v=n,_=a,w=f,S=p,I=0;80>I;I++){var k=c(u(d(r,i(I,n,a,f),t[l[I]+e],s(I)),g[I]),p);r=p,p=f,f=u(a,10),a=n,n=k,k=c(u(d(y,i(79-I,v,_,w),t[b[I]+e],o(I)),m[I]),S),y=S,S=w,w=u(_,10),_=v,v=k}k=h(this.h[1],a,w),this.h[1]=h(this.h[2],f,S),this.h[2]=h(this.h[3],p,y),this.h[3]=h(this.h[4],r,v),this.h[4]=h(this.h[0],n,_),this.h[0]=k},n.prototype._digest=function(t){return"hex"===t?f.toHex32(this.h,"little"):f.split32(this.h,"little")};var l=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],b=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],g=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],m=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},{"../hash":104}],108:[function(t,e,r){function n(){return this instanceof n?(G.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=W,void(this.W=new Array(64))):new n}function i(){return this instanceof i?(n.call(this),void(this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])):new i}function s(){return this instanceof s?(G.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=X,void(this.W=new Array(160))):new s}function o(){return this instanceof o?(s.call(this),void(this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428])):new o}function a(){return this instanceof a?(G.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],void(this.W=new Array(80))):new a}function f(t,e,r){return t&e^~t&r}function u(t,e,r){return t&e^t&r^e&r}function c(t,e,r){return t^e^r}function h(t){return M(t,2)^M(t,13)^M(t,22)}function d(t){return M(t,6)^M(t,11)^M(t,25)}function p(t){return M(t,7)^M(t,18)^t>>>3}function l(t){return M(t,17)^M(t,19)^t>>>10}function b(t,e,r,n){return 0===t?f(e,r,n):1===t||3===t?c(e,r,n):2===t?u(e,r,n):void 0}function g(t,e,r,n,i,s){var o=t&r^~t&i;return 0>o&&(o+=4294967296),o}function m(t,e,r,n,i,s){var o=e&n^~e&s;return 0>o&&(o+=4294967296),o}function y(t,e,r,n,i,s){var o=t&r^t&i^r&i;return 0>o&&(o+=4294967296),o}function v(t,e,r,n,i,s){var o=e&n^e&s^n&s;return 0>o&&(o+=4294967296),o}function _(t,e){var r=j(t,e,28),n=j(e,t,2),i=j(e,t,7),s=r^n^i;return 0>s&&(s+=4294967296),s}function w(t,e){var r=U(t,e,28),n=U(e,t,2),i=U(e,t,7),s=r^n^i;return 0>s&&(s+=4294967296),s}function S(t,e){var r=j(t,e,14),n=j(t,e,18),i=j(e,t,9),s=r^n^i;return 0>s&&(s+=4294967296),s}function I(t,e){var r=U(t,e,14),n=U(t,e,18),i=U(e,t,9),s=r^n^i;return 0>s&&(s+=4294967296),s}function k(t,e){var r=j(t,e,1),n=j(t,e,8),i=L(t,e,7),s=r^n^i;return 0>s&&(s+=4294967296),s}function E(t,e){var r=U(t,e,1),n=U(t,e,8),i=D(t,e,7),s=r^n^i;return 0>s&&(s+=4294967296),s}function A(t,e){var r=j(t,e,19),n=j(e,t,29),i=L(t,e,6),s=r^n^i;return 0>s&&(s+=4294967296),s}function x(t,e){var r=U(t,e,19),n=U(e,t,29),i=D(t,e,6),s=r^n^i;return 0>s&&(s+=4294967296),s}var P=t("../hash"),O=P.utils,B=O.assert,M=O.rotr32,R=O.rotl32,T=O.sum32,C=O.sum32_4,N=O.sum32_5,j=O.rotr64_hi,U=O.rotr64_lo,L=O.shr64_hi,D=O.shr64_lo,z=O.sum64,F=O.sum64_hi,K=O.sum64_lo,H=O.sum64_4_hi,q=O.sum64_4_lo,V=O.sum64_5_hi,Y=O.sum64_5_lo,G=P.common.BlockHash,W=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],X=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],J=[1518500249,1859775393,2400959708,3395469782];O.inherits(n,G),r.sha256=n,n.blockSize=512,n.outSize=256,n.hmacStrength=192,n.padLength=64,n.prototype._update=function(t,e){for(var r=this.W,n=0;16>n;n++)r[n]=t[e+n];for(;nn;n++)r[n]=t[e+n];for(;nn;n++)r[n]=t[e+n];for(;n>8,o=255&i;s?r.push(s,o):r.push(o)}else for(var n=0;n>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24;return e>>>0}function o(t,e){for(var r="",n=0;n>>0}return s}function c(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=s>>>16&255,r[i+2]=s>>>8&255,r[i+3]=255&s):(r[i+3]=s>>>24,r[i+2]=s>>>16&255,r[i+1]=s>>>8&255,r[i]=255&s)}return r}function h(t,e){return t>>>e|t<<32-e}function d(t,e){return t<>>32-e}function p(t,e){return t+e>>>0}function l(t,e,r){return t+e+r>>>0}function b(t,e,r,n){return t+e+r+n>>>0}function g(t,e,r,n,i){return t+e+r+n+i>>>0}function m(t,e){if(!t)throw new Error(e||"Assertion failed")}function y(t,e,r,n){var i=t[e],s=t[e+1],o=n+s>>>0,a=(n>o?1:0)+r+i;t[e]=a>>>0,t[e+1]=o}function v(t,e,r,n){var i=e+n>>>0,s=(e>i?1:0)+t+r;return s>>>0}function _(t,e,r,n){var i=e+n;return i>>>0}function w(t,e,r,n,i,s,o,a){var f=0,u=e;u=u+n>>>0,f+=e>u?1:0,u=u+s>>>0,f+=s>u?1:0,u=u+a>>>0,f+=a>u?1:0;var c=t+r+i+o+f;return c>>>0}function S(t,e,r,n,i,s,o,a){var f=e+n+s+a;return f>>>0}function I(t,e,r,n,i,s,o,a,f,u){var c=0,h=e;h=h+n>>>0,c+=e>h?1:0,h=h+s>>>0,c+=s>h?1:0,h=h+a>>>0,c+=a>h?1:0,h=h+u>>>0,c+=u>h?1:0;var d=t+r+i+o+f+c;return d>>>0}function k(t,e,r,n,i,s,o,a,f,u){var c=e+n+s+a+u;return c>>>0}function E(t,e,r){var n=e<<32-r|t>>>r;return n>>>0}function A(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}function x(t,e,r){return t>>>r}function P(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}var O=r,B=t("inherits");O.toArray=n,O.toHex=i,O.htonl=s,O.toHex32=o,O.zero2=a,O.zero8=f,O.join32=u,O.split32=c,O.rotr32=h,O.rotl32=d,O.sum32=p,O.sum32_3=l,O.sum32_4=b,O.sum32_5=g,O.assert=m,O.inherits=B,r.sum64=y,r.sum64_hi=v,r.sum64_lo=_,r.sum64_4_hi=w,r.sum64_4_lo=S,r.sum64_5_hi=I,r.sum64_5_lo=k,r.rotr64_hi=E,r.rotr64_lo=A,r.shr64_hi=x,r.shr64_lo=P},{inherits:296}],110:[function(t,e,r){e.exports={name:"elliptic",version:"6.2.2",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{test:"make lint && istanbul test _mocha --reporter=spec test/*-test.js",coveralls:"cat ./coverage/lcov.info | coveralls"},repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},keywords:["EC","Elliptic","curve","Cryptography"],author:{name:"Fedor Indutny",email:"fedor@indutny.com"},license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{browserify:"^3.44.2",coveralls:"^2.11.3",istanbul:"^0.3.17",jscs:"^1.11.3",jshint:"^2.6.0",mocha:"^2.1.0","uglify-js":"^2.4.13"},dependencies:{"bn.js":"^4.0.0",brorand:"^1.0.1","hash.js":"^1.0.0",inherits:"^2.0.1"},gitHead:"628eb61186a7f1c81247cf991d808dc9ead83645",_id:"elliptic@6.2.2",_shasum:"806bfa651a5aa4996a1e79c92b573761ea7d7574",_from:"elliptic@>=6.0.0 <7.0.0",_npmVersion:"3.3.12",_nodeVersion:"5.4.1",_npmUser:{name:"indutny",email:"fedor@indutny.com"},dist:{shasum:"806bfa651a5aa4996a1e79c92b573761ea7d7574",tarball:"http://registry.npmjs.org/elliptic/-/elliptic-6.2.2.tgz"},maintainers:[{name:"indutny",email:"fedor@indutny.com"}],directories:{},_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.2.2.tgz",readme:"ERROR: No README data found!"}},{}],111:[function(t,e,r){e.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],112:[function(t,e,r){var n=t("asn1.js"),i=n.define("RSAPrivateKey",function(){this.seq().obj(this.key("version")["int"](),this.key("modulus")["int"](),this.key("publicExponent")["int"](),this.key("privateExponent")["int"](),this.key("prime1")["int"](),this.key("prime2")["int"](),this.key("exponent1")["int"](),this.key("exponent2")["int"](),this.key("coefficient")["int"]())});r.RSAPrivateKey=i;var s=n.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus")["int"](),this.key("publicExponent")["int"]())});r.RSAPublicKey=s;var o=n.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())});r.PublicKey=o;var a=n.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p")["int"](),this.key("q")["int"](),this.key("g")["int"]()).optional())}),f=n.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version")["int"](),this.key("algorithm").use(a),this.key("subjectPrivateKey").octstr())});r.PrivateKey=f;var u=n.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters")["int"]())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});r.EncryptedPrivateKey=u;var c=n.define("DSAPrivateKey",function(){this.seq().obj(this.key("version")["int"](),this.key("p")["int"](),this.key("q")["int"](),this.key("g")["int"](),this.key("pub_key")["int"](),this.key("priv_key")["int"]())});r.DSAPrivateKey=c,r.DSAparam=n.define("DSAparam",function(){this["int"]()});var h=n.define("ECPrivateKey",function(){this.seq().obj(this.key("version")["int"](),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(d),this.key("publicKey").optional().explicit(1).bitstr())});r.ECPrivateKey=h;var d=n.define("ECParameters",function(){this.choice({namedCurve:this.objid()})});r.signature=n.define("signature",function(){this.seq().obj(this.key("r")["int"](),this.key("s")["int"]())})},{"asn1.js":115}],113:[function(t,e,r){(function(r){var n=/Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\r?\n\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n/m,i=/^-----BEGIN (.*) KEY-----\r?\n/m,s=/^-----BEGIN (.*) KEY-----\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n-----END \1 KEY-----$/m,o=t("evp_bytestokey"),a=t("browserify-aes");e.exports=function(t,e){var f,u=t.toString(),c=u.match(n);if(c){var h="aes"+c[1],d=new r(c[2],"hex"),p=new r(c[3].replace(/\r?\n/g,""),"base64"),l=o(e,d.slice(0,8),parseInt(c[1],10)).key,b=[],g=a.createDecipheriv(h,l,d);b.push(g.update(p)),b.push(g["final"]()),f=r.concat(b)}else{var m=u.match(s);f=new r(m[2].replace(/\r?\n/g,""),"base64")}var y=u.match(i)[1]+" KEY";return{tag:y,data:f}}}).call(this,t("buffer").Buffer)},{"browserify-aes":132,buffer:48,evp_bytestokey:147}],114:[function(t,e,r){(function(r){function n(t){var e;"object"!=typeof t||r.isBuffer(t)||(e=t.passphrase,t=t.key),"string"==typeof t&&(t=new r(t));var n,o,f=a(t,e),u=f.tag,c=f.data;switch(u){case"PUBLIC KEY":switch(o=s.PublicKey.decode(c,"der"),n=o.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return s.RSAPublicKey.decode(o.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return o.subjectPrivateKey=o.subjectPublicKey,{type:"ec",data:o};case"1.2.840.10040.4.1":return o.algorithm.params.pub_key=s.DSAparam.decode(o.subjectPublicKey.data,"der"),{type:"dsa",data:o.algorithm.params};default:throw new Error("unknown key id "+n)}throw new Error("unknown key type "+u);case"ENCRYPTED PRIVATE KEY":c=s.EncryptedPrivateKey.decode(c,"der"),c=i(c,e);case"PRIVATE KEY":switch(o=s.PrivateKey.decode(c,"der"),n=o.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return s.RSAPrivateKey.decode(o.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:o.algorithm.curve,privateKey:s.ECPrivateKey.decode(o.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return o.algorithm.params.priv_key=s.DSAparam.decode(o.subjectPrivateKey,"der"),{type:"dsa",params:o.algorithm.params};default:throw new Error("unknown key id "+n)}throw new Error("unknown key type "+u);case"RSA PUBLIC KEY":return s.RSAPublicKey.decode(c,"der");case"RSA PRIVATE KEY":return s.RSAPrivateKey.decode(c,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:s.DSAPrivateKey.decode(c,"der")};case"EC PRIVATE KEY":return c=s.ECPrivateKey.decode(c,"der"),{curve:c.parameters.value,privateKey:c.privateKey};default:throw new Error("unknown key type "+u)}}function i(t,e){var n=t.algorithm.decrypt.kde.kdeparams.salt,i=parseInt(t.algorithm.decrypt.kde.kdeparams.iters.toString(),10),s=o[t.algorithm.decrypt.cipher.algo.join(".")],a=t.algorithm.decrypt.cipher.iv,c=t.subjectPrivateKey,h=parseInt(s.split("-")[1],10)/8,d=u.pbkdf2Sync(e,n,i,h),p=f.createDecipheriv(s,d,a),l=[];return l.push(p.update(c)),l.push(p["final"]()),r.concat(l)}var s=t("./asn1"),o=t("./aesid.json"),a=t("./fixProc"),f=t("browserify-aes"),u=t("pbkdf2");e.exports=n,n.signature=s.signature}).call(this,t("buffer").Buffer)},{"./aesid.json":111,"./asn1":112,"./fixProc":113,"browserify-aes":132,buffer:48,pbkdf2:197}],115:[function(t,e,r){var n=r;n.bignum=t("bn.js"),n.define=t("./asn1/api").define,n.base=t("./asn1/base"),n.constants=t("./asn1/constants"),n.decoders=t("./asn1/decoders"),n.encoders=t("./asn1/encoders")},{"./asn1/api":116,"./asn1/base":118,"./asn1/constants":122,"./asn1/decoders":124,"./asn1/encoders":127,"bn.js":85}],116:[function(t,e,r){function n(t,e){this.name=t,this.body=e,this.decoders={},this.encoders={}}var i=t("../asn1"),s=t("inherits"),o=r;o.define=function(t,e){return new n(t,e)},n.prototype._createNamed=function(e){var r;try{r=t("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(n){r=function(t){this._initNamed(t)}}return s(r,e),r.prototype._initNamed=function(t){e.call(this,t)},new r(this)},n.prototype._getDecoder=function(t){return this.decoders.hasOwnProperty(t)||(this.decoders[t]=this._createNamed(i.decoders[t])),this.decoders[t]},n.prototype.decode=function(t,e,r){return this._getDecoder(e).decode(t,r)},n.prototype._getEncoder=function(t){return this.encoders.hasOwnProperty(t)||(this.encoders[t]=this._createNamed(i.encoders[t])),this.encoders[t]},n.prototype.encode=function(t,e,r){return this._getEncoder(e).encode(t,r)}},{"../asn1":115,inherits:296,vm:270}],117:[function(t,e,r){function n(t,e){return o.call(this,e),a.isBuffer(t)?(this.base=t,this.offset=0,void(this.length=t.length)):void this.error("Input not Buffer")}function i(t,e){if(Array.isArray(t))this.length=0,this.value=t.map(function(t){return t instanceof i||(t=new i(t,e)),this.length+=t.length,t},this);else if("number"==typeof t){if(!(t>=0&&255>=t))return e.error("non-byte EncoderBuffer value");this.value=t,this.length=1}else if("string"==typeof t)this.value=t,this.length=a.byteLength(t);else{if(!a.isBuffer(t))return e.error("Unsupported type: "+typeof t);this.value=t,this.length=t.length}}var s=t("inherits"),o=t("../base").Reporter,a=t("buffer").Buffer;s(n,o),r.DecoderBuffer=n,n.prototype.save=function(){return{offset:this.offset,reporter:o.prototype.save.call(this)}},n.prototype.restore=function(t){var e=new n(this.base);return e.offset=t.offset,e.length=this.offset,this.offset=t.offset,o.prototype.restore.call(this,t.reporter),e},n.prototype.isEmpty=function(){return this.offset===this.length},n.prototype.readUInt8=function(t){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(t||"DecoderBuffer overrun")},n.prototype.skip=function(t,e){if(!(this.offset+t<=this.length))return this.error(e||"DecoderBuffer overrun");var r=new n(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+t,this.offset+=t,r},n.prototype.raw=function(t){return this.base.slice(t?t.offset:this.offset,this.length)},r.EncoderBuffer=i,i.prototype.join=function(t,e){return t||(t=new a(this.length)),e||(e=0),0===this.length?t:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(t,e),e+=r.length}):("number"==typeof this.value?t[e]=this.value:"string"==typeof this.value?t.write(this.value,e):a.isBuffer(this.value)&&this.value.copy(t,e),e+=this.length),t)}},{"../base":118,buffer:48,inherits:296}],118:[function(t,e,r){var n=r;n.Reporter=t("./reporter").Reporter,n.DecoderBuffer=t("./buffer").DecoderBuffer,n.EncoderBuffer=t("./buffer").EncoderBuffer,n.Node=t("./node")},{"./buffer":117,"./node":119,"./reporter":120}],119:[function(t,e,r){function n(t,e){var r={};this._baseState=r,r.enc=t,r.parent=e||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r["default"]=null,r.explicit=null,r.implicit=null,r.parent||(r.children=[],this._wrap())}var i=t("../base").Reporter,s=t("../base").EncoderBuffer,o=t("minimalistic-assert"),a=["seq","seqof","set","setof","octstr","bitstr","objid","bool","gentime","utctime","null_","enum","int","ia5str","utf8str","bmpstr","numstr","printstr"],f=["key","obj","use","optional","explicit","implicit","def","choice","any"].concat(a),u=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];e.exports=n;var c=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit"];n.prototype.clone=function(){var t=this._baseState,e={};c.forEach(function(r){e[r]=t[r]});var r=new this.constructor(e.parent);return r._baseState=e,r},n.prototype._wrap=function(){var t=this._baseState;f.forEach(function(e){this[e]=function(){var r=new this.constructor(this);return t.children.push(r),r[e].apply(r,arguments)}},this)},n.prototype._init=function(t){var e=this._baseState;o(null===e.parent),t.call(this),e.children=e.children.filter(function(t){return t._baseState.parent===this},this),o.equal(e.children.length,1,"Root node can have only one child")},n.prototype._useArgs=function(t){var e=this._baseState,r=t.filter(function(t){return t instanceof this.constructor},this);t=t.filter(function(t){return!(t instanceof this.constructor)},this),0!==r.length&&(o(null===e.children),e.children=r,r.forEach(function(t){t._baseState.parent=this},this)),0!==t.length&&(o(null===e.args),e.args=t,e.reverseArgs=t.map(function(t){if("object"!=typeof t||t.constructor!==Object)return t;var e={};return Object.keys(t).forEach(function(r){r==(0|r)&&(r|=0);var n=t[r];e[n]=r}),e}))},u.forEach(function(t){n.prototype[t]=function(){var e=this._baseState;throw new Error(t+" not implemented for encoding: "+e.enc)}}),a.forEach(function(t){n.prototype[t]=function(){var e=this._baseState,r=Array.prototype.slice.call(arguments);return o(null===e.tag),e.tag=t,this._useArgs(r),this}}),n.prototype.use=function(t){var e=this._baseState;return o(null===e.use),e.use=t,this},n.prototype.optional=function(){var t=this._baseState;return t.optional=!0,this},n.prototype.def=function(t){var e=this._baseState;return o(null===e["default"]),e["default"]=t,e.optional=!0,this},n.prototype.explicit=function(t){var e=this._baseState;return o(null===e.explicit&&null===e.implicit),e.explicit=t,this},n.prototype.implicit=function(t){var e=this._baseState;return o(null===e.explicit&&null===e.implicit),e.implicit=t,this},n.prototype.obj=function(){var t=this._baseState,e=Array.prototype.slice.call(arguments);return t.obj=!0,0!==e.length&&this._useArgs(e),this},n.prototype.key=function(t){var e=this._baseState;return o(null===e.key),e.key=t,this},n.prototype.any=function(){var t=this._baseState;return t.any=!0,this},n.prototype.choice=function(t){var e=this._baseState;return o(null===e.choice), +e.choice=t,this._useArgs(Object.keys(t).map(function(e){return t[e]})),this},n.prototype._decode=function(t){var e=this._baseState;if(null===e.parent)return t.wrapResult(e.children[0]._decode(t));var r,n=e["default"],i=!0;if(null!==e.key&&(r=t.enterKey(e.key)),e.optional){var s=null;if(null!==e.explicit?s=e.explicit:null!==e.implicit?s=e.implicit:null!==e.tag&&(s=e.tag),null!==s||e.any){if(i=this._peekTag(t,s,e.any),t.isError(i))return i}else{var o=t.save();try{null===e.choice?this._decodeGeneric(e.tag,t):this._decodeChoice(t),i=!0}catch(a){i=!1}t.restore(o)}}var f;if(e.obj&&i&&(f=t.enterObject()),i){if(null!==e.explicit){var u=this._decodeTag(t,e.explicit);if(t.isError(u))return u;t=u}if(null===e.use&&null===e.choice){if(e.any)var o=t.save();var c=this._decodeTag(t,null!==e.implicit?e.implicit:e.tag,e.any);if(t.isError(c))return c;e.any?n=t.raw(o):t=c}if(n=e.any?n:null===e.choice?this._decodeGeneric(e.tag,t):this._decodeChoice(t),t.isError(n))return n;if(!e.any&&null===e.choice&&null!==e.children){var h=e.children.some(function(e){e._decode(t)});if(h)return err}}return e.obj&&i&&(n=t.leaveObject(f)),null===e.key||null===n&&i!==!0||t.leaveKey(r,e.key,n),n},n.prototype._decodeGeneric=function(t,e){var r=this._baseState;return"seq"===t||"set"===t?null:"seqof"===t||"setof"===t?this._decodeList(e,t,r.args[0]):"octstr"===t||"bitstr"===t?this._decodeStr(e,t):"ia5str"===t||"utf8str"===t||"bmpstr"===t?this._decodeStr(e,t):"numstr"===t||"printstr"===t?this._decodeStr(e,t):"objid"===t&&r.args?this._decodeObjid(e,r.args[0],r.args[1]):"objid"===t?this._decodeObjid(e,null,null):"gentime"===t||"utctime"===t?this._decodeTime(e,t):"null_"===t?this._decodeNull(e):"bool"===t?this._decodeBool(e):"int"===t||"enum"===t?this._decodeInt(e,r.args&&r.args[0]):null!==r.use?this._getUse(r.use,e._reporterState.obj)._decode(e):e.error("unknown tag: "+t)},n.prototype._getUse=function(t,e){var r=this._baseState;return r.useDecoder=this._use(t,e),o(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},n.prototype._decodeChoice=function(t){var e=this._baseState,r=null,n=!1;return Object.keys(e.choice).some(function(i){var s=t.save(),o=e.choice[i];try{var a=o._decode(t);if(t.isError(a))return!1;r={type:i,value:a},n=!0}catch(f){return t.restore(s),!1}return!0},this),n?r:t.error("Choice not matched")},n.prototype._createEncoderBuffer=function(t){return new s(t,this.reporter)},n.prototype._encode=function(t,e,r){var n=this._baseState;if(null===n["default"]||n["default"]!==t){var i=this._encodeValue(t,e,r);if(void 0!==i&&!this._skipDefault(i,e,r))return i}},n.prototype._encodeValue=function(t,e,r){var n=this._baseState;if(null===n.parent)return n.children[0]._encode(t,e||new i);var s=null;if(this.reporter=e,n.optional&&void 0===t){if(null===n["default"])return;t=n["default"]}var o=null,a=!1;if(n.any)s=this._createEncoderBuffer(t);else if(n.choice)s=this._encodeChoice(t,e);else if(n.children)o=n.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,e,t);if(null===r._baseState.key)return e.error("Child should have a key");var n=e.enterKey(r._baseState.key);if("object"!=typeof t)return e.error("Child expected, but input is not object");var i=r._encode(t[r._baseState.key],e,t);return e.leaveKey(n),i},this).filter(function(t){return t}),o=this._createEncoderBuffer(o);else if("seqof"===n.tag||"setof"===n.tag){if(!n.args||1!==n.args.length)return e.error("Too many args for : "+n.tag);if(!Array.isArray(t))return e.error("seqof/setof, but data is not Array");var f=this.clone();f._baseState.implicit=null,o=this._createEncoderBuffer(t.map(function(r){var n=this._baseState;return this._getUse(n.args[0],t)._encode(r,e)},f))}else null!==n.use?s=this._getUse(n.use,r)._encode(t,e):(o=this._encodePrimitive(n.tag,t),a=!0);var s;if(!n.any&&null===n.choice){var u=null!==n.implicit?n.implicit:n.tag,c=null===n.implicit?"universal":"context";null===u?null===n.use&&e.error("Tag could be ommited only for .use()"):null===n.use&&(s=this._encodeComposite(u,a,c,o))}return null!==n.explicit&&(s=this._encodeComposite(n.explicit,!1,"context",s)),s},n.prototype._encodeChoice=function(t,e){var r=this._baseState,n=r.choice[t.type];return n||o(!1,t.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(t.value,e)},n.prototype._encodePrimitive=function(t,e){var r=this._baseState;if("octstr"===t||"bitstr"===t||"ia5str"===t)return this._encodeStr(e,t);if("utf8str"===t||"bmpstr"===t)return this._encodeStr(e,t);if("numstr"===t||"printstr"===t)return this._encodeStr(e,t);if("objid"===t&&r.args)return this._encodeObjid(e,r.reverseArgs[0],r.args[1]);if("objid"===t)return this._encodeObjid(e,null,null);if("gentime"===t||"utctime"===t)return this._encodeTime(e,t);if("null_"===t)return this._encodeNull();if("int"===t||"enum"===t)return this._encodeInt(e,r.args&&r.reverseArgs[0]);if("bool"===t)return this._encodeBool(e);throw new Error("Unsupported tag: "+t)},n.prototype._isNumstr=function(t){return/^[0-9 ]*$/.test(t)},n.prototype._isPrintstr=function(t){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(t)}},{"../base":118,"minimalistic-assert":129}],120:[function(t,e,r){function n(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}function i(t,e){this.path=t,this.rethrow(e)}var s=t("inherits");r.Reporter=n,n.prototype.isError=function(t){return t instanceof i},n.prototype.save=function(){var t=this._reporterState;return{obj:t.obj,pathLen:t.path.length}},n.prototype.restore=function(t){var e=this._reporterState;e.obj=t.obj,e.path=e.path.slice(0,t.pathLen)},n.prototype.enterKey=function(t){return this._reporterState.path.push(t)},n.prototype.leaveKey=function(t,e,r){var n=this._reporterState;n.path=n.path.slice(0,t-1),null!==n.obj&&(n.obj[e]=r)},n.prototype.enterObject=function(){var t=this._reporterState,e=t.obj;return t.obj={},e},n.prototype.leaveObject=function(t){var e=this._reporterState,r=e.obj;return e.obj=t,r},n.prototype.error=function(t){var e,r=this._reporterState,n=t instanceof i;if(e=n?t:new i(r.path.map(function(t){return"["+JSON.stringify(t)+"]"}).join(""),t.message||t,t.stack),!r.options.partial)throw e;return n||r.errors.push(e),e},n.prototype.wrapResult=function(t){var e=this._reporterState;return e.options.partial?{result:this.isError(t)?null:t,errors:e.errors}:t},s(i,Error),i.prototype.rethrow=function(t){return this.message=t+" at: "+(this.path||"(shallow)"),Error.captureStackTrace(this,i),this}},{inherits:296}],121:[function(t,e,r){var n=t("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":122}],122:[function(t,e,r){var n=r;n._reverse=function(t){var e={};return Object.keys(t).forEach(function(r){(0|r)==r&&(r=0|r);var n=t[r];e[n]=r}),e},n.der=t("./der")},{"./der":121}],123:[function(t,e,r){function n(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new i,this.tree._init(t.body)}function i(t){u.Node.call(this,"der",t)}function s(t,e){var r=t.readUInt8(e);if(t.isError(r))return r;var n=h.tagClass[r>>6],i=0===(32&r);if(31===(31&r)){var s=r;for(r=0;128===(128&s);){if(s=t.readUInt8(e),t.isError(s))return s;r<<=7,r|=127&s}}else r&=31;var o=h.tag[r];return{cls:n,primitive:i,tag:r,tagStr:o}}function o(t,e,r){var n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&128===n)return null;if(0===(128&n))return n;var i=127&n;if(i>=4)return t.error("length octect is too long");n=0;for(var s=0;i>s;s++){n<<=8;var o=t.readUInt8(r);if(t.isError(o))return o;n|=o}return n}var a=t("inherits"),f=t("../../asn1"),u=f.base,c=f.bignum,h=f.constants.der;e.exports=n,n.prototype.decode=function(t,e){return t instanceof u.DecoderBuffer||(t=new u.DecoderBuffer(t,e)),this.tree._decode(t,e)},a(i,u.Node),i.prototype._peekTag=function(t,e,r){if(t.isEmpty())return!1;var n=t.save(),i=s(t,'Failed to peek tag: "'+e+'"');return t.isError(i)?i:(t.restore(n),i.tag===e||i.tagStr===e||r)},i.prototype._decodeTag=function(t,e,r){var n=s(t,'Failed to decode tag of "'+e+'"');if(t.isError(n))return n;var i=o(t,n.primitive,'Failed to get length of "'+e+'"');if(t.isError(i))return i;if(!r&&n.tag!==e&&n.tagStr!==e&&n.tagStr+"of"!==e)return t.error('Failed to match tag: "'+e+'"');if(n.primitive||null!==i)return t.skip(i,'Failed to match body of: "'+e+'"');var a=t.save(),f=this._skipUntilEnd(t,'Failed to skip indefinite length body: "'+this.tag+'"');return t.isError(f)?f:(i=t.offset-a.offset,t.restore(a),t.skip(i,'Failed to match body of: "'+e+'"'))},i.prototype._skipUntilEnd=function(t,e){for(;;){var r=s(t,e);if(t.isError(r))return r;var n=o(t,r.primitive,e);if(t.isError(n))return n;var i;if(i=r.primitive||null!==n?t.skip(n):this._skipUntilEnd(t,e),t.isError(i))return i;if("end"===r.tagStr)break}},i.prototype._decodeList=function(t,e,r){for(var n=[];!t.isEmpty();){var i=this._peekTag(t,"end");if(t.isError(i))return i;var s=r.decode(t,"der");if(t.isError(s)&&i)break;n.push(s)}return n},i.prototype._decodeStr=function(t,e){if("octstr"===e)return t.raw();if("bitstr"===e){var r=t.readUInt8();return t.isError(r)?r:{unused:r,data:t.raw()}}if("ia5str"===e||"utf8str"===e)return t.raw().toString();if("numstr"===e){var n=t.raw().toString("ascii");return this._isNumstr(n)?n:t.error("Decoding of string type: numstr unsupported characters")}if("printstr"===e){var i=t.raw().toString("ascii");return this._isPrintstr(i)?i:t.error("Decoding of string type: printstr unsupported characters")}if("bmpstr"===e){var s=t.raw();if(s.length%2===1)return t.error("Decoding of string type: bmpstr length mismatch");for(var o="",a=0;an?2e3+n:1900+n}return Date.UTC(n,i-1,s,o,a,f,0)},i.prototype._decodeNull=function(t){return null},i.prototype._decodeBool=function(t){var e=t.readUInt8();return t.isError(e)?e:0!==e},i.prototype._decodeInt=function(t,e){var r=t.raw(),n=new c(r);return e&&(n=e[n.toString(10)]||n),n},i.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getDecoder("der").tree}},{"../../asn1":115,inherits:296}],124:[function(t,e,r){var n=r;n.der=t("./der"),n.pem=t("./pem")},{"./der":123,"./pem":125}],125:[function(t,e,r){function n(t){o.call(this,t),this.enc="pem"}var i=t("inherits"),s=t("buffer").Buffer,o=(t("../../asn1"),t("./der"));i(n,o),e.exports=n,n.prototype.decode=function(t,e){for(var r=t.toString().split(/[\r\n]+/g),n=e.label.toUpperCase(),i=/^-----(BEGIN|END) ([^-]+)-----$/,a=-1,f=-1,u=0;ut?"0"+t:t}function o(t,e,r,n){var i;if("seqof"===t?t="seq":"setof"===t&&(t="set"),h.tagByName.hasOwnProperty(t))i=h.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return n.error("Unknown tag: "+t);i=t}return i>=31?n.error("Multi-octet tag encoding unsupported"):(e||(i|=32),i|=h.tagClassByName[r||"universal"]<<6)}var a=t("inherits"),f=t("buffer").Buffer,u=t("../../asn1"),c=u.base,h=(u.bignum,u.constants.der);e.exports=n,n.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},a(i,c.Node),i.prototype._encodeComposite=function(t,e,r,n){var i=o(t,e,r,this.reporter);if(n.length<128){var s=new f(2);return s[0]=i,s[1]=n.length,this._createEncoderBuffer([s,n])}for(var a=1,u=n.length;u>=256;u>>=8)a++;var s=new f(2+a);s[0]=i,s[1]=128|a;for(var u=1+a,c=n.length;c>0;u--,c>>=8)s[u]=255&c;return this._createEncoderBuffer([s,n])},i.prototype._encodeStr=function(t,e){if("octstr"===e)return this._createEncoderBuffer(t);if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("ia5str"===e||"utf8str"===e)return this._createEncoderBuffer(t);if("bmpstr"===e){for(var r=new f(2*t.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}for(var i=0,n=0;n=128;s>>=7)i++}for(var o=new f(i),a=o.length-1,n=t.length-1;n>=0;n--){var s=t[n];for(o[a--]=127&s;(s>>=7)>0;)o[a--]=128|127&s}return this._createEncoderBuffer(o)},i.prototype._encodeTime=function(t,e){var r,n=new Date(t);return"gentime"===e?r=[s(n.getFullYear()),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[s(n.getFullYear()%100),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr")},i.prototype._encodeNull=function(){return this._createEncoderBuffer("")},i.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!f.isBuffer(t)){var r=t.toArray();!t.sign&&128&r[0]&&r.unshift(0),t=new f(r)}if(f.isBuffer(t)){var n=t.length;0===t.length&&n++;var i=new f(n);return t.copy(i),0===t.length&&(i[0]=0),this._createEncoderBuffer(i)}if(128>t)return this._createEncoderBuffer(t);if(256>t)return this._createEncoderBuffer([0,t]);for(var n=1,s=t;s>=256;s>>=8)n++;for(var i=new Array(n),s=i.length-1;s>=0;s--)i[s]=255&t,t>>=8;return 128&i[0]&&i.unshift(0),this._createEncoderBuffer(new f(i))},i.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},i.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},i.prototype._skipDefault=function(t,e,r){var n,i=this._baseState;if(null===i["default"])return!1;var s=t.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i["default"],e,r).join()),s.length!==i.defaultBuffer.length)return!1;for(n=0;n0&&r.ishrn(n),r}function u(t,e){t=f(t,e),t=t.mod(e);var n=new r(t.toArray());if(n.lengthd&&(b=1),f=Math.min(t.length,h.length),t.length!==h.length&&(b=1),p=-1;++p=e)throw new Error("invalid sig")}var a=t("./curves"),f=t("elliptic"),u=t("parse-asn1"),c=t("bn.js"),h=f.ec;e.exports=n}).call(this,t("buffer").Buffer)},{"./curves":84,"bn.js":85,buffer:48,elliptic:87,"parse-asn1":114}],150:[function(t,e,r){(function(r){function n(t){this.curveType=a[t],this.curveType||(this.curveType={name:t}),this.curve=new s.ec(this.curveType.name),this.keys=void 0}function i(t,e,n){Array.isArray(t)||(t=t.toArray());var i=new r(t);if(n&&i.length=6.0.0 <7.0.0",_npmVersion:"3.3.12",_nodeVersion:"5.4.1",_npmUser:{name:"indutny",email:"fedor@indutny.com"},dist:{shasum:"806bfa651a5aa4996a1e79c92b573761ea7d7574",tarball:"http://registry.npmjs.org/elliptic/-/elliptic-6.2.2.tgz"},maintainers:[{name:"indutny",email:"fedor@indutny.com"}],directories:{},_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.2.2.tgz"}},{}],176:[function(t,e,r){(function(r){"use strict";function n(t){u.call(this,"digest"),this._hash=t,this.buffers=[]}function i(t){u.call(this,"digest"),this._hash=t}var s=t("inherits"),o=t("./md5"),a=t("ripemd160"),f=t("sha.js"),u=t("cipher-base");s(n,u),n.prototype._update=function(t){this.buffers.push(t)},n.prototype._final=function(){var t=r.concat(this.buffers),e=this._hash(t);return this.buffers=null,e},s(i,u),i.prototype._update=function(t){this._hash.update(t)},i.prototype._final=function(){return this._hash.digest()},e.exports=function(t){return t=t.toLowerCase(),"md5"===t?new n(o):"rmd160"===t||"ripemd160"===t?new n(a):new i(f(t))}}).call(this,t("buffer").Buffer)},{"./md5":178,buffer:48,"cipher-base":179,inherits:296,ripemd160:180,"sha.js":182}],177:[function(t,e,r){(function(t){"use strict";function e(e,r){if(e.length%s!==0){var n=e.length+(s-e.length%s);e=t.concat([e,o],n)}for(var i=[],a=r?e.readInt32BE:e.readInt32LE,f=0;f>5]|=128<>>9<<4)+14]=e;for(var r=1732584193,n=-271733879,i=-1732584194,c=271733878,h=0;h>16)+(e>>16)+(r>>16);return n<<16|65535&r}function c(t,e){return t<>>32-e}var h=t("./helpers");e.exports=function(t){return h.hash(t,n,16)}},{"./helpers":177}],179:[function(t,e,r){arguments[4][69][0].apply(r,arguments)},{buffer:48,dup:69,inherits:296,stream:265,string_decoder:266}],180:[function(t,e,r){(function(t){function r(t){for(var e=[],r=0,n=0;r>>5]|=t[r]<<24-n%32;return e}function n(t){for(var e=[],r=0;r<32*t.length;r+=8)e.push(t[r>>>5]>>>24-r%32&255);return e}function i(t,e,r){for(var n=0;16>n;n++){var i=r+n,h=e[i];e[i]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}var y,v,_,w,S,I,k,E,A,x;I=y=t[0],k=v=t[1],E=_=t[2],A=w=t[3],x=S=t[4];var P;for(n=0;80>n;n+=1)P=y+e[r+d[n]]|0,P+=16>n?s(v,_,w)+g[0]:32>n?o(v,_,w)+g[1]:48>n?a(v,_,w)+g[2]:64>n?f(v,_,w)+g[3]:u(v,_,w)+g[4],P=0|P,P=c(P,l[n]),P=P+S|0,y=S,S=w,w=c(_,10),_=v,v=P,P=I+e[r+p[n]]|0,P+=16>n?u(k,E,A)+m[0]:32>n?f(k,E,A)+m[1]:48>n?a(k,E,A)+m[2]:64>n?o(k,E,A)+m[3]:s(k,E,A)+m[4],P=0|P,P=c(P,b[n]),P=P+x|0,I=x,x=A,A=c(E,10),E=k,k=P;P=t[1]+_+A|0,t[1]=t[2]+w+x|0,t[2]=t[3]+S+I|0,t[3]=t[4]+y+k|0,t[4]=t[0]+v+E|0,t[0]=P}function s(t,e,r){return t^e^r}function o(t,e,r){return t&e|~t&r}function a(t,e,r){return(t|~e)^r}function f(t,e,r){return t&r|e&~r}function u(t,e,r){return t^(e|~r)}function c(t,e){return t<>>32-e}function h(e){var s=[1732584193,4023233417,2562383102,271733878,3285377520];"string"==typeof e&&(e=new t(e,"utf8"));var o=r(e),a=8*e.length,f=8*e.length;o[a>>>5]|=128<<24-a%32,o[(a+64>>>9<<4)+14]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8);for(var u=0;uu;u++){var c=s[u];s[u]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}var h=n(s);return new t(h)}var d=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],p=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],l=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],b=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],g=[0,1518500249,1859775393,2400959708,2840853838],m=[1352829926,1548603684,1836072691,2053994217,0];e.exports=h}).call(this,t("buffer").Buffer)},{buffer:48}],181:[function(t,e,r){(function(t){function r(e,r){this._block=new t(e),this._finalSize=r,this._blockSize=e,this._len=0,this._s=0}r.prototype.update=function(e,r){"string"==typeof e&&(r=r||"utf8",e=new t(e,r));for(var n=this._len+=e.length,i=this._s||0,s=0,o=this._block;n>i;){for(var a=Math.min(e.length,s+this._blockSize-i%this._blockSize),f=a-s,u=0;f>u;u++)o[i%this._blockSize+u]=e[u+s];i+=f,s+=f,i%this._blockSize===0&&this._update(o)}return this._s=i,this},r.prototype.digest=function(t){var e=8*this._len;this._block[this._len%this._blockSize]=128,this._block.fill(0,this._len%this._blockSize+1),e%(8*this._blockSize)>=8*this._finalSize&&(this._update(this._block),this._block.fill(0)),this._block.writeInt32BE(e,this._blockSize-4);var r=this._update(this._block)||this._hash();return t?r.toString(t):r},r.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=r}).call(this,t("buffer").Buffer)},{buffer:48}],182:[function(t,e,r){var r=e.exports=function(t){t=t.toLowerCase();var e=r[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e};r.sha=t("./sha"),r.sha1=t("./sha1"),r.sha224=t("./sha224"),r.sha256=t("./sha256"),r.sha384=t("./sha384"),r.sha512=t("./sha512")},{"./sha":183,"./sha1":184,"./sha224":185,"./sha256":186,"./sha384":187,"./sha512":188}],183:[function(t,e,r){(function(r){function n(){this.init(),this._w=a,o.call(this,64,56)}function i(t,e){return t<>>32-e}var s=t("inherits"),o=t("./hash"),a=new Array(80);s(n,o),n.prototype.init=function(){return this._a=1732584193,this._b=-271733879,this._c=-1732584194,this._d=271733878,this._e=-1009589776,this},n.prototype._update=function(t){function e(){return s[h-3]^s[h-8]^s[h-14]^s[h-16]}function r(t,e){s[h]=t;var r=i(o,5)+e+c+t+n;c=u,u=f,f=i(a,30),a=o,o=r,h++}var n,s=this._w,o=this._a,a=this._b,f=this._c,u=this._d,c=this._e,h=0;for(n=1518500249;16>h;)r(t.readInt32BE(4*h),a&f|~a&u);for(;20>h;)r(e(),a&f|~a&u);for(n=1859775393;40>h;)r(e(),a^f^u);for(n=-1894007588;60>h;)r(e(),a&f|a&u|f&u);for(n=-899497514;80>h;)r(e(),a^f^u);this._a=o+this._a|0,this._b=a+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=c+this._e|0},n.prototype._hash=function(){var t=new r(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=n}).call(this,t("buffer").Buffer)},{"./hash":181,buffer:48,inherits:296}],184:[function(t,e,r){(function(r){function n(){this.init(),this._w=a,o.call(this,64,56)}function i(t,e){return t<>>32-e}var s=t("inherits"),o=t("./hash"),a=new Array(80);s(n,o),n.prototype.init=function(){return this._a=1732584193,this._b=-271733879,this._c=-1732584194,this._d=271733878,this._e=-1009589776,this},n.prototype._update=function(t){function e(){return i(s[h-3]^s[h-8]^s[h-14]^s[h-16],1)}function r(t,e){s[h]=t;var r=i(o,5)+e+c+t+n;c=u,u=f,f=i(a,30),a=o,o=r,h++}var n,s=this._w,o=this._a,a=this._b,f=this._c,u=this._d,c=this._e,h=0;for(n=1518500249;16>h;)r(t.readInt32BE(4*h),a&f|~a&u);for(;20>h;)r(e(),a&f|~a&u);for(n=1859775393;40>h;)r(e(),a^f^u);for(n=-1894007588;60>h;)r(e(),a&f|a&u|f&u);for(n=-899497514;80>h;)r(e(),a^f^u);this._a=o+this._a|0,this._b=a+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=c+this._e|0},n.prototype._hash=function(){var t=new r(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=n}).call(this,t("buffer").Buffer)},{"./hash":181,buffer:48,inherits:296}],185:[function(t,e,r){(function(r){function n(){this.init(),this._w=a,o.call(this,64,56)}var i=t("inherits"),s=t("./sha256"),o=t("./hash"),a=new Array(64);i(n,s),n.prototype.init=function(){return this._a=-1056596264,this._b=914150663,this._c=812702999,this._d=-150054599,this._e=-4191439,this._f=1750603025,this._g=1694076839,this._h=-1090891868,this},n.prototype._hash=function(){var t=new r(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},e.exports=n}).call(this,t("buffer").Buffer)},{"./hash":181,"./sha256":186,buffer:48,inherits:296}],186:[function(t,e,r){(function(r){function n(){this.init(),this._w=p,h.call(this,64,56)}function i(t,e,r){return r^t&(e^r)}function s(t,e,r){return t&e|r&(t|e)}function o(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function a(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function f(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function u(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}var c=t("inherits"),h=t("./hash"),d=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],p=new Array(64);c(n,h),n.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this},n.prototype._update=function(t){function e(){return u(n[v-2])+n[v-7]+f(n[v-15])+n[v-16]}function r(t){n[v]=t;var e=y+a(b)+i(b,g,m)+d[v]+t,r=o(c)+s(c,h,p);y=m,m=g,g=b,b=l+e,l=p,p=h,h=c,c=e+r,v++}for(var n=this._w,c=0|this._a,h=0|this._b,p=0|this._c,l=0|this._d,b=0|this._e,g=0|this._f,m=0|this._g,y=0|this._h,v=0;16>v;)r(t.readInt32BE(4*v));for(;64>v;)r(e());this._a=c+this._a|0,this._b=h+this._b|0,this._c=p+this._c|0,this._d=l+this._d|0,this._e=b+this._e|0,this._f=g+this._f|0,this._g=m+this._g|0,this._h=y+this._h|0},n.prototype._hash=function(){var t=new r(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},e.exports=n}).call(this,t("buffer").Buffer)},{"./hash":181,buffer:48,inherits:296}],187:[function(t,e,r){(function(r){function n(){this.init(),this._w=a,o.call(this,128,112)}var i=t("inherits"),s=t("./sha512"),o=t("./hash"),a=new Array(160);i(n,s),n.prototype.init=function(){return this._a=-876896931,this._b=1654270250,this._c=-1856437926,this._d=355462360,this._e=1731405415,this._f=-1900787065,this._g=-619958771,this._h=1203062813,this._al=-1056596264,this._bl=914150663,this._cl=812702999,this._dl=-150054599,this._el=-4191439,this._fl=1750603025,this._gl=1694076839,this._hl=-1090891868,this},n.prototype._hash=function(){function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}var e=new r(48);return t(this._a,this._al,0),t(this._b,this._bl,8),t(this._c,this._cl,16),t(this._d,this._dl,24),t(this._e,this._el,32),t(this._f,this._fl,40),e},e.exports=n}).call(this,t("buffer").Buffer)},{"./hash":181,"./sha512":188,buffer:48,inherits:296}],188:[function(t,e,r){(function(r){function n(){this.init(),this._w=b,p.call(this,128,112)}function i(t,e,r){return r^t&(e^r)}function s(t,e,r){return t&e|r&(t|e)}function o(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function a(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function f(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function u(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function c(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function h(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}var d=t("inherits"),p=t("./hash"),l=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],b=new Array(160);d(n,p),n.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this._al=-205731576,this._bl=-2067093701,this._cl=-23791573,this._dl=1595750129,this._el=-1377402159,this._fl=725511199,this._gl=-79577749,this._hl=327033209,this},n.prototype._update=function(t){function e(){var t=p[R-30],e=p[R-30+1],r=f(t,e),i=u(e,t);t=p[R-4],e=p[R-4+1];var s=c(t,e),o=h(e,t),a=p[R-14],l=p[R-14+1],b=p[R-32],g=p[R-32+1];d=i+l,n=r+a+(i>>>0>d>>>0?1:0),d+=o,n=n+s+(o>>>0>d>>>0?1:0),d+=g,n=n+b+(g>>>0>d>>>0?1:0)}function r(){p[R]=n,p[R+1]=d;var t=s(b,g,m),e=s(I,k,E),r=o(b,I),f=o(I,b),u=a(v,x),c=a(x,v),h=l[R],T=l[R+1],C=i(v,_,w),N=i(x,P,O),j=B+c,U=S+u+(B>>>0>j>>>0?1:0);j+=N,U=U+C+(N>>>0>j>>>0?1:0),j+=T,U=U+h+(T>>>0>j>>>0?1:0),j+=d,U=U+n+(d>>>0>j>>>0?1:0);var L=f+e,D=r+t+(f>>>0>L>>>0?1:0);S=w,B=O,w=_,O=P,_=v,P=x,x=A+j|0,v=y+U+(A>>>0>x>>>0?1:0)|0,y=m,A=E,m=g,E=k,g=b,k=I,I=j+L|0,b=U+D+(j>>>0>I>>>0?1:0)|0,M++,R+=2}for(var n,d,p=this._w,b=0|this._a,g=0|this._b,m=0|this._c,y=0|this._d,v=0|this._e,_=0|this._f,w=0|this._g,S=0|this._h,I=0|this._al,k=0|this._bl,E=0|this._cl,A=0|this._dl,x=0|this._el,P=0|this._fl,O=0|this._gl,B=0|this._hl,M=0,R=0;16>M;)n=t.readInt32BE(4*R),d=t.readInt32BE(4*R+4),r();for(;80>M;)e(),r();this._al=this._al+I|0,this._bl=this._bl+k|0,this._cl=this._cl+E|0,this._dl=this._dl+A|0,this._el=this._el+x|0,this._fl=this._fl+P|0,this._gl=this._gl+O|0,this._hl=this._hl+B|0,this._a=this._a+b+(this._al>>>0>>0?1:0)|0,this._b=this._b+g+(this._bl>>>0>>0?1:0)|0,this._c=this._c+m+(this._cl>>>0>>0?1:0)|0,this._d=this._d+y+(this._dl>>>0>>0?1:0)|0,this._e=this._e+v+(this._el>>>0>>0?1:0)|0,this._f=this._f+_+(this._fl>>>0

>>0?1:0)|0,this._g=this._g+w+(this._gl>>>0>>0?1:0)|0,this._h=this._h+S+(this._hl>>>0>>0?1:0)|0},n.prototype._hash=function(){function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}var e=new r(64);return t(this._a,this._al,0),t(this._b,this._bl,8),t(this._c,this._cl,16),t(this._d,this._dl,24),t(this._e,this._el,32),t(this._f,this._fl,40),t(this._g,this._gl,48),t(this._h,this._hl,56),e},e.exports=n}).call(this,t("buffer").Buffer)},{"./hash":181,buffer:48,inherits:296}],189:[function(t,e,r){(function(r){"use strict";function n(t,e){o.call(this),t=t.toLowerCase(),"string"==typeof e&&(e=new r(e));var n="sha512"===t||"sha384"===t?128:64;this._alg=t,this._key=e,e.length>n?e=i(t).update(e).digest():e.lengthu;u++)s[u]=54^e[u],f[u]=92^e[u];this._hash=i(t).update(s)}var i=t("create-hash/browser"),s=t("inherits"),o=t("stream").Transform,a=new r(128);a.fill(0),s(n,o),n.prototype.update=function(t,e){return this._hash.update(t,e),this},n.prototype._transform=function(t,e,r){this._hash.update(t),r()},n.prototype._flush=function(t){this.push(this.digest()),t()},n.prototype.digest=function(t){var e=this._hash.digest();return i(this._alg).update(this._opad).update(e).digest(t)},e.exports=function(t,e){return new n(t,e)}}).call(this,t("buffer").Buffer)},{buffer:48,"create-hash/browser":176,inherits:296,stream:265}],190:[function(t,e,r){(function(e){function n(t){var r=new e(o[t].prime,"hex"),n=new e(o[t].gen,"hex");return new a(r,n)}function i(t,r,n,o){return e.isBuffer(r)||void 0===f[r]?i(t,"binary",r,n):(r=r||"binary",o=o||"binary",n=n||new e([2]),e.isBuffer(n)||(n=new e(n,o)),"number"==typeof t?new a(s(t,n),n,!0):(e.isBuffer(t)||(t=new e(t,r)),new a(t,n,!0)))}var s=t("./lib/generatePrime"),o=t("./lib/primes.json"),a=t("./lib/dh"),f={binary:!0,hex:!0,base64:!0};r.DiffieHellmanGroup=r.createDiffieHellmanGroup=r.getDiffieHellman=n,r.createDiffieHellman=r.DiffieHellman=i}).call(this,t("buffer").Buffer)},{"./lib/dh":191,"./lib/generatePrime":192,"./lib/primes.json":193,buffer:48}],191:[function(t,e,r){(function(r){function n(t,e){return e=e||"utf8",r.isBuffer(t)||(t=new r(t,e)),this._pub=new f(t),this}function i(t,e){return e=e||"utf8",r.isBuffer(t)||(t=new r(t,e)),this._priv=new f(t),this}function s(t,e){var r=e.toString("hex"),n=[r,t.toString(16)].join("_");if(n in y)return y[n];var i=0;if(t.isEven()||!g.simpleSieve||!g.fermatTest(t)||!c.test(t))return i+=1,i+="02"===r||"05"===r?8:4,y[n]=i,i;c.test(t.shrn(1))||(i+=2);var s;switch(r){case"02":t.mod(h).cmp(d)&&(i+=8);break;case"05":s=t.mod(p),s.cmp(l)&&s.cmp(b)&&(i+=8);break;default:i+=4}return y[n]=i,i}function o(t,e,r){this.setGenerator(e),this.__prime=new f(t),this._prime=f.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,r?(this.setPublicKey=n,this.setPrivateKey=i):this._primeCode=8}function a(t,e){var n=new r(t.toArray());return e?n.toString(e):n}var f=t("bn.js"),u=t("miller-rabin"),c=new u,h=new f(24),d=new f(11),p=new f(10),l=new f(3),b=new f(7),g=t("./generatePrime"),m=t("randombytes");e.exports=o;var y={};Object.defineProperty(o.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=s(this.__prime,this.__gen)),this._primeCode}}),o.prototype.generateKeys=function(){return this._priv||(this._priv=new f(m(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},o.prototype.computeSecret=function(t){t=new f(t),t=t.toRed(this._prime);var e=t.redPow(this._priv).fromRed(),n=new r(e.toArray()),i=this.getPrime();if(n.lengthn;n+=2){for(var i=Math.ceil(Math.sqrt(n)),s=0;r>s&&e[s]<=i&&n%e[s]!==0;s++);r!==s&&e[s]<=i||(e[r++]=n)}return v=e,e}function i(t){for(var e=n(),r=0;rt)return new f(2===e||5===e?[140,123]:[140,39]);e=new f(e);for(var r,n;;){for(r=new f(a(Math.ceil(t/8)));r.bitLength()>t;)r.ishrn(1);if(r.isEven()&&r.iadd(d),r.testn(1)||r.iadd(p),e.cmp(p)){if(!e.cmp(l))for(;r.mod(b).cmp(g);)r.iadd(y)}else for(;r.mod(u).cmp(m);)r.iadd(y);if(n=r.shrn(1),i(n)&&i(r)&&s(n)&&s(r)&&h.test(n)&&h.test(r))return r}}var a=t("randombytes");e.exports=o,o.simpleSieve=i,o.fermatTest=s;var f=t("bn.js"),u=new f(24),c=t("miller-rabin"),h=new c,d=new f(1),p=new f(2),l=new f(5),b=(new f(16),new f(8),new f(10)),g=new f(3),m=(new f(7),new f(11)),y=new f(4),v=(new f(12),null)},{"bn.js":194,"miller-rabin":195,randombytes:243}],193:[function(t,e,r){e.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],194:[function(t,e,r){arguments[4][85][0].apply(r,arguments)},{buffer:47,dup:85}],195:[function(t,e,r){function n(t){this.rand=t||new s.Rand}var i=t("bn.js"),s=t("brorand");e.exports=n,n.create=function(t){return new n(t)},n.prototype._rand=function(t){var e=t.bitLength(),r=this.rand.generate(Math.ceil(e/8));r[0]|=3;var n=7&e;return 0!==n&&(r[r.length-1]>>=7-n),new i(r)},n.prototype.test=function(t,e,r){var n=t.bitLength(),s=i.mont(t),o=new i(1).toRed(s);e||(e=Math.max(1,n/48|0));for(var a=t.subn(1),f=a.subn(1),u=0;!a.testn(u);u++);for(var c=t.shrn(u),h=a.toRed(s),d=!0;e>0;e--){var p=this._rand(f);r&&r(p);var l=p.toRed(s).redPow(c);if(0!==l.cmp(o)&&0!==l.cmp(h)){for(var b=1;u>b;b++){if(l=l.redSqr(),0===l.cmp(o))return!1;if(0===l.cmp(h))break}if(b===u)return!1}}return d},n.prototype.getDivisor=function(t,e){var r=t.bitLength(),n=i.mont(t),s=new i(1).toRed(n);e||(e=Math.max(1,r/48|0));for(var o=t.subn(1),a=o.subn(1),f=0;!o.testn(f);f++);for(var u=t.shrn(f),c=o.toRed(n);e>0;e--){var h=this._rand(a),d=t.gcd(h);if(0!==d.cmpn(1))return d;var p=h.toRed(n).redPow(u);if(0!==p.cmp(s)&&0!==p.cmp(c)){for(var l=1;f>l;l++){if(p=p.redSqr(),0===p.cmp(s))return p.fromRed().subn(1).gcd(t);if(0===p.cmp(c))break}if(l===f)return p=p.redSqr(),p.fromRed().subn(1).gcd(t)}}return!1}},{"bn.js":194,brorand:196}],196:[function(t,e,r){arguments[4][103][0].apply(r,arguments)},{dup:103}],197:[function(t,e,r){(function(e){function n(t,e,r,n,s,o){if("function"==typeof s&&(o=s,s=void 0),"function"!=typeof o)throw new Error("No callback provided to pbkdf2");var a=i(t,e,r,n,s);setTimeout(function(){o(void 0,a)})}function i(t,r,n,i,a){if("number"!=typeof n)throw new TypeError("Iterations not a number");if(0>n)throw new TypeError("Bad iterations");if("number"!=typeof i)throw new TypeError("Key length not a number");if(0>i||i>o)throw new TypeError("Bad key length");a=a||"sha1",e.isBuffer(t)||(t=new e(t,"binary")),e.isBuffer(r)||(r=new e(r,"binary"));var f,u=1,c=new e(i),h=new e(r.length+4);r.copy(h,0,0,r.length);for(var d,p,l=1;u>=l;l++){h.writeUInt32BE(l,r.length);var b=s(a,t).update(h).digest();f||(f=b.length,p=new e(f),u=Math.ceil(i/f),d=i-(u-1)*f),b.copy(p,0,0,f);for(var g=1;n>g;g++){b=s(a,t).update(b).digest();for(var m=0;f>m;m++)p[m]^=b[m]}var y=(l-1)*f,v=l===u?d:f;p.copy(c,y,0,v)}return c}var s=t("create-hmac"),o=Math.pow(2,30)-1;r.pbkdf2=n,r.pbkdf2Sync=i}).call(this,t("buffer").Buffer)},{buffer:48,"create-hmac":189}],198:[function(t,e,r){r.publicEncrypt=t("./publicEncrypt"),r.privateDecrypt=t("./privateDecrypt"),r.privateEncrypt=function(t,e){return r.publicEncrypt(t,e,!0)},r.publicDecrypt=function(t,e){return r.privateDecrypt(t,e,!0)}},{"./privateDecrypt":239,"./publicEncrypt":240}],199:[function(t,e,r){(function(r){function n(t){var e=new r(4);return e.writeUInt32BE(t,0),e}var i=t("create-hash");e.exports=function(t,e){for(var s,o=new r(""),a=0;o.length=e.length){s++;break}var o=e.slice(2,i-1);e.slice(i-1,i);if(("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&s++,o.length<8&&s++,s)throw new Error("decryption error");return e.slice(i)}function s(t,e){t=new r(t),e=new r(e);var n=0,i=t.length;t.length!==e.length&&(n++,i=Math.min(t.length,e.length));for(var s=-1;++sh||new u(e).cmp(f.modulus)>=0)throw new Error("decryption error");var p;p=s?d(new u(e),f):c(e,f);var l=new r(h-p.length);if(l.fill(0),p=r.concat([l,p],h),4===a)return n(f,p);if(1===a)return i(f,p,s);if(3===a)return p;throw new Error("unknown padding")}}).call(this,t("buffer").Buffer)},{"./mgf":199,"./withPublic":241,"./xor":242,"bn.js":200,"browserify-rsa":201,buffer:48,"create-hash":176,"parse-asn1":205}],240:[function(t,e,r){(function(r){function n(t,e){var n=t.modulus.byteLength(),i=e.length,s=f("sha1").update(new r("")).digest(),o=s.length,d=2*o;if(i>n-d-2)throw new Error("message too long");var p=new r(n-i-d-2);p.fill(0);var l=n-o-1,b=a(o),g=c(r.concat([s,p,new r([1]),e],l),u(b,l)),m=c(b,u(g,o));return new h(r.concat([new r([0]),m,g],n))}function i(t,e,n){var i=e.length,o=t.modulus.byteLength();if(i>o-11)throw new Error("message too long");var a;return n?(a=new r(o-i-3),a.fill(255)):a=s(o-i-3),new h(r.concat([new r([0,n?1:2]),a,new r([0]),e],o))}function s(t,e){for(var n,i=new r(t),s=0,o=a(2*t),f=0;t>s;)f===o.length&&(o=a(2*t),f=0),n=o[f++],n&&(i[s++]=n);return i}var o=t("parse-asn1"),a=t("randombytes"),f=t("create-hash"),u=t("./mgf"),c=t("./xor"),h=t("bn.js"),d=t("./withPublic"),p=t("browserify-rsa");e.exports=function(t,e,r){var s;s=t.padding?t.padding:r?1:4;var a,f=o(t);if(4===s)a=n(f,e);else if(1===s)a=i(f,e,r);else{if(3!==s)throw new Error("unknown padding");if(a=new h(e),a.cmp(f.modulus)>=0)throw new Error("data too long for modulus")}return r?p(a,f):d(a,f)}}).call(this,t("buffer").Buffer)},{"./mgf":199,"./withPublic":241,"./xor":242,"bn.js":200,"browserify-rsa":201,buffer:48,"create-hash":176,"parse-asn1":205,randombytes:243}],241:[function(t,e,r){(function(r){function n(t,e){return new r(t.toRed(i.mont(e.modulus)).redPow(new i(e.publicExponent)).fromRed().toArray())}var i=t("bn.js");e.exports=n}).call(this,t("buffer").Buffer)},{"bn.js":200,buffer:48}],242:[function(t,e,r){e.exports=function(t,e){for(var r=t.length,n=-1;++n65536)throw new Error("requested too many random bytes");var s=new r.Uint8Array(e);o.getRandomValues(s);var a=new n(s.buffer);return"function"==typeof i?t.nextTick(function(){i(null,a)}):a}var o=r.crypto||r.msCrypto;o&&o.getRandomValues?e.exports=s:e.exports=i}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{_process:247,buffer:48}],244:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function s(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function a(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!s(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,s,f,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],a(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,s=new Array(n-1),f=1;n>f;f++)s[f-1]=arguments[f];r.apply(this,s)}else if(o(r)){for(n=arguments.length,s=new Array(n-1),f=1;n>f;f++)s[f-1]=arguments[f];for(u=r.slice(),n=u.length,f=0;n>f;f++)u[f].apply(this,s)}return!0},n.prototype.addListener=function(t,e){var r;if(!i(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var r;r=a(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,s,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?i(t._events[e])?1:t._events[e].length:0}},{}],245:[function(t,e,r){e.exports=function(t){return!(null==t||!(t._isBuffer||t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)))}},{}],246:[function(t,e,r){e.exports=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)}},{}],247:[function(t,e,r){function n(){c=!1,a.length?u=a.concat(u):h=-1,u.length&&i()}function i(){if(!c){var t=setTimeout(n);c=!0;for(var e=u.length;e;){for(a=u,u=[];++h1)for(var r=1;r1&&(n=r[0]+"@",t=r[1]),t=t.replace(R,".");var i=t.split("."),o=s(i,e).join(".");return n+o}function a(t){for(var e,r,n=[],i=0,s=t.length;s>i;)e=t.charCodeAt(i++),e>=55296&&56319>=e&&s>i?(r=t.charCodeAt(i++),56320==(64512&r)?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),i--)):n.push(e);return n}function f(t){return s(t,function(t){var e="";return t>65535&&(t-=65536,e+=j(t>>>10&1023|55296),t=56320|1023&t),e+=j(t)}).join("")}function u(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:S}function c(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function h(t,e,r){var n=0;for(t=r?N(t/A):t>>1,t+=N(t/e);t>C*k>>1;n+=S)t=N(t/C);return N(n+(C+1)*t/(t+E))}function d(t){var e,r,n,s,o,a,c,d,p,l,b=[],g=t.length,m=0,y=P,v=x;for(r=t.lastIndexOf(O),0>r&&(r=0),n=0;r>n;++n)t.charCodeAt(n)>=128&&i("not-basic"),b.push(t.charCodeAt(n));for(s=r>0?r+1:0;g>s;){for(o=m,a=1,c=S;s>=g&&i("invalid-input"),d=u(t.charCodeAt(s++)),(d>=S||d>N((w-m)/a))&&i("overflow"),m+=d*a,p=v>=c?I:c>=v+k?k:c-v,!(p>d);c+=S)l=S-p,a>N(w/l)&&i("overflow"),a*=l;e=b.length+1,v=h(m-o,e,0==o),N(m/e)>w-y&&i("overflow"),y+=N(m/e),m%=e,b.splice(m++,0,y)}return f(b)}function p(t){var e,r,n,s,o,f,u,d,p,l,b,g,m,y,v,_=[];for(t=a(t),g=t.length,e=P,r=0,o=x,f=0;g>f;++f)b=t[f],128>b&&_.push(j(b));for(n=s=_.length,s&&_.push(O);g>n;){for(u=w,f=0;g>f;++f)b=t[f],b>=e&&u>b&&(u=b);for(m=n+1,u-e>N((w-r)/m)&&i("overflow"),r+=(u-e)*m,e=u,f=0;g>f;++f)if(b=t[f],e>b&&++r>w&&i("overflow"),b==e){for(d=r,p=S;l=o>=p?I:p>=o+k?k:p-o,!(l>d);p+=S)v=d-l,y=S-l,_.push(j(c(l+v%y,0))),d=N(v/y);_.push(j(c(d,0))),o=h(r,m,n==s),r=0,++n}++r,++e}return _.join("")}function l(t){return o(t,function(t){return B.test(t)?d(t.slice(4).toLowerCase()):t})}function b(t){return o(t,function(t){return M.test(t)?"xn--"+p(t):t})}var g="object"==typeof r&&r&&!r.nodeType&&r,m="object"==typeof e&&e&&!e.nodeType&&e,y="object"==typeof t&&t;(y.global===y||y.window===y||y.self===y)&&(n=y);var v,_,w=2147483647,S=36,I=1,k=26,E=38,A=700,x=72,P=128,O="-",B=/^xn--/,M=/[^\x20-\x7E]/,R=/[\x2E\u3002\uFF0E\uFF61]/g,T={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},C=S-I,N=Math.floor,j=String.fromCharCode;if(v={version:"1.3.2",ucs2:{decode:a,encode:f},decode:d,encode:p,toASCII:b,toUnicode:l},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return v});else if(g&&m)if(e.exports==g)m.exports=v;else for(_ in v)v.hasOwnProperty(_)&&(g[_]=v[_]);else n.punycode=v}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],249:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,s){e=e||"&",r=r||"=";var o={};if("string"!=typeof t||0===t.length)return o;var a=/\+/g;t=t.split(e);var f=1e3;s&&"number"==typeof s.maxKeys&&(f=s.maxKeys);var u=t.length;f>0&&u>f&&(u=f);for(var c=0;u>c;++c){var h,d,p,l,b=t[c].replace(a,"%20"),g=b.indexOf(r);g>=0?(h=b.substr(0,g),d=b.substr(g+1)):(h=b,d=""),p=decodeURIComponent(h),l=decodeURIComponent(d),n(o,p)?i(o[p])?o[p].push(l):o[p]=[o[p],l]:o[p]=l}return o};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],250:[function(t,e,r){"use strict";function n(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n0)if(e.ended&&!i){var a=new Error("stream.push() after EOF");t.emit("error",a)}else if(e.endEmitted&&i){var a=new Error("stream.unshift() after end event");t.emit("error",a)}else!e.decoder||i||n||(r=e.decoder.write(r)),i||(e.reading=!1),e.flowing&&0===e.length&&!e.sync?(t.emit("data",r),t.read(0)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&h(t)),p(t,e);else i||(e.reading=!1);return o(e)}function o(t){return!t.ended&&(t.needReadable||t.length=N?t=N:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function f(t,e){return 0===e.length&&e.ended?0:e.objectMode?0===t?0:1:null===t||isNaN(t)?e.flowing&&e.buffer.length?e.buffer[0].length:e.length:0>=t?0:(t>e.highWaterMark&&(e.highWaterMark=a(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function u(t,e){var r=null;return x.isBuffer(e)||"string"==typeof e||null===e||void 0===e||t.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function c(t,e){if(!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,h(t)}}function h(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(M("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?E(d,t):d(t))}function d(t){M("emit readable"),t.emit("readable"),v(t)}function p(t,e){e.readingMore||(e.readingMore=!0,E(l,t,e))}function l(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=i)r=s?n.join(""):1===n.length?n[0]:x.concat(n,i),n.length=0;else if(tu&&t>f;u++){var a=n[0],h=Math.min(t-f,a.length);s?r+=a.slice(0,h):a.copy(r,f,0,h),h0)throw new Error("endReadable called on non-empty stream");e.endEmitted||(e.ended=!0,E(S,e,t))}function S(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function I(t,e){for(var r=0,n=t.length;n>r;r++)e(t[r],r)}function k(t,e){for(var r=0,n=t.length;n>r;r++)if(t[r]===e)return r;return-1}e.exports=i;var E=t("process-nextick-args"),A=t("isarray"),x=t("buffer").Buffer;i.ReadableState=n;var P,O=(t("events"),function(t,e){return t.listeners(e).length});!function(){try{P=t("stream")}catch(e){}finally{P||(P=t("events").EventEmitter)}}();var x=t("buffer").Buffer,B=t("core-util-is");B.inherits=t("inherits");var M,R=t("util");M=R&&R.debuglog?R.debuglog("stream"):function(){};var T;B.inherits(i,P);var C,C;i.prototype.push=function(t,e){var r=this._readableState;return r.objectMode||"string"!=typeof t||(e=e||r.defaultEncoding,e!==r.encoding&&(t=new x(t,e),e="")),s(this,r,t,e,!1)},i.prototype.unshift=function(t){var e=this._readableState;return s(this,e,t,"",!0)},i.prototype.isPaused=function(){return this._readableState.flowing===!1},i.prototype.setEncoding=function(e){return T||(T=t("string_decoder/").StringDecoder),this._readableState.decoder=new T(e),this._readableState.encoding=e,this};var N=8388608;i.prototype.read=function(t){M("read",t);var e=this._readableState,r=t;if(("number"!=typeof t||t>0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return M("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?w(this):h(this),null;if(t=f(t,e),0===t&&e.ended)return 0===e.length&&w(this),null;var n=e.needReadable;M("need readable",n),(0===e.length||e.length-t0?_(t,e):null,null===i&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),r!==t&&e.ended&&0===e.length&&w(this),null!==i&&this.emit("data",i),i},i.prototype._read=function(t){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(t,e){function n(t){M("onunpipe"),t===h&&s()}function i(){M("onend"),t.end()}function s(){M("cleanup"),t.removeListener("close",f),t.removeListener("finish",u),t.removeListener("drain",g),t.removeListener("error",a),t.removeListener("unpipe",n),h.removeListener("end",i),h.removeListener("end",s),h.removeListener("data",o),m=!0,!d.awaitDrain||t._writableState&&!t._writableState.needDrain||g()}function o(e){M("ondata");var r=t.write(e);!1===r&&(1!==d.pipesCount||d.pipes[0]!==t||1!==h.listenerCount("data")||m||(M("false write response, pause",h._readableState.awaitDrain),h._readableState.awaitDrain++),h.pause())}function a(e){M("onerror",e),c(),t.removeListener("error",a),0===O(t,"error")&&t.emit("error",e)}function f(){t.removeListener("finish",u),c()}function u(){M("onfinish"),t.removeListener("close",f),c()}function c(){M("unpipe"),h.unpipe(t)}var h=this,d=this._readableState;switch(d.pipesCount){case 0:d.pipes=t;break;case 1:d.pipes=[d.pipes,t];break;default:d.pipes.push(t)}d.pipesCount+=1,M("pipe count=%d opts=%j",d.pipesCount,e);var p=(!e||e.end!==!1)&&t!==r.stdout&&t!==r.stderr,l=p?i:s;d.endEmitted?E(l):h.once("end",l),t.on("unpipe",n);var g=b(h);t.on("drain",g);var m=!1;return h.on("data",o),t._events&&t._events.error?A(t._events.error)?t._events.error.unshift(a):t._events.error=[a,t._events.error]:t.on("error",a),t.once("close",f),t.once("finish",u),t.emit("pipe",h),d.flowing||(M("pipe resume"),h.resume()),t},i.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;n>i;i++)r[i].emit("unpipe",this);return this}var i=k(e.pipes,t);return-1===i?this:(e.pipes.splice(i,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this),this)},i.prototype.on=function(t,e){var r=P.prototype.on.call(this,t,e);if("data"===t&&!1!==this._readableState.flowing&&this.resume(),"readable"===t&&this.readable){var n=this._readableState;n.readableListening||(n.readableListening=!0,n.emittedReadable=!1,n.needReadable=!0,n.reading?n.length&&h(this,n):E(g,this))}return r},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){var t=this._readableState;return t.flowing||(M("resume"),t.flowing=!0,m(this,t)),this},i.prototype.pause=function(){return M("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(M("pause"),this._readableState.flowing=!1,this.emit("pause")),this},i.prototype.wrap=function(t){var e=this._readableState,r=!1,n=this;t.on("end",function(){if(M("wrapped end"),e.decoder&&!e.ended){var t=e.decoder.end();t&&t.length&&n.push(t)}n.push(null)}),t.on("data",function(i){if(M("wrapped data"),e.decoder&&(i=e.decoder.write(i)),(!e.objectMode||null!==i&&void 0!==i)&&(e.objectMode||i&&i.length)){var s=n.push(i);s||(r=!0,t.pause())}});for(var i in t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));var s=["error","close","destroy","pause","resume"];return I(s,function(e){t.on(e,n.emit.bind(n,e))}),n._read=function(e){M("wrapped _read",e),r&&(r=!1,t.resume())},n},i._fromList=_}).call(this,t("_process"))},{"./_stream_duplex":253,_process:247,buffer:48,"core-util-is":258,events:244,inherits:296,isarray:246,"process-nextick-args":259,"string_decoder/":266,util:47}],256:[function(t,e,r){"use strict";function n(t){this.afterTransform=function(e,r){return i(t,e,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function i(t,e,r){var n=t._transformState;n.transforming=!1;var i=n.writecb;if(!i)return t.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,null!==r&&void 0!==r&&t.push(r),i&&i(e);var s=t._readableState;s.reading=!1,(s.needReadable||s.length-1))throw new TypeError("Unknown encoding: "+t);this._writableState.defaultEncoding=t},o.prototype._write=function(t,e,r){r(new Error("not implemented"))},o.prototype._writev=null,o.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||w(this,n,r)}},{"./_stream_duplex":253,buffer:48,"core-util-is":258,events:244,inherits:296,"process-nextick-args":259,"util-deprecate":260}],258:[function(t,e,r){(function(t){function e(t){return Array.isArray?Array.isArray(t):"[object Array]"===g(t)}function n(t){return"boolean"==typeof t}function i(t){return null===t}function s(t){return null==t}function o(t){return"number"==typeof t}function a(t){return"string"==typeof t}function f(t){return"symbol"==typeof t}function u(t){return void 0===t}function c(t){return"[object RegExp]"===g(t)}function h(t){return"object"==typeof t&&null!==t}function d(t){return"[object Date]"===g(t)}function p(t){return"[object Error]"===g(t)||t instanceof Error}function l(t){return"function"==typeof t}function b(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function g(t){return Object.prototype.toString.call(t)}r.isArray=e,r.isBoolean=n,r.isNull=i,r.isNullOrUndefined=s,r.isNumber=o,r.isString=a,r.isSymbol=f,r.isUndefined=u,r.isRegExp=c,r.isObject=h,r.isDate=d,r.isError=p,r.isFunction=l,r.isPrimitive=b,r.isBuffer=t.isBuffer}).call(this,{isBuffer:t("../../../../insert-module-globals/node_modules/is-buffer/index.js")})},{"../../../../insert-module-globals/node_modules/is-buffer/index.js":245}],259:[function(t,e,r){(function(t){"use strict";function r(e){for(var r=new Array(arguments.length-1),n=0;n=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&56319>=n)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var i=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),e+=t.toString(this.encoding,0,i);var i=e.length-1,n=e.charCodeAt(i);if(n>=55296&&56319>=n){var s=this.surrogateSize;return this.charLength+=s,this.charReceived+=s,this.charBuffer.copy(this.charBuffer,s,0,s),t.copy(this.charBuffer,0,0,s),e.substring(0,i)}return e},u.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var r=t[t.length-e];if(1==e&&r>>5==6){this.charLength=2;break}if(2>=e&&r>>4==14){this.charLength=3;break}if(3>=e&&r>>3==30){this.charLength=4;break}}this.charReceived=e},u.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;e+=n.slice(0,r).toString(i)}return e}},{buffer:48}],267:[function(t,e,r){function n(){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 i(t,e,r){if(t&&u(t)&&t instanceof n)return t;var i=new n;return i.parse(t,e,r),i}function s(t){return f(t)&&(t=i(t)),t instanceof n?t.format():n.prototype.format.call(t)}function o(t,e){return i(t,!1,!0).resolve(e)}function a(t,e){return t?i(t,!1,!0).resolveObject(e):e}function f(t){return"string"==typeof t}function u(t){return"object"==typeof t&&null!==t}function c(t){return null===t}function h(t){return null==t}var d=t("punycode");r.parse=i,r.resolve=o,r.resolveObject=a,r.format=s,r.Url=n;var p=/^([a-z0-9.+-]+:)/i,l=/:[0-9]*$/,b=["<",">",'"',"`"," ","\r","\n"," "],g=["{","}","|","\\","^","`"].concat(b),m=["'"].concat(g),y=["%","/","?",";","#"].concat(m),v=["/","?","#"],_=255,w=/^[a-z0-9A-Z_-]{0,63}$/,S=/^([a-z0-9A-Z_-]{0,63})(.*)$/,I={javascript:!0,"javascript:":!0},k={javascript:!0,"javascript:":!0},E={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},A=t("querystring");n.prototype.parse=function(t,e,r){if(!f(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t;n=n.trim();var i=p.exec(n);if(i){i=i[0];var s=i.toLowerCase();this.protocol=s,n=n.substr(i.length)}if(r||i||n.match(/^\/\/[^@\/]+@[^@\/]+/)){var o="//"===n.substr(0,2);!o||i&&k[i]||(n=n.substr(2),this.slashes=!0)}if(!k[i]&&(o||i&&!E[i])){for(var a=-1,u=0;uc)&&(a=c)}var h,l;l=-1===a?n.lastIndexOf("@"):n.lastIndexOf("@",a),-1!==l&&(h=n.slice(0,l),n=n.slice(l+1),this.auth=decodeURIComponent(h)),a=-1;for(var u=0;uc)&&(a=c)}-1===a&&(a=n.length),this.host=n.slice(0,a),n=n.slice(a),this.parseHost(),this.hostname=this.hostname||"";var b="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!b)for(var g=this.hostname.split(/\./),u=0,x=g.length;x>u;u++){var P=g[u];if(P&&!P.match(w)){for(var O="",B=0,M=P.length;M>B;B++)O+=P.charCodeAt(B)>127?"x":P[B];if(!O.match(w)){var R=g.slice(0,u),T=g.slice(u+1),C=P.match(S);C&&(R.push(C[1]),T.unshift(C[2])),T.length&&(n="/"+T.join(".")+n),this.hostname=R.join(".");break}}}if(this.hostname.length>_?this.hostname="":this.hostname=this.hostname.toLowerCase(),!b){for(var N=this.hostname.split("."),j=[],u=0;uu;u++){var z=m[u],F=encodeURIComponent(z);F===z&&(F=escape(z)),n=n.split(z).join(F)}var K=n.indexOf("#");-1!==K&&(this.hash=n.substr(K),n=n.slice(0,K));var H=n.indexOf("?");if(-1!==H?(this.search=n.substr(H),this.query=n.substr(H+1),e&&(this.query=A.parse(this.query)),n=n.slice(0,H)):e&&(this.search="",this.query={}),n&&(this.pathname=n),E[s]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var L=this.pathname||"",U=this.search||"";this.path=L+U}return this.href=this.format(),this},n.prototype.format=function(){var t=this.auth||"";t&&(t=encodeURIComponent(t),t=t.replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",i=!1,s="";this.host?i=t+this.host:this.hostname&&(i=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&u(this.query)&&Object.keys(this.query).length&&(s=A.stringify(this.query));var o=this.search||s&&"?"+s||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||E[e])&&i!==!1?(i="//"+(i||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):i||(i=""),n&&"#"!==n.charAt(0)&&(n="#"+n),o&&"?"!==o.charAt(0)&&(o="?"+o),r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}),o=o.replace("#","%23"),e+i+r+o+n},n.prototype.resolve=function(t){return this.resolveObject(i(t,!1,!0)).format()},n.prototype.resolveObject=function(t){if(f(t)){var e=new n;e.parse(t,!1,!0),t=e}var r=new n;if(Object.keys(this).forEach(function(t){r[t]=this[t]},this),r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol)return Object.keys(t).forEach(function(e){"protocol"!==e&&(r[e]=t[e])}),E[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r;if(t.protocol&&t.protocol!==r.protocol){if(!E[t.protocol])return Object.keys(t).forEach(function(e){r[e]=t[e]}),r.href=r.format(),r;if(r.protocol=t.protocol,t.host||k[t.protocol])r.pathname=t.pathname;else{for(var i=(t.pathname||"").split("/");i.length&&!(t.host=i.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==i[0]&&i.unshift(""),i.length<2&&i.unshift(""),r.pathname=i.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var s=r.pathname||"",o=r.search||"";r.path=s+o}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var a=r.pathname&&"/"===r.pathname.charAt(0),u=t.host||t.pathname&&"/"===t.pathname.charAt(0),d=u||a||r.host&&t.pathname,p=d,l=r.pathname&&r.pathname.split("/")||[],i=t.pathname&&t.pathname.split("/")||[],b=r.protocol&&!E[r.protocol];if(b&&(r.hostname="",r.port=null,r.host&&(""===l[0]?l[0]=r.host:l.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===i[0]?i[0]=t.host:i.unshift(t.host)),t.host=null),d=d&&(""===i[0]||""===l[0])),u)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,l=i;else if(i.length)l||(l=[]),l.pop(),l=l.concat(i),r.search=t.search,r.query=t.query;else if(!h(t.search)){if(b){r.hostname=r.host=l.shift();var g=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;g&&(r.auth=g.shift(),r.host=r.hostname=g.shift())}return r.search=t.search,r.query=t.query,c(r.pathname)&&c(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!l.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var m=l.slice(-1)[0],y=(r.host||t.host)&&("."===m||".."===m)||""===m,v=0,_=l.length;_>=0;_--)m=l[_],"."==m?l.splice(_,1):".."===m?(l.splice(_,1),v++):v&&(l.splice(_,1),v--);if(!d&&!p)for(;v--;v)l.unshift("..");!d||""===l[0]||l[0]&&"/"===l[0].charAt(0)||l.unshift(""),y&&"/"!==l.join("/").substr(-1)&&l.push("");var w=""===l[0]||l[0]&&"/"===l[0].charAt(0);if(b){r.hostname=r.host=w?"":l.length?l.shift():"";var g=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;g&&(r.auth=g.shift(),r.host=r.hostname=g.shift())}return d=d||r.host&&l.length,d&&!w&&l.unshift(""),l.length?r.pathname=l.join("/"):(r.pathname=null,r.path=null),c(r.pathname)&&c(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=l.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{punycode:248,querystring:251}],268:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],269:[function(t,e,r){(function(e,n){function i(t,e){var n={seen:[],stylize:o};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),b(e)?n.showHidden=e:e&&r._extend(n,e),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=s),f(n,t,n.depth)}function s(t,e){var r=i.styles[e];return r?"["+i.colors[r][0]+"m"+t+"["+i.colors[r][1]+"m":t}function o(t,e){return t}function a(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}function f(t,e,n){if(t.customInspect&&e&&A(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return v(i)||(i=f(t,i,n)),i}var s=u(t,e);if(s)return s;var o=Object.keys(e),b=a(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),E(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return c(e);if(0===o.length){if(A(e)){var g=e.name?": "+e.name:"";return t.stylize("[Function"+g+"]","special")}if(S(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(k(e))return t.stylize(Date.prototype.toString.call(e),"date");if(E(e))return c(e)}var m="",y=!1,_=["{","}"];if(l(e)&&(y=!0,_=["[","]"]),A(e)){var w=e.name?": "+e.name:"";m=" [Function"+w+"]"}if(S(e)&&(m=" "+RegExp.prototype.toString.call(e)),k(e)&&(m=" "+Date.prototype.toUTCString.call(e)),E(e)&&(m=" "+c(e)),0===o.length&&(!y||0==e.length))return _[0]+m+_[1];if(0>n)return S(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var I;return I=y?h(t,e,n,b,o):o.map(function(r){return d(t,e,n,b,r,y)}),t.seen.pop(),p(I,m,_)}function u(t,e){if(w(e))return t.stylize("undefined","undefined");if(v(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return y(e)?t.stylize(""+e,"number"):b(e)?t.stylize(""+e,"boolean"):g(e)?t.stylize("null","null"):void 0}function c(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,r,n,i){for(var s=[],o=0,a=e.length;a>o;++o)M(e,String(o))?s.push(d(t,e,r,n,String(o),!0)):s.push("");return i.forEach(function(i){i.match(/^\d+$/)||s.push(d(t,e,r,n,i,!0))}),s}function d(t,e,r,n,i,s){var o,a,u;if(u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]},u.get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),M(n,i)||(o="["+i+"]"),a||(t.seen.indexOf(u.value)<0?(a=g(r)?f(t,u.value,null):f(t,u.value,r-1),a.indexOf("\n")>-1&&(a=s?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),w(o)){if(s&&i.match(/^\d+$/))return a;o=JSON.stringify(""+i),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+a}function p(t,e,r){var n=0,i=t.reduce(function(t,e){return n++,e.indexOf("\n")>=0&&n++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}function l(t){return Array.isArray(t)}function b(t){return"boolean"==typeof t}function g(t){return null===t}function m(t){return null==t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function _(t){return"symbol"==typeof t}function w(t){return void 0===t}function S(t){return I(t)&&"[object RegExp]"===P(t)}function I(t){return"object"==typeof t&&null!==t}function k(t){return I(t)&&"[object Date]"===P(t)}function E(t){return I(t)&&("[object Error]"===P(t)||t instanceof Error)}function A(t){return"function"==typeof t}function x(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function P(t){return Object.prototype.toString.call(t)}function O(t){return 10>t?"0"+t.toString(10):t.toString(10)}function B(){var t=new Date,e=[O(t.getHours()),O(t.getMinutes()),O(t.getSeconds())].join(":");return[t.getDate(),N[t.getMonth()],e].join(" ")}function M(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var R=/%[sdj%]/g;r.format=function(t){if(!v(t)){for(var e=[],r=0;r=s)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return t}}),a=n[r];s>r;a=n[++r])o+=g(a)||!I(a)?" "+a:" "+i(a);return o},r.deprecate=function(t,i){function s(){if(!o){if(e.throwDeprecation)throw new Error(i);e.traceDeprecation?console.trace(i):console.error(i),o=!0}return t.apply(this,arguments)}if(w(n.process))return function(){return r.deprecate(t,i).apply(this,arguments)};if(e.noDeprecation===!0)return t;var o=!1;return s};var T,C={};r.debuglog=function(t){if(w(T)&&(T=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!C[t])if(new RegExp("\\b"+t+"\\b","i").test(T)){var n=e.pid;C[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else C[t]=function(){};return C[t]},r.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=l,r.isBoolean=b,r.isNull=g,r.isNullOrUndefined=m,r.isNumber=y,r.isString=v,r.isSymbol=_,r.isUndefined=w,r.isRegExp=S,r.isObject=I,r.isDate=k,r.isError=E,r.isFunction=A,r.isPrimitive=x,r.isBuffer=t("./support/isBuffer");var N=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];r.log=function(){console.log("%s - %s",B(),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!I(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":268,_process:247,inherits:296}],270:[function(require,module,exports){function Context(){}var indexOf=require("indexof"),Object_keys=function(t){if(Object.keys)return Object.keys(t);var e=[];for(var r in t)e.push(r);return e},forEach=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;rs;s++){var o=t.charCodeAt(s)-48;n<<=4,n|=o>=49&&54>=o?o-49+10:o>=17&&22>=o?o-17+10:15&o}return n}function o(t,e,r,n){for(var i=0,s=Math.min(t.length,r),o=e;s>o;o++){var a=t.charCodeAt(o)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}function a(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).ishln(this.n).isub(this.p),this.tmp=this._tmp()}function f(){a.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function u(){a.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function c(){a.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function h(){a.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function d(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function p(t){d.call(this,t),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).ishln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv.sign=!0,this.minv=this.minv.mod(this.r)}"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26,i.prototype._init=function(t,e,n){if("number"==typeof t)return 0>t&&(this.sign=!0,t=-t),void(67108864>t?(this.words=[67108863&t],this.length=1):4503599627370496>t?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(9007199254740992>t),this.words=[67108863&t,t/67108864&67108863,1],this.length=3));if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&36>=e),t=t.toString().replace(/\s+/g,"");var i=0;"-"===t[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.sign=!0),this.strip()},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3){var a=t[i]|t[i-1]<<8|t[i-2]<<16;this.words[o]|=a<>>26-s&67108863,s+=24,s>=26&&(s-=26,o++)}else if("le"===n)for(var i=0,o=0;i>>26-s&67108863,s+=24,s>=26&&(s-=26,o++)}return this.strip()},i.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6){var o=s(t,r,r+6);this.words[i]|=o<>>26-n&4194303,n+=24,n>=26&&(n-=26,i++)}if(r+6!==e){var o=s(t,e,r+6);this.words[i]|=o<>>26-n&4194303}this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;67108863>=i;i*=e)n++;n--,i=i/e|0;for(var s=t.length-r,a=s%n,f=Math.min(s,s-a)+r,u=0,c=r;f>c;c+=n)u=o(t,c,c+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){for(var h=1,u=o(t,c,t.length,e),c=0;a>c;c++)h*=e;this.imuln(h),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},i.prototype.inspect=function(){return(this.red?""};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],g=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(t,e){if(t=t||10,16===t||"hex"===t){for(var n="",i=0,e=0|e||1,s=0,o=0;o>>24-i&16777215,n=0!==s||o!==this.length-1?l[6-f.length]+f+n:f+n,i+=2,i>=26&&(i-=26,o--)}for(0!==s&&(n=s.toString(16)+n);n.length%e!==0;)n="0"+n;return this.sign&&(n="-"+n),n}if(t===(0|t)&&t>=2&&36>=t){var u=b[t],c=g[t],n="",h=this.clone();for(h.sign=!1;0!==h.cmpn(0);){var d=h.modn(c).toString(t);h=h.idivn(c),n=0!==h.cmpn(0)?l[u-d.length]+d+n:d+n}return 0===this.cmpn(0)&&(n="0"+n),this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(){this.strip();var t=new Array(this.byteLength());t[0]=0;for(var e=this.clone(),r=0;0!==e.cmpn(0);r++){var n=e.andln(255);e.ishrn(8),t[t.length-r-1]=n}return t},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0===(8191&e)&&(r+=13,e>>>=13),0===(127&e)&&(r+=7,e>>>=7),0===(15&e)&&(r+=4,e>>>=4),0===(3&e)&&(r+=2,e>>>=2),0===(1&e)&&r++,r},i.prototype.bitLength=function(){var t=0,e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.iand=function(t){this.sign=this.sign&&t.sign;var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.ixor=function(t){this.sign=this.sign||t.sign;var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0); +for(var n=t/26|0,i=t%26;this.length<=n;)this.words[this.length++]=0;return e?this.words[n]=this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,s=0;s>>26}for(;0!==i&&s>>26}if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(t.sign){t.sign=!1;var e=this.iadd(t);return t.sign=!0,e._normSign()}if(this.sign)return this.sign=!1,this.iadd(t),this.sign=!0,this._normSign();var r=this.cmp(t);if(0===r)return this.sign=!1,this.length=1,this.words[0]=0,this;var n,i;r>0?(n=this,i=t):(n=t,i=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e}for(;0!==s&&o>26,this.words[o]=67108863&e}if(0===s&&o>>26,s=67108863&r,o=Math.min(n,t.length-1),a=Math.max(0,n-this.length+1);o>=a;a++){var f=n-a,u=0|this.words[f],c=0|t.words[a],h=u*c,d=67108863&h;i=i+(h/67108864|0)|0,d=d+s|0,s=67108863&d,i=i+(d>>>26)|0}e.words[n]=s,r=i}return 0!==r?e.words[n]=r:e.length--,e.strip()},i.prototype._bigMulTo=function(t,e){e.sign=t.sign!==this.sign,e.length=this.length+t.length;for(var r=0,n=0,i=0;i=f;f++){var u=i-f,c=0|this.words[u],h=0|t.words[f],d=c*h,p=67108863&d;s=s+(d/67108864|0)|0,p=p+o|0,o=67108863&p,s=s+(p>>>26)|0,n+=s>>>26,s&=67108863}e.words[i]=o,r=s,s=n}return 0!==r?e.words[i]=r:e.length--,e.strip()},i.prototype.mulTo=function(t,e){var r;return r=this.length+t.length<63?this._smallMulTo(t,e):this._bigMulTo(t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.imul=function(t){if(0===this.cmpn(0)||0===t.cmpn(0))return this.words[0]=0,this.length=1,this;var e=this.length,r=t.length;this.sign=t.sign!==this.sign,this.length=this.length+t.length,this.words[this.length-1]=0;for(var n=this.length-2;n>=0;n--){for(var i=0,s=0,o=Math.min(n,r-1),a=Math.max(0,n-e+1);o>=a;a++){var f=n-a,u=this.words[f],c=t.words[a],h=u*c,d=67108863&h;i+=h/67108864|0,d+=s,s=67108863&d,i+=d>>>26}this.words[n]=s,this.words[n+1]+=i,i=0}for(var i=0,f=1;f>>26}return this.strip()},i.prototype.imuln=function(t){r("number"==typeof t);for(var e=0,n=0;n>=26,e+=i/67108864|0,e+=s>>>26,this.words[n]=67108863&s}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.ishln=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=67108863>>>26-e<<26-e;if(0!==e){for(var s=0,o=0;o>>26-e}s&&(this.words[o]=s,this.length++)}if(0!==n){for(var o=this.length-1;o>=0;o--)this.words[o+n]=this.words[o];for(var o=0;n>o;o++)this.words[o]=0;this.length+=n}return this.strip()},i.prototype.ishrn=function(t,e,n){r("number"==typeof t&&t>=0);var i;i=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<u;u++)f.words[u]=this.words[u];f.length=o}if(0===o);else if(this.length>o){this.length-=o;for(var u=0;u=0&&(0!==c||u>=i);u--){var h=this.words[u];this.words[u]=c<<26-s|h>>>s,c=h&a}return f&&0!==c&&(f.words[f.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<t?this.isubn(-t):this.sign?1===this.length&&this.words[0]=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),0>t)return this.iaddn(-t);if(this.sign)return this.sign=!1,this.iaddn(t),this.sign=!0,this;this.words[0]-=t;for(var e=0;e>26)-(u/67108864|0),this.words[i+n]=67108863&f}for(;i>26,this.words[i+n]=67108863&f}if(0===a)return this.strip();r(-1===a),a=0;for(var i=0;i>26,this.words[i]=67108863&f}return this.sign=!0,this.strip()},i.prototype._wordDiv=function(t,e){var r=this.length-t.length,n=this.clone(),s=t,o=s.words[s.length-1],a=this._countBits(o);r=26-a,0!==r&&(s=s.shln(r),n.ishln(r),o=s.words[s.length-1]);var f,u=n.length-s.length;if("mod"!==e){f=new i(null),f.length=u+1,f.words=new Array(f.length);for(var c=0;c=0;d--){var p=67108864*n.words[s.length+d]+n.words[s.length+d-1];for(p=Math.min(p/o|0,67108863),n._ishlnsubmul(s,p,d);n.sign;)p--,n.sign=!1,n._ishlnsubmul(s,1,d),0!==n.cmpn(0)&&(n.sign=!n.sign);f&&(f.words[d]=p)}return f&&f.strip(),n.strip(),"div"!==e&&0!==r&&n.ishrn(r),{div:f?f:null,mod:n}},i.prototype.divmod=function(t,e){if(r(0!==t.cmpn(0)),this.sign&&!t.sign){var n,s,o=this.neg().divmod(t,e);return"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=0===o.mod.cmpn(0)?o.mod:t.sub(o.mod)),{div:n,mod:s}}if(!this.sign&&t.sign){var n,o=this.divmod(t.neg(),e);return"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}}return this.sign&&t.sign?this.neg().divmod(t.neg(),e):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e)},i.prototype.div=function(t){return this.divmod(t,"div").div},i.prototype.mod=function(t){return this.divmod(t,"mod").mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(0===e.mod.cmpn(0))return e.div;var r=e.div.sign?e.mod.isub(t):e.mod,n=t.shrn(1),i=t.andln(1),s=r.cmp(n);return 0>s||1===i&&0===s?e.div:e.div.sign?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(67108863>=t);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+this.words[i])%t;return n},i.prototype.idivn=function(t){r(67108863>=t);for(var e=0,n=this.length-1;n>=0;n--){var i=this.words[n]+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var s=new i(1),o=new i(0),a=new i(0),f=new i(1),u=0;e.isEven()&&n.isEven();)e.ishrn(1),n.ishrn(1),++u;for(var c=n.clone(),h=e.clone();0!==e.cmpn(0);){for(;e.isEven();)e.ishrn(1),s.isEven()&&o.isEven()?(s.ishrn(1),o.ishrn(1)):(s.iadd(c).ishrn(1),o.isub(h).ishrn(1));for(;n.isEven();)n.ishrn(1),a.isEven()&&f.isEven()?(a.ishrn(1),f.ishrn(1)):(a.iadd(c).ishrn(1),f.isub(h).ishrn(1));e.cmp(n)>=0?(e.isub(n),s.isub(a),o.isub(f)):(n.isub(e),a.isub(s),f.isub(o))}return{a:a,b:f,gcd:n.ishln(u)}},i.prototype._invmp=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var s=new i(1),o=new i(0),a=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(;e.isEven();)e.ishrn(1),s.isEven()?s.ishrn(1):s.iadd(a).ishrn(1);for(;n.isEven();)n.ishrn(1),o.isEven()?o.ishrn(1):o.iadd(a).ishrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(o)):(n.isub(e),o.isub(s))}return 0===e.cmpn(1)?s:o},i.prototype.gcd=function(t){if(0===this.cmpn(0))return t.clone();if(0===t.cmpn(0))return this.clone();var e=this.clone(),r=t.clone();e.sign=!1,r.sign=!1;for(var n=0;e.isEven()&&r.isEven();n++)e.ishrn(1),r.ishrn(1);for(;;){for(;e.isEven();)e.ishrn(1);for(;r.isEven();)r.ishrn(1);var i=e.cmp(r);if(0>i){var s=e;e=r,r=s}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.ishln(n)},i.prototype.invm=function(t){return this.egcd(t).a.mod(t)},i.prototype.isEven=function(){return 0===(1&this.words[0])},i.prototype.isOdd=function(){return 1===(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<s;s++)this.words[s]=0;return this.words[n]|=i,this.length=n+1,this}for(var o=i,s=n;0!==o&&s>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.cmpn=function(t){var e=0>t;if(e&&(t=-t),this.sign&&!e)return-1;if(!this.sign&&e)return 1;t&=67108863,this.strip();var r;if(this.length>1)r=1;else{var n=this.words[0];r=n===t?0:t>n?-1:1}return this.sign&&(r=-r),r},i.prototype.cmp=function(t){if(this.sign&&!t.sign)return-1;if(!this.sign&&t.sign)return 1;var e=this.ucmp(t);return this.sign?-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length=0;r--){var n=this.words[r],i=t.words[r];if(n!==i){i>n?e=-1:n>i&&(e=1);break}}return e},i.red=function(t){return new d(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};a.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},a.prototype.ireduce=function(t){var e,r=t;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),e=r.bitLength();while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},a.prototype.split=function(t,e){t.ishrn(this.n,0,e)},a.prototype.imulK=function(t){return t.imul(this.k)},n(f,a),f.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;n>i;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];e.words[e.length++]=s&r;for(var i=10;i>>22,s=o}t.words[i-10]=s>>>22,t.length-=9},f.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e,r=0,n=0;n>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function y(t){if(m[t])return m[t];var y;if("k256"===t)y=new f;else if("p224"===t)y=new u;else if("p192"===t)y=new c;else{if("p25519"!==t)throw new Error("Unknown prime "+t);y=new h}return m[t]=y,y},d.prototype._verify1=function(t){r(!t.sign,"red works only with positives"),r(t.red,"red works only with red numbers")},d.prototype._verify2=function(t,e){r(!t.sign&&!e.sign,"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},d.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.mod(this.m)._forceRed(this)},d.prototype.neg=function(t){var e=t.clone();return e.sign=!e.sign,e.iadd(this.m)._forceRed(this)},d.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},d.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},d.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},d.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},d.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.shln(e))},d.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},d.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},d.prototype.isqr=function(t){return this.imul(t,t)},d.prototype.sqr=function(t){return this.mul(t,t)},d.prototype.sqrt=function(t){if(0===t.cmpn(0))return t.clone();var e=this.m.andln(3);if(r(e%2===1),3===e){var n=this.m.add(new i(1)).ishrn(2),s=this.pow(t,n);return s}for(var o=this.m.subn(1),a=0;0!==o.cmpn(0)&&0===o.andln(1);)a++,o.ishrn(1);r(0!==o.cmpn(0));var f=new i(1).toRed(this),u=f.redNeg(),c=this.m.subn(1).ishrn(1),h=this.m.bitLength();for(h=new i(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var d=this.pow(h,o),s=this.pow(t,o.addn(1).ishrn(1)),p=this.pow(t,o),l=a;0!==p.cmp(f);){for(var b=p,g=0;0!==b.cmp(f);g++)b=b.redSqr();r(l>g);var m=this.pow(d,new i(1).ishln(l-g-1));s=s.redMul(m),d=m.redSqr(),p=p.redMul(d),l=g}return s},d.prototype.invm=function(t){var e=t._invmp(this.m);return e.sign?(e.sign=!1,this.imod(e).redNeg()):this.imod(e)},d.prototype.pow=function(t,e){var r=[];if(0===e.cmpn(0))return new i(1);for(var n=e.clone();0!==n.cmpn(0);)r.push(n.andln(1)),n.ishrn(1);for(var s=t,o=0;o=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},p.prototype.mul=function(t,e){if(0===t.cmpn(0)||0===e.cmpn(0))return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(n).ishrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},p.prototype.invm=function(t){var e=this.imod(t._invmp(this.m).mul(this.r2));return e._forceRed(this)}}("undefined"==typeof e||e,this)},{}],273:[function(t,e,r){function n(t){if(0===t.length)return"";var e,r,n=[0];for(e=0;e>8,n[r]&=255;for(;s;)n.push(255&s),s>>=8}for(e=0;"1"===t[e]&&ee[n]?1:0,0==r);++n);return 0==r&&(e.length>t.length?r=-1:t.length>e.length&&(r=1)),r}},{}],275:[function(t,e,r){"use strict";var n=r;n.version=t("../package.json").version,n.utils=t("./elliptic/utils"),n.rand=t("brorand"),n.hmacDRBG=t("./elliptic/hmac-drbg"),n.curve=t("./elliptic/curve"),n.curves=t("./elliptic/curves"),n.ec=t("./elliptic/ec")},{"../package.json":295,"./elliptic/curve":278,"./elliptic/curves":281,"./elliptic/ec":282,"./elliptic/hmac-drbg":285,"./elliptic/utils":287,brorand:288}],276:[function(t,e,r){"use strict";function n(t,e){this.type=t,this.p=new s(e.p,16),this.red=e.prime?s.red(e.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=e.n&&new s(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4)}function i(t,e){this.curve=t,this.type=e,this.precomputed=null}var s=t("bn.js"),o=t("../../elliptic"),a=o.utils.getNAF,f=o.utils.getJSF,u=o.utils.assert;e.exports=n,n.prototype.point=function(){throw new Error("Not implemented")},n.prototype.validate=function(){throw new Error("Not implemented")},n.prototype._fixedNafMul=function(t,e){var r=t._getDoubles(),n=a(e,1),i=(1<=o;e--)f=(f<<1)+n[e];s.push(f)}for(var u=this.jpoint(null,null,null),c=this.jpoint(null,null,null),h=i;h>0;h--){for(var o=0;o=0;f--){for(var e=0;f>=0&&0===s[f];f--)e++;if(f>=0&&e++,o=o.dblp(e),0>f)break;var c=s[f];u(0!==c),o="affine"===t.type?c>0?o.mixedAdd(i[c-1>>1]):o.mixedAdd(i[-c-1>>1].neg()):c>0?o.add(i[c-1>>1]):o.add(i[-c-1>>1].neg())}return"affine"===t.type?o.toP():o},n.prototype._wnafMulAdd=function(t,e,r,n){for(var i=this._wnafT1,s=this._wnafT2,o=this._wnafT3,u=0,c=0;n>c;c++){var h=e[c],d=h._getNAFPoints(t);i[c]=d.wnd,s[c]=d.points}for(var c=n-1;c>=1;c-=2){var p=c-1,l=c;if(1===i[p]&&1===i[l]){var b=[e[p],null,null,e[l]];0===e[p].y.cmp(e[l].y)?(b[1]=e[p].add(e[l]),b[2]=e[p].toJ().mixedAdd(e[l].neg())):0===e[p].y.cmp(e[l].y.redNeg())?(b[1]=e[p].toJ().mixedAdd(e[l]),b[2]=e[p].add(e[l].neg())):(b[1]=e[p].toJ().mixedAdd(e[l]),b[2]=e[p].toJ().mixedAdd(e[l].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],m=f(r[p],r[l]);u=Math.max(m[0].length,u),o[p]=new Array(u),o[l]=new Array(u);for(var y=0;u>y;y++){var v=0|m[0][y],_=0|m[1][y];o[p][y]=g[3*(v+1)+(_+1)],o[l][y]=0,s[p]=b}}else o[p]=a(r[p],i[p]),o[l]=a(r[l],i[l]),u=Math.max(o[p].length,u),u=Math.max(o[l].length,u)}for(var w=this.jpoint(null,null,null),S=this._wnafT4,c=u;c>=0;c--){for(var I=0;c>=0;){for(var k=!0,y=0;n>y;y++)S[y]=0|o[y][c],0!==S[y]&&(k=!1);if(!k)break;I++,c--}if(c>=0&&I++,w=w.dblp(I),0>c)break;for(var y=0;n>y;y++){var h,E=S[y];0!==E&&(E>0?h=s[y][E-1>>1]:0>E&&(h=s[y][-E-1>>1].neg()),w="affine"===h.type?w.mixedAdd(h):w.add(h))}}for(var c=0;n>c;c++)s[c]=null;return w.toP()},n.BasePoint=i,i.prototype.validate=function(){return this.curve.validate(this)},i.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},i.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;e>i;i+=t){for(var s=0;t>s;s++)n=n.dbl();r.push(n)}return{step:t,points:r}},i.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<i;i++)e[i]=e[i-1].add(n);return{wnd:t,points:e}},i.prototype._getBeta=function(){return null},i.prototype.dblp=function(t){for(var e=this,r=0;t>r;r++)e=e.dbl();return e}},{"../../elliptic":275,"bn.js":272}],277:[function(t,e,r){"use strict";function n(t){this.twisted=1!==(0|t.a),this.mOneA=this.twisted&&-1===(0|t.a),this.extended=this.mOneA,u.call(this,"edwards",t),this.a=new a(t.a,16).mod(this.red.m).toRed(this.red),this.c=new a(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new a(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),c(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1===(0|t.c)}function i(t,e,r,n,i){u.BasePoint.call(this,t,"projective"),null===e&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new a(e,16),this.y=new a(r,16),this.z=n?new a(n,16):this.curve.one,this.t=i&&new a(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}var s=t("../curve"),o=t("../../elliptic"),a=t("bn.js"),f=t("inherits"),u=s.base,c=o.utils.assert;f(n,u),e.exports=n,n.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},n.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},n.prototype.jpoint=function(t,e,r,n){return this.point(t,e,r,n)},n.prototype.pointFromX=function(t,e){e=new a(e,16),e.red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),i=this.one.redSub(this.c2.redMul(this.d).redMul(r)),o=n.redMul(i.redInvm()).redSqrt(),f=o.fromRed().isOdd();return(t&&!f||!t&&f)&&(o=o.redNeg()),this.point(e,o,s.one)},n.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),r=t.y.redSqr(),n=e.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(r)));return 0===n.cmp(i)},f(i,u.BasePoint),n.prototype.pointFromJSON=function(t){return i.fromJSON(this,t)},n.prototype.point=function(t,e,r,n){return new i(this,t,e,r,n)},i.fromJSON=function(t,e){return new i(t,e[0],e[1],e[2])},i.prototype.inspect=function(){return this.isInfinity()?"":""},i.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},i.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),s=n.redAdd(e),o=s.redSub(r),a=n.redSub(e),f=i.redMul(o),u=s.redMul(a),c=i.redMul(a),h=o.redMul(s);return this.curve.point(f,u,h,c)},i.prototype._projDbl=function(){var t,e,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),s=this.y.redSqr();if(this.curve.twisted){var o=this.curve._mulA(i),a=o.redAdd(s);if(this.zOne)t=n.redSub(i).redSub(s).redMul(a.redSub(this.curve.two)),e=a.redMul(o.redSub(s)),r=a.redSqr().redSub(a).redSub(a);else{var f=this.z.redSqr(),u=a.redSub(f).redISub(f);t=n.redSub(i).redISub(s).redMul(u),e=a.redMul(o.redSub(s)),r=a.redMul(u)}}else{var o=i.redAdd(s),f=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=o.redSub(f).redSub(f);t=this.curve._mulC(n.redISub(o)).redMul(u),e=this.curve._mulC(o).redMul(i.redISub(s)),r=o.redMul(u)}return this.curve.point(t,e,r)},i.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},i.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),s=r.redSub(e),o=i.redSub(n),a=i.redAdd(n),f=r.redAdd(e),u=s.redMul(o),c=a.redMul(f),h=s.redMul(f),d=o.redMul(a);return this.curve.point(u,c,d,h)},i.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),s=this.x.redMul(t.x),o=this.y.redMul(t.y),a=this.curve.d.redMul(s).redMul(o),f=i.redSub(a),u=i.redAdd(a),c=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(o),h=n.redMul(f).redMul(c);return this.curve.twisted?(e=n.redMul(u).redMul(o.redSub(this.curve._mulA(s))),r=f.redMul(u)):(e=n.redMul(u).redMul(o.redSub(s)),r=this.curve._mulC(f).redMul(u)),this.curve.point(h,e,r)},i.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},i.prototype.mul=function(t){return this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},i.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2)},i.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},i.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},i.prototype.getX=function(){return this.normalize(),this.x.fromRed()},i.prototype.getY=function(){return this.normalize(),this.y.fromRed()},i.prototype.toP=i.prototype.normalize,i.prototype.mixedAdd=i.prototype.add},{"../../elliptic":275,"../curve":278,"bn.js":272,inherits:296}],278:[function(t,e,r){arguments[4][90][0].apply(r,arguments)},{"./base":276,"./edwards":277,"./mont":279,"./short":280,dup:90}],279:[function(t,e,r){"use strict";function n(t){f.call(this,"mont",t),this.a=new o(t.a,16).toRed(this.red),this.b=new o(t.b,16).toRed(this.red),this.i4=new o(4).toRed(this.red).redInvm(),this.two=new o(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function i(t,e,r){f.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new o(e,16),this.z=new o(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}var s=t("../curve"),o=t("bn.js"),a=t("inherits"),f=s.base;a(n,f),e.exports=n,n.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e),i=n.redSqrt();return 0===i.redSqr().cmp(n)},a(i,f.BasePoint),n.prototype.point=function(t,e){return new i(this,t,e)},n.prototype.pointFromJSON=function(t){return i.fromJSON(this,t)},i.prototype.precompute=function(){},i.fromJSON=function(t,e){return new i(t,e[0],e[1]||t.one)},i.prototype.inspect=function(){return this.isInfinity()?"":""},i.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},i.prototype.dbl=function(){var t=this.x.redAdd(this.z),e=t.redSqr(),r=this.x.redSub(this.z),n=r.redSqr(),i=e.redSub(n),s=e.redMul(n),o=i.redMul(n.redAdd(this.curve.a24.redMul(i)));return this.curve.point(s,o)},i.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},i.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),s=t.x.redSub(t.z),o=s.redMul(r),a=i.redMul(n),f=e.z.redMul(o.redAdd(a).redSqr()),u=e.x.redMul(o.redISub(a).redSqr());return this.curve.point(f,u)},i.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=this,s=[];0!==e.cmpn(0);e.ishrn(1))s.push(e.andln(1));for(var o=s.length-1;o>=0;o--)0===s[o]?(r=r.diffAdd(n,i),n=n.dbl()):(n=r.diffAdd(n,i),r=r.dbl());return n},i.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},i.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},i.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../curve":278,"bn.js":272,inherits:296}],280:[function(t,e,r){"use strict";function n(t){c.call(this,"short",t),this.a=new f(t.a,16).toRed(this.red),this.b=new f(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function i(t,e,r,n){c.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new f(e,16),this.y=new f(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function s(t,e,r,n){c.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one, +this.z=new f(0)):(this.x=new f(e,16),this.y=new f(r,16),this.z=new f(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}var o=t("../curve"),a=t("../../elliptic"),f=t("bn.js"),u=t("inherits"),c=o.base,h=a.utils.assert;u(n,c),e.exports=n,n.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new f(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=n[0].cmp(n[1])<0?n[0]:n[1],e=e.toRed(this.red)}if(t.lambda)r=new f(t.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(e))?r=i[0]:(r=i[1],h(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}var s;return s=t.basis?t.basis.map(function(t){return{a:new f(t.a,16),b:new f(t.b,16)}}):this._getEndoBasis(r),{beta:e,lambda:r,basis:s}}},n.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:f.mont(t),r=new f(2).toRed(e).redInvm(),n=r.redNeg(),i=new f(3).toRed(e).redNeg().redSqrt().redMul(r),s=n.redAdd(i).fromRed(),o=n.redSub(i).fromRed();return[s,o]},n.prototype._getEndoBasis=function(t){for(var e,r,n,i,s,o,a,u,c,h=this.n.shrn(Math.floor(this.n.bitLength()/2)),d=t,p=this.n.clone(),l=new f(1),b=new f(0),g=new f(0),m=new f(1),y=0;0!==d.cmpn(0);){var v=p.div(d);u=p.sub(v.mul(d)),c=g.sub(v.mul(l));var _=m.sub(v.mul(b));if(!n&&u.cmp(h)<0)e=a.neg(),r=l,n=u.neg(),i=c;else if(n&&2===++y)break;a=u,p=d,d=u,g=l,l=c,m=b,b=_}s=u.neg(),o=c;var w=n.sqr().add(i.sqr()),S=s.sqr().add(o.sqr());return S.cmp(w)>=0&&(s=e,o=r),n.sign&&(n=n.neg(),i=i.neg()),s.sign&&(s=s.neg(),o=o.neg()),[{a:n,b:i},{a:s,b:o}]},n.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=i.mul(r.a),a=s.mul(n.a),f=i.mul(r.b),u=s.mul(n.b),c=t.sub(o).sub(a),h=f.add(u).neg();return{k1:c,k2:h}},n.prototype.pointFromX=function(t,e){e=new f(e,16),e.red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt(),i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},n.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},n.prototype._endoWnafMulAdd=function(t,e){for(var r=this._endoWnafT1,n=this._endoWnafT2,i=0;iu;u++)r[u]=null,n[u]=null;return f},u(i,c.BasePoint),n.prototype.point=function(t,e,r){return new i(this,t,e,r)},n.prototype.pointFromJSON=function(t,e){return i.fromJSON(this,t,e)},i.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,n=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(n)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(n)}}}return e}},i.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},i.fromJSON=function(t,e,r){function n(e){return t.point(e[0],e[1],r)}"string"==typeof e&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;var s=e[2];return i.precomputed={beta:null,doubles:s.doubles&&{step:s.doubles.step,points:[i].concat(s.doubles.points.map(n))},naf:s.naf&&{wnd:s.naf.wnd,points:[i].concat(s.naf.points.map(n))}},i},i.prototype.inspect=function(){return this.isInfinity()?"":""},i.prototype.isInfinity=function(){return this.inf},i.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},i.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),s=i.redSqr().redISub(this.x.redAdd(this.x)),o=i.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},i.prototype.getX=function(){return this.x.fromRed()},i.prototype.getY=function(){return this.y.fromRed()},i.prototype.mul=function(t){return t=new f(t,16),this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},i.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},i.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},i.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},i.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var t=this.curve.jpoint(this.x,this.y,this.curve.one);return t},u(s,c.BasePoint),n.prototype.jpoint=function(t,e,r){return new s(this,t,e,r)},s.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},s.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},s.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),f=s.redSub(o);if(0===a.cmpn(0))return 0!==f.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),h=n.redMul(u),d=f.redSqr().redIAdd(c).redISub(h).redISub(h),p=f.redMul(h.redISub(d)).redISub(s.redMul(c)),l=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(d,p,l)},s.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(n),a=i.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=o.redSqr(),u=f.redMul(o),c=r.redMul(f),h=a.redSqr().redIAdd(u).redISub(c).redISub(c),d=a.redMul(c.redISub(h)).redISub(i.redMul(u)),p=this.z.redMul(o);return this.curve.jpoint(h,d,p)},s.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,r=0;t>r;r++)e=e.dbl();return e}for(var n=this.curve.a,i=this.curve.tinv,s=this.x,o=this.y,a=this.z,f=a.redSqr().redSqr(),u=o.redAdd(o),r=0;t>r;r++){var c=s.redSqr(),h=u.redSqr(),d=h.redSqr(),p=c.redAdd(c).redIAdd(c).redIAdd(n.redMul(f)),l=s.redMul(h),b=p.redSqr().redISub(l.redAdd(l)),g=l.redISub(b),m=p.redMul(g);m=m.redIAdd(m).redISub(d);var y=u.redMul(a);t>r+1&&(f=f.redMul(d)),s=b,a=y,u=m}return this.curve.jpoint(s,u.redMul(i),a)},s.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},s.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),s=i.redSqr(),o=this.x.redAdd(i).redSqr().redISub(n).redISub(s);o=o.redIAdd(o);var a=n.redAdd(n).redIAdd(n),f=a.redSqr().redISub(o).redISub(o),u=s.redIAdd(s);u=u.redIAdd(u),u=u.redIAdd(u),t=f,e=a.redMul(o.redISub(f)).redISub(u),r=this.y.redAdd(this.y)}else{var c=this.x.redSqr(),h=this.y.redSqr(),d=h.redSqr(),p=this.x.redAdd(h).redSqr().redISub(c).redISub(d);p=p.redIAdd(p);var l=c.redAdd(c).redIAdd(c),b=l.redSqr(),g=d.redIAdd(d);g=g.redIAdd(g),g=g.redIAdd(g),t=b.redISub(p).redISub(p),e=l.redMul(p.redISub(t)).redISub(g),r=this.y.redMul(this.z),r=r.redIAdd(r)}return this.curve.jpoint(t,e,r)},s.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),s=i.redSqr(),o=this.x.redAdd(i).redSqr().redISub(n).redISub(s);o=o.redIAdd(o);var a=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),f=a.redSqr().redISub(o).redISub(o);t=f;var u=s.redIAdd(s);u=u.redIAdd(u),u=u.redIAdd(u),e=a.redMul(o.redISub(f)).redISub(u),r=this.y.redAdd(this.y)}else{var c=this.z.redSqr(),h=this.y.redSqr(),d=this.x.redMul(h),p=this.x.redSub(c).redMul(this.x.redAdd(c));p=p.redAdd(p).redIAdd(p);var l=d.redIAdd(d);l=l.redIAdd(l);var b=l.redAdd(l);t=p.redSqr().redISub(b),r=this.y.redAdd(this.z).redSqr().redISub(h).redISub(c);var g=h.redSqr();g=g.redIAdd(g),g=g.redIAdd(g),g=g.redIAdd(g),e=p.redMul(l.redISub(t)).redISub(g)}return this.curve.jpoint(t,e,r)},s.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),s=e.redSqr(),o=r.redSqr(),a=s.redAdd(s).redIAdd(s).redIAdd(t.redMul(i)),f=e.redAdd(e);f=f.redIAdd(f);var u=f.redMul(o),c=a.redSqr().redISub(u.redAdd(u)),h=u.redISub(c),d=o.redSqr();d=d.redIAdd(d),d=d.redIAdd(d),d=d.redIAdd(d);var p=a.redMul(h).redISub(d),l=r.redAdd(r).redMul(n);return this.curve.jpoint(c,p,l)},s.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),n=e.redSqr(),i=t.redAdd(t).redIAdd(t),s=i.redSqr(),o=this.x.redAdd(e).redSqr().redISub(t).redISub(n);o=o.redIAdd(o),o=o.redAdd(o).redIAdd(o),o=o.redISub(s);var a=o.redSqr(),f=n.redIAdd(n);f=f.redIAdd(f),f=f.redIAdd(f),f=f.redIAdd(f);var u=i.redIAdd(o).redSqr().redISub(s).redISub(a).redISub(f),c=e.redMul(u);c=c.redIAdd(c),c=c.redIAdd(c);var h=this.x.redMul(a).redISub(c);h=h.redIAdd(h),h=h.redIAdd(h);var d=this.y.redMul(u.redMul(f.redISub(u)).redISub(o.redMul(a)));d=d.redIAdd(d),d=d.redIAdd(d),d=d.redIAdd(d);var p=this.z.redAdd(o).redSqr().redISub(r).redISub(a);return this.curve.jpoint(h,d,p)},s.prototype.mul=function(t,e){return t=new f(t,e),this.curve._wnafMul(this,t)},s.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var n=e.redMul(this.z),i=r.redMul(t.z);return 0===this.y.redMul(i).redISub(t.y.redMul(n)).cmpn(0)},s.prototype.inspect=function(){return this.isInfinity()?"":""},s.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":275,"../curve":278,"bn.js":272,inherits:296}],281:[function(t,e,r){"use strict";function n(t){"short"===t.type?this.curve=new a.curve["short"](t):"edwards"===t.type?this.curve=new a.curve.edwards(t):this.curve=new a.curve.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,f(this.g.validate(),"Invalid curve"),f(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function i(t,e){Object.defineProperty(s,t,{configurable:!0,enumerable:!0,get:function(){var r=new n(e);return Object.defineProperty(s,t,{configurable:!0,enumerable:!0,value:r}),r}})}var s=r,o=t("hash.js"),a=t("../elliptic"),f=a.utils.assert;s.PresetCurve=n,i("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),i("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),i("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),i("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"0",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),i("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var u;try{u=t("./precomputed/secp256k1")}catch(c){u=void 0}i("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",u]})},{"../elliptic":275,"./precomputed/secp256k1":286,"hash.js":289}],282:[function(t,e,r){"use strict";function n(t){return this instanceof n?("string"==typeof t&&(a(s.curves.hasOwnProperty(t),"Unknown curve "+t),t=s.curves[t]),t instanceof s.curves.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.shrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),void(this.hash=t.hash||t.curve.hash)):new n(t)}var i=t("bn.js"),s=t("../../elliptic"),o=s.utils,a=o.assert,f=t("./key"),u=t("./signature");e.exports=n,n.prototype.keyPair=function(t){return new f(this,t)},n.prototype.keyFromPrivate=function(t,e){return f.fromPrivate(this,t,e)},n.prototype.keyFromPublic=function(t,e){return f.fromPublic(this,t,e)},n.prototype.genKeyPair=function(t){t||(t={});for(var e=new s.hmacDRBG({hash:this.hash,pers:t.pers,entropy:t.entropy||s.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new i(2));;){var o=new i(e.generate(r));if(!(o.cmp(n)>0))return o.iaddn(1),this.keyFromPrivate(o)}},n.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.shrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},n.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new i(t,16));for(var o=this.n.byteLength(),a=e.getPrivate().toArray(),f=a.length;21>f;f++)a.unshift(0);for(var c=t.toArray(),f=c.length;o>f;f++)c.unshift(0);for(var h=new s.hmacDRBG({hash:this.hash,entropy:a,nonce:c}),d=this.n.sub(new i(1));;){var p=new i(h.generate(this.n.byteLength()));if(p=this._truncateToN(p,!0),!(p.cmpn(1)<=0||p.cmp(d)>=0)){var l=this.g.mul(p);if(!l.isInfinity()){var b=l.getX().mod(this.n);if(0!==b.cmpn(0)){var g=p.invm(this.n).mul(b.mul(e.getPrivate()).iadd(t)).mod(this.n);if(0!==g.cmpn(0))return n.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g)),new u({r:b,s:g})}}}}},n.prototype.verify=function(t,e,r,n){t=this._truncateToN(new i(t,16)),r=this.keyFromPublic(r,n),e=new u(e,"hex");var s=e.r,o=e.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),f=a.mul(t).mod(this.n),c=a.mul(s).mod(this.n),h=this.g.mulAdd(f,r.getPublic(),c);return h.isInfinity()?!1:0===h.getX().mod(this.n).cmp(s)}},{"../../elliptic":275,"./key":283,"./signature":284,"bn.js":272}],283:[function(t,e,r){"use strict";function n(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var i=t("bn.js"),s=t("../../elliptic"),o=s.utils;e.exports=n,n.fromPublic=function(t,e,r){return e instanceof n?e:new n(t,{pub:e,pubEnc:r})},n.fromPrivate=function(t,e,r){return e instanceof n?e:new n(t,{priv:e,privEnc:r})},n.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},n.prototype.getPublic=function(t,e){if(this.pub||(this.pub=this.ec.g.mul(this.priv)),"string"==typeof t&&(e=t,t=null),!e)return this.pub;for(var r=this.ec.curve.p.byteLength(),n=this.pub.getX().toArray(),i=n.length;r>i;i++)n.unshift(0);var s;if("mont"!==this.ec.curve.type)if(t)s=[this.pub.getY().isEven()?2:3].concat(n);else{for(var a=this.pub.getY().toArray(),i=a.length;r>i;i++)a.unshift(0);var s=[4].concat(n,a)}else s=n;return o.encode(s,e)},n.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},n.prototype._importPrivate=function(t,e){this.priv=new i(t,e||16),this.priv=this.priv.mod(this.ec.curve.n)},n.prototype._importPublic=function(t,e){return t.x||t.y?void(this.pub=this.ec.curve.point(t.x,t.y)):(t=o.toArray(t,e),"mont"!==this.ec.curve.type?this._importPublicShort(t):this._importPublicMont(t))},n.prototype._importPublicShort=function(t){var e=this.ec.curve.p.byteLength();4===t[0]&&t.length-1===2*e?this.pub=this.ec.curve.point(t.slice(1,1+e),t.slice(1+e,1+2*e)):2!==t[0]&&3!==t[0]||t.length-1!==e||(this.pub=this.ec.curve.pointFromX(3===t[0],t.slice(1,1+e)))},n.prototype._importPublicMont=function(t){this.pub=this.ec.curve.point(t,1)},n.prototype.derive=function(t){return t.mul(this.priv).getX()},n.prototype.sign=function(t){return this.ec.sign(t,this)},n.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},n.prototype.inspect=function(){return""}},{"../../elliptic":275,"bn.js":272}],284:[function(t,e,r){"use strict";function n(t,e){return t instanceof n?t:void(this._importDER(t,e)||(a(t.r&&t.s,"Signature without r or s"),this.r=new i(t.r,16),this.s=new i(t.s,16)))}var i=t("bn.js"),s=t("../../elliptic"),o=s.utils,a=o.assert;e.exports=n,n.prototype._importDER=function(t,e){if(t=o.toArray(t,e),t.length<6||48!==t[0]||2!==t[2])return!1;var r=t[1];if(1+r>t.length)return!1;var n=t[3];if(n>=128)return!1;if(4+n+2>=t.length)return!1;if(2!==t[4+n])return!1;var s=t[5+n];return s>=128?!1:4+n+2+s>t.length?!1:(this.r=new i(t.slice(4,4+n)),this.s=new i(t.slice(4+n+2,4+n+2+s)),!0)},n.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r));var n=e.length+r.length+4,i=[48,n,2,e.length];return i=i.concat(e,[2,r.length],r),o.encode(i,t)}},{"../../elliptic":275,"bn.js":272}],285:[function(t,e,r){arguments[4][100][0].apply(r,arguments)},{"../elliptic":275,dup:100,"hash.js":289}],286:[function(t,e,r){arguments[4][101][0].apply(r,arguments)},{dup:101}],287:[function(t,e,r){"use strict";function n(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var n=0;n>8,o=255&i;s?r.push(s,o):r.push(o)}return r}function i(t){return 1===t.length?"0"+t:t}function s(t){for(var e="",r=0;r=0;){var s;if(i.isOdd()){var o=i.andln(n-1);s=o>(n>>1)-1?(n>>1)-o:o,i.isubn(s)}else s=0;r.push(s);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?e+1:1,f=1;a>f;f++)r.push(0);i.ishrn(a)}return r}function a(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n=0,i=0;t.cmpn(-n)>0||e.cmpn(-i)>0;){var s=t.andln(3)+n&3,o=e.andln(3)+i&3;3===s&&(s=-1),3===o&&(o=-1);var a;if(0===(1&s))a=0;else{var f=t.andln(7)+n&7;a=3!==f&&5!==f||2!==o?s:-s}r[0].push(a);var u;if(0===(1&o))u=0;else{var f=e.andln(7)+i&7;u=3!==f&&5!==f||2!==s?o:-o}r[1].push(u),2*n===a+1&&(n=1-n),2*i===u+1&&(i=1-i),t.ishrn(1),e.ishrn(1)}return r}var f=r;f.assert=function(t,e){if(!t)throw new Error(e||"Assertion failed")},f.toArray=n,f.zero2=i,f.toHex=s,f.encode=function(t,e){return"hex"===e?s(t):t},f.getNAF=o,f.getJSF=a},{}],288:[function(t,e,r){arguments[4][103][0].apply(r,arguments)},{dup:103}],289:[function(t,e,r){arguments[4][104][0].apply(r,arguments)},{"./hash/common":290,"./hash/hmac":291,"./hash/ripemd":292,"./hash/sha":293,"./hash/utils":294,dup:104}],290:[function(t,e,r){arguments[4][105][0].apply(r,arguments)},{"../hash":289,dup:105}],291:[function(t,e,r){arguments[4][106][0].apply(r,arguments)},{"../hash":289,dup:106}],292:[function(t,e,r){arguments[4][107][0].apply(r,arguments)},{"../hash":289,dup:107}],293:[function(t,e,r){arguments[4][108][0].apply(r,arguments)},{"../hash":289,dup:108}],294:[function(t,e,r){arguments[4][109][0].apply(r,arguments)},{dup:109,inherits:296}],295:[function(t,e,r){e.exports={name:"elliptic",version:"3.0.3",description:"EC cryptography",main:"lib/elliptic.js",scripts:{test:"make lint && mocha --reporter=spec test/*-test.js"},repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},keywords:["EC","Elliptic","curve","Cryptography"],author:{name:"Fedor Indutny",email:"fedor@indutny.com"},license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{browserify:"^3.44.2",jscs:"^1.11.3",jshint:"^2.6.0",mocha:"^2.1.0","uglify-js":"^2.4.13"},dependencies:{"bn.js":"^2.0.0",brorand:"^1.0.1","hash.js":"^1.0.0",inherits:"^2.0.1"},readme:"# Elliptic [![Build Status](https://secure.travis-ci.org/indutny/elliptic.png)](http://travis-ci.org/indutny/elliptic)\n\nFast elliptic-curve cryptography in a plain javascript implementation.\n\nNOTE: Please take a look at http://safecurves.cr.yp.to/ before choosing a curve\nfor your cryptography operations.\n\n## Incentive\n\nECC is much slower than regular RSA cryptography, the JS implementations are\neven more slower.\n\n## Benchmarks\n\n```bash\n$ node benchmarks/index.js\nBenchmarking: sign\nelliptic#sign x 262 ops/sec ±0.51% (177 runs sampled)\neccjs#sign x 55.91 ops/sec ±0.90% (144 runs sampled)\n------------------------\nFastest is elliptic#sign\n========================\nBenchmarking: verify\nelliptic#verify x 113 ops/sec ±0.50% (166 runs sampled)\neccjs#verify x 48.56 ops/sec ±0.36% (125 runs sampled)\n------------------------\nFastest is elliptic#verify\n========================\nBenchmarking: gen\nelliptic#gen x 294 ops/sec ±0.43% (176 runs sampled)\neccjs#gen x 62.25 ops/sec ±0.63% (129 runs sampled)\n------------------------\nFastest is elliptic#gen\n========================\nBenchmarking: ecdh\nelliptic#ecdh x 136 ops/sec ±0.85% (156 runs sampled)\n------------------------\nFastest is elliptic#ecdh\n========================\n```\n\n## API\n\n### ECDSA\n\n```javascript\nvar EC = require('elliptic').ec;\n\n// Create and initialize EC context\n// (better do it once and reuse it)\nvar ec = new EC('secp256k1');\n\n// Generate keys\nvar key = ec.genKeyPair();\n\n// Sign message (must be an array, or it'll be treated as a hex sequence)\nvar msg = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];\nvar signature = key.sign(msg);\n\n// Export DER encoded signature in Array\nvar derSign = signature.toDER();\n\n// Verify signature\nconsole.log(key.verify(msg, derSign));\n```\n\n### ECDH\n\n```javascript\n// Generate keys\nvar key1 = ec.genKeyPair();\nvar key2 = ec.genKeyPair();\n\nvar shared1 = key1.derive(key2.getPublic());\nvar shared2 = key2.derive(key1.getPublic());\n\nconsole.log('Both shared secrets are BN instances');\nconsole.log(shared1.toString(16));\nconsole.log(shared2.toString(16));\n```\n\nNOTE: `.derive()` returns a [BN][1] instance.\n\n## Supported curves\n\nElliptic.js support following curve types:\n\n* Short Weierstrass\n* Montgomery\n* Edwards\n* Twisted Edwards\n\nFollowing curve 'presets' are embedded into the library:\n\n* `secp256k1`\n* `p192`\n* `p224`\n* `p256`\n* `curve25519`\n* `ed25519`\n\nNOTE: That `curve25519` could not be used for ECDSA, use `ed25519` instead.\n\n### Implementation details\n\nECDSA is using deterministic `k` value generation as per [RFC6979][0]. Most of\nthe curve operations are performed on non-affine coordinates (either projective\nor extended), various windowing techniques are used for different cases.\n\nAll operations are performed in reduction context using [bn.js][1], hashing is\nprovided by [hash.js][2]\n\n### Related projects\n\n* [eccrypto][3]: isomorphic implementation of ECDSA, ECDH and ECIES for both\n browserify and node (uses `elliptic` for browser and [secp256k1-node][4] for\n node)\n\n#### LICENSE\n\nThis software is licensed under the MIT License.\n\nCopyright Fedor Indutny, 2014.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to permit\npersons to whom the Software is furnished to do so, subject to the\nfollowing conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\nNO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\nDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\nUSE OR OTHER DEALINGS IN THE SOFTWARE.\n\n[0]: http://tools.ietf.org/html/rfc6979\n[1]: https://github.com/indutny/bn.js\n[2]: https://github.com/indutny/hash.js\n[3]: https://github.com/bitchan/eccrypto\n[4]: https://github.com/wanderer/secp256k1-node\n",readmeFilename:"README.md",_id:"elliptic@3.0.3",_shasum:"865c9b420bfbe55006b9f969f97a0d2c44966595",_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-3.0.3.tgz",_from:"https://registry.npmjs.org/elliptic/-/elliptic-3.0.3.tgz"}},{}],296:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],297:[function(t,e,r){(function(t){(function(){function n(t,e){if(t!==e){var r=null===t,n=t===E,i=t===t,s=null===e,o=e===E,a=e===e;if(t>e&&!s||!i||r&&!o&&a||n&&a)return 1;if(e>t&&!r||!a||s&&!n&&i||o&&i)return-1}return 0}function i(t,e,r){for(var n=t.length,i=r?n:-1;r?i--:++i-1;);return r}function u(t,e){for(var r=t.length;r--&&e.indexOf(t.charAt(r))>-1;);return r}function c(t,e){return n(t.criteria,e.criteria)||t.index-e.index}function h(t,e,r){for(var i=-1,s=t.criteria,o=e.criteria,a=s.length,f=r.length;++i=f)return u;var c=r[i];return u*("asc"===c||c===!0?1:-1)}}return t.index-e.index}function d(t){return qt[t]}function p(t){return Vt[t]}function l(t,e,r){return e?t=Wt[t]:r&&(t=Xt[t]),"\\"+t}function b(t){return"\\"+Xt[t]}function g(t,e,r){for(var n=t.length,i=e+(r?0:-1);r?i--:++i=t&&t>=9&&13>=t||32==t||160==t||5760==t||6158==t||t>=8192&&(8202>=t||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function v(t,e){for(var r=-1,n=t.length,i=-1,s=[];++re,i=r?t.length:0,s=Vr(0,i,this.__views__),o=s.start,a=s.end,f=a-o,u=n?a:o-1,c=this.__iteratees__,h=c.length,d=0,p=Io(f,this.__takeCount__);if(!r||z>i||i==f&&p==f)return rr(n&&r?t.reverse():t,this.__actions__);var l=[];t:for(;f--&&p>d;){u+=e;for(var b=-1,g=t[u];++b=z?lr(e):null,u=e.length;f&&(o=Zt,a=!1,e=f);t:for(;++ir&&(r=-r>i?0:i+r),n=n===E||n>i?i:+n||0,0>n&&(n+=i),i=r>n?0:n>>>0,r>>>=0;i>r;)t[r++]=e;return t}function xe(t,e){var r=[];return jo(t,function(t,n,i){e(t,n,i)&&r.push(t)}),r}function Pe(t,e,r,n){var i;return r(t,function(t,r,s){return e(t,r,s)?(i=n?r:t,!1):void 0}),i}function Oe(t,e,r,n){n||(n=[]);for(var i=-1,s=t.length;++in;)t=t[e[n++]];return n&&n==i?t:E}}function Ne(t,e,r,n,i,s){return t===e?!0:null==t||null==e||!Ci(t)&&!m(e)?t!==t&&e!==e:je(t,e,Ne,r,n,i,s)}function je(t,e,r,n,i,s,o){var a=Oa(t),f=Oa(e),u=Y,c=Y;a||(u=ro.call(t),u==V?u=$:u!=$&&(a=Hi(t))),f||(c=ro.call(e),c==V?c=$:c!=$&&(f=Hi(e)));var h=u==$,d=c==$,p=u==c;if(p&&!a&&!h)return Lr(t,e,u);if(!i){var l=h&&to.call(t,"__wrapped__"),b=d&&to.call(e,"__wrapped__");if(l||b)return r(l?t.value():t,b?e.value():e,n,i,s,o)}if(!p)return!1;s||(s=[]),o||(o=[]);for(var g=s.length;g--;)if(s[g]==t)return o[g]==e;s.push(t),o.push(e);var m=(a?Ur:Dr)(t,e,r,n,i,s,o);return s.pop(),o.pop(),m}function Ue(t,e,r){var n=e.length,i=n,s=!r;if(null==t)return!i;for(t=hn(t);n--;){var o=e[n];if(s&&o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++ne&&(e=-e>i?0:i+e),r=r===E||r>i?i:+r||0,0>r&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var s=zs(i);++n=z,f=a?lr():null,u=[];f?(n=Zt,o=!1):(a=!1,f=e?[]:u);t:for(;++r=i){for(;i>n;){var s=n+i>>>1,o=t[s];(r?e>=o:e>o)&&null!==o?n=s+1:i=s}return i}return ir(t,e,xs,r)}function ir(t,e,r,n){e=r(e);for(var i=0,s=t?t.length:0,o=e!==e,a=null===e,f=e===E;s>i;){var u=yo((i+s)/2),c=r(t[u]),h=c!==E,d=c===c;if(o)var p=d||n;else p=a?d&&h&&(n||null!=c):f?d&&(n||h):null==c?!1:n?e>=c:e>c;p?i=u+1:s=u}return Io(s,Bo)}function sr(t,e,r){if("function"!=typeof t)return xs;if(e===E)return t;switch(r){case 1:return function(r){return t.call(e,r)};case 3:return function(r,n,i){return t.call(e,r,n,i)};case 4:return function(r,n,i,s){return t.call(e,r,n,i,s)};case 5:return function(r,n,i,s,o){return t.call(e,r,n,i,s,o)}}return function(){return t.apply(e,arguments)}}function or(t){var e=new so(t.byteLength),r=new lo(e);return r.set(new lo(t)),e}function ar(t,e,r){for(var n=r.length,i=-1,s=So(t.length-n,0),o=-1,a=e.length,f=zs(a+s);++o2?r[i-2]:E,o=i>2?r[2]:E,a=i>1?r[i-1]:E;for("function"==typeof s?(s=sr(s,a,5),i-=2):(s="function"==typeof a?a:E,i-=s?1:0),o&&Qr(r[0],r[1],o)&&(s=3>i?E:s,i=1);++n-1?r[o]:E}return Pe(r,n,t)}}function wr(t){return function(e,r,n){return e&&e.length?(r=zr(r,n,3),i(e,r,t)):-1}}function Sr(t){return function(e,r,n){return r=zr(r,n,3),Pe(e,r,t,!0)}}function Ir(t){return function(){for(var e,r=arguments.length,n=t?r:-1,i=0,s=zs(r);t?n--:++n=z)return e.plant(n).value();for(var i=0,o=r?s[i].apply(this,t):n;++iy){var k=a?te(a):E,A=So(u-y,0),O=l?I:E,B=l?E:I,M=l?w:E,C=l?E:w;e|=l?R:T,e&=~(l?T:R),b||(e&=~(x|P));var N=[t,e,r,M,O,C,B,k,f,A],j=Mr.apply(E,N);return tn(t)&&Ho(j,N),j.placeholder=S,j}}var U=d?r:this,L=p?U[t]:t;return a&&(w=fn(w,a)),h&&f=e||!_o(e))return"";var i=e-n;return r=null==r?" ":r+"",gs(r,go(i/r.length)).slice(0,i)}function Tr(t,e,r,n){function i(){for(var e=-1,a=arguments.length,f=-1,u=n.length,c=zs(u+a);++ff))return!1;for(;++a-1&&t%1==0&&e>t}function Qr(t,e,r){if(!Ci(r))return!1;var n=typeof e;if("number"==n?Jr(r)&&Zr(e,r.length):"string"==n&&e in r){var i=r[e];return t===t?t===i:i!==i}return!1}function $r(t,e){var r=typeof t;if("string"==r&&Et.test(t)||"number"==r)return!0;if(Oa(t))return!1;var n=!kt.test(t);return n||null!=e&&t in hn(e)}function tn(t){var r=Fr(t);if(!(r in Z.prototype))return!1;var n=e[r];if(t===n)return!0;var i=Fo(n);return!!i&&t===i[0]}function en(t){return"number"==typeof t&&t>-1&&t%1==0&&Ro>=t}function rn(t){return t===t&&!Ci(t)}function nn(t,e){var r=t[1],n=e[1],i=r|n,s=C>i,o=n==C&&r==B||n==C&&r==N&&t[7].length<=e[8]||n==(C|N)&&r==B;if(!s&&!o)return t;n&x&&(t[2]=e[2],i|=r&x?0:O);var a=e[3];if(a){var f=t[3];t[3]=f?ar(f,a,e[4]):te(a),t[4]=f?v(t[3],q):te(e[4])}return a=e[5],a&&(f=t[5],t[5]=f?fr(f,a,e[6]):te(a),t[6]=f?v(t[5],q):te(e[6])),a=e[7],a&&(t[7]=te(a)),n&C&&(t[8]=null==t[8]?e[8]:Io(t[8],e[8])),null==t[9]&&(t[9]=e[9]),t[0]=e[0],t[1]=i,t}function sn(t,e){return t===E?e:Ba(t,e,sn)}function on(t,e){t=hn(t);for(var r=-1,n=e.length,i={};++rn;)o[++s]=We(t,n,n+=e);return o}function bn(t){for(var e=-1,r=t?t.length:0,n=-1,i=[];++ee?0:e)):[]}function mn(t,e,r){var n=t?t.length:0;return n?((r?Qr(t,e,r):null==e)&&(e=1),e=n-(+e||0),We(t,0,0>e?0:e)):[]}function yn(t,e,r){return t&&t.length?er(t,zr(e,r,3),!0,!0):[]}function vn(t,e,r){return t&&t.length?er(t,zr(e,r,3),!0):[]}function _n(t,e,r,n){var i=t?t.length:0;return i?(r&&"number"!=typeof r&&Qr(t,e,r)&&(r=0,n=i),Ae(t,e,r,n)):[]}function wn(t){return t?t[0]:E}function Sn(t,e,r){var n=t?t.length:0;return r&&Qr(t,e,r)&&(e=!1),n?Oe(t,e):[]}function In(t){var e=t?t.length:0;return e?Oe(t,!0):[]}function kn(t,e,r){var n=t?t.length:0;if(!n)return-1;if("number"==typeof r)r=0>r?So(n+r,0):r;else if(r){var i=nr(t,e);return n>i&&(e===e?e===t[i]:t[i]!==t[i])?i:-1}return s(t,e,r||0)}function En(t){return mn(t,1)}function An(t){var e=t?t.length:0;return e?t[e-1]:E}function xn(t,e,r){var n=t?t.length:0;if(!n)return-1;var i=n;if("number"==typeof r)i=(0>r?So(n+r,0):Io(r||0,n-1))+1;else if(r){i=nr(t,e,!0)-1;var s=t[i];return(e===e?e===s:s!==s)?i:-1}if(e!==e)return g(t,i,!0);for(;i--;)if(t[i]===e)return i;return-1}function Pn(){var t=arguments,e=t[0];if(!e||!e.length)return e;for(var r=0,n=Kr(),i=t.length;++r-1;)po.call(e,s,1);return e}function On(t,e,r){var n=[];if(!t||!t.length)return n;var i=-1,s=[],o=t.length;for(e=zr(e,r,3);++ie?0:e)):[]}function Tn(t,e,r){var n=t?t.length:0;return n?((r?Qr(t,e,r):null==e)&&(e=1),e=n-(+e||0),We(t,0>e?0:e)):[]}function Cn(t,e,r){return t&&t.length?er(t,zr(e,r,3),!1,!0):[]}function Nn(t,e,r){return t&&t.length?er(t,zr(e,r,3)):[]}function jn(t,e,r,n){var i=t?t.length:0;if(!i)return[];null!=e&&"boolean"!=typeof e&&(n=r,r=Qr(t,e,n)?E:e,e=!1);var o=zr();return(null!=r||o!==_e)&&(r=o(r,n,3)),e&&Kr()==s?_(t,r):$e(t,r)}function Un(t){if(!t||!t.length)return[];var e=-1,r=0;t=ae(t,function(t){return Jr(t)?(r=So(t.length,r),!0):void 0});for(var n=zs(r);++er?So(i+r,0):r||0,"string"==typeof t||!Oa(t)&&Ki(t)?i>=r&&t.indexOf(e,r)>-1:!!i&&Kr(t,e,r)>-1}function ti(t,e,r){var n=Oa(t)?fe:Le;return e=zr(e,r,3),n(t,e)}function ei(t,e){return ti(t,Ts(e))}function ri(t,e,r){var n=Oa(t)?ae:xe;return e=zr(e,r,3),n(t,function(t,r,n){return!e(t,r,n)})}function ni(t,e,r){if(r?Qr(t,e,r):null==e){t=cn(t);var n=t.length;return n>0?t[Ye(0,n-1)]:E}var i=-1,s=Gi(t),n=s.length,o=n-1;for(e=Io(0>e?0:+e||0,n);++i0&&(r=e.apply(this,arguments)),1>=t&&(e=E),r}}function pi(t,e,r){function n(){p&&oo(p),u&&oo(u),b=0,u=p=l=E}function i(e,r){r&&oo(r),u=p=l=E,e&&(b=ba(),c=t.apply(d,f),p||u||(f=d=E))}function s(){var t=e-(ba()-h);0>=t||t>e?i(l,u):p=ho(s,t)}function o(){i(m,p)}function a(){if(f=arguments,h=ba(),d=this,l=m&&(p||!y),g===!1)var r=y&&!p;else{u||y||(b=h);var n=g-(h-b),i=0>=n||n>g;i?(u&&(u=oo(u)),b=h,c=t.apply(d,f)):u||(u=ho(o,n))}return i&&p?p=oo(p):p||e===g||(p=ho(s,e)),r&&(i=!0,c=t.apply(d,f)),!i||p||u||(f=d=E),c}var f,u,c,h,d,p,l,b=0,g=!1,m=!0;if("function"!=typeof t)throw new Xs(H);if(e=0>e?0:+e||0,r===!0){var y=!0;m=!1}else Ci(r)&&(y=!!r.leading,g="maxWait"in r&&So(+r.maxWait||0,e),m="trailing"in r?!!r.trailing:m);return a.cancel=n,a}function li(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new Xs(H);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=t.apply(this,n);return r.cache=s.set(i,o),o};return r.cache=new li.Cache,r}function bi(t){if("function"!=typeof t)throw new Xs(H);return function(){return!t.apply(this,arguments)}}function gi(t){return di(2,t)}function mi(t,e){if("function"!=typeof t)throw new Xs(H);return e=So(e===E?t.length-1:+e||0,0),function(){for(var r=arguments,n=-1,i=So(r.length-e,0),s=zs(i);++ne}function ki(t,e){return t>=e}function Ei(t){return m(t)&&Jr(t)&&to.call(t,"callee")&&!uo.call(t,"callee")}function Ai(t){return t===!0||t===!1||m(t)&&ro.call(t)==G}function xi(t){return m(t)&&ro.call(t)==W}function Pi(t){return!!t&&1===t.nodeType&&m(t)&&!zi(t)}function Oi(t){return null==t?!0:Jr(t)&&(Oa(t)||Ki(t)||Ei(t)||m(t)&&Ti(t.splice))?!t.length:!za(t).length}function Bi(t,e,r,n){r="function"==typeof r?sr(r,n,3):E;var i=r?r(t,e):E;return i===E?Ne(t,e,r):!!i}function Mi(t){return m(t)&&"string"==typeof t.message&&ro.call(t)==X}function Ri(t){return"number"==typeof t&&_o(t)}function Ti(t){return Ci(t)&&ro.call(t)==J}function Ci(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Ni(t,e,r,n){return r="function"==typeof r?sr(r,n,3):E,Ue(t,Hr(e),r)}function ji(t){return Di(t)&&t!=+t}function Ui(t){return null==t?!1:Ti(t)?io.test($s.call(t)):m(t)&&Ct.test(t)}function Li(t){return null===t}function Di(t){return"number"==typeof t||m(t)&&ro.call(t)==Q}function zi(t){var e;if(!m(t)||ro.call(t)!=$||Ei(t)||!to.call(t,"constructor")&&(e=t.constructor,"function"==typeof e&&!(e instanceof e)))return!1;var r;return Be(t,function(t,e){r=e}),r===E||to.call(t,r)}function Fi(t){return Ci(t)&&ro.call(t)==tt}function Ki(t){return"string"==typeof t||m(t)&&ro.call(t)==rt}function Hi(t){return m(t)&&en(t.length)&&!!Kt[ro.call(t)]}function qi(t){return t===E}function Vi(t,e){return e>t}function Yi(t,e){return e>=t}function Gi(t){var e=t?Ko(t):0;return en(e)?e?te(t):[]:ss(t)}function Wi(t){return ve(t,ts(t))}function Xi(t,e,r){var n=No(t);return r&&Qr(t,e,r)&&(e=E),e?me(n,e):n}function Ji(t){return Te(t,ts(t))}function Zi(t,e,r){var n=null==t?E:Ce(t,dn(e),e+"");return n===E?r:n}function Qi(t,e){if(null==t)return!1;var r=to.call(t,e);if(!r&&!$r(e)){if(e=dn(e),t=1==e.length?t:Ce(t,We(e,0,-1)),null==t)return!1;e=An(e),r=to.call(t,e)}return r||en(t.length)&&Zr(e,t.length)&&(Oa(t)||Ei(t))}function $i(t,e,r){r&&Qr(t,e,r)&&(e=E);for(var n=-1,i=za(t),s=i.length,o={};++n0;++n=Io(e,r)&&tr?0:+r||0,n),r-=e.length,r>=0&&t.indexOf(e,r)==r}function ds(t){return t=a(t),t&&_t.test(t)?t.replace(yt,p):t}function ps(t){return t=a(t),t&&Pt.test(t)?t.replace(xt,l):t||"(?:)"}function ls(t,e,r){t=a(t),e=+e;var n=t.length;if(n>=e||!_o(e))return t;var i=(e-n)/2,s=yo(i),o=go(i);return r=Rr("",o,r),r.slice(0,s)+t+r}function bs(t,e,r){return(r?Qr(t,e,r):null==e)?e=0:e&&(e=+e),t=vs(t),Eo(t,e||(Tt.test(t)?16:10))}function gs(t,e){var r="";if(t=a(t),e=+e,1>e||!t||!_o(e))return r;do e%2&&(r+=t),e=yo(e/2),t+=t;while(e);return r}function ms(t,e,r){return t=a(t),r=null==r?0:Io(0>r?0:+r||0,t.length),t.lastIndexOf(e,r)==r}function ys(t,r,n){var i=e.templateSettings;n&&Qr(t,r,n)&&(r=n=E),t=a(t),r=ge(me({},n||r),i,be);var s,o,f=ge(me({},r.imports),i.imports,be),u=za(f),c=tr(f,u),h=0,d=r.interpolate||Ut,p="__p += '",l=Gs((r.escape||Ut).source+"|"+d.source+"|"+(d===It?Mt:Ut).source+"|"+(r.evaluate||Ut).source+"|$","g"),g="//# sourceURL="+("sourceURL"in r?r.sourceURL:"lodash.templateSources["+ ++Ft+"]")+"\n";t.replace(l,function(e,r,n,i,a,f){return n||(n=i),p+=t.slice(h,f).replace(Lt,b),r&&(s=!0,p+="' +\n__e("+r+") +\n'"),a&&(o=!0,p+="';\n"+a+";\n__p += '"),n&&(p+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),h=f+e.length,e}),p+="';\n";var m=r.variable;m||(p="with (obj) {\n"+p+"\n}\n"),p=(o?p.replace(lt,""):p).replace(bt,"$1").replace(gt,"$1;"),p="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(s?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";var y=Za(function(){return Hs(u,g+"return "+p).apply(E,c)});if(y.source=p,Mi(y))throw y;return y}function vs(t,e,r){var n=t;return(t=a(t))?(r?Qr(n,e,r):null==e)?t.slice(w(t),S(t)+1):(e+="",t.slice(f(t,e),u(t,e)+1)):t}function _s(t,e,r){var n=t;return t=a(t),t?(r?Qr(n,e,r):null==e)?t.slice(w(t)):t.slice(f(t,e+"")):t}function ws(t,e,r){var n=t;return t=a(t),t?(r?Qr(n,e,r):null==e)?t.slice(0,S(t)+1):t.slice(0,u(t,e+"")+1):t}function Ss(t,e,r){r&&Qr(t,e,r)&&(e=E);var n=j,i=U;if(null!=e)if(Ci(e)){var s="separator"in e?e.separator:s;n="length"in e?+e.length||0:n,i="omission"in e?a(e.omission):i}else n=+e||0;if(t=a(t),n>=t.length)return t;var o=n-i.length;if(1>o)return i;var f=t.slice(0,o);if(null==s)return f+i;if(Fi(s)){if(t.slice(o).search(s)){var u,c,h=t.slice(0,o);for(s.global||(s=Gs(s.source,(Rt.exec(s)||"")+"g")),s.lastIndex=0;u=s.exec(h);)c=u.index;f=f.slice(0,null==c?o:c)}}else if(t.indexOf(s,o)!=o){var d=f.lastIndexOf(s);d>-1&&(f=f.slice(0,d))}return f+i}function Is(t){return t=a(t),t&&vt.test(t)?t.replace(mt,I):t}function ks(t,e,r){return r&&Qr(t,e,r)&&(e=E),t=a(t),t.match(e||Dt)||[]}function Es(t,e,r){return r&&Qr(t,e,r)&&(e=E),m(t)?Ps(t):_e(t,e)}function As(t){return function(){return t}}function xs(t){return t}function Ps(t){return De(we(t,!0))}function Os(t,e){return ze(t,we(e,!0))}function Bs(t,e,r){if(null==r){var n=Ci(e),i=n?za(e):E,s=i&&i.length?Te(e,i):E;(s?s.length:n)||(s=!1,r=e,e=t,t=this)}s||(s=Te(e,za(e)));var o=!0,a=-1,f=Ti(t),u=s.length;r===!1?o=!1:Ci(r)&&"chain"in r&&(o=r.chain);for(;++at||!_o(t))return[];var n=-1,i=zs(Io(t,Oo));for(e=sr(e,r,1);++nn?i[n]=e(n):e(n);return i}function Us(t){var e=++eo;return a(t)+e}function Ls(t,e){return(+t||0)+(+e||0)}function Ds(t,e,r){return r&&Qr(t,e,r)&&(e=E),e=zr(e,r,3),1==e.length?pe(Oa(t)?t:cn(t),e):Qe(t,e)}t=t?ne.defaults(re.Object(),t,ne.pick(re,zt)):re;var zs=t.Array,Fs=t.Date,Ks=t.Error,Hs=t.Function,qs=t.Math,Vs=t.Number,Ys=t.Object,Gs=t.RegExp,Ws=t.String,Xs=t.TypeError,Js=zs.prototype,Zs=Ys.prototype,Qs=Ws.prototype,$s=Hs.prototype.toString,to=Zs.hasOwnProperty,eo=0,ro=Zs.toString,no=re._,io=Gs("^"+$s.call(to).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),so=t.ArrayBuffer,oo=t.clearTimeout,ao=t.parseFloat,fo=qs.pow,uo=Zs.propertyIsEnumerable,co=qr(t,"Set"),ho=t.setTimeout,po=Js.splice,lo=t.Uint8Array,bo=qr(t,"WeakMap"),go=qs.ceil,mo=qr(Ys,"create"),yo=qs.floor,vo=qr(zs,"isArray"),_o=t.isFinite,wo=qr(Ys,"keys"),So=qs.max,Io=qs.min,ko=qr(Fs,"now"),Eo=t.parseInt,Ao=qs.random,xo=Vs.NEGATIVE_INFINITY,Po=Vs.POSITIVE_INFINITY,Oo=4294967295,Bo=Oo-1,Mo=Oo>>>1,Ro=9007199254740991,To=bo&&new bo,Co={};e.support={};e.templateSettings={escape:wt,evaluate:St,interpolate:It,variable:"",imports:{_:e}};var No=function(){function t(){}return function(e){if(Ci(e)){t.prototype=e;var r=new t;t.prototype=E}return r||{}}}(),jo=hr(Me),Uo=hr(Re,!0),Lo=dr(),Do=dr(!0),zo=To?function(t,e){return To.set(t,e),t}:xs,Fo=To?function(t){return To.get(t)}:Rs,Ko=He("length"),Ho=function(){var t=0,e=0;return function(r,n){var i=ba(),s=D-(i-e);if(e=i,s>0){if(++t>=L)return r}else t=0;return zo(r,n)}}(),qo=mi(function(t,e){return m(t)&&Jr(t)?Ie(t,Oe(e,!1,!0)):[]}),Vo=wr(),Yo=wr(!0),Go=mi(function(t){for(var e=t.length,r=e,n=zs(h),i=Kr(),o=i==s,a=[];r--;){var f=t[r]=Jr(f=t[r])?f:[];n[r]=o&&f.length>=120?lr(r&&f):null}var u=t[0],c=-1,h=u?u.length:0,d=n[0];t:for(;++c2?t[e-2]:E,n=e>1?t[e-1]:E;return e>2&&"function"==typeof r?e-=2:(r=e>1&&"function"==typeof n?(--e,n):E,n=E),t.length=e,Ln(t,r,n)}),ea=mi(function(t){return t=Oe(t),this.thru(function(e){return $t(Oa(e)?e:[hn(e)],t)})}),ra=mi(function(t,e){return ye(t,Oe(e))}),na=ur(function(t,e,r){to.call(t,r)?++t[r]:t[r]=1}),ia=_r(jo),sa=_r(Uo,!0),oa=kr(ee,jo),aa=kr(ie,Uo),fa=ur(function(t,e,r){to.call(t,r)?t[r].push(e):t[r]=[e]}),ua=ur(function(t,e,r){t[r]=e}),ca=mi(function(t,e,r){var n=-1,i="function"==typeof e,s=$r(e),o=Jr(t)?zs(t.length):[];return jo(t,function(t){var a=i?e:s&&null!=t?t[e]:E;o[++n]=a?a.apply(t,r):Xr(t,e,r)}),o}),ha=ur(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]}),da=Br(ce,jo),pa=Br(he,Uo),la=mi(function(t,e){if(null==t)return[];var r=e[2];return r&&Qr(e[0],e[1],r)&&(e.length=1),Ze(t,Oe(e),[])}),ba=ko||function(){return(new Fs).getTime()},ga=mi(function(t,e,r){var n=x;if(r.length){var i=v(r,ga.placeholder);n|=R}return jr(t,n,e,r,i)}),ma=mi(function(t,e){e=e.length?Oe(e):Ji(t);for(var r=-1,n=e.length;++r0||0>e)?new Z(r):(0>t?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==E&&(e=+e||0,r=0>e?r.dropRight(-e):r.take(e-t)),r)},Z.prototype.takeRightWhile=function(t,e){return this.reverse().takeWhile(t,e).reverse()},Z.prototype.toArray=function(){return this.take(Po)},Me(Z.prototype,function(t,r){var n=/^(?:filter|map|reject)|While$/.test(r),i=/^(?:first|last)$/.test(r),s=e[i?"take"+("last"==r?"Right":""):r];s&&(e.prototype[r]=function(){var e=i?[1]:arguments,r=this.__chain__,o=this.__wrapped__,a=!!this.__actions__.length,f=o instanceof Z,u=e[0],c=f||Oa(o);c&&n&&"function"==typeof u&&1!=u.length&&(f=c=!1);var h=function(t){return i&&r?s(t,1)[0]:s.apply(E,ue([t],e))},d={func:Hn,args:[h],thisArg:E},p=f&&!a;if(i&&!r)return p?(o=o.clone(),o.__actions__.push(d),t.call(o)):s.call(E,this.value())[0];if(!i&&c){o=p?o:new Z(this);var l=t.apply(o,e);return l.__actions__.push(d),new y(l,r)}return this.thru(h)})}),ee(["join","pop","push","replace","shift","sort","splice","split","unshift"],function(t){var r=(/^(?:replace|split)$/.test(t)?Qs:Js)[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",i=/^(?:join|pop|replace|shift)$/.test(t);e.prototype[t]=function(){var t=arguments;return i&&!this.__chain__?r.apply(this.value(),t):this[n](function(e){return r.apply(e,t)})}}),Me(Z.prototype,function(t,r){var n=e[r];if(n){var i=n.name,s=Co[i]||(Co[i]=[]);s.push({name:r,func:n})}}),Co[Mr(E,P).name]=[{name:"wrapper",func:E}],Z.prototype.clone=et,Z.prototype.reverse=nt,Z.prototype.value=qt,e.prototype.chain=qn,e.prototype.commit=Vn,e.prototype.concat=ea,e.prototype.plant=Yn,e.prototype.reverse=Gn,e.prototype.toString=Wn,e.prototype.run=e.prototype.toJSON=e.prototype.valueOf=e.prototype.value=Xn,e.prototype.collect=e.prototype.map,e.prototype.head=e.prototype.first,e.prototype.select=e.prototype.filter,e.prototype.tail=e.prototype.rest,e}var E,A="3.10.1",x=1,P=2,O=4,B=8,M=16,R=32,T=64,C=128,N=256,j=30,U="...",L=150,D=16,z=200,F=1,K=2,H="Expected a function",q="__lodash_placeholder__",V="[object Arguments]",Y="[object Array]",G="[object Boolean]",W="[object Date]",X="[object Error]",J="[object Function]",Z="[object Map]",Q="[object Number]",$="[object Object]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object WeakMap]",it="[object ArrayBuffer]",st="[object Float32Array]",ot="[object Float64Array]",at="[object Int8Array]",ft="[object Int16Array]",ut="[object Int32Array]",ct="[object Uint8Array]",ht="[object Uint8ClampedArray]",dt="[object Uint16Array]",pt="[object Uint32Array]",lt=/\b__p \+= '';/g,bt=/\b(__p \+=) '' \+/g,gt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,mt=/&(?:amp|lt|gt|quot|#39|#96);/g,yt=/[&<>"'`]/g,vt=RegExp(mt.source),_t=RegExp(yt.source),wt=/<%-([\s\S]+?)%>/g,St=/<%([\s\S]+?)%>/g,It=/<%=([\s\S]+?)%>/g,kt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,Et=/^\w*$/,At=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,xt=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,Pt=RegExp(xt.source),Ot=/[\u0300-\u036f\ufe20-\ufe23]/g,Bt=/\\(\\)?/g,Mt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Rt=/\w*$/,Tt=/^0[xX]/,Ct=/^\[object .+?Constructor\]$/,Nt=/^\d+$/,jt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Ut=/($^)/,Lt=/['\n\r\u2028\u2029\\]/g,Dt=function(){var t="[A-Z\\xc0-\\xd6\\xd8-\\xde]",e="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(t+"+(?="+t+e+")|"+t+"?"+e+"|"+t+"+|[0-9]+","g")}(),zt=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","isFinite","parseFloat","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap"],Ft=-1,Kt={};Kt[st]=Kt[ot]=Kt[at]=Kt[ft]=Kt[ut]=Kt[ct]=Kt[ht]=Kt[dt]=Kt[pt]=!0,Kt[V]=Kt[Y]=Kt[it]=Kt[G]=Kt[W]=Kt[X]=Kt[J]=Kt[Z]=Kt[Q]=Kt[$]=Kt[tt]=Kt[et]=Kt[rt]=Kt[nt]=!1;var Ht={};Ht[V]=Ht[Y]=Ht[it]=Ht[G]=Ht[W]=Ht[st]=Ht[ot]=Ht[at]=Ht[ft]=Ht[ut]=Ht[Q]=Ht[$]=Ht[tt]=Ht[rt]=Ht[ct]=Ht[ht]=Ht[dt]=Ht[pt]=!0,Ht[X]=Ht[J]=Ht[Z]=Ht[et]=Ht[nt]=!1;var qt={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},Vt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Yt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Gt={"function":!0,object:!0},Wt={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Xt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Jt=Gt[typeof r]&&r&&!r.nodeType&&r,Zt=Gt[typeof e]&&e&&!e.nodeType&&e,Qt=Jt&&Zt&&"object"==typeof t&&t&&t.Object&&t,$t=Gt[typeof self]&&self&&self.Object&&self,te=Gt[typeof window]&&window&&window.Object&&window,ee=Zt&&Zt.exports===Jt&&Jt,re=Qt||te!==(this&&this.window)&&te||$t||this,ne=k();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(re._=ne,define(function(){return ne})):Jt&&Zt?ee?(Zt.exports=ne)._=ne:Jt._=ne:re._=ne}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],298:[function(t,e,r){(function(r){var n=t("./word-array"),i=function(){function t(){}return{extend:function(e){t.prototype=this;var r=new t;return e&&r.mixIn(e),r.hasOwnProperty("init")||(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),s=i.extend({reset:function(){this._data=new n,this._nDataBytes=0},_append:function(t){r.isBuffer(t)&&(t=n.fromBuffer(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,r=e.words,i=e.sigBytes,s=this.blockSize,o=4*s,a=i/o;a=t?Math.ceil(a):Math.max((0|a)-this._minBufferSize,0);var f=a*s,u=Math.min(4*f,i);if(f){for(var c=0;f>c;c+=s)this._doProcessBlock(r,c);var h=r.splice(0,f);e.sigBytes-=u}return new n(h,u)},clone:function(){var t=i.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),o=s.extend({cfg:i.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){s.reset.call(this),this._doReset()},update:function(t){return"string"==typeof t&&(t=n.fromBuffer(new r(t,"utf8"))),r.isBuffer(t)&&(t=n.fromBuffer(t)),this._append(t),this._process(),this},finalize:function(t){"string"==typeof t&&(t=n.fromBuffer(new r(t,"utf8"))),r.isBuffer(t)&&(t=n.fromBuffer(t)),t&&this._append(t);var e=this._doFinalize();return e.toBuffer()},blockSize:16,_createHelper:function(t){return function(e,r){return new t.init(r).finalize(e)}}});e.exports.Hasher=o}).call(this,t("buffer").Buffer)},{"./word-array":302,buffer:48}],299:[function(t,e,r){(function(r){function n(t){if(!(this instanceof n))return new n(t);var e=this._hasher=new i.init;"string"==typeof t&&(t=s.fromBuffer(new r(t,"utf8"))),r.isBuffer(t)&&(t=s.fromBuffer(t));var o=e.blockSize,a=4*o;t.sigBytes>a&&(t=e.finalize(t)),t.clamp();for(var f=this._oKey=t.clone(),u=this._iKey=t.clone(),c=f.words,h=u.words,d=0;o>d;d++)c[d]^=1549556828,h[d]^=909522486;f.sigBytes=u.sigBytes=a,this.reset()}var i=t("./sha512").sha512,s=t("./word-array");n.prototype.reset=function(){var t=this._hasher;t.reset(),t.update(this._iKey)},n.prototype.update=function(t){return"string"==typeof t&&(t=s.fromBuffer(new r(t,"utf8"))),r.isBuffer(t)&&(t=s.fromBuffer(t)),this._hasher.update(t),this},n.prototype.finalize=function(t){"string"==typeof t&&(t=s.fromBuffer(new r(t,"utf8"))),r.isBuffer(t)&&(t=s.fromBuffer(t));var e=this._hasher,n=e.finalize(t);e.reset();var i=e.finalize(this._oKey.clone().concat(n));return i},e.exports=n}).call(this,t("buffer").Buffer)},{"./sha512":301,"./word-array":302,buffer:48}],300:[function(t,e,r){e.exports=t("./sha512"),e.exports.hmac=t("./hmac")},{"./hmac":299,"./sha512":301}],301:[function(t,e,r){var n=t("./cryptojs").Hasher,i=t("./x64"),s=i.Word,o=i.WordArray,a=[s(1116352408,3609767458),s(1899447441,602891725),s(3049323471,3964484399),s(3921009573,2173295548),s(961987163,4081628472),s(1508970993,3053834265),s(2453635748,2937671579),s(2870763221,3664609560),s(3624381080,2734883394),s(310598401,1164996542),s(607225278,1323610764),s(1426881987,3590304994),s(1925078388,4068182383),s(2162078206,991336113),s(2614888103,633803317),s(3248222580,3479774868),s(3835390401,2666613458),s(4022224774,944711139),s(264347078,2341262773),s(604807628,2007800933),s(770255983,1495990901),s(1249150122,1856431235),s(1555081692,3175218132),s(1996064986,2198950837),s(2554220882,3999719339),s(2821834349,766784016),s(2952996808,2566594879),s(3210313671,3203337956),s(3336571891,1034457026),s(3584528711,2466948901),s(113926993,3758326383),s(338241895,168717936),s(666307205,1188179964),s(773529912,1546045734),s(1294757372,1522805485),s(1396182291,2643833823),s(1695183700,2343527390),s(1986661051,1014477480),s(2177026350,1206759142),s(2456956037,344077627),s(2730485921,1290863460),s(2820302411,3158454273),s(3259730800,3505952657),s(3345764771,106217008),s(3516065817,3606008344),s(3600352804,1432725776),s(4094571909,1467031594),s(275423344,851169720),s(430227734,3100823752),s(506948616,1363258195),s(659060556,3750685593),s(883997877,3785050280),s(958139571,3318307427),s(1322822218,3812723403),s(1537002063,2003034995),s(1747873779,3602036899),s(1955562222,1575990012),s(2024104815,1125592928),s(2227730452,2716904306),s(2361852424,442776044),s(2428436474,593698344),s(2756734187,3733110249),s(3204031479,2999351573),s(3329325298,3815920427),s(3391569614,3928383900),s(3515267271,566280711),s(3940187606,3454069534),s(4118630271,4000239992),s(116418474,1914138554),s(174292421,2731055270),s(289380356,3203993006),s(460393269,320620315),s(685471733,587496836),s(852142971,1086792851),s(1017036298,365543100),s(1126000580,2618297676),s(1288033470,3409855158),s(1501505948,4234509866),s(1607167915,987167468),s(1816402316,1246189591)],f=[];!function(){for(var t=0;80>t;t++)f[t]=s()}();var u=n.extend({_doReset:function(){this._hash=new o([s(1779033703,4089235720),s(3144134277,2227873595),s(1013904242,4271175723),s(2773480762,1595750129),s(1359893119,2917565137),s(2600822924,725511199),s(528734635,4215389547),s(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],o=r[3],u=r[4],c=r[5],h=r[6],d=r[7],p=n.high,l=n.low,b=i.high,g=i.low,m=s.high,y=s.low,v=o.high,_=o.low,w=u.high,S=u.low,I=c.high,k=c.low,E=h.high,A=h.low,x=d.high,P=d.low,O=p,B=l,M=b,R=g,T=m,C=y,N=v,j=_,U=w,L=S,D=I,z=k,F=E,K=A,H=x,q=P,V=0;80>V;V++){var Y=f[V];if(16>V)var G=Y.high=0|t[e+2*V],W=Y.low=0|t[e+2*V+1];else{var X=f[V-15],J=X.high,Z=X.low,Q=(J>>>1|Z<<31)^(J>>>8|Z<<24)^J>>>7,$=(Z>>>1|J<<31)^(Z>>>8|J<<24)^(Z>>>7|J<<25),tt=f[V-2],et=tt.high,rt=tt.low,nt=(et>>>19|rt<<13)^(et<<3|rt>>>29)^et>>>6,it=(rt>>>19|et<<13)^(rt<<3|et>>>29)^(rt>>>6|et<<26),st=f[V-7],ot=st.high,at=st.low,ft=f[V-16],ut=ft.high,ct=ft.low,W=$+at,G=Q+ot+($>>>0>W>>>0?1:0),W=W+it,G=G+nt+(it>>>0>W>>>0?1:0),W=W+ct,G=G+ut+(ct>>>0>W>>>0?1:0);Y.high=G,Y.low=W}var ht=U&D^~U&F,dt=L&z^~L&K,pt=O&M^O&T^M&T,lt=B&R^B&C^R&C,bt=(O>>>28|B<<4)^(O<<30|B>>>2)^(O<<25|B>>>7),gt=(B>>>28|O<<4)^(B<<30|O>>>2)^(B<<25|O>>>7),mt=(U>>>14|L<<18)^(U>>>18|L<<14)^(U<<23|L>>>9),yt=(L>>>14|U<<18)^(L>>>18|U<<14)^(L<<23|U>>>9),vt=a[V],_t=vt.high,wt=vt.low,St=q+yt,It=H+mt+(q>>>0>St>>>0?1:0),St=St+dt,It=It+ht+(dt>>>0>St>>>0?1:0),St=St+wt,It=It+_t+(wt>>>0>St>>>0?1:0),St=St+W,It=It+G+(W>>>0>St>>>0?1:0),kt=gt+lt,Et=bt+pt+(gt>>>0>kt>>>0?1:0);H=F,q=K,F=D,K=z,D=U,z=L,L=j+St|0,U=N+It+(j>>>0>L>>>0?1:0)|0,N=T,j=C,T=M,C=R,M=O,R=B,B=St+kt|0,O=It+Et+(St>>>0>B>>>0?1:0)|0}l=n.low=l+B,n.high=p+O+(B>>>0>l>>>0?1:0),g=i.low=g+R,i.high=b+M+(R>>>0>g>>>0?1:0),y=s.low=y+C,s.high=m+T+(C>>>0>y>>>0?1:0),_=o.low=_+j,o.high=v+N+(j>>>0>_>>>0?1:0),S=u.low=S+L,u.high=w+U+(L>>>0>S>>>0?1:0),k=c.low=k+z,c.high=I+D+(z>>>0>k>>>0?1:0),A=h.low=A+K,h.high=E+F+(K>>>0>A>>>0?1:0),P=d.low=P+q,d.high=x+H+(q>>>0>P>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;e[n>>>5]|=128<<24-n%32,e[(n+128>>>10<<5)+30]=Math.floor(r/4294967296),e[(n+128>>>10<<5)+31]=r,t.sigBytes=4*e.length,this._process();var i=this._hash.toX32();return i},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});e.exports=n._createHelper(u),e.exports.sha512=u},{"./cryptojs":298,"./x64":303}],302:[function(t,e,r){(function(t,r){function n(t,e){this.words=t||[],void 0!=e?this.sigBytes=e:this.sigBytes=4*this.words.length}e.exports=n,n.prototype.concat=function(t){r.isBuffer(t)&&(t=n.fromBuffer(t));var e=this.words,i=t.words,s=this.sigBytes,o=t.sigBytes;if(this.clamp(),s%4)for(var a=0;o>a;a++){var f=i[a>>>2]>>>24-a%4*8&255;e[s+a>>>2]|=f<<24-(s+a)%4*8}else if(i.length>65535)for(var a=0;o>a;a+=4)e[s+a>>>2]=i[a>>>2];else e.push.apply(e,i);return this.sigBytes+=o,this},n.prototype.clamp=function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=Math.ceil(e/4)},n.prototype.clone=function(){var t=new n(this.words.slice(0));return t},n.prototype.toBuffer=function(){for(var t=new r(4*this.words.length),e=0;eo;o+=4){var a=e.readUInt32BE(o);s.push(a)}for(var f=0,u=r-i,c=0;i>c;c+=1)f|=e.readUInt8(u+c)<<8*(3-c);return i>0&&s.push(f),new n(s,e.length)}for(var o=0;r>o;o+=4){var a=e.readUInt32BE(o,!0);s.push(a)}return new n(s,e.length)}}).call(this,t("_process"),t("buffer").Buffer)},{_process:247,buffer:48}],303:[function(t,e,r){function n(t,e){return this instanceof n?(this.high=t,void(this.low=e)):new n(t,e)}function i(t){this.words=t||[]}var s=t("./word-array");i.prototype.toX32=function(){for(var t=this.words,e=t.length,r=[],n=0;e>n;n++){var i=t[n];r.push(i.high),r.push(i.low)}return new s(r,this.sigBytes)},e.exports.Word=n,e.exports.WordArray=i},{"./word-array":302}],304:[function(t,e,r){e.exports={name:"bitcore-lib",version:"0.13.13",description:"A pure and powerful JavaScript Bitcoin library.",author:"BitPay ",main:"index.js",scripts:{lint:"gulp lint",test:"gulp test",coverage:"gulp coverage",build:"gulp"},contributors:[{name:"Daniel Cousens",email:"bitcoin@dcousens.com"},{name:"Esteban Ordano",email:"eordano@gmail.com"},{name:"Gordon Hall",email:"gordon@bitpay.com"},{name:"Jeff Garzik",email:"jgarzik@bitpay.com"},{name:"Kyle Drake",email:"kyle@kyledrake.net"},{name:"Manuel Araoz",email:"manuelaraoz@gmail.com"},{name:"Matias Alejo Garcia",email:"ematiu@gmail.com"},{name:"Ryan X. Charles",email:"ryanxcharles@gmail.com"},{name:"Stefan Thomas",email:"moon@justmoon.net"},{name:"Stephen Pair",email:"stephen@bitpay.com"},{name:"Wei Lu",email:"luwei.here@gmail.com"}],keywords:["bitcoin","transaction","address","p2p","ecies","cryptocurrency","blockchain","payment","bip21","bip32","bip37","bip69","bip70","multisig"],repository:{type:"git",url:"https://github.com/bitpay/bitcore-lib.git"},browser:{request:"browser-request"},dependencies:{"bn.js":"=2.0.4",bs58:"=2.0.0","buffer-compare":"=1.0.0",elliptic:"=3.0.3",inherits:"=2.0.1",lodash:"=3.10.1",sha512:"=0.0.1"},devDependencies:{"bitcore-build":"bitpay/bitcore-build",brfs:"^1.2.0",chai:"^1.10.0",gulp:"^3.8.10",sinon:"^1.13.0"},license:"MIT"}},{}],"bitcore-lib":[function(t,e,r){(function(r,n){"use strict";var i=e.exports;i.version="v"+t("./package.json").version,i.versionGuard=function(t){if(void 0!==t){var e="More than one instance of bitcore-lib found. Please make sure to require bitcore-lib and check that submodules do not also include their own bitcore-lib dependency.";throw new Error(e)}},i.versionGuard(r._bitcore),r._bitcore=i.version,i.crypto={},i.crypto.BN=t("./lib/crypto/bn"),i.crypto.ECDSA=t("./lib/crypto/ecdsa"),i.crypto.Hash=t("./lib/crypto/hash"),i.crypto.Random=t("./lib/crypto/random"),i.crypto.Point=t("./lib/crypto/point"),i.crypto.Signature=t("./lib/crypto/signature"),i.encoding={},i.encoding.Base58=t("./lib/encoding/base58"),i.encoding.Base58Check=t("./lib/encoding/base58check"),i.encoding.BufferReader=t("./lib/encoding/bufferreader"),i.encoding.BufferWriter=t("./lib/encoding/bufferwriter"),i.encoding.Varint=t("./lib/encoding/varint"),i.util={},i.util.buffer=t("./lib/util/buffer"),i.util.js=t("./lib/util/js"),i.util.preconditions=t("./lib/util/preconditions"),i.errors=t("./lib/errors"),i.Address=t("./lib/address"),i.Block=t("./lib/block"),i.MerkleBlock=t("./lib/block/merkleblock"),i.BlockHeader=t("./lib/block/blockheader"),i.HDPrivateKey=t("./lib/hdprivatekey.js"),i.HDPublicKey=t("./lib/hdpublickey.js"),i.Networks=t("./lib/networks"),i.Opcode=t("./lib/opcode"),i.PrivateKey=t("./lib/privatekey"),i.PublicKey=t("./lib/publickey"),i.Script=t("./lib/script"),i.Transaction=t("./lib/transaction"),i.URI=t("./lib/uri"),i.Unit=t("./lib/unit"),i.deps={},i.deps.bnjs=t("bn.js"),i.deps.bs58=t("bs58"),i.deps.Buffer=n,i.deps.elliptic=t("elliptic"),i.deps._=t("lodash"),i._HDKeyCache=t("./lib/hdkeycache"),i.Transaction.sighash=t("./lib/transaction/sighash")}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"./lib/address":1,"./lib/block":4,"./lib/block/blockheader":3,"./lib/block/merkleblock":5,"./lib/crypto/bn":6,"./lib/crypto/ecdsa":7,"./lib/crypto/hash":8,"./lib/crypto/point":9,"./lib/crypto/random":10,"./lib/crypto/signature":11,"./lib/encoding/base58":12,"./lib/encoding/base58check":13,"./lib/encoding/bufferreader":14,"./lib/encoding/bufferwriter":15,"./lib/encoding/varint":16,"./lib/errors":17,"./lib/hdkeycache":19,"./lib/hdprivatekey.js":20,"./lib/hdpublickey.js":21,"./lib/networks":22,"./lib/opcode":23,"./lib/privatekey":24,"./lib/publickey":25,"./lib/script":26,"./lib/transaction":29,"./lib/transaction/sighash":37,"./lib/unit":41,"./lib/uri":42,"./lib/util/buffer":43,"./lib/util/js":44,"./lib/util/preconditions":45,"./package.json":304,"bn.js":272,bs58:273,buffer:48,elliptic:275,lodash:297}]},{},[]); \ No newline at end of file diff --git a/public/assets/nedb.min.js b/public/assets/nedb.min.js new file mode 100644 index 00000000..b251dcbe --- /dev/null +++ b/public/assets/nedb.min.js @@ -0,0 +1,4 @@ +!function(t){if("function"==typeof bootstrap)bootstrap("nedb",t);else if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeNedb=t}else"undefined"!=typeof window?window.Nedb=t():global.Nedb=t()}(function(){var t;return function(t,e,n){function r(n,o){if(!e[n]){if(!t[n]){var a="function"==typeof require&&require;if(!o&&a)return a(n,!0);if(i)return i(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=e[n]={exports:{}};t[n][0].call(u.exports,function(e){var i=t[n][1][e];return r(i?i:e)},u,u.exports)}return e[n].exports}for(var i="function"==typeof require&&require,o=0;oi;i++)r[i].apply(this,n);return!0}return!1},o.prototype.addListener=function(t,e){if("function"!=typeof e)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",t,e),this._events[t])if(a(this._events[t])){if(!this._events[t].warned){var n;n=void 0!==this._events.maxListeners?this._events.maxListeners:u,n&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace())}this._events[t].push(e)}else this._events[t]=[this._events[t],e];else this._events[t]=e;return this},o.prototype.on=o.prototype.addListener,o.prototype.once=function(t,e){var n=this;return n.on(t,function r(){n.removeListener(t,r),e.apply(this,arguments)}),this},o.prototype.removeListener=function(t,e){if("function"!=typeof e)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var n=this._events[t];if(a(n)){var i=r(n,e);if(0>i)return this;n.splice(i,1),0==n.length&&delete this._events[t]}else this._events[t]===e&&delete this._events[t];return this},o.prototype.removeAllListeners=function(t){return 0===arguments.length?(this._events={},this):(t&&this._events&&this._events[t]&&(this._events[t]=null),this)},o.prototype.listeners=function(t){return this._events||(this._events={}),this._events[t]||(this._events[t]=[]),a(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]},o.listenerCount=function(t,e){var n;return n=t._events&&t._events[e]?"function"==typeof t._events[e]?1:t._events[e].length:0}},{__browserify_process:4}],2:[function(t,e,n){function r(t,e){for(var n=[],r=0;r=0;r--){var i=t[r];"."==i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}var o=t("__browserify_process"),a=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;n.resolve=function(){for(var t="",e=!1,n=arguments.length;n>=-1&&!e;n--){var a=n>=0?arguments[n]:o.cwd();"string"==typeof a&&a&&(t=a+"/"+t,e="/"===a.charAt(0))}return t=i(r(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."},n.normalize=function(t){var e="/"===t.charAt(0),n="/"===t.slice(-1);return t=i(r(t.split("/"),function(t){return!!t}),!e).join("/"),t||e||(t="."),t&&n&&(t+="/"),(e?"/":"")+t},n.join=function(){var t=Array.prototype.slice.call(arguments,0);return n.normalize(r(t,function(t){return t&&"string"==typeof t}).join("/"))},n.dirname=function(t){var e=a.exec(t)[1]||"",n=!1;return e?1===e.length||n&&e.length<=3&&":"===e.charAt(1)?e:e.substring(0,e.length-1):"."},n.basename=function(t,e){var n=a.exec(t)[2]||"";return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),n},n.extname=function(t){return a.exec(t)[3]||""},n.relative=function(t,e){function r(t){for(var e=0;e=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),o=r(e.split("/")),a=Math.min(i.length,o.length),u=a,s=0;a>s;s++)if(i[s]!==o[s]){u=s;break}for(var c=[],s=u;ss)return i(t)?h(""+t,"regexp"):h("[Object]","special");l.push(t);var w=d.map(function(e){var n,i;if(t.__lookupGetter__&&(t.__lookupGetter__(e)?i=t.__lookupSetter__(e)?h("[Getter/Setter]","special"):h("[Getter]","special"):t.__lookupSetter__(e)&&(i=h("[Setter]","special"))),p.indexOf(e)<0&&(n="["+e+"]"),i||(l.indexOf(t[e])<0?(i=null===s?f(t[e]):f(t[e],s-1),i.indexOf("\n")>-1&&(i=r(t)?i.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+i.split("\n").map(function(t){return" "+t}).join("\n"))):i=h("[Circular]","special")),"undefined"==typeof n){if("Array"===g&&e.match(/^\d+$/))return i;n=JSON.stringify(""+e),n.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(n=n.substr(1,n.length-2),n=h(n,"name")):(n=n.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),n=h(n,"string"))}return n+": "+i});l.pop();var _=0,k=w.reduce(function(t,e){return _++,e.indexOf("\n")>=0&&_++,t+e.length+1},0);return w=k>50?m[0]+(""===v?"":v+"\n ")+" "+w.join(",\n ")+" "+m[1]:m[0]+v+" "+w.join(", ")+" "+m[1]}var l=[],h=function(t,e){var n={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},r={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[e];return r?"["+n[r][0]+"m"+t+"["+n[r][1]+"m":t};return c||(h=function(t){return t}),f(t,"undefined"==typeof s?2:s)},n.log=function(){},n.pump=null;var a=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e},u=Object.getOwnPropertyNames||function(t){var e=[];for(var n in t)Object.hasOwnProperty.call(t,n)&&e.push(n);return e},s=Object.create||function(t,e){var n;if(null===t)n={__proto__:null};else{if("object"!=typeof t)throw new TypeError("typeof prototype["+typeof t+"] != 'object'");var r=function(){};r.prototype=t,n=new r,n.__proto__=t}return"undefined"!=typeof e&&Object.defineProperties&&Object.defineProperties(n,e),n};n.inherits=function(t,e){t.super_=e,t.prototype=s(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})};var c=/%[sdj%]/g;n.format=function(t){if("string"!=typeof t){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":return JSON.stringify(i[r++]);default:return t}}),u=i[r];o>r;u=i[++r])a+=null===u||"object"!=typeof u?" "+u:" "+n.inspect(u);return a}},{events:1}],4:[function(t,e){var n=e.exports={};n.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")}},{}],5:[function(t,e){function n(t,e,n){this.db=t,this.query=e||{},n&&(this.execFn=n)}var r=t("./model"),i=t("underscore");n.prototype.limit=function(t){return this._limit=t,this},n.prototype.skip=function(t){return this._skip=t,this},n.prototype.sort=function(t){return this._sort=t,this},n.prototype.projection=function(t){return this._projection=t,this},n.prototype.project=function(t){var e,n,o,a=[],u=this;return void 0===this._projection||0===Object.keys(this._projection).length?t:(e=0===this._projection._id?!1:!0,this._projection=i.omit(this._projection,"_id"),o=Object.keys(this._projection),o.forEach(function(t){if(void 0!==n&&u._projection[t]!==n)throw new Error("Can't both keep and omit fields except for _id");n=u._projection[t]}),t.forEach(function(t){var i;1===n?(i={$set:{}},o.forEach(function(e){i.$set[e]=r.getDotValue(t,e),void 0===i.$set[e]&&delete i.$set[e]}),i=r.modify({},i)):(i={$unset:{}},o.forEach(function(t){i.$unset[t]=!0}),i=r.modify(t,i)),e?i._id=t._id:delete i._id,a.push(i)}),a)},n.prototype._exec=function(t){function e(e,n){return c.execFn?c.execFn(e,n,t):t(e,n)}var n,i,o,a=[],u=0,s=0,c=this,f=null;this.db.getCandidates(this.query,function(t,l){if(t)return e(t);try{for(n=0;ns)s+=1;else if(a.push(l[n]),u+=1,c._limit&&c._limit<=u)break}catch(t){return e(t)}if(c._sort){i=Object.keys(c._sort);var h=[];for(n=0;nr;r++)0==(3&r)&&(e=4294967296*Math.random()),n[r]=255&e>>>((3&r)<<3);return n}function r(t){function e(t){return o[63&t>>18]+o[63&t>>12]+o[63&t>>6]+o[63&t]}var n,r,i,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=t.length%3,u="";for(i=0,r=t.length-a;r>i;i+=3)n=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=e(n);switch(a){case 1:n=t[t.length-1],u+=o[n>>2],u+=o[63&n<<4],u+="==";break;case 2:n=(t[t.length-2]<<8)+t[t.length-1],u+=o[n>>10],u+=o[63&n>>4],u+=o[63&n<<2],u+="="}return u}function i(t){return r(n(Math.ceil(Math.max(8,2*t)))).replace(/[+\/]/g,"").slice(0,t)}e.exports.uid=i},{}],7:[function(t,e){function n(t){var e;"string"==typeof t?(e=t,this.inMemoryOnly=!1):(t=t||{},e=t.filename,this.inMemoryOnly=t.inMemoryOnly||!1,this.autoload=t.autoload||!1,this.timestampData=t.timestampData||!1),e&&"string"==typeof e&&0!==e.length?this.filename=e:(this.filename=null,this.inMemoryOnly=!0),this.compareStrings=t.compareStrings,this.persistence=new f({db:this,nodeWebkitAppName:t.nodeWebkitAppName,afterSerialization:t.afterSerialization,beforeDeserialization:t.beforeDeserialization,corruptAlertThreshold:t.corruptAlertThreshold}),this.executor=new a,this.inMemoryOnly&&(this.executor.ready=!0),this.indexes={},this.indexes._id=new u({fieldName:"_id",unique:!0}),this.ttlIndexes={},this.autoload&&this.loadDatabase(t.onload||function(t){if(t)throw t})}var r=t("./customUtils"),i=t("./model"),o=t("async"),a=t("./executor"),u=t("./indexes"),s=t("util"),c=t("underscore"),f=t("./persistence"),l=t("./cursor");s.inherits(n,t("events").EventEmitter),n.prototype.loadDatabase=function(){this.executor.push({"this":this.persistence,fn:this.persistence.loadDatabase,arguments:arguments},!0)},n.prototype.getAllData=function(){return this.indexes._id.getAll()},n.prototype.resetIndexes=function(t){var e=this;Object.keys(this.indexes).forEach(function(n){e.indexes[n].reset(t)})},n.prototype.ensureIndex=function(t,e){var n,r=e||function(){};if(t=t||{},!t.fieldName)return n=new Error("Cannot create an index without a fieldName"),n.missingFieldName=!0,r(n);if(this.indexes[t.fieldName])return r(null);this.indexes[t.fieldName]=new u(t),void 0!==t.expireAfterSeconds&&(this.ttlIndexes[t.fieldName]=t.expireAfterSeconds);try{this.indexes[t.fieldName].insert(this.getAllData())}catch(i){return delete this.indexes[t.fieldName],r(i)}this.persistence.persistNewState([{$$indexCreated:t}],function(t){return t?r(t):r(null)})},n.prototype.removeIndex=function(t,e){var n=e||function(){};delete this.indexes[t],this.persistence.persistNewState([{$$indexRemoved:t}],function(t){return t?n(t):n(null)})},n.prototype.addToIndexes=function(t){var e,n,r,i=Object.keys(this.indexes);for(e=0;ee;e+=1)this.indexes[i[e]].remove(t);throw r}},n.prototype.removeFromIndexes=function(t){var e=this;Object.keys(this.indexes).forEach(function(n){e.indexes[n].remove(t)})},n.prototype.updateIndexes=function(t,e){var n,r,i,o=Object.keys(this.indexes);for(n=0;nn;n+=1)this.indexes[o[n]].revertUpdate(t,e);throw i}},n.prototype.getCandidates=function(t,e,n){var r,i=Object.keys(this.indexes),a=this;"function"==typeof e&&(n=e,e=!1),o.waterfall([function(e){return r=[],Object.keys(t).forEach(function(e){("string"==typeof t[e]||"number"==typeof t[e]||"boolean"==typeof t[e]||s.isDate(t[e])||null===t[e])&&r.push(e)}),r=c.intersection(r,i),r.length>0?e(null,a.indexes[r[0]].getMatching(t[r[0]])):(r=[],Object.keys(t).forEach(function(e){t[e]&&t[e].hasOwnProperty("$in")&&r.push(e)}),r=c.intersection(r,i),r.length>0?e(null,a.indexes[r[0]].getMatching(t[r[0]].$in)):(r=[],Object.keys(t).forEach(function(e){t[e]&&(t[e].hasOwnProperty("$lt")||t[e].hasOwnProperty("$lte")||t[e].hasOwnProperty("$gt")||t[e].hasOwnProperty("$gte"))&&r.push(e)}),r=c.intersection(r,i),r.length>0?e(null,a.indexes[r[0]].getBetweenBounds(t[r[0]])):e(null,a.getAllData())))},function(t){if(e)return n(null,t);var r=[],i=[],u=Object.keys(a.ttlIndexes);t.forEach(function(t){var e=!0;u.forEach(function(n){void 0!==t[n]&&s.isDate(t[n])&&Date.now()>t[n].getTime()+1e3*a.ttlIndexes[n]&&(e=!1)}),e?i.push(t):r.push(t._id)}),o.eachSeries(r,function(t,e){a._remove({_id:t},{},function(t){return t?n(t):e()})},function(){return n(null,i)})}])},n.prototype._insert=function(t,e){var n,r=e||function(){};try{n=this.prepareDocumentForInsertion(t),this._insertInCache(n)}catch(o){return r(o)}this.persistence.persistNewState(s.isArray(n)?n:[n],function(t){return t?r(t):r(null,i.deepCopy(n))})},n.prototype.createNewId=function(){var t=r.uid(16);return this.indexes._id.getMatching(t).length>0&&(t=this.createNewId()),t},n.prototype.prepareDocumentForInsertion=function(t){var e,n=this;if(s.isArray(t))e=[],t.forEach(function(t){e.push(n.prepareDocumentForInsertion(t))});else{e=i.deepCopy(t),void 0===e._id&&(e._id=this.createNewId());var r=new Date;this.timestampData&&void 0===e.createdAt&&(e.createdAt=r),this.timestampData&&void 0===e.updatedAt&&(e.updatedAt=r),i.checkObject(e)}return e},n.prototype._insertInCache=function(t){s.isArray(t)?this._insertMultipleDocsInCache(t):this.addToIndexes(t)},n.prototype._insertMultipleDocsInCache=function(t){var e,n,r;for(e=0;ee;e+=1)this.removeFromIndexes(t[e]);throw r}},n.prototype.insert=function(){this.executor.push({"this":this,fn:this._insert,arguments:arguments})},n.prototype.count=function(t,e){var n=new l(this,t,function(t,e,n){return t?n(t):n(null,e.length)});return"function"!=typeof e?n:(n.exec(e),void 0)},n.prototype.find=function(t,e,n){switch(arguments.length){case 1:e={};break;case 2:"function"==typeof e&&(n=e,e={})}var r=new l(this,t,function(t,e,n){var r,o=[];if(t)return n(t);for(r=0;ri;i+=1)this.tree.delete(n[i],t);throw c}}else this.tree.insert(e,t)},i.prototype.insertMultipleDocs=function(t){var e,n,r;for(e=0;ee;e+=1)this.remove(t[e]);throw n}},i.prototype.remove=function(t){var e,n=this;return s.isArray(t)?(t.forEach(function(t){n.remove(t)}),void 0):(e=a.getDotValue(t,this.fieldName),void 0===e&&this.sparse||(s.isArray(e)?u.uniq(e,r).forEach(function(e){n.tree.delete(e,t)}):this.tree.delete(e,t)),void 0)},i.prototype.update=function(t,e){if(s.isArray(t))return this.updateMultipleDocs(t),void 0;this.remove(t);try{this.insert(e)}catch(n){throw this.insert(t),n}},i.prototype.updateMultipleDocs=function(t){var e,n,r;for(e=0;ee;e+=1)this.remove(t[e].newDoc);for(e=0;et?-1:t>e?1:0}function c(t,e){var n,r;for(n=0;n0){for(i=0;i=3||2===Object.keys(n).length&&void 0===n.$slice)throw new Error("Can only use $slice in cunjunction with $each when $push to array");if(!m.isArray(n.$each))throw new Error("$each requires an array value");if(n.$each.forEach(function(n){t[e].push(n)}),void 0===n.$slice||"number"!=typeof n.$slice)return;if(0===n.$slice)t[e]=[];else{var r,i,o=t[e].length;n.$slice<0?(r=Math.max(0,o+n.$slice),i=o):n.$slice>0&&(r=0,i=Math.min(o,n.$slice)),t[e]=t[e].slice(r,i)}}else t[e].push(n)},_.$addToSet=function(t,e,n){var r=!0;if(t.hasOwnProperty(e)||(t[e]=[]),!m.isArray(t[e]))throw new Error("Can't $addToSet an element on non-array values");if(null!==n&&"object"==typeof n&&n.$each){if(Object.keys(n).length>1)throw new Error("Can't use another field in conjunction with $each");if(!m.isArray(n.$each))throw new Error("$each requires an array value");n.$each.forEach(function(n){_.$addToSet(t,e,n)})}else t[e].forEach(function(t){0===f(t,n)&&(r=!1)}),r&&t[e].push(n)},_.$pop=function(t,e,n){if(!m.isArray(t[e]))throw new Error("Can't $pop an element from non-array values");if("number"!=typeof n)throw new Error(n+" isn't an integer, can't use it with $pop");0!==n&&(t[e]=n>0?t[e].slice(0,t[e].length-1):t[e].slice(1))},_.$pull=function(t,e,n){var r,i;if(!m.isArray(t[e]))throw new Error("Can't $pull an element from non-array values");for(r=t[e],i=r.length-1;i>=0;i-=1)v(r[i],n)&&r.splice(i,1)},_.$inc=function(t,e,n){if("number"!=typeof n)throw new Error(n+" must be a number");if("number"!=typeof t[e]){if(b.has(t,e))throw new Error("Don't use the $inc modifier on non-number fields");t[e]=n}else t[e]+=n},_.$max=function(t,e,n){"undefined"==typeof t[e]?t[e]=n:n>t[e]&&(t[e]=n)},_.$min=function(t,e,n){"undefined"==typeof t[e]?t[e]=n:nt},k.$lte=function(t,e){return y(t,e)&&e>=t},k.$gt=function(t,e){return y(t,e)&&t>e},k.$gte=function(t,e){return y(t,e)&&t>=e},k.$ne=function(t,e){return void 0===t?!0:!d(t,e)},k.$in=function(t,e){var n;if(!m.isArray(e))throw new Error("$in operator called with a non-array");for(n=0;ne;e+=1)for(r=0;10>r;r+=1)if(i=s.uid(e),this.beforeDeserialization(this.afterSerialization(i))!==i)throw new Error("beforeDeserialization is not the reverse of afterSerialization, cautiously refusing to start NeDB to prevent dataloss");this.filename&&t.nodeWebkitAppName&&(console.log("=================================================================="),console.log("WARNING: The nodeWebkitAppName option is deprecated"),console.log("To get the path to the directory where Node Webkit stores the data"),console.log("for your app, use the internal nw.gui module like this"),console.log("require('nw.gui').App.dataPath"),console.log("See https://github.com/rogerwang/node-webkit/issues/500"),console.log("=================================================================="),this.filename=n.getNWAppFilename(t.nodeWebkitAppName,this.filename))}var r=t("__browserify_process"),i=t("./storage"),o=t("path"),a=t("./model"),u=t("async"),s=t("./customUtils"),c=t("./indexes");n.ensureDirectoryExists=function(t,e){var n=e||function(){};i.mkdirp(t,function(t){return n(t)})},n.getNWAppFilename=function(t,e){var n;switch(r.platform){case"win32":case"win64":if(n=r.env.LOCALAPPDATA||r.env.APPDATA,!n)throw new Error("Couldn't find the base application data folder");n=o.join(n,t);break;case"darwin":if(n=r.env.HOME,!n)throw new Error("Couldn't find the base application data directory");n=o.join(n,"Library","Application Support",t);break;case"linux":if(n=r.env.HOME,!n)throw new Error("Couldn't find the base application data directory");n=o.join(n,".config",t);break;default:throw new Error("Can't use the Node Webkit relative path for platform "+r.platform)}return o.join(n,"nedb-data",e)},n.prototype.persistCachedDatabase=function(t){var e=t||function(){},n="",r=this;return this.inMemoryOnly?e(null):(this.db.getAllData().forEach(function(t){n+=r.afterSerialization(a.serialize(t))+"\n"}),Object.keys(this.db.indexes).forEach(function(t){"_id"!=t&&(n+=r.afterSerialization(a.serialize({$$indexCreated:{fieldName:t,unique:r.db.indexes[t].unique,sparse:r.db.indexes[t].sparse}}))+"\n")}),i.crashSafeWriteFile(this.filename,n,function(t){return t?e(t):(r.db.emit("compaction.done"),e(null))}),void 0)},n.prototype.compactDatafile=function(){this.db.executor.push({"this":this,fn:this.persistCachedDatabase,arguments:[]})},n.prototype.setAutocompactionInterval=function(t){var e=this,n=5e3,r=Math.max(t||0,n);this.stopAutocompaction(),this.autocompactionIntervalId=setInterval(function(){e.compactDatafile()},r)},n.prototype.stopAutocompaction=function(){this.autocompactionIntervalId&&clearInterval(this.autocompactionIntervalId)},n.prototype.persistNewState=function(t,e){var n=this,r="",o=e||function(){};return n.inMemoryOnly?o(null):(t.forEach(function(t){r+=n.afterSerialization(a.serialize(t))+"\n"}),0===r.length?o(null):(i.appendFile(n.filename,r,"utf8",function(t){return o(t)}),void 0))},n.prototype.treatRawData=function(t){var e,n=t.split("\n"),r={},i=[],o={},u=-1;for(e=0;e0&&u/n.length>this.corruptAlertThreshold)throw new Error("More than "+Math.floor(100*this.corruptAlertThreshold)+"% of the data file is corrupt, the wrong beforeDeserialization hook may be used. Cautiously refusing to start NeDB to prevent dataloss");return Object.keys(r).forEach(function(t){i.push(r[t])}),{data:i,indexes:o}},n.prototype.loadDatabase=function(t){var e=t||function(){},r=this;return r.db.resetIndexes(),r.inMemoryOnly?e(null):(u.waterfall([function(t){n.ensureDirectoryExists(o.dirname(r.filename),function(){i.ensureDatafileIntegrity(r.filename,function(){i.readFile(r.filename,"utf8",function(e,n){if(e)return t(e);try{var i=r.treatRawData(n)}catch(o){return t(o)}Object.keys(i.indexes).forEach(function(t){r.db.indexes[t]=new c(i.indexes[t])});try{r.db.resetIndexes(i.data)}catch(o){return r.db.resetIndexes(),t(o)}r.db.persistence.persistCachedDatabase(t)})})})}],function(t){return t?e(t):(r.db.executor.processBuffer(),e(null))}),void 0)},e.exports=n},{"./customUtils":6,"./indexes":9,"./model":10,"./storage":12,__browserify_process:4,async:13,path:2}],12:[function(t,e){function n(t,e){f.getItem(t,function(t,n){return null!==n?e(!0):e(!1)})}function r(t,e,n){f.getItem(t,function(r,i){null===i?f.removeItem(e,function(){return n()}):f.setItem(e,i,function(){f.removeItem(t,function(){return n()})})})}function i(t,e,n,r){"function"==typeof n&&(r=n),f.setItem(t,e,function(){return r()})}function o(t,e,n,r){"function"==typeof n&&(r=n),f.getItem(t,function(n,i){i=i||"",i+=e,f.setItem(t,i,function(){return r()})})}function a(t,e,n){"function"==typeof e&&(n=e),f.getItem(t,function(t,e){return n(null,e||"")})}function u(t,e){f.removeItem(t,function(){return e()})}function s(t,e){return e()}function c(t,e){return e(null)}var f=t("localforage");f.config({name:"NeDB",storeName:"nedbdata"}),e.exports.exists=n,e.exports.rename=r,e.exports.writeFile=i,e.exports.crashSafeWriteFile=i,e.exports.appendFile=o,e.exports.readFile=a,e.exports.unlink=u,e.exports.mkdirp=s,e.exports.ensureDatafileIntegrity=c},{localforage:18}],13:[function(e,n){var r=e("__browserify_process");!function(){function e(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(i,arguments)}}var i,o,a={};i=this,null!=i&&(o=i.async),a.noConflict=function(){return i.async=o,a};var u=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n=t.length&&r(null))}))})},a.forEach=a.each,a.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n(null):i())})};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,n,r){var i=l(e);i.apply(null,[t,n,r])},a.forEachLimit=a.eachLimit;var l=function(t){return function(e,n,r){if(r=r||function(){},!e.length||0>=t)return r();var i=0,o=0,a=0;!function u(){if(i>=e.length)return r();for(;t>a&&o=e.length?r():u())})}()}},h=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},p=function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(n))}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},y=function(t,e,n,r){var i=[];e=s(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n,r){i[t.index]=r,e(n)})},function(t){r(t,i)})};a.map=h(y),a.mapSeries=d(y),a.mapLimit=function(t,e,n,r){return v(e)(t,n,r)};var v=function(t){return p(t,y)};a.reduce=function(t,e,n,r){a.eachSeries(t,function(t,r){n(e,t,function(t,n){e=n,r(t)})},function(t){r(t,e)})},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,n,r){var i=s(t,function(t){return t}).reverse();a.reduce(i,e,n,r)},a.foldr=a.reduceRight;var g=function(t,e,n,r){var i=[];e=s(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n&&i.push(t),e()})},function(){r(s(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};a.filter=h(g),a.filterSeries=d(g),a.select=a.filter,a.selectSeries=a.filterSeries;var m=function(t,e,n,r){var i=[];e=s(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n||i.push(t),e()})},function(){r(s(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};a.reject=h(m),a.rejectSeries=d(m);var b=function(t,e,n,r){t(e,function(t,e){n(t,function(n){n?(r(t),r=function(){}):e()})},function(){r()})};a.detect=h(b),a.detectSeries=d(b),a.some=function(t,e,n){a.each(t,function(t,r){e(t,function(t){t&&(n(!0),n=function(){}),r()})},function(){n(!1)})},a.any=a.some,a.every=function(t,e,n){a.each(t,function(t,r){e(t,function(t){t||(n(!1),n=function(){}),r()})},function(){n(!0)})},a.all=a.every,a.sortBy=function(t,e,n){a.map(t,function(t,n){e(t,function(e,r){e?n(e):n(null,{value:t,criteria:r})})},function(t,e){if(t)return n(t);var r=function(t,e){var n=t.criteria,r=e.criteria;return r>n?-1:n>r?1:0};n(null,s(e.sort(r),function(t){return t.value}))})},a.auto=function(t,e){e=e||function(){};var n=f(t);if(!n.length)return e(null);var r={},i=[],o=function(t){i.unshift(t)},s=function(t){for(var e=0;ee;e++)t[e].apply(null,arguments)}])))};return i.memo=n,i.unmemoized=t,i},a.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},a.times=function(t,e,n){for(var r=[],i=0;t>i;i++)r.push(i);return a.map(r,e,n)},a.timesSeries=function(t,e,n){for(var r=[],i=0;t>i;i++)r.push(i);return a.mapSeries(r,e,n)},a.compose=function(){var t=Array.prototype.reverse.call(arguments);return function(){var e=this,n=Array.prototype.slice.call(arguments),r=n.pop();a.reduce(t,n,function(t,n,r){n.apply(e,t.concat([function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);r(t,e)}]))},function(t,n){r.apply(e,[t].concat(n))})}};var x=function(t,e){var n=function(){var n=this,r=Array.prototype.slice.call(arguments),i=r.pop();return t(e,function(t,e){t.apply(n,r.concat([e]))},i)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};a.applyEach=h(x),a.applyEachSeries=d(x),a.forever=function(t,e){function n(r){if(r){if(e)return e(r);throw r}t(n)}n()},"undefined"!=typeof t&&t.amd?t([],function(){return a}):"undefined"!=typeof n&&n.exports?n.exports=a:i.async=a}()},{__browserify_process:4}],14:[function(t,e){e.exports.BinarySearchTree=t("./lib/bst"),e.exports.AVLTree=t("./lib/avltree")},{"./lib/avltree":15,"./lib/bst":16}],15:[function(t,e){function n(t){this.tree=new r(t)}function r(t){t=t||{},this.left=null,this.right=null,this.parent=void 0!==t.parent?t.parent:null,t.hasOwnProperty("key")&&(this.key=t.key),this.data=t.hasOwnProperty("value")?[t.value]:[],this.unique=t.unique||!1,this.compareKeys=t.compareKeys||o.defaultCompareKeysFunction,this.checkValueEquality=t.checkValueEquality||o.defaultCheckValueEquality}var i=t("./bst"),o=t("./customUtils"),a=t("util");t("underscore"),a.inherits(r,i),n._AVLTree=r,r.prototype.checkHeightCorrect=function(){var t,e;if(this.hasOwnProperty("key")){if(this.left&&void 0===this.left.height)throw new Error("Undefined height for node "+this.left.key);if(this.right&&void 0===this.right.height)throw new Error("Undefined height for node "+this.right.key);if(void 0===this.height)throw new Error("Undefined height for node "+this.key);if(t=this.left?this.left.height:0,e=this.right?this.right.height:0,this.height!==1+Math.max(t,e))throw new Error("Height constraint failed for node "+this.key);this.left&&this.left.checkHeightCorrect(),this.right&&this.right.checkHeightCorrect()}},r.prototype.balanceFactor=function(){var t=this.left?this.left.height:0,e=this.right?this.right.height:0;return t-e},r.prototype.checkBalanceFactors=function(){if(Math.abs(this.balanceFactor())>1)throw new Error("Tree is unbalanced at node "+this.key);this.left&&this.left.checkBalanceFactors(),this.right&&this.right.checkBalanceFactors()},r.prototype.checkIsAVLT=function(){r.super_.prototype.checkIsBST.call(this),this.checkHeightCorrect(),this.checkBalanceFactors()},n.prototype.checkIsAVLT=function(){this.tree.checkIsAVLT()},r.prototype.rightRotation=function(){var t,e,n,r,i=this,o=this.left;return o?(t=o.right,i.parent?(o.parent=i.parent,i.parent.left===i?i.parent.left=o:i.parent.right=o):o.parent=null,o.right=i,i.parent=o,i.left=t,t&&(t.parent=i),e=o.left?o.left.height:0,n=t?t.height:0,r=i.right?i.right.height:0,i.height=Math.max(n,r)+1,o.height=Math.max(e,i.height)+1,o):this},r.prototype.leftRotation=function(){var t,e,n,r,i=this,o=this.right;return o?(t=o.left,i.parent?(o.parent=i.parent,i.parent.left===i?i.parent.left=o:i.parent.right=o):o.parent=null,o.left=i,i.parent=o,i.right=t,t&&(t.parent=i),e=i.left?i.left.height:0,n=t?t.height:0,r=o.right?o.right.height:0,i.height=Math.max(e,n)+1,o.height=Math.max(r,i.height)+1,o):this},r.prototype.rightTooSmall=function(){return this.balanceFactor()<=1?this:(this.left.balanceFactor()<0&&this.left.leftRotation(),this.rightRotation())},r.prototype.leftTooSmall=function(){return this.balanceFactor()>=-1?this:(this.right.balanceFactor()>0&&this.right.rightRotation(),this.leftRotation())},r.prototype.rebalanceAlongPath=function(t){var e,n,r=this;if(!this.hasOwnProperty("key"))return delete this.height,this;for(n=t.length-1;n>=0;n-=1)t[n].height=1+Math.max(t[n].left?t[n].left.height:0,t[n].right?t[n].right.height:0),t[n].balanceFactor()>1&&(e=t[n].rightTooSmall(),0===n&&(r=e)),t[n].balanceFactor()<-1&&(e=t[n].leftTooSmall(),0===n&&(r=e));return r},r.prototype.insert=function(t,e){var n=[],r=this;if(!this.hasOwnProperty("key"))return this.key=t,this.data.push(e),this.height=1,this;for(;;){if(0===r.compareKeys(r.key,t)){if(r.unique){var i=new Error("Can't insert key "+t+", it violates the unique constraint");throw i.key=t,i.errorType="uniqueViolated",i}return r.data.push(e),this}if(n.push(r),r.compareKeys(t,r.key)<0){if(!r.left){n.push(r.createLeftChild({key:t,value:e}));break}r=r.left}else{if(!r.right){n.push(r.createRightChild({key:t,value:e}));break}r=r.right}}return this.rebalanceAlongPath(n)},n.prototype.insert=function(t,e){var n=this.tree.insert(t,e);n&&(this.tree=n)},r.prototype.delete=function(t,e){var n,r=[],i=this,o=[];if(!this.hasOwnProperty("key"))return this;for(;;){if(0===i.compareKeys(t,i.key))break;if(o.push(i),i.compareKeys(t,i.key)<0){if(!i.left)return this;i=i.left}else{if(!i.right)return this;i=i.right}}if(i.data.length>1&&e)return i.data.forEach(function(t){i.checkValueEquality(t,e)||r.push(t)}),i.data=r,this;if(!i.left&&!i.right)return i===this?(delete i.key,i.data=[],delete i.height,this):(i.parent.left===i?i.parent.left=null:i.parent.right=null,this.rebalanceAlongPath(o));if(!i.left||!i.right)return n=i.left?i.left:i.right,i===this?(n.parent=null,n):(i.parent.left===i?(i.parent.left=n,n.parent=i.parent):(i.parent.right=n,n.parent=i.parent),this.rebalanceAlongPath(o));if(o.push(i),n=i.left,!n.right)return i.key=n.key,i.data=n.data,i.left=n.left,n.left&&(n.left.parent=i),this.rebalanceAlongPath(o);for(;;){if(!n.right)break;o.push(n),n=n.right}return i.key=n.key,i.data=n.data,n.parent.right=n.left,n.left&&(n.left.parent=n.parent),this.rebalanceAlongPath(o)},n.prototype.delete=function(t,e){var n=this.tree.delete(t,e);n&&(this.tree=n)},["getNumberOfKeys","search","betweenBounds","prettyPrint","executeOnEveryNode"].forEach(function(t){n.prototype[t]=function(){return this.tree[t].apply(this.tree,arguments)}}),e.exports=n},{"./bst":16,"./customUtils":17,underscore:19,util:3}],16:[function(t,e){function n(t){t=t||{},this.left=null,this.right=null,this.parent=void 0!==t.parent?t.parent:null,t.hasOwnProperty("key")&&(this.key=t.key),this.data=t.hasOwnProperty("value")?[t.value]:[],this.unique=t.unique||!1,this.compareKeys=t.compareKeys||i.defaultCompareKeysFunction,this.checkValueEquality=t.checkValueEquality||i.defaultCheckValueEquality}function r(t,e){var n;for(n=0;n=0)throw new Error("Tree with root "+t.key+" is not a binary search tree")}),this.left.checkNodeOrdering()),this.right&&(this.right.checkAllNodesFullfillCondition(function(e){if(t.compareKeys(e,t.key)<=0)throw new Error("Tree with root "+t.key+" is not a binary search tree")}),this.right.checkNodeOrdering()))},n.prototype.checkInternalPointers=function(){if(this.left){if(this.left.parent!==this)throw new Error("Parent pointer broken for key "+this.key);this.left.checkInternalPointers()}if(this.right){if(this.right.parent!==this)throw new Error("Parent pointer broken for key "+this.key);this.right.checkInternalPointers()}},n.prototype.checkIsBST=function(){if(this.checkNodeOrdering(),this.checkInternalPointers(),this.parent)throw new Error("The root shouldn't have a parent")},n.prototype.getNumberOfKeys=function(){var t;return this.hasOwnProperty("key")?(t=1,this.left&&(t+=this.left.getNumberOfKeys()),this.right&&(t+=this.right.getNumberOfKeys()),t):0},n.prototype.createSimilar=function(t){return t=t||{},t.unique=this.unique,t.compareKeys=this.compareKeys,t.checkValueEquality=this.checkValueEquality,new this.constructor(t)},n.prototype.createLeftChild=function(t){var e=this.createSimilar(t);return e.parent=this,this.left=e,e},n.prototype.createRightChild=function(t){var e=this.createSimilar(t);return e.parent=this,this.right=e,e},n.prototype.insert=function(t,e){if(!this.hasOwnProperty("key"))return this.key=t,this.data.push(e),void 0;if(0===this.compareKeys(this.key,t)){if(this.unique){var n=new Error("Can't insert key "+t+", it violates the unique constraint");throw n.key=t,n.errorType="uniqueViolated",n}return this.data.push(e),void 0}this.compareKeys(t,this.key)<0?this.left?this.left.insert(t,e):this.createLeftChild({key:t,value:e}):this.right?this.right.insert(t,e):this.createRightChild({key:t,value:e})},n.prototype.search=function(t){return this.hasOwnProperty("key")?0===this.compareKeys(this.key,t)?this.data:this.compareKeys(t,this.key)<0?this.left?this.left.search(t):[]:this.right?this.right.search(t):[]:[]},n.prototype.getLowerBoundMatcher=function(t){var e=this;return t.hasOwnProperty("$gt")||t.hasOwnProperty("$gte")?t.hasOwnProperty("$gt")&&t.hasOwnProperty("$gte")?0===e.compareKeys(t.$gte,t.$gt)?function(n){return e.compareKeys(n,t.$gt)>0}:e.compareKeys(t.$gte,t.$gt)>0?function(n){return e.compareKeys(n,t.$gte)>=0}:function(n){return e.compareKeys(n,t.$gt)>0}:t.hasOwnProperty("$gt")?function(n){return e.compareKeys(n,t.$gt)>0}:function(n){return e.compareKeys(n,t.$gte)>=0}:function(){return!0}},n.prototype.getUpperBoundMatcher=function(t){var e=this;return t.hasOwnProperty("$lt")||t.hasOwnProperty("$lte")?t.hasOwnProperty("$lt")&&t.hasOwnProperty("$lte")?0===e.compareKeys(t.$lte,t.$lt)?function(n){return e.compareKeys(n,t.$lt)<0}:e.compareKeys(t.$lte,t.$lt)<0?function(n){return e.compareKeys(n,t.$lte)<=0}:function(n){return e.compareKeys(n,t.$lt)<0}:t.hasOwnProperty("$lt")?function(n){return e.compareKeys(n,t.$lt)<0}:function(n){return e.compareKeys(n,t.$lte)<=0}:function(){return!0}},n.prototype.betweenBounds=function(t,e,n){var i=[];return this.hasOwnProperty("key")?(e=e||this.getLowerBoundMatcher(t),n=n||this.getUpperBoundMatcher(t),e(this.key)&&this.left&&r(i,this.left.betweenBounds(t,e,n)),e(this.key)&&n(this.key)&&r(i,this.data),n(this.key)&&this.right&&r(i,this.right.betweenBounds(t,e,n)),i):[]},n.prototype.deleteIfLeaf=function(){return this.left||this.right?!1:this.parent?(this.parent.left===this?this.parent.left=null:this.parent.right=null,!0):(delete this.key,this.data=[],!0)},n.prototype.deleteIfOnlyOneChild=function(){var t;return this.left&&!this.right&&(t=this.left),!this.left&&this.right&&(t=this.right),t?this.parent?(this.parent.left===this?(this.parent.left=t,t.parent=this.parent):(this.parent.right=t,t.parent=this.parent),!0):(this.key=t.key,this.data=t.data,this.left=null,t.left&&(this.left=t.left,t.left.parent=this),this.right=null,t.right&&(this.right=t.right,t.right.parent=this),!0):!1},n.prototype.delete=function(t,e){var n,r=[],i=this;if(this.hasOwnProperty("key")){if(this.compareKeys(t,this.key)<0)return this.left&&this.left.delete(t,e),void 0;if(this.compareKeys(t,this.key)>0)return this.right&&this.right.delete(t,e),void 0;if(0!==!this.compareKeys(t,this.key))return this.data.length>1&&void 0!==e?(this.data.forEach(function(t){i.checkValueEquality(t,e)||r.push(t)}),i.data=r,void 0):(this.deleteIfLeaf()||this.deleteIfOnlyOneChild()||(Math.random()>=.5?(n=this.left.getMaxKeyDescendant(),this.key=n.key,this.data=n.data,this===n.parent?(this.left=n.left,n.left&&(n.left.parent=n.parent)):(n.parent.right=n.left,n.left&&(n.left.parent=n.parent))):(n=this.right.getMinKeyDescendant(),this.key=n.key,this.data=n.data,this===n.parent?(this.right=n.right,n.right&&(n.right.parent=n.parent)):(n.parent.left=n.right,n.right&&(n.right.parent=n.parent)))),void 0)}},n.prototype.executeOnEveryNode=function(t){this.left&&this.left.executeOnEveryNode(t),t(this),this.right&&this.right.executeOnEveryNode(t)},n.prototype.prettyPrint=function(t,e){e=e||"",console.log(e+"* "+this.key),t&&console.log(e+"* "+this.data),(this.left||this.right)&&(this.left?this.left.prettyPrint(t,e+" "):console.log(e+" *"),this.right?this.right.prettyPrint(t,e+" "):console.log(e+" *"))},e.exports=n},{"./customUtils":17}],17:[function(t,e){function n(t){var e,r;return 0===t?[]:1===t?[0]:(e=n(t-1),r=Math.floor(Math.random()*t),e.splice(r,0,t-1),e)}function r(t,e){if(e>t)return-1;if(t>e)return 1;if(t===e)return 0;var n=new Error("Couldn't compare elements");throw n.a=t,n.b=e,n}function i(t,e){return t===e}e.exports.getRandomArray=n,e.exports.defaultCompareKeysFunction=r,e.exports.defaultCheckValueEquality=i},{}],18:[function(e,n,r){var i=e("__browserify_process"),o=self;!function(){var t,e,n,r;!function(){var i={},o={};t=function(t,e,n){i[t]={deps:e,callback:n}},r=n=e=function(t){function n(e){if("."!==e.charAt(0))return e;for(var n=e.split("/"),r=t.split("/").slice(0,-1),i=0,o=n.length;o>i;i++){var a=n[i];if(".."===a)r.pop();else{if("."===a)continue;r.push(a)}}return r.join("/")}if(r._eak_seen=i,o[t])return o[t];if(o[t]={},!i[t])throw new Error("Could not find module "+t);for(var a,u=i[t],s=u.deps,c=u.callback,f=[],l=0,h=s.length;h>l;l++)"exports"===s[l]?f.push(a={}):f.push(e(n(s[l])));var p=c.apply(this,f);return o[t]=a||p}}(),t("promise/all",["./utils","exports"],function(t,e){"use strict";function n(t){var e=this;if(!r(t))throw new TypeError("You must pass an array to all.");return new e(function(e,n){function r(t){return function(e){o(t,e)}}function o(t,n){u[t]=n,0===--s&&e(u)}var a,u=[],s=t.length;0===s&&e([]);for(var c=0;cn;n++){var i=t[n];this.supports(i)&&e.push(i)}return e},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0;ei;i++)r[i]=t.charCodeAt(i);return n}function r(t){return new Promise(function(e,n){var r=new XMLHttpRequest;r.open("GET",t),r.withCredentials=!0,r.responseType="arraybuffer",r.onreadystatechange=function(){return 4===r.readyState?200===r.status?e({response:r.response,type:r.getResponseHeader("Content-Type")}):(n({status:r.status,response:r.response}),void 0):void 0},r.send()})}function i(e){return new Promise(function(n,i){var o=t([""],{type:"image/png"}),a=e.transaction([S],"readwrite");a.objectStore(S).put(o,"key"),a.oncomplete=function(){var t=e.transaction([S],"readwrite"),o=t.objectStore(S).get("key");o.onerror=i,o.onsuccess=function(t){var e=t.target.result,i=URL.createObjectURL(e);r(i).then(function(t){n(!(!t||"image/png"!==t.type))},function(){n(!1)}).then(function(){URL.revokeObjectURL(i)})}}})["catch"](function(){return!1})}function o(t){return"boolean"==typeof A?Promise.resolve(A):i(t).then(function(t){return A=t})}function a(t){return new Promise(function(e,n){var r=new FileReader;r.onerror=n,r.onloadend=function(n){var r=btoa(n.target.result||"");e({__local_forage_encoded_blob:!0,data:r,type:t.type})},r.readAsBinaryString(t)})}function u(e){var r=n(atob(e.data));return t([r],{type:e.type})}function s(t){return t&&t.__local_forage_encoded_blob}function c(t){function e(){return Promise.resolve()}var n=this,r={db:null};if(t)for(var i in t)r[i]=t[i];O||(O={});var o=O[r.name];o||(o={forages:[],db:null},O[r.name]=o),o.forages.push(this);for(var a=[],u=0;ut.db.version;if(r&&(t.version!==e&&x.console.warn('The database "'+t.name+'"'+" can't be downgraded from version "+t.db.version+" to version "+t.version+"."),t.version=t.db.version),i||n){if(n){var o=t.db.version+1;o>t.version&&(t.version=o)}return!0}return!1}function d(t,e){var n=this;"string"!=typeof t&&(x.console.warn(t+" used as a key, but it is not a string."),t=String(t));var r=new Promise(function(e,r){n.ready().then(function(){var i=n._dbInfo,o=i.db.transaction(i.storeName,"readonly").objectStore(i.storeName),a=o.get(t);a.onsuccess=function(){var t=a.result;void 0===t&&(t=null),s(t)&&(t=u(t)),e(t)},a.onerror=function(){r(a.error)}})["catch"](r)});return k(r,e),r}function y(t,e){var n=this,r=new Promise(function(e,r){n.ready().then(function(){var i=n._dbInfo,o=i.db.transaction(i.storeName,"readonly").objectStore(i.storeName),a=o.openCursor(),c=1;a.onsuccess=function(){var n=a.result;if(n){var r=n.value;s(r)&&(r=u(r));var i=t(r,n.key,c++);void 0!==i?e(i):n["continue"]()}else e()},a.onerror=function(){r(a.error)}})["catch"](r)});return k(r,e),r}function v(t,e,n){var r=this;"string"!=typeof t&&(x.console.warn(t+" used as a key, but it is not a string."),t=String(t));var i=new Promise(function(n,i){var u;r.ready().then(function(){return u=r._dbInfo,o(u.db)}).then(function(t){return!t&&e instanceof Blob?a(e):e}).then(function(e){var r=u.db.transaction(u.storeName,"readwrite"),o=r.objectStore(u.storeName);null===e&&(e=void 0);var a=o.put(e,t);r.oncomplete=function(){void 0===e&&(e=null),n(e)},r.onabort=r.onerror=function(){var t=a.error?a.error:a.transaction.error;i(t)}})["catch"](i)});return k(i,n),i}function g(t,e){var n=this;"string"!=typeof t&&(x.console.warn(t+" used as a key, but it is not a string."),t=String(t));var r=new Promise(function(e,r){n.ready().then(function(){var i=n._dbInfo,o=i.db.transaction(i.storeName,"readwrite"),a=o.objectStore(i.storeName),u=a["delete"](t);o.oncomplete=function(){e()},o.onerror=function(){r(u.error)},o.onabort=function(){var t=u.error?u.error:u.transaction.error;r(t)}})["catch"](r)});return k(r,e),r}function m(t){var e=this,n=new Promise(function(t,n){e.ready().then(function(){var r=e._dbInfo,i=r.db.transaction(r.storeName,"readwrite"),o=i.objectStore(r.storeName),a=o.clear();i.oncomplete=function(){t()},i.onabort=i.onerror=function(){var t=a.error?a.error:a.transaction.error;n(t)}})["catch"](n)});return k(n,t),n}function b(t){var e=this,n=new Promise(function(t,n){e.ready().then(function(){var r=e._dbInfo,i=r.db.transaction(r.storeName,"readonly").objectStore(r.storeName),o=i.count();o.onsuccess=function(){t(o.result)},o.onerror=function(){n(o.error)}})["catch"](n)});return k(n,t),n}function w(t,e){var n=this,r=new Promise(function(e,r){return 0>t?(e(null),void 0):(n.ready().then(function(){var i=n._dbInfo,o=i.db.transaction(i.storeName,"readonly").objectStore(i.storeName),a=!1,u=o.openCursor();u.onsuccess=function(){var n=u.result;return n?(0===t?e(n.key):a?e(n.key):(a=!0,n.advance(t)),void 0):(e(null),void 0)},u.onerror=function(){r(u.error)}})["catch"](r),void 0)});return k(r,e),r}function _(t){var e=this,n=new Promise(function(t,n){e.ready().then(function(){var r=e._dbInfo,i=r.db.transaction(r.storeName,"readonly").objectStore(r.storeName),o=i.openCursor(),a=[];o.onsuccess=function(){var e=o.result;return e?(a.push(e.key),e["continue"](),void 0):(t(a),void 0)},o.onerror=function(){n(o.error)}})["catch"](n)});return k(n,t),n}function k(t,e){e&&t.then(function(t){e(null,t)},function(t){e(t)})}var x=this,E=E||this.indexedDB||this.webkitIndexedDB||this.mozIndexedDB||this.OIndexedDB||this.msIndexedDB;if(E){var A,O,S="local-forage-detect-blob-support",j={_driver:"asyncStorage",_initStorage:c,iterate:y,getItem:d,setItem:v,removeItem:g,clear:m,length:b,key:w,keys:_};e["default"]=j}}.call("undefined"!=typeof window?window:self),t.exports=e["default"]},function(t,e,n){"use strict";e.__esModule=!0,function(){function t(t){var e=this,r={};if(t)for(var i in t)r[i]=t[i];return r.keyPrefix=r.name+"/",r.storeName!==e._defaultConfig.storeName&&(r.keyPrefix+=r.storeName+"/"),e._dbInfo=r,new Promise(function(t){t(n(3))}).then(function(t){return r.serializer=t,Promise.resolve()})}function r(t){var e=this,n=e.ready().then(function(){for(var t=e._dbInfo.keyPrefix,n=p.length-1;n>=0;n--){var r=p.key(n);0===r.indexOf(t)&&p.removeItem(r)}});return l(n,t),n}function i(t,e){var n=this;"string"!=typeof t&&(h.console.warn(t+" used as a key, but it is not a string."),t=String(t));var r=n.ready().then(function(){var e=n._dbInfo,r=p.getItem(e.keyPrefix+t);return r&&(r=e.serializer.deserialize(r)),r});return l(r,e),r}function o(t,e){var n=this,r=n.ready().then(function(){for(var e=n._dbInfo,r=e.keyPrefix,i=r.length,o=p.length,a=1,u=0;o>u;u++){var s=p.key(u);if(0===s.indexOf(r)){var c=p.getItem(s);if(c&&(c=e.serializer.deserialize(c)),c=t(c,s.substring(i),a++),void 0!==c)return c}}});return l(r,e),r}function a(t,e){var n=this,r=n.ready().then(function(){var e,r=n._dbInfo;try{e=p.key(t)}catch(i){e=null}return e&&(e=e.substring(r.keyPrefix.length)),e});return l(r,e),r}function u(t){var e=this,n=e.ready().then(function(){for(var t=e._dbInfo,n=p.length,r=[],i=0;n>i;i++)0===p.key(i).indexOf(t.keyPrefix)&&r.push(p.key(i).substring(t.keyPrefix.length));return r});return l(n,t),n}function s(t){var e=this,n=e.keys().then(function(t){return t.length});return l(n,t),n}function c(t,e){var n=this;"string"!=typeof t&&(h.console.warn(t+" used as a key, but it is not a string."),t=String(t));var r=n.ready().then(function(){var e=n._dbInfo;p.removeItem(e.keyPrefix+t)});return l(r,e),r}function f(t,e,n){var r=this;"string"!=typeof t&&(h.console.warn(t+" used as a key, but it is not a string."),t=String(t));var i=r.ready().then(function(){void 0===e&&(e=null);var n=e;return new Promise(function(i,o){var a=r._dbInfo;a.serializer.serialize(e,function(e,r){if(r)o(r);else try{p.setItem(a.keyPrefix+t,e),i(n)}catch(u){("QuotaExceededError"===u.name||"NS_ERROR_DOM_QUOTA_REACHED"===u.name)&&o(u),o(u)}})})});return l(i,n),i}function l(t,e){e&&t.then(function(t){e(null,t)},function(t){e(t)})}var h=this,p=null;try{if(!(this.localStorage&&"setItem"in this.localStorage))return;p=this.localStorage}catch(d){return}var y={_driver:"localStorageWrapper",_initStorage:t,iterate:o,getItem:i,setItem:f,removeItem:c,clear:r,length:s,key:a,keys:u};e["default"]=y}.call("undefined"!=typeof window?window:self),t.exports=e["default"]},function(t,e){"use strict";e.__esModule=!0,function(){function t(t,e){t=t||[],e=e||{};try{return new Blob(t,e)}catch(n){if("TypeError"!==n.name)throw n;for(var r=x.BlobBuilder||x.MSBlobBuilder||x.MozBlobBuilder||x.WebKitBlobBuilder,i=new r,o=0;oe;e+=4)n=a.indexOf(t[e]),r=a.indexOf(t[e+1]),i=a.indexOf(t[e+2]),o=a.indexOf(t[e+3]),l[c++]=n<<2|r>>4,l[c++]=(15&r)<<4|i>>2,l[c++]=(3&i)<<6|63&o;return f}function o(t){var e,n=new Uint8Array(t),r="";for(e=0;e>2],r+=a[(3&n[e])<<4|n[e+1]>>4],r+=a[(15&n[e+1])<<2|n[e+2]>>6],r+=a[63&n[e+2]];return 2===n.length%3?r=r.substring(0,r.length-1)+"=":1===n.length%3&&(r=r.substring(0,r.length-2)+"=="),r}var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u="~~local_forage_type~",s=/^~~local_forage_type~([^~]+)~/,c="__lfsc__:",f=c.length,l="arbf",h="blob",p="si08",d="ui08",y="uic8",v="si16",g="si32",m="ur16",b="ui32",w="fl32",_="fl64",k=f+l.length,x=this,E={serialize:n,deserialize:r,stringToBuffer:i,bufferToString:o};e["default"]=E}.call("undefined"!=typeof window?window:self),t.exports=e["default"]},function(t,e,n){"use strict";e.__esModule=!0,function(){function t(t){var e=this,r={db:null};if(t)for(var i in t)r[i]="string"!=typeof t[i]?t[i].toString():t[i];var o=new Promise(function(n,i){try{r.db=p(r.name,String(r.version),r.description,r.size)}catch(o){return e.setDriver(e.LOCALSTORAGE).then(function(){return e._initStorage(t)}).then(n)["catch"](i)}r.db.transaction(function(t){t.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],function(){e._dbInfo=r,n()},function(t,e){i(e)})})});return new Promise(function(t){t(n(3))}).then(function(t){return r.serializer=t,o})}function r(t,e){var n=this;"string"!=typeof t&&(h.console.warn(t+" used as a key, but it is not a string."),t=String(t));var r=new Promise(function(e,r){n.ready().then(function(){var i=n._dbInfo;i.db.transaction(function(n){n.executeSql("SELECT * FROM "+i.storeName+" WHERE key = ? LIMIT 1",[t],function(t,n){var r=n.rows.length?n.rows.item(0).value:null;r&&(r=i.serializer.deserialize(r)),e(r)},function(t,e){r(e)})})})["catch"](r)});return l(r,e),r}function i(t,e){var n=this,r=new Promise(function(e,r){n.ready().then(function(){var i=n._dbInfo;i.db.transaction(function(n){n.executeSql("SELECT * FROM "+i.storeName,[],function(n,r){for(var o=r.rows,a=o.length,u=0;a>u;u++){var s=o.item(u),c=s.value;if(c&&(c=i.serializer.deserialize(c)),c=t(c,s.key,u+1),void 0!==c)return e(c),void 0}e()},function(t,e){r(e)})})})["catch"](r)});return l(r,e),r}function o(t,e,n){var r=this;"string"!=typeof t&&(h.console.warn(t+" used as a key, but it is not a string."),t=String(t));var i=new Promise(function(n,i){r.ready().then(function(){void 0===e&&(e=null);var o=e,a=r._dbInfo;a.serializer.serialize(e,function(e,r){r?i(r):a.db.transaction(function(r){r.executeSql("INSERT OR REPLACE INTO "+a.storeName+" (key, value) VALUES (?, ?)",[t,e],function(){n(o)},function(t,e){i(e)})},function(t){t.code===t.QUOTA_ERR&&i(t)})})})["catch"](i)});return l(i,n),i}function a(t,e){var n=this;"string"!=typeof t&&(h.console.warn(t+" used as a key, but it is not a string."),t=String(t));var r=new Promise(function(e,r){n.ready().then(function(){var i=n._dbInfo;i.db.transaction(function(n){n.executeSql("DELETE FROM "+i.storeName+" WHERE key = ?",[t],function(){e()},function(t,e){r(e)})})})["catch"](r)});return l(r,e),r}function u(t){var e=this,n=new Promise(function(t,n){e.ready().then(function(){var r=e._dbInfo;r.db.transaction(function(e){e.executeSql("DELETE FROM "+r.storeName,[],function(){t()},function(t,e){n(e)})})})["catch"](n)});return l(n,t),n}function s(t){var e=this,n=new Promise(function(t,n){e.ready().then(function(){var r=e._dbInfo;r.db.transaction(function(e){e.executeSql("SELECT COUNT(key) as c FROM "+r.storeName,[],function(e,n){var r=n.rows.item(0).c;t(r)},function(t,e){n(e)})})})["catch"](n)});return l(n,t),n}function c(t,e){var n=this,r=new Promise(function(e,r){n.ready().then(function(){var i=n._dbInfo;i.db.transaction(function(n){n.executeSql("SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[t+1],function(t,n){var r=n.rows.length?n.rows.item(0).key:null;e(r)},function(t,e){r(e)})})})["catch"](r)});return l(r,e),r}function f(t){var e=this,n=new Promise(function(t,n){e.ready().then(function(){var r=e._dbInfo;r.db.transaction(function(e){e.executeSql("SELECT key FROM "+r.storeName,[],function(e,n){for(var r=[],i=0;ir;r++)if(e.call(n,t[r],r,t)===i)return}else for(var a in t)if(A.has(t,a)&&e.call(n,t[a],a,t)===i)return};A.map=A.collect=function(t,e,n){var r=[];return null==t?r:d&&t.map===d?t.map(e,n):(O(t,function(t,i,o){r[r.length]=e.call(n,t,i,o)}),r)};var S="Reduce of empty array with no initial value";A.reduce=A.foldl=A.inject=function(t,e,n,r){var i=arguments.length>2;if(null==t&&(t=[]),y&&t.reduce===y)return r&&(e=A.bind(e,r)),i?t.reduce(e,n):t.reduce(e);if(O(t,function(t,o,a){i?n=e.call(r,n,t,o,a):(n=t,i=!0)}),!i)throw new TypeError(S);return n},A.reduceRight=A.foldr=function(t,e,n,r){var i=arguments.length>2;if(null==t&&(t=[]),v&&t.reduceRight===v)return r&&(e=A.bind(e,r)),i?t.reduceRight(e,n):t.reduceRight(e);var o=t.length;if(o!==+o){var a=A.keys(t);o=a.length}if(O(t,function(u,s,c){s=a?a[--o]:--o,i?n=e.call(r,n,t[s],s,c):(n=t[s],i=!0)}),!i)throw new TypeError(S);return n},A.find=A.detect=function(t,e,n){var r;return j(t,function(t,i,o){return e.call(n,t,i,o)?(r=t,!0):void 0}),r},A.filter=A.select=function(t,e,n){var r=[];return null==t?r:g&&t.filter===g?t.filter(e,n):(O(t,function(t,i,o){e.call(n,t,i,o)&&(r[r.length]=t)}),r)},A.reject=function(t,e,n){return A.filter(t,function(t,r,i){return!e.call(n,t,r,i)},n)},A.every=A.all=function(t,e,n){e||(e=A.identity);var r=!0;return null==t?r:m&&t.every===m?t.every(e,n):(O(t,function(t,o,a){return(r=r&&e.call(n,t,o,a))?void 0:i}),!!r)};var j=A.some=A.any=function(t,e,n){e||(e=A.identity);var r=!1;return null==t?r:b&&t.some===b?t.some(e,n):(O(t,function(t,o,a){return r||(r=e.call(n,t,o,a))?i:void 0}),!!r)};A.contains=A.include=function(t,e){return null==t?!1:w&&t.indexOf===w?-1!=t.indexOf(e):j(t,function(t){return t===e})},A.invoke=function(t,e){var n=c.call(arguments,2),r=A.isFunction(e);return A.map(t,function(t){return(r?e:t[e]).apply(t,n)})},A.pluck=function(t,e){return A.map(t,function(t){return t[e]})},A.where=function(t,e,n){return A.isEmpty(e)?n?null:[]:A[n?"find":"filter"](t,function(t){for(var n in e)if(e[n]!==t[n])return!1;return!0})},A.findWhere=function(t,e){return A.where(t,e,!0)},A.max=function(t,e,n){if(!e&&A.isArray(t)&&t[0]===+t[0]&&t.length<65535)return Math.max.apply(Math,t);if(!e&&A.isEmpty(t))return-1/0;var r={computed:-1/0,value:-1/0};return O(t,function(t,i,o){var a=e?e.call(n,t,i,o):t;a>=r.computed&&(r={value:t,computed:a})}),r.value},A.min=function(t,e,n){if(!e&&A.isArray(t)&&t[0]===+t[0]&&t.length<65535)return Math.min.apply(Math,t);if(!e&&A.isEmpty(t))return 1/0;var r={computed:1/0,value:1/0};return O(t,function(t,i,o){var a=e?e.call(n,t,i,o):t;ar||void 0===n)return 1;if(r>n||void 0===r)return-1}return t.indexo;){var u=o+a>>>1;n.call(r,t[u])=0})})},A.difference=function(t){var e=f.apply(o,c.call(arguments,1));return A.filter(t,function(t){return!A.contains(e,t)})},A.zip=function(){for(var t=c.call(arguments),e=A.max(A.pluck(t,"length")),n=new Array(e),r=0;e>r;r++)n[r]=A.pluck(t,""+r);return n},A.object=function(t,e){if(null==t)return{};for(var n={},r=0,i=t.length;i>r;r++)e?n[t[r]]=e[r]:n[t[r][0]]=t[r][1];return n},A.indexOf=function(t,e,n){if(null==t)return-1;var r=0,i=t.length;if(n){if("number"!=typeof n)return r=A.sortedIndex(t,e),t[r]===e?r:-1;r=0>n?Math.max(0,i+n):n}if(w&&t.indexOf===w)return t.indexOf(e,n);for(;i>r;r++)if(t[r]===e)return r;return-1},A.lastIndexOf=function(t,e,n){if(null==t)return-1;var r=null!=n;if(_&&t.lastIndexOf===_)return r?t.lastIndexOf(e,n):t.lastIndexOf(e);for(var i=r?n:t.length;i--;)if(t[i]===e)return i;return-1},A.range=function(t,e,n){arguments.length<=1&&(e=t||0,t=0),n=arguments[2]||1;for(var r=Math.max(Math.ceil((e-t)/n),0),i=0,o=new Array(r);r>i;)o[i++]=t,t+=n;return o},A.bind=function(t,e){if(t.bind===E&&E)return E.apply(t,c.call(arguments,1));var n=c.call(arguments,2);return function(){return t.apply(e,n.concat(c.call(arguments)))}},A.partial=function(t){var e=c.call(arguments,1);return function(){return t.apply(this,e.concat(c.call(arguments)))}},A.bindAll=function(t){var e=c.call(arguments,1);return 0===e.length&&(e=A.functions(t)),O(e,function(e){t[e]=A.bind(t[e],t)}),t},A.memoize=function(t,e){var n={};return e||(e=A.identity),function(){var r=e.apply(this,arguments);return A.has(n,r)?n[r]:n[r]=t.apply(this,arguments)}},A.delay=function(t,e){var n=c.call(arguments,2);return setTimeout(function(){return t.apply(null,n)},e)},A.defer=function(t){return A.delay.apply(A,[t,1].concat(c.call(arguments,1)))},A.throttle=function(t,e){var n,r,i,o,a=0,u=function(){a=new Date,i=null,o=t.apply(n,r)};return function(){var s=new Date,c=e-(s-a);return n=this,r=arguments,0>=c?(clearTimeout(i),i=null,a=s,o=t.apply(n,r)):i||(i=setTimeout(u,c)),o}},A.debounce=function(t,e,n){var r,i;return function(){var o=this,a=arguments,u=function(){r=null,n||(i=t.apply(o,a))},s=n&&!r;return clearTimeout(r),r=setTimeout(u,e),s&&(i=t.apply(o,a)),i}},A.once=function(t){var e,n=!1;return function(){return n?e:(n=!0,e=t.apply(this,arguments),t=null,e)}},A.wrap=function(t,e){return function(){var n=[t];return s.apply(n,arguments),e.apply(this,n)}},A.compose=function(){var t=arguments;return function(){for(var e=arguments,n=t.length-1;n>=0;n--)e=[t[n].apply(this,e)];return e[0]}},A.after=function(t,e){return 0>=t?e():function(){return--t<1?e.apply(this,arguments):void 0}},A.keys=x||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var n in t)A.has(t,n)&&(e[e.length]=n);return e},A.values=function(t){var e=[];for(var n in t)A.has(t,n)&&e.push(t[n]);return e},A.pairs=function(t){var e=[];for(var n in t)A.has(t,n)&&e.push([n,t[n]]);return e},A.invert=function(t){var e={};for(var n in t)A.has(t,n)&&(e[t[n]]=n);return e},A.functions=A.methods=function(t){var e=[];for(var n in t)A.isFunction(t[n])&&e.push(n);return e.sort()},A.extend=function(t){return O(c.call(arguments,1),function(e){if(e)for(var n in e)t[n]=e[n]}),t},A.pick=function(t){var e={},n=f.apply(o,c.call(arguments,1));return O(n,function(n){n in t&&(e[n]=t[n])}),e},A.omit=function(t){var e={},n=f.apply(o,c.call(arguments,1));for(var r in t)A.contains(n,r)||(e[r]=t[r]);return e},A.defaults=function(t){return O(c.call(arguments,1),function(e){if(e)for(var n in e)null==t[n]&&(t[n]=e[n]) +}),t},A.clone=function(t){return A.isObject(t)?A.isArray(t)?t.slice():A.extend({},t):t},A.tap=function(t,e){return e(t),t};var N=function(t,e,n,r){if(t===e)return 0!==t||1/t==1/e;if(null==t||null==e)return t===e;t instanceof A&&(t=t._wrapped),e instanceof A&&(e=e._wrapped);var i=l.call(t);if(i!=l.call(e))return!1;switch(i){case"[object String]":return t==String(e);case"[object Number]":return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case"[object Date]":case"[object Boolean]":return+t==+e;case"[object RegExp]":return t.source==e.source&&t.global==e.global&&t.multiline==e.multiline&&t.ignoreCase==e.ignoreCase}if("object"!=typeof t||"object"!=typeof e)return!1;for(var o=n.length;o--;)if(n[o]==t)return r[o]==e;n.push(t),r.push(e);var a=0,u=!0;if("[object Array]"==i){if(a=t.length,u=a==e.length)for(;a--&&(u=N(t[a],e[a],n,r)););}else{var s=t.constructor,c=e.constructor;if(s!==c&&!(A.isFunction(s)&&s instanceof s&&A.isFunction(c)&&c instanceof c))return!1;for(var f in t)if(A.has(t,f)&&(a++,!(u=A.has(e,f)&&N(t[f],e[f],n,r))))break;if(u){for(f in e)if(A.has(e,f)&&!a--)break;u=!a}}return n.pop(),r.pop(),u};A.isEqual=function(t,e){return N(t,e,[],[])},A.isEmpty=function(t){if(null==t)return!0;if(A.isArray(t)||A.isString(t))return 0===t.length;for(var e in t)if(A.has(t,e))return!1;return!0},A.isElement=function(t){return!(!t||1!==t.nodeType)},A.isArray=k||function(t){return"[object Array]"==l.call(t)},A.isObject=function(t){return t===Object(t)},O(["Arguments","Function","String","Number","Date","RegExp"],function(t){A["is"+t]=function(e){return l.call(e)=="[object "+t+"]"}}),A.isArguments(arguments)||(A.isArguments=function(t){return!(!t||!A.has(t,"callee"))}),"function"!=typeof/./&&(A.isFunction=function(t){return"function"==typeof t}),A.isFinite=function(t){return isFinite(t)&&!isNaN(parseFloat(t))},A.isNaN=function(t){return A.isNumber(t)&&t!=+t},A.isBoolean=function(t){return t===!0||t===!1||"[object Boolean]"==l.call(t)},A.isNull=function(t){return null===t},A.isUndefined=function(t){return void 0===t},A.has=function(t,e){return h.call(t,e)},A.noConflict=function(){return t._=r,this},A.identity=function(t){return t},A.times=function(t,e,n){for(var r=Array(t),i=0;t>i;i++)r[i]=e.call(n,i);return r},A.random=function(t,e){return null==e&&(e=t,t=0),t+Math.floor(Math.random()*(e-t+1))};var P={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};P.unescape=A.invert(P.escape);var T={escape:new RegExp("["+A.keys(P.escape).join("")+"]","g"),unescape:new RegExp("("+A.keys(P.unescape).join("|")+")","g")};A.each(["escape","unescape"],function(t){A[t]=function(e){return null==e?"":(""+e).replace(T[t],function(e){return P[t][e]})}}),A.result=function(t,e){if(null==t)return null;var n=t[e];return A.isFunction(n)?n.call(t):n},A.mixin=function(t){O(A.functions(t),function(e){var n=A[e]=t[e];A.prototype[e]=function(){var t=[this._wrapped];return s.apply(t,arguments),R.call(this,n.apply(A,t))}})};var C=0;A.uniqueId=function(t){var e=++C+"";return t?t+e:e},A.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var M=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},F=/\\|'|\r|\n|\t|\u2028|\u2029/g;A.template=function(t,e,n){var r;n=A.defaults({},n,A.templateSettings);var i=new RegExp([(n.escape||M).source,(n.interpolate||M).source,(n.evaluate||M).source].join("|")+"|$","g"),o=0,a="__p+='";t.replace(i,function(e,n,r,i,u){return a+=t.slice(o,u).replace(F,function(t){return"\\"+B[t]}),n&&(a+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(a+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(a+="';\n"+i+"\n__p+='"),o=u+e.length,e}),a+="';\n",n.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{r=new Function(n.variable||"obj","_",a)}catch(u){throw u.source=a,u}if(e)return r(e,A);var s=function(t){return r.call(this,t,A)};return s.source="function("+(n.variable||"obj")+"){\n"+a+"}",s},A.chain=function(t){return A(t).chain()};var R=function(t){return this._chain?A(t).chain():t};A.mixin(A),O(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=o[t];A.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!=t&&"splice"!=t||0!==n.length||delete n[0],R.call(this,n)}}),O(["concat","join","slice"],function(t){var e=o[t];A.prototype[t]=function(){return R.call(this,e.apply(this._wrapped,arguments))}}),A.extend(A.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}.call(this)},{}]},{},[7])(7)}); \ No newline at end of file diff --git a/public/assets/objectid.js b/public/assets/objectid.js new file mode 100644 index 00000000..7f32db8c --- /dev/null +++ b/public/assets/objectid.js @@ -0,0 +1,120 @@ +/* +* +* Copyright (c) 2011-2014- Justin Dearing (zippy1981@gmail.com) +* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) +* and GPL (http://www.opensource.org/licenses/gpl-license.php) version 2 licenses. +* This software is not distributed under version 3 or later of the GPL. +* +* Version 1.0.2 +* +*/ + +if (!document) var document = { cookie: '' }; // fix crashes on node + +/** + * Javascript class that mimics how WCF serializes a object of type MongoDB.Bson.ObjectId + * and converts between that format and the standard 24 character representation. +*/ +var ObjectId = (function () { + var increment = Math.floor(Math.random() * (16777216)); + var pid = Math.floor(Math.random() * (65536)); + var machine = Math.floor(Math.random() * (16777216)); + + var setMachineCookie = function() { + var cookieList = document.cookie.split('; '); + for (var i in cookieList) { + var cookie = cookieList[i].split('='); + var cookieMachineId = parseInt(cookie[1], 10); + if (cookie[0] == 'mongoMachineId' && cookieMachineId && cookieMachineId >= 0 && cookieMachineId <= 16777215) { + machine = cookieMachineId; + break; + } + } + document.cookie = 'mongoMachineId=' + machine + ';expires=Tue, 19 Jan 2038 05:00:00 GMT;path=/'; + }; + if (typeof (localStorage) != 'undefined') { + try { + var mongoMachineId = parseInt(localStorage['mongoMachineId']); + if (mongoMachineId >= 0 && mongoMachineId <= 16777215) { + machine = Math.floor(localStorage['mongoMachineId']); + } + // Just always stick the value in. + localStorage['mongoMachineId'] = machine; + } catch (e) { + setMachineCookie(); + } + } + else { + setMachineCookie(); + } + + function ObjId() { + if (!(this instanceof ObjectId)) { + return new ObjectId(arguments[0], arguments[1], arguments[2], arguments[3]).toString(); + } + + if (typeof (arguments[0]) == 'object') { + this.timestamp = arguments[0].timestamp; + this.machine = arguments[0].machine; + this.pid = arguments[0].pid; + this.increment = arguments[0].increment; + } + else if (typeof (arguments[0]) == 'string' && arguments[0].length == 24) { + this.timestamp = Number('0x' + arguments[0].substr(0, 8)), + this.machine = Number('0x' + arguments[0].substr(8, 6)), + this.pid = Number('0x' + arguments[0].substr(14, 4)), + this.increment = Number('0x' + arguments[0].substr(18, 6)) + } + else if (arguments.length == 4 && arguments[0] != null) { + this.timestamp = arguments[0]; + this.machine = arguments[1]; + this.pid = arguments[2]; + this.increment = arguments[3]; + } + else { + this.timestamp = Math.floor(new Date().valueOf() / 1000); + this.machine = machine; + this.pid = pid; + this.increment = increment++; + if (increment > 0xffffff) { + increment = 0; + } + } + }; + return ObjId; +})(); + +ObjectId.prototype.getDate = function () { + return new Date(this.timestamp * 1000); +}; + +ObjectId.prototype.toArray = function () { + var strOid = this.toString(); + var array = []; + var i; + for(i = 0; i < 12; i++) { + array[i] = parseInt(strOid.slice(i*2, i*2+2), 16); + } + return array; +}; + +/** +* Turns a WCF representation of a BSON ObjectId into a 24 character string representation. +*/ +ObjectId.prototype.toString = function () { + if (this.timestamp === undefined + || this.machine === undefined + || this.pid === undefined + || this.increment === undefined) { + return 'Invalid ObjectId'; + } + + var timestamp = this.timestamp.toString(16); + var machine = this.machine.toString(16); + var pid = this.pid.toString(16); + var increment = this.increment.toString(16); + return '00000000'.substr(0, 8 - timestamp.length) + timestamp + + '000000'.substr(0, 6 - machine.length) + machine + + '0000'.substr(0, 4 - pid.length) + pid + + '000000'.substr(0, 6 - increment.length) + increment; +}; diff --git a/public/assets/peer.min.js b/public/assets/peer.min.js new file mode 100644 index 00000000..0aa06e93 --- /dev/null +++ b/public/assets/peer.min.js @@ -0,0 +1,2 @@ +/*! peerjs build:0.3.14, production. Copyright(c) 2013 Michelle Bu */!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gd.chunkedMTU)return void this._sendChunks(e);d.supports.sctp?d.supports.binaryBlob?this._bufferedSend(e):d.blobToArrayBuffer(e,function(a){c._bufferedSend(a)}):d.blobToBinaryString(e,function(a){c._bufferedSend(a)})}else this._bufferedSend(a)},c.prototype._bufferedSend=function(a){(this._buffering||!this._trySend(a))&&(this._buffer.push(a),this.bufferSize=this._buffer.length)},c.prototype._trySend=function(a){try{this._dc.send(a)}catch(b){this._buffering=!0;var c=this;return setTimeout(function(){c._buffering=!1,c._tryBuffer()},100),!1}return!0},c.prototype._tryBuffer=function(){if(0!==this._buffer.length){var a=this._buffer[0];this._trySend(a)&&(this._buffer.shift(),this.bufferSize=this._buffer.length,this._tryBuffer())}},c.prototype._sendChunks=function(a){for(var b=d.chunk(a),c=0,e=b.length;e>c;c+=1){var a=b[c];this.send(a,!0)}},c.prototype.handleMessage=function(a){var b=a.payload;switch(a.type){case"ANSWER":this._peerBrowser=b.browser,f.handleSDP(a.type,this,b.sdp);break;case"CANDIDATE":f.handleCandidate(this,b.candidate);break;default:d.warn("Unrecognized message type:",a.type,"from peer:",this.peer)}},b.exports=c},{"./negotiator":5,"./util":8,eventemitter3:9,reliable:12}],3:[function(a){window.Socket=a("./socket"),window.MediaConnection=a("./mediaconnection"),window.DataConnection=a("./dataconnection"),window.Peer=a("./peer"),window.RTCPeerConnection=a("./adapter").RTCPeerConnection,window.RTCSessionDescription=a("./adapter").RTCSessionDescription,window.RTCIceCandidate=a("./adapter").RTCIceCandidate,window.Negotiator=a("./negotiator"),window.util=a("./util"),window.BinaryPack=a("js-binarypack")},{"./adapter":1,"./dataconnection":2,"./mediaconnection":4,"./negotiator":5,"./peer":6,"./socket":7,"./util":8,"js-binarypack":10}],4:[function(a,b){function c(a,b,g){return this instanceof c?(e.call(this),this.options=d.extend({},g),this.open=!1,this.type="media",this.peer=a,this.provider=b,this.metadata=this.options.metadata,this.localStream=this.options._stream,this.id=this.options.connectionId||c._idPrefix+d.randomToken(),void(this.localStream&&f.startConnection(this,{_stream:this.localStream,originator:!0}))):new c(a,b,g)}var d=a("./util"),e=a("eventemitter3"),f=a("./negotiator");d.inherits(c,e),c._idPrefix="mc_",c.prototype.addStream=function(a){d.log("Receiving stream",a),this.remoteStream=a,this.emit("stream",a)},c.prototype.handleMessage=function(a){var b=a.payload;switch(a.type){case"ANSWER":f.handleSDP(a.type,this,b.sdp),this.open=!0;break;case"CANDIDATE":f.handleCandidate(this,b.candidate);break;default:d.warn("Unrecognized message type:",a.type,"from peer:",this.peer)}},c.prototype.answer=function(a){if(this.localStream)return void d.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");this.options._payload._stream=a,this.localStream=a,f.startConnection(this,this.options._payload);for(var b=this.provider._getMessages(this.id),c=0,e=b.length;e>c;c+=1)this.handleMessage(b[c]);this.open=!0},c.prototype.close=function(){this.open&&(this.open=!1,f.cleanup(this),this.emit("close"))},b.exports=c},{"./negotiator":5,"./util":8,eventemitter3:9}],5:[function(a,b){var c=a("./util"),d=a("./adapter").RTCPeerConnection,e=a("./adapter").RTCSessionDescription,f=a("./adapter").RTCIceCandidate,g={pcs:{data:{},media:{}},queue:[]};g._idPrefix="pc_",g.startConnection=function(a,b){var d=g._getPeerConnection(a,b);if("media"===a.type&&b._stream&&d.addStream(b._stream),a.pc=a.peerConnection=d,b.originator){if("data"===a.type){var e={};c.supports.sctp||(e={reliable:b.reliable});var f=d.createDataChannel(a.label,e);a.initialize(f)}c.supports.onnegotiationneeded||g._makeOffer(a)}else g.handleSDP("OFFER",a,b.sdp)},g._getPeerConnection=function(a,b){g.pcs[a.type]||c.error(a.type+" is not a valid connection type. Maybe you overrode the `type` property somewhere."),g.pcs[a.type][a.peer]||(g.pcs[a.type][a.peer]={});{var d;g.pcs[a.type][a.peer]}return b.pc&&(d=g.pcs[a.type][a.peer][b.pc]),d&&"stable"===d.signalingState||(d=g._startPeerConnection(a)),d},g._startPeerConnection=function(a){c.log("Creating RTCPeerConnection.");var b=g._idPrefix+c.randomToken(),e={};"data"!==a.type||c.supports.sctp?"media"===a.type&&(e={optional:[{DtlsSrtpKeyAgreement:!0}]}):e={optional:[{RtpDataChannels:!0}]};var f=new d(a.provider.options.config,e);return g.pcs[a.type][a.peer][b]=f,g._setupListeners(a,f,b),f},g._setupListeners=function(a,b){var d=a.peer,e=a.id,f=a.provider;c.log("Listening for ICE candidates."),b.onicecandidate=function(b){b.candidate&&(c.log("Received ICE candidates for:",a.peer),f.socket.send({type:"CANDIDATE",payload:{candidate:b.candidate,type:a.type,connectionId:a.id},dst:d}))},b.oniceconnectionstatechange=function(){switch(b.iceConnectionState){case"disconnected":case"failed":c.log("iceConnectionState is disconnected, closing connections to "+d),a.close();break;case"completed":b.onicecandidate=c.noop}},b.onicechange=b.oniceconnectionstatechange,c.log("Listening for `negotiationneeded`"),b.onnegotiationneeded=function(){c.log("`negotiationneeded` triggered"),"stable"==b.signalingState?g._makeOffer(a):c.log("onnegotiationneeded triggered when not stable. Is another connection being established?")},c.log("Listening for data channel"),b.ondatachannel=function(a){c.log("Received data channel");var b=a.channel,g=f.getConnection(d,e);g.initialize(b)},c.log("Listening for remote stream"),b.onaddstream=function(a){c.log("Received remote stream");var b=a.stream,g=f.getConnection(d,e);"media"===g.type&&g.addStream(b)}},g.cleanup=function(a){c.log("Cleaning up PeerConnection to "+a.peer);var b=a.pc;!b||"closed"===b.readyState&&"closed"===b.signalingState||(b.close(),a.pc=null)},g._makeOffer=function(a){var b=a.pc;b.createOffer(function(d){c.log("Created offer."),!c.supports.sctp&&"data"===a.type&&a.reliable&&(d.sdp=Reliable.higherBandwidthSDP(d.sdp)),b.setLocalDescription(d,function(){c.log("Set localDescription: offer","for:",a.peer),a.provider.socket.send({type:"OFFER",payload:{sdp:d,type:a.type,label:a.label,connectionId:a.id,reliable:a.reliable,serialization:a.serialization,metadata:a.metadata,browser:c.browser},dst:a.peer})},function(b){a.provider.emitError("webrtc",b),c.log("Failed to setLocalDescription, ",b)})},function(b){a.provider.emitError("webrtc",b),c.log("Failed to createOffer, ",b)},a.options.constraints)},g._makeAnswer=function(a){var b=a.pc;b.createAnswer(function(d){c.log("Created answer."),!c.supports.sctp&&"data"===a.type&&a.reliable&&(d.sdp=Reliable.higherBandwidthSDP(d.sdp)),b.setLocalDescription(d,function(){c.log("Set localDescription: answer","for:",a.peer),a.provider.socket.send({type:"ANSWER",payload:{sdp:d,type:a.type,connectionId:a.id,browser:c.browser},dst:a.peer})},function(b){a.provider.emitError("webrtc",b),c.log("Failed to setLocalDescription, ",b)})},function(b){a.provider.emitError("webrtc",b),c.log("Failed to create answer, ",b)})},g.handleSDP=function(a,b,d){d=new e(d);var f=b.pc;c.log("Setting remote description",d),f.setRemoteDescription(d,function(){c.log("Set remoteDescription:",a,"for:",b.peer),"OFFER"===a&&g._makeAnswer(b)},function(a){b.provider.emitError("webrtc",a),c.log("Failed to setRemoteDescription, ",a)})},g.handleCandidate=function(a,b){var d=b.candidate,e=b.sdpMLineIndex;a.pc.addIceCandidate(new f({sdpMLineIndex:e,candidate:d})),c.log("Added ICE candidate for:",a.peer)},b.exports=g},{"./adapter":1,"./util":8}],6:[function(a,b){function c(a,b){return this instanceof c?(e.call(this),a&&a.constructor==Object?(b=a,a=void 0):a&&(a=a.toString()),b=d.extend({debug:0,host:d.CLOUD_HOST,port:d.CLOUD_PORT,key:"peerjs",path:"/",token:d.randomToken(),config:d.defaultConfig},b),this.options=b,"/"===b.host&&(b.host=window.location.hostname),"/"!==b.path[0]&&(b.path="/"+b.path),"/"!==b.path[b.path.length-1]&&(b.path+="/"),void 0===b.secure&&b.host!==d.CLOUD_HOST&&(b.secure=d.isSecure()),b.logFunction&&d.setLogFunction(b.logFunction),d.setLogLevel(b.debug),d.supports.audioVideo||d.supports.data?d.validateId(a)?d.validateKey(b.key)?b.secure&&"0.peerjs.com"===b.host?void this._delayedAbort("ssl-unavailable","The cloud server currently does not support HTTPS. Please run your own PeerServer to use HTTPS."):(this.destroyed=!1,this.disconnected=!1,this.open=!1,this.connections={},this._lostMessages={},this._initializeServerConnection(),void(a?this._initialize(a):this._retrieveId())):void this._delayedAbort("invalid-key",'API KEY "'+b.key+'" is invalid'):void this._delayedAbort("invalid-id",'ID "'+a+'" is invalid'):void this._delayedAbort("browser-incompatible","The current browser does not support WebRTC")):new c(a,b)}var d=a("./util"),e=a("eventemitter3"),f=a("./socket"),g=a("./mediaconnection"),h=a("./dataconnection");d.inherits(c,e),c.prototype._initializeServerConnection=function(){var a=this;this.socket=new f(this.options.secure,this.options.host,this.options.port,this.options.path,this.options.key),this.socket.on("message",function(b){a._handleMessage(b)}),this.socket.on("error",function(b){a._abort("socket-error",b)}),this.socket.on("disconnected",function(){a.disconnected||(a.emitError("network","Lost connection to server."),a.disconnect())}),this.socket.on("close",function(){a.disconnected||a._abort("socket-closed","Underlying socket is already closed.")})},c.prototype._retrieveId=function(){var a=this,b=new XMLHttpRequest,c=this.options.secure?"https://":"http://",e=c+this.options.host+":"+this.options.port+this.options.path+this.options.key+"/id",f="?ts="+(new Date).getTime()+Math.random();e+=f,b.open("get",e,!0),b.onerror=function(b){d.error("Error retrieving ID",b);var c="";"/"===a.options.path&&a.options.host!==d.CLOUD_HOST&&(c=" If you passed in a `path` to your self-hosted PeerServer, you'll also need to pass in that same path when creating a new Peer."),a._abort("server-error","Could not get an ID from the server."+c)},b.onreadystatechange=function(){return 4===b.readyState?200!==b.status?void b.onerror():void a._initialize(b.responseText):void 0},b.send(null)},c.prototype._initialize=function(a){this.id=a,this.socket.start(this.id,this.options.token)},c.prototype._handleMessage=function(a){var b,c=a.type,e=a.payload,f=a.src;switch(c){case"OPEN":this.emit("open",this.id),this.open=!0;break;case"ERROR":this._abort("server-error",e.msg);break;case"ID-TAKEN":this._abort("unavailable-id","ID `"+this.id+"` is taken");break;case"INVALID-KEY":this._abort("invalid-key",'API KEY "'+this.options.key+'" is invalid');break;case"LEAVE":d.log("Received leave message from",f),this._cleanupPeer(f);break;case"EXPIRE":this.emitError("peer-unavailable","Could not connect to peer "+f);break;case"OFFER":var i=e.connectionId;if(b=this.getConnection(f,i))d.warn("Offer received for existing Connection ID:",i);else{if("media"===e.type)b=new g(f,this,{connectionId:i,_payload:e,metadata:e.metadata}),this._addConnection(f,b),this.emit("call",b);else{if("data"!==e.type)return void d.warn("Received malformed connection type:",e.type);b=new h(f,this,{connectionId:i,_payload:e,metadata:e.metadata,label:e.label,serialization:e.serialization,reliable:e.reliable}),this._addConnection(f,b),this.emit("connection",b)}for(var j=this._getMessages(i),k=0,l=j.length;l>k;k+=1)b.handleMessage(j[k])}break;default:if(!e)return void d.warn("You received a malformed message from "+f+" of type "+c);var m=e.connectionId;b=this.getConnection(f,m),b&&b.pc?b.handleMessage(a):m?this._storeMessage(m,a):d.warn("You received an unrecognized message:",a)}},c.prototype._storeMessage=function(a,b){this._lostMessages[a]||(this._lostMessages[a]=[]),this._lostMessages[a].push(b)},c.prototype._getMessages=function(a){var b=this._lostMessages[a];return b?(delete this._lostMessages[a],b):[]},c.prototype.connect=function(a,b){if(this.disconnected)return d.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect, or call reconnect on this peer if you believe its ID to still be available."),void this.emitError("disconnected","Cannot connect to new Peer after disconnecting from server.");var c=new h(a,this,b);return this._addConnection(a,c),c},c.prototype.call=function(a,b,c){if(this.disconnected)return d.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect."),void this.emitError("disconnected","Cannot connect to new Peer after disconnecting from server.");if(!b)return void d.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");c=c||{},c._stream=b;var e=new g(a,this,c);return this._addConnection(a,e),e},c.prototype._addConnection=function(a,b){this.connections[a]||(this.connections[a]=[]),this.connections[a].push(b)},c.prototype.getConnection=function(a,b){var c=this.connections[a];if(!c)return null;for(var d=0,e=c.length;e>d;d++)if(c[d].id===b)return c[d];return null},c.prototype._delayedAbort=function(a,b){var c=this;d.setZeroTimeout(function(){c._abort(a,b)})},c.prototype._abort=function(a,b){d.error("Aborting!"),this._lastServerId?this.disconnect():this.destroy(),this.emitError(a,b)},c.prototype.emitError=function(a,b){d.error("Error:",b),"string"==typeof b&&(b=new Error(b)),b.type=a,this.emit("error",b)},c.prototype.destroy=function(){this.destroyed||(this._cleanup(),this.disconnect(),this.destroyed=!0)},c.prototype._cleanup=function(){if(this.connections)for(var a=Object.keys(this.connections),b=0,c=a.length;c>b;b++)this._cleanupPeer(a[b]);this.emit("close")},c.prototype._cleanupPeer=function(a){for(var b=this.connections[a],c=0,d=b.length;d>c;c+=1)b[c].close()},c.prototype.disconnect=function(){var a=this;d.setZeroTimeout(function(){a.disconnected||(a.disconnected=!0,a.open=!1,a.socket&&a.socket.close(),a.emit("disconnected",a.id),a._lastServerId=a.id,a.id=null)})},c.prototype.reconnect=function(){if(this.disconnected&&!this.destroyed)d.log("Attempting reconnection to server with ID "+this._lastServerId),this.disconnected=!1,this._initializeServerConnection(),this._initialize(this._lastServerId);else{if(this.destroyed)throw new Error("This peer cannot reconnect to the server. It has already been destroyed.");if(this.disconnected||this.open)throw new Error("Peer "+this.id+" cannot reconnect because it is not disconnected from the server!");d.error("In a hurry? We're still trying to make the initial connection!")}},c.prototype.listAllPeers=function(a){a=a||function(){};var b=this,c=new XMLHttpRequest,e=this.options.secure?"https://":"http://",f=e+this.options.host+":"+this.options.port+this.options.path+this.options.key+"/peers",g="?ts="+(new Date).getTime()+Math.random();f+=g,c.open("get",f,!0),c.onerror=function(){b._abort("server-error","Could not get peers from the server."),a([])},c.onreadystatechange=function(){if(4===c.readyState){if(401===c.status){var e="";throw e=b.options.host!==d.CLOUD_HOST?"It looks like you're using the cloud server. You can email team@peerjs.com to enable peer listing for your API key.":"You need to enable `allow_discovery` on your self-hosted PeerServer to use this feature.",a([]),new Error("It doesn't look like you have permission to list peers IDs. "+e)}a(200!==c.status?[]:JSON.parse(c.responseText))}},c.send(null)},b.exports=c},{"./dataconnection":2,"./mediaconnection":4,"./socket":7,"./util":8,eventemitter3:9}],7:[function(a,b){function c(a,b,d,f,g){if(!(this instanceof c))return new c(a,b,d,f,g);e.call(this),this.disconnected=!1,this._queue=[];var h=a?"https://":"http://",i=a?"wss://":"ws://";this._httpUrl=h+b+":"+d+f+g,this._wsUrl=i+b+":"+d+f+"peerjs?key="+g}var d=a("./util"),e=a("eventemitter3");d.inherits(c,e),c.prototype.start=function(a,b){this.id=a,this._httpUrl+="/"+a+"/"+b,this._wsUrl+="&id="+a+"&token="+b,this._startXhrStream(),this._startWebSocket()},c.prototype._startWebSocket=function(){var a=this;this._socket||(this._socket=new WebSocket(this._wsUrl),this._socket.onmessage=function(b){try{var c=JSON.parse(b.data)}catch(e){return void d.log("Invalid server message",b.data)}a.emit("message",c)},this._socket.onclose=function(){d.log("Socket closed."),a.disconnected=!0,a.emit("disconnected")},this._socket.onopen=function(){a._timeout&&(clearTimeout(a._timeout),setTimeout(function(){a._http.abort(),a._http=null},5e3)),a._sendQueuedMessages(),d.log("Socket open")})},c.prototype._startXhrStream=function(a){try{var b=this;this._http=new XMLHttpRequest,this._http._index=1,this._http._streamIndex=a||0,this._http.open("post",this._httpUrl+"/id?i="+this._http._streamIndex,!0),this._http.onerror=function(){clearTimeout(b._timeout),b.emit("disconnected")},this._http.onreadystatechange=function(){2==this.readyState&&this.old?(this.old.abort(),delete this.old):this.readyState>2&&200===this.status&&this.responseText&&b._handleStream(this)},this._http.send(null),this._setHTTPTimeout()}catch(c){d.log("XMLHttpRequest not available; defaulting to WebSockets")}},c.prototype._handleStream=function(a){var b=a.responseText.split("\n");if(a._buffer)for(;a._buffer.length>0;){var c=a._buffer.shift(),e=b[c];try{e=JSON.parse(e)}catch(f){a._buffer.shift(c);break}this.emit("message",e)}var g=b[a._index];if(g)if(a._index+=1,a._index===b.length)a._buffer||(a._buffer=[]),a._buffer.push(a._index-1);else{try{g=JSON.parse(g)}catch(f){return void d.log("Invalid server message",g)}this.emit("message",g)}},c.prototype._setHTTPTimeout=function(){var a=this;this._timeout=setTimeout(function(){var b=a._http;a._wsOpen()?b.abort():(a._startXhrStream(b._streamIndex+1),a._http.old=b)},25e3)},c.prototype._wsOpen=function(){return this._socket&&1==this._socket.readyState},c.prototype._sendQueuedMessages=function(){for(var a=0,b=this._queue.length;b>a;a+=1)this.send(this._queue[a])},c.prototype.send=function(a){if(!this.disconnected){if(!this.id)return void this._queue.push(a);if(!a.type)return void this.emit("error","Invalid message");var b=JSON.stringify(a);if(this._wsOpen())this._socket.send(b);else{var c=new XMLHttpRequest,d=this._httpUrl+"/"+a.type.toLowerCase();c.open("post",d,!0),c.setRequestHeader("Content-Type","application/json"),c.send(b)}}},c.prototype.close=function(){!this.disconnected&&this._wsOpen()&&(this._socket.close(),this.disconnected=!0)},b.exports=c},{"./util":8,eventemitter3:9}],8:[function(a,b){var c={iceServers:[{url:"stun:stun.l.google.com:19302"}]},d=1,e=a("js-binarypack"),f=a("./adapter").RTCPeerConnection,g={noop:function(){},CLOUD_HOST:"0.peerjs.com",CLOUD_PORT:9e3,chunkedBrowsers:{Chrome:1},chunkedMTU:16300,logLevel:0,setLogLevel:function(a){var b=parseInt(a,10);g.logLevel=isNaN(parseInt(a,10))?a?3:0:b,g.log=g.warn=g.error=g.noop,g.logLevel>0&&(g.error=g._printWith("ERROR")),g.logLevel>1&&(g.warn=g._printWith("WARNING")),g.logLevel>2&&(g.log=g._print)},setLogFunction:function(a){a.constructor!==Function?g.warn("The log function you passed in is not a function. Defaulting to regular logs."):g._print=a},_printWith:function(a){return function(){var b=Array.prototype.slice.call(arguments);b.unshift(a),g._print.apply(g,b)}},_print:function(){var a=!1,b=Array.prototype.slice.call(arguments);b.unshift("PeerJS: ");for(var c=0,d=b.length;d>c;c++)b[c]instanceof Error&&(b[c]="("+b[c].name+") "+b[c].message,a=!0);a?console.error.apply(console,b):console.log.apply(console,b)},defaultConfig:c,browser:function(){return window.mozRTCPeerConnection?"Firefox":window.webkitRTCPeerConnection?"Chrome":window.RTCPeerConnection?"Supported":"Unsupported"}(),supports:function(){if("undefined"==typeof f)return{};var a,b,d=!0,e=!0,h=!1,i=!1,j=!!window.webkitRTCPeerConnection;try{a=new f(c,{optional:[{RtpDataChannels:!0}]})}catch(k){d=!1,e=!1}if(d)try{b=a.createDataChannel("_PEERJSTEST")}catch(k){d=!1}if(d){try{b.binaryType="blob",h=!0}catch(k){}var l=new f(c,{});try{var m=l.createDataChannel("_PEERJSRELIABLETEST",{});i=m.reliable}catch(k){}l.close()}if(e&&(e=!!a.addStream),!j&&d){var n=new f(c,{optional:[{RtpDataChannels:!0}]});n.onnegotiationneeded=function(){j=!0,g&&g.supports&&(g.supports.onnegotiationneeded=!0)},n.createDataChannel("_PEERJSNEGOTIATIONTEST"),setTimeout(function(){n.close()},1e3)}return a&&a.close(),{audioVideo:e,data:d,binaryBlob:h,binary:i,reliable:i,sctp:i,onnegotiationneeded:j}}(),validateId:function(a){return!a||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.exec(a)},validateKey:function(a){return!a||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.exec(a)},debug:!1,inherits:function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})},extend:function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a},pack:e.pack,unpack:e.unpack,log:function(){if(g.debug){var a=!1,b=Array.prototype.slice.call(arguments);b.unshift("PeerJS: ");for(var c=0,d=b.length;d>c;c++)b[c]instanceof Error&&(b[c]="("+b[c].name+") "+b[c].message,a=!0);a?console.error.apply(console,b):console.log.apply(console,b)}},setZeroTimeout:function(a){function b(b){d.push(b),a.postMessage(e,"*")}function c(b){b.source==a&&b.data==e&&(b.stopPropagation&&b.stopPropagation(),d.length&&d.shift()())}var d=[],e="zero-timeout-message";return a.addEventListener?a.addEventListener("message",c,!0):a.attachEvent&&a.attachEvent("onmessage",c),b}(window),chunk:function(a){for(var b=[],c=a.size,e=index=0,f=Math.ceil(c/g.chunkedMTU);c>e;){var h=Math.min(c,e+g.chunkedMTU),i=a.slice(e,h),j={__peerData:d,n:index,data:i,total:f};b.push(j),e=h,index+=1}return d+=1,b},blobToArrayBuffer:function(a,b){var c=new FileReader;c.onload=function(a){b(a.target.result)},c.readAsArrayBuffer(a)},blobToBinaryString:function(a,b){var c=new FileReader;c.onload=function(a){b(a.target.result)},c.readAsBinaryString(a)},binaryStringToArrayBuffer:function(a){for(var b=new Uint8Array(a.length),c=0;cb;b++)d.push(this._events[a][b].fn);return d},d.prototype.emit=function(a,b,c,d,e,f){if(!this._events||!this._events[a])return!1;var g,h,i,j=this._events[a],k=j.length,l=arguments.length,m=j[0];if(1===k){switch(m.once&&this.removeListener(a,m.fn,!0),l){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,b),!0;case 3:return m.fn.call(m.context,b,c),!0;case 4:return m.fn.call(m.context,b,c,d),!0;case 5:return m.fn.call(m.context,b,c,d,e),!0;case 6:return m.fn.call(m.context,b,c,d,e,f),!0}for(h=1,g=new Array(l-1);l>h;h++)g[h-1]=arguments[h];m.fn.apply(m.context,g)}else for(h=0;k>h;h++)switch(j[h].once&&this.removeListener(a,j[h].fn,!0),l){case 1:j[h].fn.call(j[h].context);break;case 2:j[h].fn.call(j[h].context,b);break;case 3:j[h].fn.call(j[h].context,b,c);break;default:if(!g)for(i=1,g=new Array(l-1);l>i;i++)g[i-1]=arguments[i];j[h].fn.apply(j[h].context,g)}return!0},d.prototype.on=function(a,b,d){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),this._events[a].push(new c(b,d||this)),this},d.prototype.once=function(a,b,d){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),this._events[a].push(new c(b,d||this,!0)),this},d.prototype.removeListener=function(a,b,c){if(!this._events||!this._events[a])return this;var d=this._events[a],e=[];if(b)for(var f=0,g=d.length;g>f;f++)d[f].fn!==b&&d[f].once!==c&&e.push(d[f]);return this._events[a]=e.length?e:null,this},d.prototype.removeAllListeners=function(a){return this._events?(a?this._events[a]=null:this._events={},this):this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prototype.setMaxListeners=function(){return this},d.EventEmitter=d,d.EventEmitter2=d,d.EventEmitter3=d,"object"==typeof b&&b.exports&&(b.exports=d)},{}],10:[function(a,b){function c(a){this.index=0,this.dataBuffer=a,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}function d(){this.bufferBuilder=new g}function e(a){var b=a.charCodeAt(0);return 2047>=b?"00":65535>=b?"000":2097151>=b?"0000":67108863>=b?"00000":"000000"}function f(a){return a.length>600?new Blob([a]).size:a.replace(/[^\u0000-\u007F]/g,e).length}var g=a("./bufferbuilder").BufferBuilder,h=a("./bufferbuilder").binaryFeatures,i={unpack:function(a){var b=new c(a);return b.unpack()},pack:function(a){var b=new d;b.pack(a);var c=b.getBuffer();return c}};b.exports=i,c.prototype.unpack=function(){var a=this.unpack_uint8();if(128>a){var b=a;return b}if(32>(224^a)){var c=(224^a)-32;return c}var d;if((d=160^a)<=15)return this.unpack_raw(d);if((d=176^a)<=15)return this.unpack_string(d);if((d=144^a)<=15)return this.unpack_array(d);if((d=128^a)<=15)return this.unpack_map(d);switch(a){case 192:return null;case 193:return void 0;case 194:return!1;case 195:return!0;case 202:return this.unpack_float();case 203:return this.unpack_double();case 204:return this.unpack_uint8();case 205:return this.unpack_uint16();case 206:return this.unpack_uint32();case 207:return this.unpack_uint64();case 208:return this.unpack_int8();case 209:return this.unpack_int16();case 210:return this.unpack_int32();case 211:return this.unpack_int64();case 212:return void 0;case 213:return void 0;case 214:return void 0;case 215:return void 0;case 216:return d=this.unpack_uint16(),this.unpack_string(d);case 217:return d=this.unpack_uint32(),this.unpack_string(d);case 218:return d=this.unpack_uint16(),this.unpack_raw(d);case 219:return d=this.unpack_uint32(),this.unpack_raw(d);case 220:return d=this.unpack_uint16(),this.unpack_array(d);case 221:return d=this.unpack_uint32(),this.unpack_array(d);case 222:return d=this.unpack_uint16(),this.unpack_map(d);case 223:return d=this.unpack_uint32(),this.unpack_map(d)}},c.prototype.unpack_uint8=function(){var a=255&this.dataView[this.index];return this.index++,a},c.prototype.unpack_uint16=function(){var a=this.read(2),b=256*(255&a[0])+(255&a[1]);return this.index+=2,b},c.prototype.unpack_uint32=function(){var a=this.read(4),b=256*(256*(256*a[0]+a[1])+a[2])+a[3];return this.index+=4,b},c.prototype.unpack_uint64=function(){var a=this.read(8),b=256*(256*(256*(256*(256*(256*(256*a[0]+a[1])+a[2])+a[3])+a[4])+a[5])+a[6])+a[7];return this.index+=8,b},c.prototype.unpack_int8=function(){var a=this.unpack_uint8();return 128>a?a:a-256},c.prototype.unpack_int16=function(){var a=this.unpack_uint16();return 32768>a?a:a-65536},c.prototype.unpack_int32=function(){var a=this.unpack_uint32();return ae;)b=d[e],128>b?(f+=String.fromCharCode(b),e++):32>(192^b)?(c=(192^b)<<6|63&d[e+1],f+=String.fromCharCode(c),e+=2):(c=(15&b)<<12|(63&d[e+1])<<6|63&d[e+2],f+=String.fromCharCode(c),e+=3);return this.index+=a,f},c.prototype.unpack_array=function(a){for(var b=new Array(a),c=0;a>c;c++)b[c]=this.unpack();return b},c.prototype.unpack_map=function(a){for(var b={},c=0;a>c;c++){var d=this.unpack(),e=this.unpack();b[d]=e}return b},c.prototype.unpack_float=function(){var a=this.unpack_uint32(),b=a>>31,c=(a>>23&255)-127,d=8388607&a|8388608;return(0==b?1:-1)*d*Math.pow(2,c-23)},c.prototype.unpack_double=function(){var a=this.unpack_uint32(),b=this.unpack_uint32(),c=a>>31,d=(a>>20&2047)-1023,e=1048575&a|1048576,f=e*Math.pow(2,d-20)+b*Math.pow(2,d-52);return(0==c?1:-1)*f},c.prototype.read=function(a){var b=this.index;if(b+a<=this.length)return this.dataView.subarray(b,b+a);throw new Error("BinaryPackFailure: read index out of range")},d.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()},d.prototype.pack=function(a){var b=typeof a;if("string"==b)this.pack_string(a);else if("number"==b)Math.floor(a)===a?this.pack_integer(a):this.pack_double(a);else if("boolean"==b)a===!0?this.bufferBuilder.append(195):a===!1&&this.bufferBuilder.append(194);else if("undefined"==b)this.bufferBuilder.append(192);else{if("object"!=b)throw new Error('Type "'+b+'" not yet supported');if(null===a)this.bufferBuilder.append(192);else{var c=a.constructor;if(c==Array)this.pack_array(a);else if(c==Blob||c==File)this.pack_bin(a); +else if(c==ArrayBuffer)this.pack_bin(h.useArrayBufferView?new Uint8Array(a):a);else if("BYTES_PER_ELEMENT"in a)this.pack_bin(h.useArrayBufferView?new Uint8Array(a.buffer):a.buffer);else if(c==Object)this.pack_object(a);else if(c==Date)this.pack_string(a.toString());else{if("function"!=typeof a.toBinaryPack)throw new Error('Type "'+c.toString()+'" not yet supported');this.bufferBuilder.append(a.toBinaryPack())}}}this.bufferBuilder.flush()},d.prototype.pack_bin=function(a){var b=a.length||a.byteLength||a.size;if(15>=b)this.pack_uint8(160+b);else if(65535>=b)this.bufferBuilder.append(218),this.pack_uint16(b);else{if(!(4294967295>=b))throw new Error("Invalid length");this.bufferBuilder.append(219),this.pack_uint32(b)}this.bufferBuilder.append(a)},d.prototype.pack_string=function(a){var b=f(a);if(15>=b)this.pack_uint8(176+b);else if(65535>=b)this.bufferBuilder.append(216),this.pack_uint16(b);else{if(!(4294967295>=b))throw new Error("Invalid length");this.bufferBuilder.append(217),this.pack_uint32(b)}this.bufferBuilder.append(a)},d.prototype.pack_array=function(a){var b=a.length;if(15>=b)this.pack_uint8(144+b);else if(65535>=b)this.bufferBuilder.append(220),this.pack_uint16(b);else{if(!(4294967295>=b))throw new Error("Invalid length");this.bufferBuilder.append(221),this.pack_uint32(b)}for(var c=0;b>c;c++)this.pack(a[c])},d.prototype.pack_integer=function(a){if(a>=-32&&127>=a)this.bufferBuilder.append(255&a);else if(a>=0&&255>=a)this.bufferBuilder.append(204),this.pack_uint8(a);else if(a>=-128&&127>=a)this.bufferBuilder.append(208),this.pack_int8(a);else if(a>=0&&65535>=a)this.bufferBuilder.append(205),this.pack_uint16(a);else if(a>=-32768&&32767>=a)this.bufferBuilder.append(209),this.pack_int16(a);else if(a>=0&&4294967295>=a)this.bufferBuilder.append(206),this.pack_uint32(a);else if(a>=-2147483648&&2147483647>=a)this.bufferBuilder.append(210),this.pack_int32(a);else if(a>=-0x8000000000000000&&0x8000000000000000>=a)this.bufferBuilder.append(211),this.pack_int64(a);else{if(!(a>=0&&0x10000000000000000>=a))throw new Error("Invalid integer");this.bufferBuilder.append(207),this.pack_uint64(a)}},d.prototype.pack_double=function(a){var b=0;0>a&&(b=1,a=-a);var c=Math.floor(Math.log(a)/Math.LN2),d=a/Math.pow(2,c)-1,e=Math.floor(d*Math.pow(2,52)),f=Math.pow(2,32),g=b<<31|c+1023<<20|e/f&1048575,h=e%f;this.bufferBuilder.append(203),this.pack_int32(g),this.pack_int32(h)},d.prototype.pack_object=function(a){var b=Object.keys(a),c=b.length;if(15>=c)this.pack_uint8(128+c);else if(65535>=c)this.bufferBuilder.append(222),this.pack_uint16(c);else{if(!(4294967295>=c))throw new Error("Invalid length");this.bufferBuilder.append(223),this.pack_uint32(c)}for(var d in a)a.hasOwnProperty(d)&&(this.pack(d),this.pack(a[d]))},d.prototype.pack_uint8=function(a){this.bufferBuilder.append(a)},d.prototype.pack_uint16=function(a){this.bufferBuilder.append(a>>8),this.bufferBuilder.append(255&a)},d.prototype.pack_uint32=function(a){var b=4294967295&a;this.bufferBuilder.append((4278190080&b)>>>24),this.bufferBuilder.append((16711680&b)>>>16),this.bufferBuilder.append((65280&b)>>>8),this.bufferBuilder.append(255&b)},d.prototype.pack_uint64=function(a){var b=a/Math.pow(2,32),c=a%Math.pow(2,32);this.bufferBuilder.append((4278190080&b)>>>24),this.bufferBuilder.append((16711680&b)>>>16),this.bufferBuilder.append((65280&b)>>>8),this.bufferBuilder.append(255&b),this.bufferBuilder.append((4278190080&c)>>>24),this.bufferBuilder.append((16711680&c)>>>16),this.bufferBuilder.append((65280&c)>>>8),this.bufferBuilder.append(255&c)},d.prototype.pack_int8=function(a){this.bufferBuilder.append(255&a)},d.prototype.pack_int16=function(a){this.bufferBuilder.append((65280&a)>>8),this.bufferBuilder.append(255&a)},d.prototype.pack_int32=function(a){this.bufferBuilder.append(a>>>24&255),this.bufferBuilder.append((16711680&a)>>>16),this.bufferBuilder.append((65280&a)>>>8),this.bufferBuilder.append(255&a)},d.prototype.pack_int64=function(a){var b=Math.floor(a/Math.pow(2,32)),c=a%Math.pow(2,32);this.bufferBuilder.append((4278190080&b)>>>24),this.bufferBuilder.append((16711680&b)>>>16),this.bufferBuilder.append((65280&b)>>>8),this.bufferBuilder.append(255&b),this.bufferBuilder.append((4278190080&c)>>>24),this.bufferBuilder.append((16711680&c)>>>16),this.bufferBuilder.append((65280&c)>>>8),this.bufferBuilder.append(255&c)}},{"./bufferbuilder":11}],11:[function(a,b){function c(){this._pieces=[],this._parts=[]}var d={};d.useBlobBuilder=function(){try{return new Blob([]),!1}catch(a){return!0}}(),d.useArrayBufferView=!d.useBlobBuilder&&function(){try{return 0===new Blob([new Uint8Array([])]).size}catch(a){return!0}}(),b.exports.binaryFeatures=d;var e=b.exports.BlobBuilder;"undefined"!=typeof window&&(e=b.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder),c.prototype.append=function(a){"number"==typeof a?this._pieces.push(a):(this.flush(),this._parts.push(a))},c.prototype.flush=function(){if(this._pieces.length>0){var a=new Uint8Array(this._pieces);d.useArrayBufferView||(a=a.buffer),this._parts.push(a),this._pieces=[]}},c.prototype.getBuffer=function(){if(this.flush(),d.useBlobBuilder){for(var a=new e,b=0,c=this._parts.length;c>b;b++)a.append(this._parts[b]);return a.getBlob()}return new Blob(this._parts)},b.exports.BufferBuilder=c},{}],12:[function(a,b){function c(a,b){return this instanceof c?(this._dc=a,d.debug=b,this._outgoing={},this._incoming={},this._received={},this._window=1e3,this._mtu=500,this._interval=0,this._count=0,this._queue=[],void this._setupDC()):new c(a)}var d=a("./util");c.prototype.send=function(a){var b=d.pack(a);return b.sizec;c+=1)a._intervalSend(b[c]);else a._intervalSend(b)},this._interval)},c.prototype._intervalSend=function(a){var b=this;a=d.pack(a),d.blobToBinaryString(a,function(a){b._dc.send(a)}),0===b._queue.length&&(clearTimeout(b._timeout),b._timeout=null)},c.prototype._processAcks=function(){for(var a in this._outgoing)this._outgoing.hasOwnProperty(a)&&this._sendWindowedChunks(a)},c.prototype._handleSend=function(a){for(var b=!0,c=0,d=this._queue.length;d>c;c+=1){var e=this._queue[c];e===a?b=!1:e._multiple&&-1!==e.indexOf(a)&&(b=!1)}b&&(this._queue.push(a),this._timeout||this._setupInterval())},c.prototype._setupDC=function(){var a=this;this._dc.onmessage=function(b){var c=b.data,e=c.constructor;if(e===String){var f=d.binaryStringToArrayBuffer(c);c=d.unpack(f),a._handleMessage(c)}}},c.prototype._handleMessage=function(a){var b,c=a[1],e=this._incoming[c],f=this._outgoing[c];switch(a[0]){case"no":var g=c;g&&this.onmessage(d.unpack(g));break;case"end":if(b=e,this._received[c]=a[2],!b)break;this._ack(c);break;case"ack":if(b=f){var h=a[2];b.ack=Math.max(h,b.ack),b.ack>=b.chunks.length?(d.log("Time: ",new Date-b.timer),delete this._outgoing[c]):this._processAcks()}break;case"chunk":if(b=e,!b){var i=this._received[c];if(i===!0)break;b={ack:["ack",c,0],chunks:[]},this._incoming[c]=b}var j=a[2],k=a[3];b.chunks[j]=new Uint8Array(k),j===b.ack[2]&&this._calculateNextAck(c),this._ack(c);break;default:this._handleSend(a)}},c.prototype._chunk=function(a){for(var b=[],c=a.size,e=0;c>e;){var f=Math.min(c,e+this._mtu),g=a.slice(e,f),h={payload:g};b.push(h),e=f}return d.log("Created",b.length,"chunks."),b},c.prototype._ack=function(a){var b=this._incoming[a].ack;this._received[a]===b[2]&&(this._complete(a),this._received[a]=!0),this._handleSend(b)},c.prototype._calculateNextAck=function(a){for(var b=this._incoming[a],c=b.chunks,d=0,e=c.length;e>d;d+=1)if(void 0===c[d])return void(b.ack[2]=d);b.ack[2]=c.length},c.prototype._sendWindowedChunks=function(a){d.log("sendWindowedChunks for: ",a);for(var b=this._outgoing[a],c=b.chunks,e=[],f=Math.min(b.ack+this._window,c.length),g=b.ack;f>g;g+=1)c[g].sent&&g!==b.ack||(c[g].sent=!0,e.push(["chunk",a,g,c[g].payload]));b.ack+this._window>=c.length&&e.push(["end",a,c.length]),e._multiple=!0,this._handleSend(e)},c.prototype._complete=function(a){d.log("Completed called for",a);var b=this,c=this._incoming[a].chunks,e=new Blob(c);d.blobToArrayBuffer(e,function(a){b.onmessage(d.unpack(a))}),delete this._incoming[a]},c.higherBandwidthSDP=function(a){var b=navigator.appVersion.match(/Chrome\/(.*?) /);if(b&&(b=parseInt(b[1].split(".").shift()),31>b)){var c=a.split("b=AS:30"),d="b=AS:102400";if(c.length>1)return c[0]+d+c[1]}return a},c.prototype.onmessage=function(){},b.exports.Reliable=c},{"./util":13}],13:[function(a,b){var c=a("js-binarypack"),d={debug:!1,inherits:function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})},extend:function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a},pack:c.pack,unpack:c.unpack,log:function(){if(d.debug){for(var a=[],b=0;b type pairs - class2type = {}, +var class2type = {}; - // List of deleted data cache ids, so we can reuse them - core_deletedIds = [], +var toString = class2type.toString; - core_version = "1.10.2", +var hasOwn = class2type.hasOwnProperty; - // Save a reference to some core methods - core_concat = core_deletedIds.concat, - core_push = core_deletedIds.push, - core_slice = core_deletedIds.slice, - core_indexOf = core_deletedIds.indexOf, - core_toString = class2type.toString, - core_hasOwn = class2type.hasOwnProperty, - core_trim = core_version.trim, +var support = {}; + + + +var + version = "2.2.2", // Define a local copy of jQuery jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' - return new jQuery.fn.init( selector, context, rootjQuery ); + // Need init if jQuery is called (just allow error to be thrown if not included) + return new jQuery.fn.init( selector, context ); }, - // Used for matching numbers - core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, - - // Used for splitting on whitespace - core_rnotwhite = /\S+/g, - - // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) + // Support: Android<4.1 + // Make sure we trim BOM and NBSP rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, - // A simple way to check for HTML strings - // Prioritize #id over to avoid XSS via location.hash (#9521) - // Strict HTML recognition (#11290: must start with <) - rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, - - // Match a standalone tag - rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, - - // JSON RegExp - rvalidchars = /^[\],:{}\s]*$/, - rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, - rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, - rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g, - // Matches dashed string for camelizing rmsPrefix = /^-ms-/, rdashAlpha = /-([\da-z])/gi, @@ -93,134 +86,14 @@ var // Used by jQuery.camelCase as callback to replace() fcamelCase = function( all, letter ) { return letter.toUpperCase(); - }, - - // The ready event handler - completed = function( event ) { - - // readyState === "complete" is good enough for us to call the dom ready in oldIE - if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) { - detach(); - jQuery.ready(); - } - }, - // Clean-up method for dom ready events - detach = function() { - if ( document.addEventListener ) { - document.removeEventListener( "DOMContentLoaded", completed, false ); - window.removeEventListener( "load", completed, false ); - - } else { - document.detachEvent( "onreadystatechange", completed ); - window.detachEvent( "onload", completed ); - } }; jQuery.fn = jQuery.prototype = { + // The current version of jQuery being used - jquery: core_version, + jquery: version, constructor: jQuery, - init: function( selector, context, rootjQuery ) { - var match, elem; - - // HANDLE: $(""), $(null), $(undefined), $(false) - if ( !selector ) { - return this; - } - - // Handle HTML strings - if ( typeof selector === "string" ) { - if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { - // Assume that strings that start and end with <> are HTML and skip the regex check - match = [ null, selector, null ]; - - } else { - match = rquickExpr.exec( selector ); - } - - // Match html or make sure no context is specified for #id - if ( match && (match[1] || !context) ) { - - // HANDLE: $(html) -> $(array) - if ( match[1] ) { - context = context instanceof jQuery ? context[0] : context; - - // scripts is true for back-compat - jQuery.merge( this, jQuery.parseHTML( - match[1], - context && context.nodeType ? context.ownerDocument || context : document, - true - ) ); - - // HANDLE: $(html, props) - if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { - for ( match in context ) { - // Properties of context are called as methods if possible - if ( jQuery.isFunction( this[ match ] ) ) { - this[ match ]( context[ match ] ); - - // ...and otherwise set as attributes - } else { - this.attr( match, context[ match ] ); - } - } - } - - return this; - - // HANDLE: $(#id) - } else { - elem = document.getElementById( match[2] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id !== match[2] ) { - return rootjQuery.find( selector ); - } - - // Otherwise, we inject the element directly into the jQuery object - this.length = 1; - this[0] = elem; - } - - this.context = document; - this.selector = selector; - return this; - } - - // HANDLE: $(expr, $(...)) - } else if ( !context || context.jquery ) { - return ( context || rootjQuery ).find( selector ); - - // HANDLE: $(expr, context) - // (which is just equivalent to: $(context).find(expr) - } else { - return this.constructor( context ).find( selector ); - } - - // HANDLE: $(DOMElement) - } else if ( selector.nodeType ) { - this.context = this[0] = selector; - this.length = 1; - return this; - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction( selector ) ) { - return rootjQuery.ready( selector ); - } - - if ( selector.selector !== undefined ) { - this.selector = selector.selector; - this.context = selector.context; - } - - return jQuery.makeArray( selector, this ); - }, // Start with an empty selector selector: "", @@ -229,19 +102,19 @@ jQuery.fn = jQuery.prototype = { length: 0, toArray: function() { - return core_slice.call( this ); + return slice.call( this ); }, // Get the Nth element in the matched element set OR // Get the whole matched element set as a clean array get: function( num ) { - return num == null ? + return num != null ? - // Return a 'clean' array - this.toArray() : + // Return just the one element from the set + ( num < 0 ? this[ num + this.length ] : this[ num ] ) : - // Return just the object - ( num < 0 ? this[ this.length + num ] : this[ num ] ); + // Return all the elements in a clean array + slice.call( this ); }, // Take an array of elements and push it onto the stack @@ -260,21 +133,18 @@ jQuery.fn = jQuery.prototype = { }, // Execute a callback for every element in the matched set. - // (You can seed the arguments with an array of args, but this is - // only used internally.) - each: function( callback, args ) { - return jQuery.each( this, callback, args ); + each: function( callback ) { + return jQuery.each( this, callback ); }, - ready: function( fn ) { - // Add the callback - jQuery.ready.promise().done( fn ); - - return this; + map: function( callback ) { + return this.pushStack( jQuery.map( this, function( elem, i ) { + return callback.call( elem, i, elem ); + } ) ); }, slice: function() { - return this.pushStack( core_slice.apply( this, arguments ) ); + return this.pushStack( slice.apply( this, arguments ) ); }, first: function() { @@ -288,32 +158,23 @@ jQuery.fn = jQuery.prototype = { eq: function( i ) { var len = this.length, j = +i + ( i < 0 ? len : 0 ); - return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); - }, - - map: function( callback ) { - return this.pushStack( jQuery.map(this, function( elem, i ) { - return callback.call( elem, i, elem ); - })); + return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); }, end: function() { - return this.prevObject || this.constructor(null); + return this.prevObject || this.constructor(); }, // For internal use only. // Behaves like an Array's method, not like a jQuery method. - push: core_push, - sort: [].sort, - splice: [].splice + push: push, + sort: arr.sort, + splice: arr.splice }; -// Give the init function the jQuery prototype for later instantiation -jQuery.fn.init.prototype = jQuery.fn; - jQuery.extend = jQuery.fn.extend = function() { - var src, copyIsArray, copy, name, options, clone, - target = arguments[0] || {}, + var options, name, src, copy, copyIsArray, clone, + target = arguments[ 0 ] || {}, i = 1, length = arguments.length, deep = false; @@ -321,25 +182,28 @@ jQuery.extend = jQuery.fn.extend = function() { // Handle a deep copy situation if ( typeof target === "boolean" ) { deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; + + // Skip the boolean and the target + target = arguments[ i ] || {}; + i++; } // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + if ( typeof target !== "object" && !jQuery.isFunction( target ) ) { target = {}; } - // extend jQuery itself if only one argument is passed - if ( length === i ) { + // Extend jQuery itself if only one argument is passed + if ( i === length ) { target = this; - --i; + i--; } for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) { + if ( ( options = arguments[ i ] ) != null ) { + // Extend the base object for ( name in options ) { src = target[ name ]; @@ -351,13 +215,15 @@ jQuery.extend = jQuery.fn.extend = function() { } // Recurse if we're merging plain objects or arrays - if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( deep && copy && ( jQuery.isPlainObject( copy ) || + ( copyIsArray = jQuery.isArray( copy ) ) ) ) { + if ( copyIsArray ) { copyIsArray = false; - clone = src && jQuery.isArray(src) ? src : []; + clone = src && jQuery.isArray( src ) ? src : []; } else { - clone = src && jQuery.isPlainObject(src) ? src : {}; + clone = src && jQuery.isPlainObject( src ) ? src : {}; } // Never move original objects, clone them @@ -375,133 +241,63 @@ jQuery.extend = jQuery.fn.extend = function() { return target; }; -jQuery.extend({ - // Unique for each copy of jQuery on the page - // Non-digits removed to match rinlinejQuery - expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ), - - noConflict: function( deep ) { - if ( window.$ === jQuery ) { - window.$ = _$; - } - - if ( deep && window.jQuery === jQuery ) { - window.jQuery = _jQuery; - } - - return jQuery; - }, +jQuery.extend( { - // Is the DOM ready to be used? Set to true once it occurs. - isReady: false, + // Unique for each copy of jQuery on the page + expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), - // A counter to track how many items to wait for before - // the ready event fires. See #6781 - readyWait: 1, + // Assume jQuery is ready without the ready module + isReady: true, - // Hold (or release) the ready event - holdReady: function( hold ) { - if ( hold ) { - jQuery.readyWait++; - } else { - jQuery.ready( true ); - } + error: function( msg ) { + throw new Error( msg ); }, - // Handle when the DOM is ready - ready: function( wait ) { - - // Abort if there are pending holds or we're already ready - if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { - return; - } - - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( !document.body ) { - return setTimeout( jQuery.ready ); - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if ( wait !== true && --jQuery.readyWait > 0 ) { - return; - } - - // If there are functions bound, to execute - readyList.resolveWith( document, [ jQuery ] ); - - // Trigger any bound ready events - if ( jQuery.fn.trigger ) { - jQuery( document ).trigger("ready").off("ready"); - } - }, + noop: function() {}, - // See test/unit/core.js for details concerning isFunction. - // Since version 1.3, DOM methods and functions like alert - // aren't supported. They return false on IE (#2968). isFunction: function( obj ) { - return jQuery.type(obj) === "function"; + return jQuery.type( obj ) === "function"; }, - isArray: Array.isArray || function( obj ) { - return jQuery.type(obj) === "array"; - }, + isArray: Array.isArray, isWindow: function( obj ) { - /* jshint eqeqeq: false */ - return obj != null && obj == obj.window; + return obj != null && obj === obj.window; }, isNumeric: function( obj ) { - return !isNaN( parseFloat(obj) ) && isFinite( obj ); - }, - type: function( obj ) { - if ( obj == null ) { - return String( obj ); - } - return typeof obj === "object" || typeof obj === "function" ? - class2type[ core_toString.call(obj) ] || "object" : - typeof obj; + // parseFloat NaNs numeric-cast false positives (null|true|false|"") + // ...but misinterprets leading-number strings, particularly hex literals ("0x...") + // subtraction forces infinities to NaN + // adding 1 corrects loss of precision from parseFloat (#15100) + var realStringObj = obj && obj.toString(); + return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0; }, isPlainObject: function( obj ) { var key; - // Must be an Object. - // Because of IE, we also have to check the presence of the constructor property. - // Make sure that DOM nodes and window objects don't pass through, as well - if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + // Not plain objects: + // - Any object or value whose internal [[Class]] property is not "[object Object]" + // - DOM nodes + // - window + if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { return false; } - try { - // Not own constructor property must be Object - if ( obj.constructor && - !core_hasOwn.call(obj, "constructor") && - !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { - return false; - } - } catch ( e ) { - // IE8,9 Will throw exceptions on certain host objects #9897 + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call( obj, "constructor" ) && + !hasOwn.call( obj.constructor.prototype || {}, "isPrototypeOf" ) ) { return false; } - // Support: IE<9 - // Handle iteration over inherited properties before own properties. - if ( jQuery.support.ownLast ) { - for ( key in obj ) { - return core_hasOwn.call( obj, key ); - } - } - // Own properties are enumerated firstly, so to speed up, - // if last one is own, then all properties are own. + // if last one is own, then all properties are own for ( key in obj ) {} - return key === undefined || core_hasOwn.call( obj, key ); + return key === undefined || hasOwn.call( obj, key ); }, isEmptyObject: function( obj ) { @@ -512,109 +308,45 @@ jQuery.extend({ return true; }, - error: function( msg ) { - throw new Error( msg ); - }, - - // data: string of html - // context (optional): If specified, the fragment will be created in this context, defaults to document - // keepScripts (optional): If true, will include scripts passed in the html string - parseHTML: function( data, context, keepScripts ) { - if ( !data || typeof data !== "string" ) { - return null; - } - if ( typeof context === "boolean" ) { - keepScripts = context; - context = false; - } - context = context || document; - - var parsed = rsingleTag.exec( data ), - scripts = !keepScripts && []; - - // Single tag - if ( parsed ) { - return [ context.createElement( parsed[1] ) ]; + type: function( obj ) { + if ( obj == null ) { + return obj + ""; } - parsed = jQuery.buildFragment( [ data ], context, scripts ); - if ( scripts ) { - jQuery( scripts ).remove(); - } - return jQuery.merge( [], parsed.childNodes ); + // Support: Android<4.0, iOS<6 (functionish RegExp) + return typeof obj === "object" || typeof obj === "function" ? + class2type[ toString.call( obj ) ] || "object" : + typeof obj; }, - parseJSON: function( data ) { - // Attempt to parse using the native JSON parser first - if ( window.JSON && window.JSON.parse ) { - return window.JSON.parse( data ); - } - - if ( data === null ) { - return data; - } - - if ( typeof data === "string" ) { + // Evaluates a script in a global context + globalEval: function( code ) { + var script, + indirect = eval; - // Make sure leading/trailing whitespace is removed (IE can't handle it) - data = jQuery.trim( data ); + code = jQuery.trim( code ); - if ( data ) { - // Make sure the incoming data is actual JSON - // Logic borrowed from http://json.org/json2.js - if ( rvalidchars.test( data.replace( rvalidescape, "@" ) - .replace( rvalidtokens, "]" ) - .replace( rvalidbraces, "")) ) { + if ( code ) { - return ( new Function( "return " + data ) )(); - } - } - } + // If the code includes a valid, prologue position + // strict mode pragma, execute code by injecting a + // script tag into the document. + if ( code.indexOf( "use strict" ) === 1 ) { + script = document.createElement( "script" ); + script.text = code; + document.head.appendChild( script ).parentNode.removeChild( script ); + } else { - jQuery.error( "Invalid JSON: " + data ); - }, + // Otherwise, avoid the DOM node creation, insertion + // and removal by using an indirect global eval - // Cross-browser xml parsing - parseXML: function( data ) { - var xml, tmp; - if ( !data || typeof data !== "string" ) { - return null; - } - try { - if ( window.DOMParser ) { // Standard - tmp = new DOMParser(); - xml = tmp.parseFromString( data , "text/xml" ); - } else { // IE - xml = new ActiveXObject( "Microsoft.XMLDOM" ); - xml.async = "false"; - xml.loadXML( data ); + indirect( code ); } - } catch( e ) { - xml = undefined; - } - if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { - jQuery.error( "Invalid XML: " + data ); - } - return xml; - }, - - noop: function() {}, - - // Evaluates a script in a global context - // Workarounds based on findings by Jim Driscoll - // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context - globalEval: function( data ) { - if ( data && jQuery.trim( data ) ) { - // We use execScript on Internet Explorer - // We use an anonymous function so that context is window - // rather than jQuery in Firefox - ( window.execScript || function( data ) { - window[ "eval" ].call( window, data ); - } )( data ); } }, // Convert dashed to camelCase; used by the css and data modules + // Support: IE9-11+ // Microsoft forgot to hump their vendor prefix (#9572) camelCase: function( string ) { return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); @@ -624,49 +356,20 @@ jQuery.extend({ return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); }, - // args is for internal usage only - each: function( obj, callback, args ) { - var value, - i = 0, - length = obj.length, - isArray = isArraylike( obj ); - - if ( args ) { - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback.apply( obj[ i ], args ); - - if ( value === false ) { - break; - } - } - } else { - for ( i in obj ) { - value = callback.apply( obj[ i ], args ); + each: function( obj, callback ) { + var length, i = 0; - if ( value === false ) { - break; - } + if ( isArrayLike( obj ) ) { + length = obj.length; + for ( ; i < length; i++ ) { + if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { + break; } } - - // A special, fast, case for the most common use of each } else { - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback.call( obj[ i ], i, obj[ i ] ); - - if ( value === false ) { - break; - } - } - } else { - for ( i in obj ) { - value = callback.call( obj[ i ], i, obj[ i ] ); - - if ( value === false ) { - break; - } + for ( i in obj ) { + if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { + break; } } } @@ -674,33 +377,25 @@ jQuery.extend({ return obj; }, - // Use native String.trim function wherever possible - trim: core_trim && !core_trim.call("\uFEFF\xA0") ? - function( text ) { - return text == null ? - "" : - core_trim.call( text ); - } : - - // Otherwise use our own trimming functionality - function( text ) { - return text == null ? - "" : - ( text + "" ).replace( rtrim, "" ); - }, + // Support: Android<4.1 + trim: function( text ) { + return text == null ? + "" : + ( text + "" ).replace( rtrim, "" ); + }, // results is for internal usage only makeArray: function( arr, results ) { var ret = results || []; if ( arr != null ) { - if ( isArraylike( Object(arr) ) ) { + if ( isArrayLike( Object( arr ) ) ) { jQuery.merge( ret, typeof arr === "string" ? [ arr ] : arr ); } else { - core_push.call( ret, arr ); + push.call( ret, arr ); } } @@ -708,40 +403,16 @@ jQuery.extend({ }, inArray: function( elem, arr, i ) { - var len; - - if ( arr ) { - if ( core_indexOf ) { - return core_indexOf.call( arr, elem, i ); - } - - len = arr.length; - i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; - - for ( ; i < len; i++ ) { - // Skip accessing in sparse arrays - if ( i in arr && arr[ i ] === elem ) { - return i; - } - } - } - - return -1; + return arr == null ? -1 : indexOf.call( arr, elem, i ); }, merge: function( first, second ) { - var l = second.length, - i = first.length, - j = 0; + var len = +second.length, + j = 0, + i = first.length; - if ( typeof l === "number" ) { - for ( ; j < l; j++ ) { - first[ i++ ] = second[ j ]; - } - } else { - while ( second[j] !== undefined ) { - first[ i++ ] = second[ j++ ]; - } + for ( ; j < len; j++ ) { + first[ i++ ] = second[ j ]; } first.length = i; @@ -749,40 +420,39 @@ jQuery.extend({ return first; }, - grep: function( elems, callback, inv ) { - var retVal, - ret = [], + grep: function( elems, callback, invert ) { + var callbackInverse, + matches = [], i = 0, - length = elems.length; - inv = !!inv; + length = elems.length, + callbackExpect = !invert; // Go through the array, only saving the items // that pass the validator function for ( ; i < length; i++ ) { - retVal = !!callback( elems[ i ], i ); - if ( inv !== retVal ) { - ret.push( elems[ i ] ); + callbackInverse = !callback( elems[ i ], i ); + if ( callbackInverse !== callbackExpect ) { + matches.push( elems[ i ] ); } } - return ret; + return matches; }, // arg is for internal usage only map: function( elems, callback, arg ) { - var value, + var length, value, i = 0, - length = elems.length, - isArray = isArraylike( elems ), ret = []; - // Go through the array, translating each of the items to their - if ( isArray ) { + // Go through the array, translating each of the items to their new values + if ( isArrayLike( elems ) ) { + length = elems.length; for ( ; i < length; i++ ) { value = callback( elems[ i ], i, arg ); if ( value != null ) { - ret[ ret.length ] = value; + ret.push( value ); } } @@ -792,13 +462,13 @@ jQuery.extend({ value = callback( elems[ i ], i, arg ); if ( value != null ) { - ret[ ret.length ] = value; + ret.push( value ); } } } // Flatten any nested arrays - return core_concat.apply( [], ret ); + return concat.apply( [], ret ); }, // A global GUID counter for objects @@ -807,7 +477,7 @@ jQuery.extend({ // Bind a function to a context, optionally partially applying any // arguments. proxy: function( fn, context ) { - var args, proxy, tmp; + var tmp, args, proxy; if ( typeof context === "string" ) { tmp = fn[ context ]; @@ -822,9 +492,9 @@ jQuery.extend({ } // Simulated bind - args = core_slice.call( arguments, 2 ); + args = slice.call( arguments, 2 ); proxy = function() { - return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) ); + return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); }; // Set the guid of unique handler to the same of original handler, so it can be removed @@ -833,193 +503,69 @@ jQuery.extend({ return proxy; }, - // Multifunctional method to get and set values of a collection - // The value/s can optionally be executed if it's a function - access: function( elems, fn, key, value, chainable, emptyGet, raw ) { - var i = 0, - length = elems.length, - bulk = key == null; - - // Sets many values - if ( jQuery.type( key ) === "object" ) { - chainable = true; - for ( i in key ) { - jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); - } - - // Sets one value - } else if ( value !== undefined ) { - chainable = true; - - if ( !jQuery.isFunction( value ) ) { - raw = true; - } - - if ( bulk ) { - // Bulk operations run against the entire set - if ( raw ) { - fn.call( elems, value ); - fn = null; - - // ...except when executing function values - } else { - bulk = fn; - fn = function( elem, key, value ) { - return bulk.call( jQuery( elem ), value ); - }; - } - } - - if ( fn ) { - for ( ; i < length; i++ ) { - fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); - } - } - } - - return chainable ? - elems : - - // Gets - bulk ? - fn.call( elems ) : - length ? fn( elems[0], key ) : emptyGet; - }, - - now: function() { - return ( new Date() ).getTime(); - }, - - // A method for quickly swapping in/out CSS properties to get correct calculations. - // Note: this method belongs to the css module but it's needed here for the support module. - // If support gets modularized, this method should be moved back to the css module. - swap: function( elem, options, callback, args ) { - var ret, name, - old = {}; - - // Remember the old values, and insert the new ones - for ( name in options ) { - old[ name ] = elem.style[ name ]; - elem.style[ name ] = options[ name ]; - } - - ret = callback.apply( elem, args || [] ); - - // Revert the old values - for ( name in options ) { - elem.style[ name ] = old[ name ]; - } - - return ret; - } -}); - -jQuery.ready.promise = function( obj ) { - if ( !readyList ) { - - readyList = jQuery.Deferred(); - - // Catch cases where $(document).ready() is called after the browser event has already occurred. - // we once tried to use readyState "interactive" here, but it caused issues like the one - // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 - if ( document.readyState === "complete" ) { - // Handle it asynchronously to allow scripts the opportunity to delay ready - setTimeout( jQuery.ready ); - - // Standards-based browsers support DOMContentLoaded - } else if ( document.addEventListener ) { - // Use the handy event callback - document.addEventListener( "DOMContentLoaded", completed, false ); - - // A fallback to window.onload, that will always work - window.addEventListener( "load", completed, false ); - - // If IE event model is used - } else { - // Ensure firing before onload, maybe late but safe also for iframes - document.attachEvent( "onreadystatechange", completed ); - - // A fallback to window.onload, that will always work - window.attachEvent( "onload", completed ); - - // If IE and not a frame - // continually check to see if the document is ready - var top = false; - - try { - top = window.frameElement == null && document.documentElement; - } catch(e) {} - - if ( top && top.doScroll ) { - (function doScrollCheck() { - if ( !jQuery.isReady ) { - - try { - // Use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - top.doScroll("left"); - } catch(e) { - return setTimeout( doScrollCheck, 50 ); - } + now: Date.now, - // detach all dom ready events - detach(); + // jQuery.support is not used in Core but other projects attach their + // properties to it so it needs to exist. + support: support +} ); - // and execute any waiting functions - jQuery.ready(); - } - })(); - } - } - } - return readyList.promise( obj ); -}; +// JSHint would error on this code due to the Symbol not being defined in ES5. +// Defining this global in .jshintrc would create a danger of using the global +// unguarded in another place, it seems safer to just disable JSHint for these +// three lines. +/* jshint ignore: start */ +if ( typeof Symbol === "function" ) { + jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; +} +/* jshint ignore: end */ // Populate the class2type map -jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { +jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), +function( i, name ) { class2type[ "[object " + name + "]" ] = name.toLowerCase(); -}); +} ); -function isArraylike( obj ) { - var length = obj.length, +function isArrayLike( obj ) { + + // Support: iOS 8.2 (not reproducible in simulator) + // `in` check used to prevent JIT error (gh-2145) + // hasOwn isn't used here due to false negatives + // regarding Nodelist length in IE + var length = !!obj && "length" in obj && obj.length, type = jQuery.type( obj ); - if ( jQuery.isWindow( obj ) ) { + if ( type === "function" || jQuery.isWindow( obj ) ) { return false; } - if ( obj.nodeType === 1 && length ) { - return true; - } - - return type === "array" || type !== "function" && - ( length === 0 || - typeof length === "number" && length > 0 && ( length - 1 ) in obj ); + return type === "array" || length === 0 || + typeof length === "number" && length > 0 && ( length - 1 ) in obj; } - -// All jQuery objects should point back to these -rootjQuery = jQuery(document); +var Sizzle = /*! - * Sizzle CSS Selector Engine v1.10.2 + * Sizzle CSS Selector Engine v2.2.1 * http://sizzlejs.com/ * - * Copyright 2013 jQuery Foundation, Inc. and other contributors + * Copyright jQuery Foundation and other contributors * Released under the MIT license * http://jquery.org/license * - * Date: 2013-07-03 + * Date: 2015-10-17 */ -(function( window, undefined ) { +(function( window ) { var i, support, - cachedruns, Expr, getText, isXML, + tokenize, compile, + select, outermostContext, sortInput, + hasDuplicate, // Local document vars setDocument, @@ -1032,24 +578,21 @@ var i, contains, // Instance-specific data - expando = "sizzle" + -(new Date()), + expando = "sizzle" + 1 * new Date(), preferredDoc = window.document, dirruns = 0, done = 0, classCache = createCache(), tokenCache = createCache(), compilerCache = createCache(), - hasDuplicate = false, sortOrder = function( a, b ) { if ( a === b ) { hasDuplicate = true; - return 0; } return 0; }, // General-purpose constants - strundefined = typeof undefined, MAX_NEGATIVE = 1 << 31, // Instance methods @@ -1059,12 +602,13 @@ var i, push_native = arr.push, push = arr.push, slice = arr.slice, - // Use a stripped-down indexOf if we can't use a native one - indexOf = arr.indexOf || function( elem ) { + // Use a stripped-down indexOf as it's faster than native + // http://jsperf.com/thor-indexof-vs-for/5 + indexOf = function( list, elem ) { var i = 0, - len = this.length; + len = list.length; for ( ; i < len; i++ ) { - if ( this[i] === elem ) { + if ( list[i] === elem ) { return i; } } @@ -1075,44 +619,46 @@ var i, // Regular expressions - // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace + // http://www.w3.org/TR/css3-selectors/#whitespace whitespace = "[\\x20\\t\\r\\n\\f]", - // http://www.w3.org/TR/css3-syntax/#characters - characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", - - // Loosely modeled on CSS identifier characters - // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors - // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier - identifier = characterEncoding.replace( "w", "w#" ), - - // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors - attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + - "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", - - // Prefer arguments quoted, - // then not containing pseudos/brackets, - // then attribute selectors/non-parenthetical expressions, - // then anything else - // These preferences are here to reduce the number of selectors - // needing tokenize in the PSEUDO preFilter - pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)", + + // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier + identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", + + // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors + attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + + // Operator (capture 2) + "*([*^$|!~]?=)" + whitespace + + // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + + "*\\]", + + pseudos = ":(" + identifier + ")(?:\\((" + + // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: + // 1. quoted (capture 3; capture 4 or capture 5) + "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + + // 2. simple (capture 6) + "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + + // 3. anything else (capture 2) + ".*" + + ")\\)|)", // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter + rwhitespace = new RegExp( whitespace + "+", "g" ), rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), - rsibling = new RegExp( whitespace + "*[+~]" ), - rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*)" + whitespace + "*\\]", "g" ), + rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), rpseudo = new RegExp( pseudos ), ridentifier = new RegExp( "^" + identifier + "$" ), matchExpr = { - "ID": new RegExp( "^#(" + characterEncoding + ")" ), - "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), - "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), + "ID": new RegExp( "^#(" + identifier + ")" ), + "CLASS": new RegExp( "^\\.(" + identifier + ")" ), + "TAG": new RegExp( "^(" + identifier + "|[*])" ), "ATTR": new RegExp( "^" + attributes ), "PSEUDO": new RegExp( "^" + pseudos ), "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + @@ -1125,14 +671,15 @@ var i, whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) }, + rinputs = /^(?:input|select|textarea|button)$/i, + rheader = /^h\d$/i, + rnative = /^[^{]+\{\s*\[native \w/, // Easily-parseable/retrievable ID or TAG or CLASS selectors rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, - rinputs = /^(?:input|select|textarea|button)$/i, - rheader = /^h\d$/i, - + rsibling = /[+~]/, rescape = /'|\\/g, // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters @@ -1140,15 +687,23 @@ var i, funescape = function( _, escaped, escapedWhitespace ) { var high = "0x" + escaped - 0x10000; // NaN means non-codepoint - // Support: Firefox + // Support: Firefox<24 // Workaround erroneous numeric interpretation of +"0x" return high !== high || escapedWhitespace ? escaped : - // BMP codepoint high < 0 ? + // BMP codepoint String.fromCharCode( high + 0x10000 ) : // Supplemental Plane codepoint (surrogate pair) String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); + }, + + // Used for iframes + // See setDocument() + // Removing the function wrapper causes a "Permission Denied" + // error in IE + unloadHandler = function() { + setDocument(); }; // Optimize for push.apply( _, NodeList ) @@ -1181,104 +736,129 @@ try { } function Sizzle( selector, context, results, seed ) { - var match, elem, m, nodeType, - // QSA vars - i, groups, old, nid, newContext, newSelector; + var m, i, elem, nid, nidselect, match, groups, newSelector, + newContext = context && context.ownerDocument, - if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { - setDocument( context ); - } + // nodeType defaults to 9, since context defaults to document + nodeType = context ? context.nodeType : 9; - context = context || document; results = results || []; - if ( !selector || typeof selector !== "string" ) { + // Return early from calls with invalid selector or context + if ( typeof selector !== "string" || !selector || + nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { + return results; } - if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { - return []; - } + // Try to shortcut find operations (as opposed to filters) in HTML documents + if ( !seed ) { - if ( documentIsHTML && !seed ) { + if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { + setDocument( context ); + } + context = context || document; - // Shortcuts - if ( (match = rquickExpr.exec( selector )) ) { - // Speed-up: Sizzle("#ID") - if ( (m = match[1]) ) { - if ( nodeType === 9 ) { - elem = context.getElementById( m ); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE, Opera, and Webkit return items - // by name instead of ID - if ( elem.id === m ) { - results.push( elem ); + if ( documentIsHTML ) { + + // If the selector is sufficiently simple, try using a "get*By*" DOM method + // (excepting DocumentFragment context, where the methods don't exist) + if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { + + // ID selector + if ( (m = match[1]) ) { + + // Document context + if ( nodeType === 9 ) { + if ( (elem = context.getElementById( m )) ) { + + // Support: IE, Opera, Webkit + // TODO: identify versions + // getElementById can match elements by name instead of ID + if ( elem.id === m ) { + results.push( elem ); + return results; + } + } else { return results; } + + // Element context } else { - return results; - } - } else { - // Context is not a document - if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && - contains( context, elem ) && elem.id === m ) { - results.push( elem ); - return results; + + // Support: IE, Opera, Webkit + // TODO: identify versions + // getElementById can match elements by name instead of ID + if ( newContext && (elem = newContext.getElementById( m )) && + contains( context, elem ) && + elem.id === m ) { + + results.push( elem ); + return results; + } } - } - // Speed-up: Sizzle("TAG") - } else if ( match[2] ) { - push.apply( results, context.getElementsByTagName( selector ) ); - return results; + // Type selector + } else if ( match[2] ) { + push.apply( results, context.getElementsByTagName( selector ) ); + return results; - // Speed-up: Sizzle(".CLASS") - } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) { - push.apply( results, context.getElementsByClassName( m ) ); - return results; + // Class selector + } else if ( (m = match[3]) && support.getElementsByClassName && + context.getElementsByClassName ) { + + push.apply( results, context.getElementsByClassName( m ) ); + return results; + } } - } - // QSA path - if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { - nid = old = expando; - newContext = context; - newSelector = nodeType === 9 && selector; + // Take advantage of querySelectorAll + if ( support.qsa && + !compilerCache[ selector + " " ] && + (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { - // qSA works strangely on Element-rooted queries - // We can work around this by specifying an extra ID on the root - // and working up from there (Thanks to Andrew Dupont for the technique) - // IE 8 doesn't work on object elements - if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { - groups = tokenize( selector ); + if ( nodeType !== 1 ) { + newContext = context; + newSelector = selector; - if ( (old = context.getAttribute("id")) ) { - nid = old.replace( rescape, "\\$&" ); - } else { - context.setAttribute( "id", nid ); - } - nid = "[id='" + nid + "'] "; + // qSA looks outside Element context, which is not what we want + // Thanks to Andrew Dupont for this workaround technique + // Support: IE <=8 + // Exclude object elements + } else if ( context.nodeName.toLowerCase() !== "object" ) { - i = groups.length; - while ( i-- ) { - groups[i] = nid + toSelector( groups[i] ); + // Capture the context ID, setting it first if necessary + if ( (nid = context.getAttribute( "id" )) ) { + nid = nid.replace( rescape, "\\$&" ); + } else { + context.setAttribute( "id", (nid = expando) ); + } + + // Prefix every selector in the list + groups = tokenize( selector ); + i = groups.length; + nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']"; + while ( i-- ) { + groups[i] = nidselect + " " + toSelector( groups[i] ); + } + newSelector = groups.join( "," ); + + // Expand context for sibling selectors + newContext = rsibling.test( selector ) && testContext( context.parentNode ) || + context; } - newContext = rsibling.test( selector ) && context.parentNode || context; - newSelector = groups.join(","); - } - if ( newSelector ) { - try { - push.apply( results, - newContext.querySelectorAll( newSelector ) - ); - return results; - } catch(qsaError) { - } finally { - if ( !old ) { - context.removeAttribute("id"); + if ( newSelector ) { + try { + push.apply( results, + newContext.querySelectorAll( newSelector ) + ); + return results; + } catch ( qsaError ) { + } finally { + if ( nid === expando ) { + context.removeAttribute( "id" ); + } } } } @@ -1291,7 +871,7 @@ function Sizzle( selector, context, results, seed ) { /** * Create key-value caches of limited size - * @returns {Function(string, Object)} Returns the Object data after storing it on itself with + * @returns {function(string, object)} Returns the Object data after storing it on itself with * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) * deleting the oldest entry */ @@ -1300,11 +880,11 @@ function createCache() { function cache( key, value ) { // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) - if ( keys.push( key += " " ) > Expr.cacheLength ) { + if ( keys.push( key + " " ) > Expr.cacheLength ) { // Only keep the most recent entries delete cache[ keys.shift() ]; } - return (cache[ key ] = value); + return (cache[ key + " " ] = value); } return cache; } @@ -1346,7 +926,7 @@ function assert( fn ) { */ function addHandle( attrs, handler ) { var arr = attrs.split("|"), - i = attrs.length; + i = arr.length; while ( i-- ) { Expr.attrHandle[ arr[i] ] = handler; @@ -1427,8 +1007,21 @@ function createPositionalPseudo( fn ) { } /** - * Detect xml + * Checks a node for validity as a Sizzle context + * @param {Element|Object=} context + * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value + */ +function testContext( context ) { + return context && typeof context.getElementsByTagName !== "undefined" && context; +} + +// Expose support vars for convenience +support = Sizzle.support = {}; + +/** + * Detects XML nodes * @param {Element|Object} elem An element or a document + * @returns {Boolean} True iff elem is a non-HTML XML node */ isXML = Sizzle.isXML = function( elem ) { // documentElement is verified for cases where it doesn't yet exist @@ -1437,45 +1030,44 @@ isXML = Sizzle.isXML = function( elem ) { return documentElement ? documentElement.nodeName !== "HTML" : false; }; -// Expose support vars for convenience -support = Sizzle.support = {}; - /** * Sets document-related variables once based on the current document * @param {Element|Object} [doc] An element or document object to use to set the document * @returns {Object} Returns the current document */ setDocument = Sizzle.setDocument = function( node ) { - var doc = node ? node.ownerDocument || node : preferredDoc, - parent = doc.defaultView; + var hasCompare, parent, + doc = node ? node.ownerDocument || node : preferredDoc; - // If no document and documentElement is available, return + // Return early if doc is invalid or already selected if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { return document; } - // Set our document + // Update global variables document = doc; - docElem = doc.documentElement; - - // Support tests - documentIsHTML = !isXML( doc ); - - // Support: IE>8 - // If iframe document is assigned to "document" variable and if iframe has been reloaded, - // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 - // IE6-8 do not support the defaultView property so parent will be undefined - if ( parent && parent.attachEvent && parent !== parent.top ) { - parent.attachEvent( "onbeforeunload", function() { - setDocument(); - }); + docElem = document.documentElement; + documentIsHTML = !isXML( document ); + + // Support: IE 9-11, Edge + // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) + if ( (parent = document.defaultView) && parent.top !== parent ) { + // Support: IE 11 + if ( parent.addEventListener ) { + parent.addEventListener( "unload", unloadHandler, false ); + + // Support: IE 9 - 10 only + } else if ( parent.attachEvent ) { + parent.attachEvent( "onunload", unloadHandler ); + } } /* Attributes ---------------------------------------------------------------------- */ // Support: IE<8 - // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans) + // Verify that getAttribute really returns attributes and not properties + // (excepting IE8 booleans) support.attributes = assert(function( div ) { div.className = "i"; return !div.getAttribute("className"); @@ -1486,21 +1078,12 @@ setDocument = Sizzle.setDocument = function( node ) { // Check if getElementsByTagName("*") returns only elements support.getElementsByTagName = assert(function( div ) { - div.appendChild( doc.createComment("") ); + div.appendChild( document.createComment("") ); return !div.getElementsByTagName("*").length; }); - // Check if getElementsByClassName can be trusted - support.getElementsByClassName = assert(function( div ) { - div.innerHTML = "

"; - - // Support: Safari<4 - // Catch class over-caching - div.firstChild.className = "i"; - // Support: Opera<10 - // Catch gEBCN failure to find non-leading classes - return div.getElementsByClassName("i").length === 2; - }); + // Support: IE<9 + support.getElementsByClassName = rnative.test( document.getElementsByClassName ); // Support: IE<10 // Check if getElementById returns elements by name @@ -1508,17 +1091,15 @@ setDocument = Sizzle.setDocument = function( node ) { // so use a roundabout getElementsByName test support.getById = assert(function( div ) { docElem.appendChild( div ).id = expando; - return !doc.getElementsByName || !doc.getElementsByName( expando ).length; + return !document.getElementsByName || !document.getElementsByName( expando ).length; }); // ID find and filter if ( support.getById ) { Expr.find["ID"] = function( id, context ) { - if ( typeof context.getElementById !== strundefined && documentIsHTML ) { + if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { var m = context.getElementById( id ); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - return m && m.parentNode ? [m] : []; + return m ? [ m ] : []; } }; Expr.filter["ID"] = function( id ) { @@ -1535,7 +1116,8 @@ setDocument = Sizzle.setDocument = function( node ) { Expr.filter["ID"] = function( id ) { var attrId = id.replace( runescape, funescape ); return function( elem ) { - var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); + var node = typeof elem.getAttributeNode !== "undefined" && + elem.getAttributeNode("id"); return node && node.value === attrId; }; }; @@ -1544,14 +1126,20 @@ setDocument = Sizzle.setDocument = function( node ) { // Tag Expr.find["TAG"] = support.getElementsByTagName ? function( tag, context ) { - if ( typeof context.getElementsByTagName !== strundefined ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { return context.getElementsByTagName( tag ); + + // DocumentFragment nodes don't have gEBTN + } else if ( support.qsa ) { + return context.querySelectorAll( tag ); } } : + function( tag, context ) { var elem, tmp = [], i = 0, + // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too results = context.getElementsByTagName( tag ); // Filter out possible comments @@ -1569,7 +1157,7 @@ setDocument = Sizzle.setDocument = function( node ) { // Class Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { - if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) { + if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { return context.getElementsByClassName( className ); } }; @@ -1589,7 +1177,7 @@ setDocument = Sizzle.setDocument = function( node ) { // See http://bugs.jquery.com/ticket/13378 rbuggyQSA = []; - if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { + if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { // Build QSA regex // Regex strategy adopted from Diego Perini assert(function( div ) { @@ -1598,7 +1186,17 @@ setDocument = Sizzle.setDocument = function( node ) { // setting a boolean content attribute, // since its presence should be enough // http://bugs.jquery.com/ticket/12359 - div.innerHTML = ""; + docElem.appendChild( div ).innerHTML = "" + + ""; + + // Support: IE8, Opera 11-12.16 + // Nothing should be selected when empty strings follow ^= or $= or *= + // The test attribute must be unknown in Opera but "safe" for WinRT + // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section + if ( div.querySelectorAll("[msallowcapture^='']").length ) { + rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); + } // Support: IE8 // Boolean attributes and "value" are not treated correctly @@ -1606,27 +1204,37 @@ setDocument = Sizzle.setDocument = function( node ) { rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); } + // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ + if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { + rbuggyQSA.push("~="); + } + // Webkit/Opera - :checked should return selected option elements // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked // IE8 throws error here and will not see later tests if ( !div.querySelectorAll(":checked").length ) { rbuggyQSA.push(":checked"); } + + // Support: Safari 8+, iOS 8+ + // https://bugs.webkit.org/show_bug.cgi?id=136851 + // In-page `selector#id sibing-combinator selector` fails + if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { + rbuggyQSA.push(".#.+[+~]"); + } }); assert(function( div ) { - - // Support: Opera 10-12/IE8 - // ^= $= *= and empty values - // Should not select anything // Support: Windows 8 Native Apps - // The type attribute is restricted during .innerHTML assignment - var input = doc.createElement("input"); + // The type and name attributes are restricted during .innerHTML assignment + var input = document.createElement("input"); input.setAttribute( "type", "hidden" ); - div.appendChild( input ).setAttribute( "t", "" ); + div.appendChild( input ).setAttribute( "name", "D" ); - if ( div.querySelectorAll("[t^='']").length ) { - rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); + // Support: IE8 + // Enforce case-sensitivity of name attribute + if ( div.querySelectorAll("[name=d]").length ) { + rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); } // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) @@ -1641,7 +1249,8 @@ setDocument = Sizzle.setDocument = function( node ) { }); } - if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector || + if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || + docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector) )) ) { @@ -1663,11 +1272,12 @@ setDocument = Sizzle.setDocument = function( node ) { /* Contains ---------------------------------------------------------------------- */ + hasCompare = rnative.test( docElem.compareDocumentPosition ); // Element contains another - // Purposefully does not implement inclusive descendent + // Purposefully self-exclusive // As in, an element does not contain itself - contains = rnative.test( docElem.contains ) || docElem.compareDocumentPosition ? + contains = hasCompare || rnative.test( docElem.contains ) ? function( a, b ) { var adown = a.nodeType === 9 ? a.documentElement : a, bup = b && b.parentNode; @@ -1692,7 +1302,7 @@ setDocument = Sizzle.setDocument = function( node ) { ---------------------------------------------------------------------- */ // Document order sorting - sortOrder = docElem.compareDocumentPosition ? + sortOrder = hasCompare ? function( a, b ) { // Flag for duplicate removal @@ -1701,34 +1311,46 @@ setDocument = Sizzle.setDocument = function( node ) { return 0; } - var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b ); - + // Sort on method existence if only one input has compareDocumentPosition + var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; if ( compare ) { - // Disconnected nodes - if ( compare & 1 || - (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { + return compare; + } - // Choose the first element that is related to our preferred document - if ( a === doc || contains(preferredDoc, a) ) { - return -1; - } - if ( b === doc || contains(preferredDoc, b) ) { - return 1; - } + // Calculate position if both inputs belong to the same document + compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? + a.compareDocumentPosition( b ) : - // Maintain original order - return sortInput ? - ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : - 0; + // Otherwise we know they are disconnected + 1; + + // Disconnected nodes + if ( compare & 1 || + (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { + + // Choose the first element that is related to our preferred document + if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { + return -1; + } + if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { + return 1; } - return compare & 4 ? -1 : 1; + // Maintain original order + return sortInput ? + ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : + 0; } - // Not directly comparable, sort on existence of method - return a.compareDocumentPosition ? -1 : 1; + return compare & 4 ? -1 : 1; } : function( a, b ) { + // Exit early if the nodes are identical + if ( a === b ) { + hasDuplicate = true; + return 0; + } + var cur, i = 0, aup = a.parentNode, @@ -1736,19 +1358,14 @@ setDocument = Sizzle.setDocument = function( node ) { ap = [ a ], bp = [ b ]; - // Exit early if the nodes are identical - if ( a === b ) { - hasDuplicate = true; - return 0; - // Parentless nodes are either documents or disconnected - } else if ( !aup || !bup ) { - return a === doc ? -1 : - b === doc ? 1 : + if ( !aup || !bup ) { + return a === document ? -1 : + b === document ? 1 : aup ? -1 : bup ? 1 : sortInput ? - ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : + ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 0; // If the nodes are siblings, we can do a quick check @@ -1781,7 +1398,7 @@ setDocument = Sizzle.setDocument = function( node ) { 0; }; - return doc; + return document; }; Sizzle.matches = function( expr, elements ) { @@ -1798,6 +1415,7 @@ Sizzle.matchesSelector = function( elem, expr ) { expr = expr.replace( rattributeQuotes, "='$1']" ); if ( support.matchesSelector && documentIsHTML && + !compilerCache[ expr + " " ] && ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { @@ -1811,10 +1429,10 @@ Sizzle.matchesSelector = function( elem, expr ) { elem.document && elem.document.nodeType !== 11 ) { return ret; } - } catch(e) {} + } catch (e) {} } - return Sizzle( expr, document, null, [elem] ).length > 0; + return Sizzle( expr, document, null, [ elem ] ).length > 0; }; Sizzle.contains = function( context, elem ) { @@ -1837,13 +1455,13 @@ Sizzle.attr = function( elem, name ) { fn( elem, name, !documentIsHTML ) : undefined; - return val === undefined ? + return val !== undefined ? + val : support.attributes || !documentIsHTML ? elem.getAttribute( name ) : (val = elem.getAttributeNode(name)) && val.specified ? val.value : - null : - val; + null; }; Sizzle.error = function( msg ) { @@ -1876,6 +1494,10 @@ Sizzle.uniqueSort = function( results ) { } } + // Clear input after sorting to release objects + // See https://github.com/jquery/sizzle/pull/225 + sortInput = null; + return results; }; @@ -1891,13 +1513,13 @@ getText = Sizzle.getText = function( elem ) { if ( !nodeType ) { // If no nodeType, this is expected to be an array - for ( ; (node = elem[i]); i++ ) { + while ( (node = elem[i++]) ) { // Do not traverse comment nodes ret += getText( node ); } } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { // Use textContent for elements - // innerText usage removed for consistency of new lines (see #11153) + // innerText usage removed for consistency of new lines (jQuery #11153) if ( typeof elem.textContent === "string" ) { return elem.textContent; } else { @@ -1939,7 +1561,7 @@ Expr = Sizzle.selectors = { match[1] = match[1].replace( runescape, funescape ); // Move the given value to match[3] whether quoted or unquoted - match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape ); + match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); if ( match[2] === "~=" ) { match[3] = " " + match[3] + " "; @@ -1982,15 +1604,15 @@ Expr = Sizzle.selectors = { "PSEUDO": function( match ) { var excess, - unquoted = !match[5] && match[2]; + unquoted = !match[6] && match[2]; if ( matchExpr["CHILD"].test( match[0] ) ) { return null; } // Accept quoted arguments as-is - if ( match[3] && match[4] !== undefined ) { - match[2] = match[4]; + if ( match[3] ) { + match[2] = match[4] || match[5] || ""; // Strip excess characters from unquoted arguments } else if ( unquoted && rpseudo.test( unquoted ) && @@ -2026,7 +1648,7 @@ Expr = Sizzle.selectors = { return pattern || (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && classCache( className, function( elem ) { - return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" ); + return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); }); }, @@ -2048,7 +1670,7 @@ Expr = Sizzle.selectors = { operator === "^=" ? check && result.indexOf( check ) === 0 : operator === "*=" ? check && result.indexOf( check ) > -1 : operator === "$=" ? check && result.slice( -check.length ) === check : - operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : + operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : false; }; @@ -2067,11 +1689,12 @@ Expr = Sizzle.selectors = { } : function( elem, context, xml ) { - var cache, outerCache, node, diff, nodeIndex, start, + var cache, uniqueCache, outerCache, node, nodeIndex, start, dir = simple !== forward ? "nextSibling" : "previousSibling", parent = elem.parentNode, name = ofType && elem.nodeName.toLowerCase(), - useCache = !xml && !ofType; + useCache = !xml && !ofType, + diff = false; if ( parent ) { @@ -2080,7 +1703,10 @@ Expr = Sizzle.selectors = { while ( dir ) { node = elem; while ( (node = node[ dir ]) ) { - if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { + if ( ofType ? + node.nodeName.toLowerCase() === name : + node.nodeType === 1 ) { + return false; } } @@ -2094,11 +1720,21 @@ Expr = Sizzle.selectors = { // non-xml :nth-child(...) stores cache data on `parent` if ( forward && useCache ) { + // Seek `elem` from a previously-cached index - outerCache = parent[ expando ] || (parent[ expando ] = {}); - cache = outerCache[ type ] || []; - nodeIndex = cache[0] === dirruns && cache[1]; - diff = cache[0] === dirruns && cache[2]; + + // ...in a gzip-friendly way + node = parent; + outerCache = node[ expando ] || (node[ expando ] = {}); + + // Support: IE <9 only + // Defend against cloned attroperties (jQuery gh-1709) + uniqueCache = outerCache[ node.uniqueID ] || + (outerCache[ node.uniqueID ] = {}); + + cache = uniqueCache[ type ] || []; + nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; + diff = nodeIndex && cache[ 2 ]; node = nodeIndex && parent.childNodes[ nodeIndex ]; while ( (node = ++nodeIndex && node && node[ dir ] || @@ -2108,29 +1744,55 @@ Expr = Sizzle.selectors = { // When found, cache indexes on `parent` and break if ( node.nodeType === 1 && ++diff && node === elem ) { - outerCache[ type ] = [ dirruns, nodeIndex, diff ]; + uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; break; } } - // Use previously-cached element index if available - } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { - diff = cache[1]; - - // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) } else { - // Use the same loop as above to seek `elem` from the start - while ( (node = ++nodeIndex && node && node[ dir ] || - (diff = nodeIndex = 0) || start.pop()) ) { + // Use previously-cached element index if available + if ( useCache ) { + // ...in a gzip-friendly way + node = elem; + outerCache = node[ expando ] || (node[ expando ] = {}); - if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { - // Cache the index of each encountered element - if ( useCache ) { - (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; - } + // Support: IE <9 only + // Defend against cloned attroperties (jQuery gh-1709) + uniqueCache = outerCache[ node.uniqueID ] || + (outerCache[ node.uniqueID ] = {}); - if ( node === elem ) { - break; + cache = uniqueCache[ type ] || []; + nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; + diff = nodeIndex; + } + + // xml :nth-child(...) + // or :nth-last-child(...) or :nth(-last)?-of-type(...) + if ( diff === false ) { + // Use the same loop as above to seek `elem` from the start + while ( (node = ++nodeIndex && node && node[ dir ] || + (diff = nodeIndex = 0) || start.pop()) ) { + + if ( ( ofType ? + node.nodeName.toLowerCase() === name : + node.nodeType === 1 ) && + ++diff ) { + + // Cache the index of each encountered element + if ( useCache ) { + outerCache = node[ expando ] || (node[ expando ] = {}); + + // Support: IE <9 only + // Defend against cloned attroperties (jQuery gh-1709) + uniqueCache = outerCache[ node.uniqueID ] || + (outerCache[ node.uniqueID ] = {}); + + uniqueCache[ type ] = [ dirruns, diff ]; + } + + if ( node === elem ) { + break; + } } } } @@ -2168,7 +1830,7 @@ Expr = Sizzle.selectors = { matched = fn( seed, argument ), i = matched.length; while ( i-- ) { - idx = indexOf.call( seed, matched[i] ); + idx = indexOf( seed, matched[i] ); seed[ idx ] = !( matches[ idx ] = matched[i] ); } }) : @@ -2207,6 +1869,8 @@ Expr = Sizzle.selectors = { function( elem, context, xml ) { input[0] = elem; matcher( input, null, xml, results ); + // Don't keep the element (issue #299) + input[0] = null; return !results.pop(); }; }), @@ -2218,6 +1882,7 @@ Expr = Sizzle.selectors = { }), "contains": markFunction(function( text ) { + text = text.replace( runescape, funescape ); return function( elem ) { return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; }; @@ -2294,12 +1959,11 @@ Expr = Sizzle.selectors = { // Contents "empty": function( elem ) { // http://www.w3.org/TR/selectors/#empty-pseudo - // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), - // not comment, processing instructions, or others - // Thanks to Diego Perini for the nodeName shortcut - // Greater than "@" means alpha characters (specifically not starting with "#" or "?") + // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), + // but not by others (comment: 8; processing instruction: 7; etc.) + // nodeType < 6 works because attributes (2) do not appear as children for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { - if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) { + if ( elem.nodeType < 6 ) { return false; } } @@ -2326,11 +1990,12 @@ Expr = Sizzle.selectors = { "text": function( elem ) { var attr; - // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) - // use getAttribute instead to test this case return elem.nodeName.toLowerCase() === "input" && elem.type === "text" && - ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type ); + + // Support: IE<8 + // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" + ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); }, // Position-in-collection @@ -2395,7 +2060,7 @@ function setFilters() {} setFilters.prototype = Expr.filters = Expr.pseudos; Expr.setFilters = new setFilters(); -function tokenize( selector, parseOnly ) { +tokenize = Sizzle.tokenize = function( selector, parseOnly ) { var matched, match, tokens, type, soFar, groups, preFilters, cached = tokenCache[ selector + " " ]; @@ -2416,7 +2081,7 @@ function tokenize( selector, parseOnly ) { // Don't consume trailing commas as valid soFar = soFar.slice( match[0].length ) || soFar; } - groups.push( tokens = [] ); + groups.push( (tokens = []) ); } matched = false; @@ -2460,7 +2125,7 @@ function tokenize( selector, parseOnly ) { Sizzle.error( selector ) : // Cache the tokens tokenCache( selector, groups ).slice( 0 ); -} +}; function toSelector( tokens ) { var i = 0, @@ -2489,10 +2154,10 @@ function addCombinator( matcher, combinator, base ) { // Check against all ancestor/preceding elements function( elem, context, xml ) { - var data, cache, outerCache, - dirkey = dirruns + " " + doneName; + var oldCache, uniqueCache, outerCache, + newCache = [ dirruns, doneName ]; - // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching + // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching if ( xml ) { while ( (elem = elem[ dir ]) ) { if ( elem.nodeType === 1 || checkNonElements ) { @@ -2505,14 +2170,22 @@ function addCombinator( matcher, combinator, base ) { while ( (elem = elem[ dir ]) ) { if ( elem.nodeType === 1 || checkNonElements ) { outerCache = elem[ expando ] || (elem[ expando ] = {}); - if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) { - if ( (data = cache[1]) === true || data === cachedruns ) { - return data === true; - } + + // Support: IE <9 only + // Defend against cloned attroperties (jQuery gh-1709) + uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); + + if ( (oldCache = uniqueCache[ dir ]) && + oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { + + // Assign to newCache so results back-propagate to previous elements + return (newCache[ 2 ] = oldCache[ 2 ]); } else { - cache = outerCache[ dir ] = [ dirkey ]; - cache[1] = matcher( elem, context, xml ) || cachedruns; - if ( cache[1] === true ) { + // Reuse newcache so results back-propagate to previous elements + uniqueCache[ dir ] = newCache; + + // A match means we're done; a fail means we have to keep checking + if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { return true; } } @@ -2536,6 +2209,15 @@ function elementMatcher( matchers ) { matchers[0]; } +function multipleContexts( selector, contexts, results ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + Sizzle( selector, contexts[i], results ); + } + return results; +} + function condense( unmatched, map, filter, context, xml ) { var elem, newUnmatched = [], @@ -2627,7 +2309,7 @@ function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postS i = matcherOut.length; while ( i-- ) { if ( (elem = matcherOut[i]) && - (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { + (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { seed[temp] = !(results[temp] = elem); } @@ -2662,13 +2344,16 @@ function matcherFromTokens( tokens ) { return elem === checkContext; }, implicitRelative, true ), matchAnyContext = addCombinator( function( elem ) { - return indexOf.call( checkContext, elem ) > -1; + return indexOf( checkContext, elem ) > -1; }, implicitRelative, true ), matchers = [ function( elem, context, xml ) { - return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( + var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( (checkContext = context).nodeType ? matchContext( elem, context, xml ) : matchAnyContext( elem, context, xml ) ); + // Avoid hanging onto element (issue #299) + checkContext = null; + return ret; } ]; for ( ; i < len; i++ ) { @@ -2706,42 +2391,43 @@ function matcherFromTokens( tokens ) { } function matcherFromGroupMatchers( elementMatchers, setMatchers ) { - // A counter to specify which element is currently being matched - var matcherCachedRuns = 0, - bySet = setMatchers.length > 0, + var bySet = setMatchers.length > 0, byElement = elementMatchers.length > 0, - superMatcher = function( seed, context, xml, results, expandContext ) { + superMatcher = function( seed, context, xml, results, outermost ) { var elem, j, matcher, - setMatched = [], matchedCount = 0, i = "0", unmatched = seed && [], - outermost = expandContext != null, + setMatched = [], contextBackup = outermostContext, - // We must always have either seed elements or context - elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ), + // We must always have either seed elements or outermost context + elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), // Use integer dirruns iff this is the outermost matcher - dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1); + dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), + len = elems.length; if ( outermost ) { - outermostContext = context !== document && context; - cachedruns = matcherCachedRuns; + outermostContext = context === document || context || outermost; } // Add elements passing elementMatchers directly to results - // Keep `i` a string if there are no elements so `matchedCount` will be "00" below - for ( ; (elem = elems[i]) != null; i++ ) { + // Support: IE<9, Safari + // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id + for ( ; i !== len && (elem = elems[i]) != null; i++ ) { if ( byElement && elem ) { j = 0; + if ( !context && elem.ownerDocument !== document ) { + setDocument( elem ); + xml = !documentIsHTML; + } while ( (matcher = elementMatchers[j++]) ) { - if ( matcher( elem, context, xml ) ) { + if ( matcher( elem, context || document, xml) ) { results.push( elem ); break; } } if ( outermost ) { dirruns = dirrunsUnique; - cachedruns = ++matcherCachedRuns; } } @@ -2759,8 +2445,17 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) { } } - // Apply set filters to unmatched elements + // `i` is now the count of elements visited above, and adding it to `matchedCount` + // makes the latter nonnegative. matchedCount += i; + + // Apply set filters to unmatched elements + // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` + // equals `i`), unless we didn't visit _any_ elements in the above loop because we have + // no element matchers and no seed. + // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that + // case, which will result in a "00" `matchedCount` that differs from `i` but is also + // numerically zero. if ( bySet && i !== matchedCount ) { j = 0; while ( (matcher = setMatchers[j++]) ) { @@ -2806,7 +2501,7 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) { superMatcher; } -compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { +compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { var i, setMatchers = [], elementMatchers = [], @@ -2814,12 +2509,12 @@ compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { if ( !cached ) { // Generate a function of recursive functions that can be used to check each element - if ( !group ) { - group = tokenize( selector ); + if ( !match ) { + match = tokenize( selector ); } - i = group.length; + i = match.length; while ( i-- ) { - cached = matcherFromTokens( group[i] ); + cached = matcherFromTokens( match[i] ); if ( cached[ expando ] ) { setMatchers.push( cached ); } else { @@ -2829,91 +2524,101 @@ compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { // Cache the compiled function cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); + + // Save selector and tokenization + cached.selector = selector; } return cached; }; -function multipleContexts( selector, contexts, results ) { - var i = 0, - len = contexts.length; - for ( ; i < len; i++ ) { - Sizzle( selector, contexts[i], results ); - } - return results; -} - -function select( selector, context, results, seed ) { +/** + * A low-level selection function that works with Sizzle's compiled + * selector functions + * @param {String|Function} selector A selector or a pre-compiled + * selector function built with Sizzle.compile + * @param {Element} context + * @param {Array} [results] + * @param {Array} [seed] A set of elements to match against + */ +select = Sizzle.select = function( selector, context, results, seed ) { var i, tokens, token, type, find, - match = tokenize( selector ); + compiled = typeof selector === "function" && selector, + match = !seed && tokenize( (selector = compiled.selector || selector) ); - if ( !seed ) { - // Try to minimize operations if there is only one group - if ( match.length === 1 ) { + results = results || []; - // Take a shortcut and set the context if the root selector is an ID - tokens = match[0] = match[0].slice( 0 ); - if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && - support.getById && context.nodeType === 9 && documentIsHTML && - Expr.relative[ tokens[1].type ] ) { + // Try to minimize operations if there is only one selector in the list and no seed + // (the latter of which guarantees us context) + if ( match.length === 1 ) { - context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; - if ( !context ) { - return results; - } - selector = selector.slice( tokens.shift().value.length ); - } + // Reduce context if the leading compound selector is an ID + tokens = match[0] = match[0].slice( 0 ); + if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && + support.getById && context.nodeType === 9 && documentIsHTML && + Expr.relative[ tokens[1].type ] ) { - // Fetch a seed set for right-to-left matching - i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; - while ( i-- ) { - token = tokens[i]; + context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; + if ( !context ) { + return results; - // Abort if we hit a combinator - if ( Expr.relative[ (type = token.type) ] ) { - break; - } - if ( (find = Expr.find[ type ]) ) { - // Search, expanding context for leading sibling combinators - if ( (seed = find( - token.matches[0].replace( runescape, funescape ), - rsibling.test( tokens[0].type ) && context.parentNode || context - )) ) { - - // If seed is empty or no tokens remain, we can return early - tokens.splice( i, 1 ); - selector = seed.length && toSelector( tokens ); - if ( !selector ) { - push.apply( results, seed ); - return results; - } + // Precompiled matchers will still verify ancestry, so step up a level + } else if ( compiled ) { + context = context.parentNode; + } - break; + selector = selector.slice( tokens.shift().value.length ); + } + + // Fetch a seed set for right-to-left matching + i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; + while ( i-- ) { + token = tokens[i]; + + // Abort if we hit a combinator + if ( Expr.relative[ (type = token.type) ] ) { + break; + } + if ( (find = Expr.find[ type ]) ) { + // Search, expanding context for leading sibling combinators + if ( (seed = find( + token.matches[0].replace( runescape, funescape ), + rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context + )) ) { + + // If seed is empty or no tokens remain, we can return early + tokens.splice( i, 1 ); + selector = seed.length && toSelector( tokens ); + if ( !selector ) { + push.apply( results, seed ); + return results; } + + break; } } } } - // Compile and execute a filtering function + // Compile and execute a filtering function if one is not provided // Provide `match` to avoid retokenization if we modified the selector above - compile( selector, match )( + ( compiled || compile( selector, match ) )( seed, context, !documentIsHTML, results, - rsibling.test( selector ) + !context || rsibling.test( selector ) && testContext( context.parentNode ) || context ); return results; -} +}; // One-time assignments // Sort stability support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; -// Support: Chrome<14 +// Support: Chrome 14-35+ // Always assume duplicates if they aren't passed to the comparison function -support.detectDuplicates = hasDuplicate; +support.detectDuplicates = !!hasDuplicate; // Initialize against the default document setDocument(); @@ -2961,3164 +2666,2812 @@ if ( !assert(function( div ) { addHandle( booleans, function( elem, name, isXML ) { var val; if ( !isXML ) { - return (val = elem.getAttributeNode( name )) && val.specified ? - val.value : - elem[ name ] === true ? name.toLowerCase() : null; + return elem[ name ] === true ? name.toLowerCase() : + (val = elem.getAttributeNode( name )) && val.specified ? + val.value : + null; } }); } +return Sizzle; + +})( window ); + + + jQuery.find = Sizzle; jQuery.expr = Sizzle.selectors; -jQuery.expr[":"] = jQuery.expr.pseudos; -jQuery.unique = Sizzle.uniqueSort; +jQuery.expr[ ":" ] = jQuery.expr.pseudos; +jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; jQuery.text = Sizzle.getText; jQuery.isXMLDoc = Sizzle.isXML; jQuery.contains = Sizzle.contains; -})( window ); -// String to Object options format cache -var optionsCache = {}; -// Convert String-formatted options into Object-formatted ones and store in cache -function createOptions( options ) { - var object = optionsCache[ options ] = {}; - jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) { - object[ flag ] = true; - }); - return object; -} +var dir = function( elem, dir, until ) { + var matched = [], + truncate = until !== undefined; -/* - * Create a callback list using the following parameters: - * - * options: an optional list of space-separated options that will change how - * the callback list behaves or a more traditional option object - * - * By default a callback list will act like an event callback list and can be - * "fired" multiple times. - * - * Possible options: - * - * once: will ensure the callback list can only be fired once (like a Deferred) - * - * memory: will keep track of previous values and will call any callback added - * after the list has been fired right away with the latest "memorized" - * values (like a Deferred) - * - * unique: will ensure a callback can only be added once (no duplicate in the list) - * - * stopOnFalse: interrupt callings when a callback returns false - * - */ -jQuery.Callbacks = function( options ) { + while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { + if ( elem.nodeType === 1 ) { + if ( truncate && jQuery( elem ).is( until ) ) { + break; + } + matched.push( elem ); + } + } + return matched; +}; - // Convert options from String-formatted to Object-formatted if needed - // (we check in cache first) - options = typeof options === "string" ? - ( optionsCache[ options ] || createOptions( options ) ) : - jQuery.extend( {}, options ); - var // Flag to know if list is currently firing - firing, - // Last fire value (for non-forgettable lists) - memory, - // Flag to know if list was already fired - fired, - // End of the loop when firing - firingLength, - // Index of currently firing callback (modified by remove if needed) - firingIndex, - // First callback to fire (used internally by add and fireWith) - firingStart, - // Actual callback list - list = [], - // Stack of fire calls for repeatable lists - stack = !options.once && [], - // Fire callbacks - fire = function( data ) { - memory = options.memory && data; - fired = true; - firingIndex = firingStart || 0; - firingStart = 0; - firingLength = list.length; - firing = true; - for ( ; list && firingIndex < firingLength; firingIndex++ ) { - if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { - memory = false; // To prevent further calls using add - break; - } - } - firing = false; - if ( list ) { - if ( stack ) { - if ( stack.length ) { - fire( stack.shift() ); - } - } else if ( memory ) { - list = []; - } else { - self.disable(); - } - } - }, - // Actual Callbacks object - self = { - // Add a callback or a collection of callbacks to the list - add: function() { - if ( list ) { - // First, we save the current length - var start = list.length; - (function add( args ) { - jQuery.each( args, function( _, arg ) { - var type = jQuery.type( arg ); - if ( type === "function" ) { - if ( !options.unique || !self.has( arg ) ) { - list.push( arg ); - } - } else if ( arg && arg.length && type !== "string" ) { - // Inspect recursively - add( arg ); - } - }); - })( arguments ); - // Do we need to add the callbacks to the - // current firing batch? - if ( firing ) { - firingLength = list.length; - // With memory, if we're not firing then - // we should call right away - } else if ( memory ) { - firingStart = start; - fire( memory ); - } - } - return this; - }, - // Remove a callback from the list - remove: function() { - if ( list ) { - jQuery.each( arguments, function( _, arg ) { - var index; - while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { - list.splice( index, 1 ); - // Handle firing indexes - if ( firing ) { - if ( index <= firingLength ) { - firingLength--; - } - if ( index <= firingIndex ) { - firingIndex--; - } - } - } - }); - } - return this; - }, - // Check if a given callback is in the list. - // If no argument is given, return whether or not list has callbacks attached. - has: function( fn ) { - return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); - }, - // Remove all callbacks from the list - empty: function() { - list = []; - firingLength = 0; - return this; - }, - // Have the list do nothing anymore - disable: function() { - list = stack = memory = undefined; - return this; - }, - // Is it disabled? - disabled: function() { - return !list; - }, - // Lock the list in its current state - lock: function() { - stack = undefined; - if ( !memory ) { - self.disable(); - } - return this; - }, - // Is it locked? - locked: function() { - return !stack; - }, - // Call all callbacks with the given context and arguments - fireWith: function( context, args ) { - if ( list && ( !fired || stack ) ) { - args = args || []; - args = [ context, args.slice ? args.slice() : args ]; - if ( firing ) { - stack.push( args ); - } else { - fire( args ); - } - } - return this; - }, - // Call all the callbacks with the given arguments - fire: function() { - self.fireWith( this, arguments ); - return this; - }, - // To know if the callbacks have already been called at least once - fired: function() { - return !!fired; - } - }; +var siblings = function( n, elem ) { + var matched = []; - return self; + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + matched.push( n ); + } + } + + return matched; }; -jQuery.extend({ - Deferred: function( func ) { - var tuples = [ - // action, add listener, listener list, final state - [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], - [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], - [ "notify", "progress", jQuery.Callbacks("memory") ] - ], - state = "pending", - promise = { - state: function() { - return state; - }, - always: function() { - deferred.done( arguments ).fail( arguments ); - return this; - }, - then: function( /* fnDone, fnFail, fnProgress */ ) { - var fns = arguments; - return jQuery.Deferred(function( newDefer ) { - jQuery.each( tuples, function( i, tuple ) { - var action = tuple[ 0 ], - fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; - // deferred[ done | fail | progress ] for forwarding actions to newDefer - deferred[ tuple[1] ](function() { - var returned = fn && fn.apply( this, arguments ); - if ( returned && jQuery.isFunction( returned.promise ) ) { - returned.promise() - .done( newDefer.resolve ) - .fail( newDefer.reject ) - .progress( newDefer.notify ); - } else { - newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); - } - }); - }); - fns = null; - }).promise(); - }, - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function( obj ) { - return obj != null ? jQuery.extend( obj, promise ) : promise; - } - }, - deferred = {}; - // Keep pipe for back-compat - promise.pipe = promise.then; +var rneedsContext = jQuery.expr.match.needsContext; - // Add list-specific methods - jQuery.each( tuples, function( i, tuple ) { - var list = tuple[ 2 ], - stateString = tuple[ 3 ]; +var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ ); - // promise[ done | fail | progress ] = list.add - promise[ tuple[1] ] = list.add; - // Handle state - if ( stateString ) { - list.add(function() { - // state = [ resolved | rejected ] - state = stateString; - // [ reject_list | resolve_list ].disable; progress_list.lock - }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); - } +var risSimple = /^.[^:#\[\.,]*$/; - // deferred[ resolve | reject | notify ] - deferred[ tuple[0] ] = function() { - deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); - return this; - }; - deferred[ tuple[0] + "With" ] = list.fireWith; - }); +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, not ) { + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep( elements, function( elem, i ) { + /* jshint -W018 */ + return !!qualifier.call( elem, i, elem ) !== not; + } ); - // Make the deferred a promise - promise.promise( deferred ); + } - // Call given func if any - if ( func ) { - func.call( deferred, deferred ); + if ( qualifier.nodeType ) { + return jQuery.grep( elements, function( elem ) { + return ( elem === qualifier ) !== not; + } ); + + } + + if ( typeof qualifier === "string" ) { + if ( risSimple.test( qualifier ) ) { + return jQuery.filter( qualifier, elements, not ); } - // All done! - return deferred; - }, + qualifier = jQuery.filter( qualifier, elements ); + } - // Deferred helper - when: function( subordinate /* , ..., subordinateN */ ) { - var i = 0, - resolveValues = core_slice.call( arguments ), - length = resolveValues.length, + return jQuery.grep( elements, function( elem ) { + return ( indexOf.call( qualifier, elem ) > -1 ) !== not; + } ); +} - // the count of uncompleted subordinates - remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, +jQuery.filter = function( expr, elems, not ) { + var elem = elems[ 0 ]; - // the master Deferred. If resolveValues consist of only a single Deferred, just use that. - deferred = remaining === 1 ? subordinate : jQuery.Deferred(), + if ( not ) { + expr = ":not(" + expr + ")"; + } - // Update function for both resolve and progress values - updateFunc = function( i, contexts, values ) { - return function( value ) { - contexts[ i ] = this; - values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value; - if( values === progressValues ) { - deferred.notifyWith( contexts, values ); - } else if ( !( --remaining ) ) { - deferred.resolveWith( contexts, values ); - } - }; - }, + return elems.length === 1 && elem.nodeType === 1 ? + jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : + jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { + return elem.nodeType === 1; + } ) ); +}; - progressValues, progressContexts, resolveContexts; +jQuery.fn.extend( { + find: function( selector ) { + var i, + len = this.length, + ret = [], + self = this; - // add listeners to Deferred subordinates; treat others as resolved - if ( length > 1 ) { - progressValues = new Array( length ); - progressContexts = new Array( length ); - resolveContexts = new Array( length ); - for ( ; i < length; i++ ) { - if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { - resolveValues[ i ].promise() - .done( updateFunc( i, resolveContexts, resolveValues ) ) - .fail( deferred.reject ) - .progress( updateFunc( i, progressContexts, progressValues ) ); - } else { - --remaining; + if ( typeof selector !== "string" ) { + return this.pushStack( jQuery( selector ).filter( function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } } - } + } ) ); } - // if we're not waiting on anything, resolve the master - if ( !remaining ) { - deferred.resolveWith( resolveContexts, resolveValues ); + for ( i = 0; i < len; i++ ) { + jQuery.find( selector, self[ i ], ret ); } - return deferred.promise(); - } -}); -jQuery.support = (function( support ) { - - var all, a, input, select, fragment, opt, eventName, isSupported, i, - div = document.createElement("div"); - - // Setup - div.setAttribute( "className", "t" ); - div.innerHTML = "
a"; + // Needed because $( selector, context ) becomes $( context ).find( selector ) + ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); + ret.selector = this.selector ? this.selector + " " + selector : selector; + return ret; + }, + filter: function( selector ) { + return this.pushStack( winnow( this, selector || [], false ) ); + }, + not: function( selector ) { + return this.pushStack( winnow( this, selector || [], true ) ); + }, + is: function( selector ) { + return !!winnow( + this, - // Finish early in limited (non-browser) environments - all = div.getElementsByTagName("*") || []; - a = div.getElementsByTagName("a")[ 0 ]; - if ( !a || !a.style || !all.length ) { - return support; + // If this is a positional/relative selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + typeof selector === "string" && rneedsContext.test( selector ) ? + jQuery( selector ) : + selector || [], + false + ).length; } +} ); - // First batch of tests - select = document.createElement("select"); - opt = select.appendChild( document.createElement("option") ); - input = div.getElementsByTagName("input")[ 0 ]; - - a.style.cssText = "top:1px;float:left;opacity:.5"; - // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) - support.getSetAttribute = div.className !== "t"; +// Initialize a jQuery object - // IE strips leading whitespace when .innerHTML is used - support.leadingWhitespace = div.firstChild.nodeType === 3; - // Make sure that tbody elements aren't automatically inserted - // IE will insert them into empty tables - support.tbody = !div.getElementsByTagName("tbody").length; +// A central reference to the root jQuery(document) +var rootjQuery, - // Make sure that link elements get serialized correctly by innerHTML - // This requires a wrapper element in IE - support.htmlSerialize = !!div.getElementsByTagName("link").length; + // A simple way to check for HTML strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + // Strict HTML recognition (#11290: must start with <) + rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, - // Get the style information from getAttribute - // (IE uses .cssText instead) - support.style = /top/.test( a.getAttribute("style") ); + init = jQuery.fn.init = function( selector, context, root ) { + var match, elem; - // Make sure that URLs aren't manipulated - // (IE normalizes it by default) - support.hrefNormalized = a.getAttribute("href") === "/a"; + // HANDLE: $(""), $(null), $(undefined), $(false) + if ( !selector ) { + return this; + } - // Make sure that element opacity exists - // (IE uses filter instead) - // Use a regex to work around a WebKit issue. See #5145 - support.opacity = /^0.5/.test( a.style.opacity ); + // Method init() accepts an alternate rootjQuery + // so migrate can support jQuery.sub (gh-2101) + root = root || rootjQuery; - // Verify style float existence - // (IE uses styleFloat instead of cssFloat) - support.cssFloat = !!a.style.cssFloat; + // Handle HTML strings + if ( typeof selector === "string" ) { + if ( selector[ 0 ] === "<" && + selector[ selector.length - 1 ] === ">" && + selector.length >= 3 ) { - // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere) - support.checkOn = !!input.value; + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; - // Make sure that a selected-by-default option has a working selected property. - // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) - support.optSelected = opt.selected; + } else { + match = rquickExpr.exec( selector ); + } - // Tests for enctype support on a form (#6743) - support.enctype = !!document.createElement("form").enctype; + // Match html or make sure no context is specified for #id + if ( match && ( match[ 1 ] || !context ) ) { - // Makes sure cloning an html5 element does not cause problems - // Where outerHTML is undefined, this still works - support.html5Clone = document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>"; + // HANDLE: $(html) -> $(array) + if ( match[ 1 ] ) { + context = context instanceof jQuery ? context[ 0 ] : context; - // Will be defined later - support.inlineBlockNeedsLayout = false; - support.shrinkWrapBlocks = false; - support.pixelPosition = false; - support.deleteExpando = true; - support.noCloneEvent = true; - support.reliableMarginRight = true; - support.boxSizingReliable = true; + // Option to run scripts is true for back-compat + // Intentionally let the error be thrown if parseHTML is not present + jQuery.merge( this, jQuery.parseHTML( + match[ 1 ], + context && context.nodeType ? context.ownerDocument || context : document, + true + ) ); - // Make sure checked status is properly cloned - input.checked = true; - support.noCloneChecked = input.cloneNode( true ).checked; + // HANDLE: $(html, props) + if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { + for ( match in context ) { - // Make sure that the options inside disabled selects aren't marked as disabled - // (WebKit marks them as disabled) - select.disabled = true; - support.optDisabled = !opt.disabled; + // Properties of context are called as methods if possible + if ( jQuery.isFunction( this[ match ] ) ) { + this[ match ]( context[ match ] ); - // Support: IE<9 - try { - delete div.test; - } catch( e ) { - support.deleteExpando = false; - } + // ...and otherwise set as attributes + } else { + this.attr( match, context[ match ] ); + } + } + } - // Check if we can trust getAttribute("value") - input = document.createElement("input"); - input.setAttribute( "value", "" ); - support.input = input.getAttribute( "value" ) === ""; + return this; - // Check if an input maintains its value after becoming a radio - input.value = "t"; - input.setAttribute( "type", "radio" ); - support.radioValue = input.value === "t"; + // HANDLE: $(#id) + } else { + elem = document.getElementById( match[ 2 ] ); - // #11217 - WebKit loses check when the name is after the checked attribute - input.setAttribute( "checked", "t" ); - input.setAttribute( "name", "t" ); + // Support: Blackberry 4.6 + // gEBID returns nodes no longer in the document (#6963) + if ( elem && elem.parentNode ) { - fragment = document.createDocumentFragment(); - fragment.appendChild( input ); + // Inject the element directly into the jQuery object + this.length = 1; + this[ 0 ] = elem; + } - // Check if a disconnected checkbox will retain its checked - // value of true after appended to the DOM (IE6/7) - support.appendChecked = input.checked; + this.context = document; + this.selector = selector; + return this; + } - // WebKit doesn't clone checked state correctly in fragments - support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || root ).find( selector ); - // Support: IE<9 - // Opera does not clone events (and typeof div.attachEvent === undefined). - // IE9-10 clones events bound via attachEvent, but they don't trigger with .click() - if ( div.attachEvent ) { - div.attachEvent( "onclick", function() { - support.noCloneEvent = false; - }); + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } - div.cloneNode( true ).click(); - } + // HANDLE: $(DOMElement) + } else if ( selector.nodeType ) { + this.context = this[ 0 ] = selector; + this.length = 1; + return this; - // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event) - // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP) - for ( i in { submit: true, change: true, focusin: true }) { - div.setAttribute( eventName = "on" + i, "t" ); + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return root.ready !== undefined ? + root.ready( selector ) : - support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false; - } + // Execute immediately if ready is not present + selector( jQuery ); + } - div.style.backgroundClip = "content-box"; - div.cloneNode( true ).style.backgroundClip = ""; - support.clearCloneStyle = div.style.backgroundClip === "content-box"; + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } - // Support: IE<9 - // Iteration over object's inherited properties before its own. - for ( i in jQuery( support ) ) { - break; - } - support.ownLast = i !== "0"; + return jQuery.makeArray( selector, this ); + }; - // Run tests that need a body at doc ready - jQuery(function() { - var container, marginDiv, tds, - divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;", - body = document.getElementsByTagName("body")[0]; +// Give the init function the jQuery prototype for later instantiation +init.prototype = jQuery.fn; - if ( !body ) { - // Return for frameset docs that don't have a body - return; - } +// Initialize central reference +rootjQuery = jQuery( document ); - container = document.createElement("div"); - container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px"; - body.appendChild( container ).appendChild( div ); +var rparentsprev = /^(?:parents|prev(?:Until|All))/, - // Support: IE8 - // Check if table cells still have offsetWidth/Height when they are set - // to display:none and there are still other visible table cells in a - // table row; if so, offsetWidth/Height are not reliable for use when - // determining if an element has been hidden directly using - // display:none (it is still safe to use offsets if a parent element is - // hidden; don safety goggles and see bug #4512 for more information). - div.innerHTML = "
t
"; - tds = div.getElementsByTagName("td"); - tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; - isSupported = ( tds[ 0 ].offsetHeight === 0 ); + // Methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; - tds[ 0 ].style.display = ""; - tds[ 1 ].style.display = "none"; +jQuery.fn.extend( { + has: function( target ) { + var targets = jQuery( target, this ), + l = targets.length; - // Support: IE8 - // Check if empty table cells still have offsetWidth/Height - support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); + return this.filter( function() { + var i = 0; + for ( ; i < l; i++ ) { + if ( jQuery.contains( this, targets[ i ] ) ) { + return true; + } + } + } ); + }, - // Check box-sizing and margin behavior. - div.innerHTML = ""; - div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; + closest: function( selectors, context ) { + var cur, + i = 0, + l = this.length, + matched = [], + pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; - // Workaround failing boxSizing test due to offsetWidth returning wrong value - // with some non-1 values of body zoom, ticket #13543 - jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() { - support.boxSizing = div.offsetWidth === 4; - }); + for ( ; i < l; i++ ) { + for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { - // Use window.getComputedStyle because jsdom on node.js will break without it. - if ( window.getComputedStyle ) { - support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; - support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; + // Always skip document fragments + if ( cur.nodeType < 11 && ( pos ? + pos.index( cur ) > -1 : - // Check if div with explicit width and no margin-right incorrectly - // gets computed margin-right based on width of container. (#3333) - // Fails in WebKit before Feb 2011 nightlies - // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - marginDiv = div.appendChild( document.createElement("div") ); - marginDiv.style.cssText = div.style.cssText = divReset; - marginDiv.style.marginRight = marginDiv.style.width = "0"; - div.style.width = "1px"; + // Don't pass non-elements to Sizzle + cur.nodeType === 1 && + jQuery.find.matchesSelector( cur, selectors ) ) ) { - support.reliableMarginRight = - !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); - } - - if ( typeof div.style.zoom !== core_strundefined ) { - // Support: IE<8 - // Check if natively block-level elements act like inline-block - // elements when setting their display to 'inline' and giving - // them layout - div.innerHTML = ""; - div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1"; - support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); - - // Support: IE6 - // Check if elements with layout shrink-wrap their children - div.style.display = "block"; - div.innerHTML = "
"; - div.firstChild.style.width = "5px"; - support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); - - if ( support.inlineBlockNeedsLayout ) { - // Prevent IE 6 from affecting layout for positioned elements #11048 - // Prevent IE from shrinking the body in IE 7 mode #12869 - // Support: IE<8 - body.style.zoom = 1; + matched.push( cur ); + break; + } } } - body.removeChild( container ); - - // Null elements to avoid leaks in IE - container = div = tds = marginDiv = null; - }); - - // Null elements to avoid leaks in IE - all = select = fragment = opt = a = input = null; - - return support; -})({}); + return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); + }, -var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, - rmultiDash = /([A-Z])/g; + // Determine the position of an element within the set + index: function( elem ) { -function internalData( elem, name, data, pvt /* Internal Use Only */ ){ - if ( !jQuery.acceptData( elem ) ) { - return; - } + // No argument, return index in parent + if ( !elem ) { + return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; + } - var ret, thisCache, - internalKey = jQuery.expando, + // Index in selector + if ( typeof elem === "string" ) { + return indexOf.call( jQuery( elem ), this[ 0 ] ); + } - // We have to handle DOM nodes and JS objects differently because IE6-7 - // can't GC object references properly across the DOM-JS boundary - isNode = elem.nodeType, + // Locate the position of the desired element + return indexOf.call( this, - // Only DOM nodes need the global jQuery cache; JS object data is - // attached directly to the object so GC can occur automatically - cache = isNode ? jQuery.cache : elem, + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[ 0 ] : elem + ); + }, - // Only defining an ID for JS objects if its cache already exists allows - // the code to shortcut on the same path as a DOM node with no cache - id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; + add: function( selector, context ) { + return this.pushStack( + jQuery.uniqueSort( + jQuery.merge( this.get(), jQuery( selector, context ) ) + ) + ); + }, - // Avoid doing any more work than we need to when trying to get data on an - // object that has no data at all - if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) { - return; + addBack: function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter( selector ) + ); } +} ); - if ( !id ) { - // Only DOM nodes need a new unique ID for each element since their data - // ends up in the global cache - if ( isNode ) { - id = elem[ internalKey ] = core_deletedIds.pop() || jQuery.guid++; - } else { - id = internalKey; - } - } +function sibling( cur, dir ) { + while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} + return cur; +} - if ( !cache[ id ] ) { - // Avoid exposing jQuery metadata on plain JS objects when the object - // is serialized using JSON.stringify - cache[ id ] = isNode ? {} : { toJSON: jQuery.noop }; +jQuery.each( { + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return sibling( elem, "nextSibling" ); + }, + prev: function( elem ) { + return sibling( elem, "previousSibling" ); + }, + nextAll: function( elem ) { + return dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return siblings( ( elem.parentNode || {} ).firstChild, elem ); + }, + children: function( elem ) { + return siblings( elem.firstChild ); + }, + contents: function( elem ) { + return elem.contentDocument || jQuery.merge( [], elem.childNodes ); } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var matched = jQuery.map( this, fn, until ); - // An object can be passed to jQuery.data instead of a key/value pair; this gets - // shallow copied over onto the existing cache - if ( typeof name === "object" || typeof name === "function" ) { - if ( pvt ) { - cache[ id ] = jQuery.extend( cache[ id ], name ); - } else { - cache[ id ].data = jQuery.extend( cache[ id ].data, name ); + if ( name.slice( -5 ) !== "Until" ) { + selector = until; } - } - thisCache = cache[ id ]; - - // jQuery data() is stored in a separate object inside the object's internal data - // cache in order to avoid key collisions between internal data and user-defined - // data. - if ( !pvt ) { - if ( !thisCache.data ) { - thisCache.data = {}; + if ( selector && typeof selector === "string" ) { + matched = jQuery.filter( selector, matched ); } - thisCache = thisCache.data; - } - - if ( data !== undefined ) { - thisCache[ jQuery.camelCase( name ) ] = data; - } - - // Check for both converted-to-camel and non-converted data property names - // If a data property was specified - if ( typeof name === "string" ) { - - // First Try to find as-is property data - ret = thisCache[ name ]; + if ( this.length > 1 ) { - // Test for null|undefined property data - if ( ret == null ) { + // Remove duplicates + if ( !guaranteedUnique[ name ] ) { + jQuery.uniqueSort( matched ); + } - // Try to find the camelCased property - ret = thisCache[ jQuery.camelCase( name ) ]; + // Reverse order for parents* and prev-derivatives + if ( rparentsprev.test( name ) ) { + matched.reverse(); + } } - } else { - ret = thisCache; - } - - return ret; -} - -function internalRemoveData( elem, name, pvt ) { - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var thisCache, i, - isNode = elem.nodeType, - - // See jQuery.data for more information - cache = isNode ? jQuery.cache : elem, - id = isNode ? elem[ jQuery.expando ] : jQuery.expando; - - // If there is already no cache entry for this object, there is no - // purpose in continuing - if ( !cache[ id ] ) { - return; - } - - if ( name ) { - thisCache = pvt ? cache[ id ] : cache[ id ].data; + return this.pushStack( matched ); + }; +} ); +var rnotwhite = ( /\S+/g ); - if ( thisCache ) { - // Support array or space separated string names for data keys - if ( !jQuery.isArray( name ) ) { - // try the string as a key before any manipulation - if ( name in thisCache ) { - name = [ name ]; - } else { +// Convert String-formatted options into Object-formatted ones +function createOptions( options ) { + var object = {}; + jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { + object[ flag ] = true; + } ); + return object; +} - // split the camel cased version by spaces unless a key with the spaces exists - name = jQuery.camelCase( name ); - if ( name in thisCache ) { - name = [ name ]; - } else { - name = name.split(" "); - } - } - } else { - // If "name" is an array of keys... - // When data is initially created, via ("key", "val") signature, - // keys will be converted to camelCase. - // Since there is no way to tell _how_ a key was added, remove - // both plain key and camelCase key. #12786 - // This will only penalize the array argument path. - name = name.concat( jQuery.map( name, jQuery.camelCase ) ); - } +/* + * Create a callback list using the following parameters: + * + * options: an optional list of space-separated options that will change how + * the callback list behaves or a more traditional option object + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible options: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( options ) { - i = name.length; - while ( i-- ) { - delete thisCache[ name[i] ]; - } + // Convert options from String-formatted to Object-formatted if needed + // (we check in cache first) + options = typeof options === "string" ? + createOptions( options ) : + jQuery.extend( {}, options ); - // If there is no data left in the cache, we want to continue - // and let the cache object itself get destroyed - if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) { - return; - } - } - } + var // Flag to know if list is currently firing + firing, - // See jQuery.data for more information - if ( !pvt ) { - delete cache[ id ].data; + // Last fire value for non-forgettable lists + memory, - // Don't destroy the parent cache unless the internal data object - // had been the only thing left in it - if ( !isEmptyDataObject( cache[ id ] ) ) { - return; - } - } + // Flag to know if list was already fired + fired, - // Destroy the cache - if ( isNode ) { - jQuery.cleanData( [ elem ], true ); + // Flag to prevent firing + locked, - // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) - /* jshint eqeqeq: false */ - } else if ( jQuery.support.deleteExpando || cache != cache.window ) { - /* jshint eqeqeq: true */ - delete cache[ id ]; + // Actual callback list + list = [], - // When all else fails, null - } else { - cache[ id ] = null; - } -} + // Queue of execution data for repeatable lists + queue = [], -jQuery.extend({ - cache: {}, + // Index of currently firing callback (modified by add/remove as needed) + firingIndex = -1, - // The following elements throw uncatchable exceptions if you - // attempt to add expando properties to them. - noData: { - "applet": true, - "embed": true, - // Ban all objects except for Flash (which handle expandos) - "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" - }, + // Fire callbacks + fire = function() { - hasData: function( elem ) { - elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; - return !!elem && !isEmptyDataObject( elem ); - }, + // Enforce single-firing + locked = options.once; - data: function( elem, name, data ) { - return internalData( elem, name, data ); - }, + // Execute callbacks for all pending executions, + // respecting firingIndex overrides and runtime changes + fired = firing = true; + for ( ; queue.length; firingIndex = -1 ) { + memory = queue.shift(); + while ( ++firingIndex < list.length ) { - removeData: function( elem, name ) { - return internalRemoveData( elem, name ); - }, + // Run callback and check for early termination + if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && + options.stopOnFalse ) { - // For internal use only. - _data: function( elem, name, data ) { - return internalData( elem, name, data, true ); - }, + // Jump to end and forget the data so .add doesn't re-fire + firingIndex = list.length; + memory = false; + } + } + } - _removeData: function( elem, name ) { - return internalRemoveData( elem, name, true ); - }, + // Forget the data if we're done with it + if ( !options.memory ) { + memory = false; + } - // A method for determining if a DOM node can handle the data expando - acceptData: function( elem ) { - // Do not set data on non-element because it will not be cleared (#8335). - if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) { - return false; - } + firing = false; - var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ]; + // Clean up if we're done firing for good + if ( locked ) { - // nodes accept data unless otherwise specified; rejection can be conditional - return !noData || noData !== true && elem.getAttribute("classid") === noData; - } -}); + // Keep an empty list if we have data for future add calls + if ( memory ) { + list = []; -jQuery.fn.extend({ - data: function( key, value ) { - var attrs, name, - data = null, - i = 0, - elem = this[0]; + // Otherwise, this object is spent + } else { + list = ""; + } + } + }, - // Special expections of .data basically thwart jQuery.access, - // so implement the relevant behavior ourselves + // Actual Callbacks object + self = { - // Gets all values - if ( key === undefined ) { - if ( this.length ) { - data = jQuery.data( elem ); + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + + // If we have memory from a past run, we should fire after adding + if ( memory && !firing ) { + firingIndex = list.length - 1; + queue.push( memory ); + } + + ( function add( args ) { + jQuery.each( args, function( _, arg ) { + if ( jQuery.isFunction( arg ) ) { + if ( !options.unique || !self.has( arg ) ) { + list.push( arg ); + } + } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { - if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { - attrs = elem.attributes; - for ( ; i < attrs.length; i++ ) { - name = attrs[i].name; + // Inspect recursively + add( arg ); + } + } ); + } )( arguments ); - if ( name.indexOf("data-") === 0 ) { - name = jQuery.camelCase( name.slice(5) ); + if ( memory && !firing ) { + fire(); + } + } + return this; + }, - dataAttr( elem, name, data[ name ] ); + // Remove a callback from the list + remove: function() { + jQuery.each( arguments, function( _, arg ) { + var index; + while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { + list.splice( index, 1 ); + + // Handle firing indexes + if ( index <= firingIndex ) { + firingIndex--; } } - jQuery._data( elem, "parsedAttrs", true ); + } ); + return this; + }, + + // Check if a given callback is in the list. + // If no argument is given, return whether or not list has callbacks attached. + has: function( fn ) { + return fn ? + jQuery.inArray( fn, list ) > -1 : + list.length > 0; + }, + + // Remove all callbacks from the list + empty: function() { + if ( list ) { + list = []; } - } + return this; + }, - return data; - } + // Disable .fire and .add + // Abort any current/pending executions + // Clear all callbacks and values + disable: function() { + locked = queue = []; + list = memory = ""; + return this; + }, + disabled: function() { + return !list; + }, - // Sets multiple values - if ( typeof key === "object" ) { - return this.each(function() { - jQuery.data( this, key ); - }); - } + // Disable .fire + // Also disable .add unless we have memory (since it would have no effect) + // Abort any pending executions + lock: function() { + locked = queue = []; + if ( !memory ) { + list = memory = ""; + } + return this; + }, + locked: function() { + return !!locked; + }, - return arguments.length > 1 ? + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( !locked ) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + queue.push( args ); + if ( !firing ) { + fire(); + } + } + return this; + }, - // Sets one value - this.each(function() { - jQuery.data( this, key, value ); - }) : + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, - // Gets one value - // Try to fetch any internally stored data first - elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null; - }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!fired; + } + }; - removeData: function( key ) { - return this.each(function() { - jQuery.removeData( this, key ); - }); - } -}); + return self; +}; -function dataAttr( elem, key, data ) { - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if ( data === undefined && elem.nodeType === 1 ) { - var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); +jQuery.extend( { - data = elem.getAttribute( name ); + Deferred: function( func ) { + var tuples = [ - if ( typeof data === "string" ) { - try { - data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - // Only convert to a number if it doesn't change the string - +data + "" === data ? +data : - rbrace.test( data ) ? jQuery.parseJSON( data ) : - data; - } catch( e ) {} + // action, add listener, listener list, final state + [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ], + [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ], + [ "notify", "progress", jQuery.Callbacks( "memory" ) ] + ], + state = "pending", + promise = { + state: function() { + return state; + }, + always: function() { + deferred.done( arguments ).fail( arguments ); + return this; + }, + then: function( /* fnDone, fnFail, fnProgress */ ) { + var fns = arguments; + return jQuery.Deferred( function( newDefer ) { + jQuery.each( tuples, function( i, tuple ) { + var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; - // Make sure we set the data so it isn't changed later - jQuery.data( elem, key, data ); + // deferred[ done | fail | progress ] for forwarding actions to newDefer + deferred[ tuple[ 1 ] ]( function() { + var returned = fn && fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise() + .progress( newDefer.notify ) + .done( newDefer.resolve ) + .fail( newDefer.reject ); + } else { + newDefer[ tuple[ 0 ] + "With" ]( + this === promise ? newDefer.promise() : this, + fn ? [ returned ] : arguments + ); + } + } ); + } ); + fns = null; + } ).promise(); + }, - } else { - data = undefined; - } - } + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + return obj != null ? jQuery.extend( obj, promise ) : promise; + } + }, + deferred = {}; - return data; -} + // Keep pipe for back-compat + promise.pipe = promise.then; -// checks a cache object for emptiness -function isEmptyDataObject( obj ) { - var name; - for ( name in obj ) { + // Add list-specific methods + jQuery.each( tuples, function( i, tuple ) { + var list = tuple[ 2 ], + stateString = tuple[ 3 ]; - // if the public data object is empty, the private is still empty - if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { - continue; - } - if ( name !== "toJSON" ) { - return false; - } - } + // promise[ done | fail | progress ] = list.add + promise[ tuple[ 1 ] ] = list.add; - return true; -} -jQuery.extend({ - queue: function( elem, type, data ) { - var queue; + // Handle state + if ( stateString ) { + list.add( function() { - if ( elem ) { - type = ( type || "fx" ) + "queue"; - queue = jQuery._data( elem, type ); + // state = [ resolved | rejected ] + state = stateString; - // Speed up dequeue by getting out quickly if this is just a lookup - if ( data ) { - if ( !queue || jQuery.isArray(data) ) { - queue = jQuery._data( elem, type, jQuery.makeArray(data) ); - } else { - queue.push( data ); - } + // [ reject_list | resolve_list ].disable; progress_list.lock + }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); } - return queue || []; - } - }, - - dequeue: function( elem, type ) { - type = type || "fx"; - var queue = jQuery.queue( elem, type ), - startLength = queue.length, - fn = queue.shift(), - hooks = jQuery._queueHooks( elem, type ), - next = function() { - jQuery.dequeue( elem, type ); + // deferred[ resolve | reject | notify ] + deferred[ tuple[ 0 ] ] = function() { + deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments ); + return this; }; + deferred[ tuple[ 0 ] + "With" ] = list.fireWith; + } ); - // If the fx queue is dequeued, always remove the progress sentinel - if ( fn === "inprogress" ) { - fn = queue.shift(); - startLength--; + // Make the deferred a promise + promise.promise( deferred ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); } - if ( fn ) { + // All done! + return deferred; + }, - // Add a progress sentinel to prevent the fx queue from being - // automatically dequeued - if ( type === "fx" ) { - queue.unshift( "inprogress" ); - } + // Deferred helper + when: function( subordinate /* , ..., subordinateN */ ) { + var i = 0, + resolveValues = slice.call( arguments ), + length = resolveValues.length, - // clear up the last queue stop function - delete hooks.stop; - fn.call( elem, next, hooks ); + // the count of uncompleted subordinates + remaining = length !== 1 || + ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, + + // the master Deferred. + // If resolveValues consist of only a single Deferred, just use that. + deferred = remaining === 1 ? subordinate : jQuery.Deferred(), + + // Update function for both resolve and progress values + updateFunc = function( i, contexts, values ) { + return function( value ) { + contexts[ i ] = this; + values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; + if ( values === progressValues ) { + deferred.notifyWith( contexts, values ); + } else if ( !( --remaining ) ) { + deferred.resolveWith( contexts, values ); + } + }; + }, + + progressValues, progressContexts, resolveContexts; + + // Add listeners to Deferred subordinates; treat others as resolved + if ( length > 1 ) { + progressValues = new Array( length ); + progressContexts = new Array( length ); + resolveContexts = new Array( length ); + for ( ; i < length; i++ ) { + if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { + resolveValues[ i ].promise() + .progress( updateFunc( i, progressContexts, progressValues ) ) + .done( updateFunc( i, resolveContexts, resolveValues ) ) + .fail( deferred.reject ); + } else { + --remaining; + } + } } - if ( !startLength && hooks ) { - hooks.empty.fire(); + // If we're not waiting on anything, resolve the master + if ( !remaining ) { + deferred.resolveWith( resolveContexts, resolveValues ); } - }, - // not intended for public consumption - generates a queueHooks object, or returns the current one - _queueHooks: function( elem, type ) { - var key = type + "queueHooks"; - return jQuery._data( elem, key ) || jQuery._data( elem, key, { - empty: jQuery.Callbacks("once memory").add(function() { - jQuery._removeData( elem, type + "queue" ); - jQuery._removeData( elem, key ); - }) - }); + return deferred.promise(); } -}); +} ); -jQuery.fn.extend({ - queue: function( type, data ) { - var setter = 2; - if ( typeof type !== "string" ) { - data = type; - type = "fx"; - setter--; - } +// The deferred used on DOM ready +var readyList; - if ( arguments.length < setter ) { - return jQuery.queue( this[0], type ); - } +jQuery.fn.ready = function( fn ) { - return data === undefined ? - this : - this.each(function() { - var queue = jQuery.queue( this, type, data ); + // Add the callback + jQuery.ready.promise().done( fn ); - // ensure a hooks for this queue - jQuery._queueHooks( this, type ); + return this; +}; - if ( type === "fx" && queue[0] !== "inprogress" ) { - jQuery.dequeue( this, type ); - } - }); - }, - dequeue: function( type ) { - return this.each(function() { - jQuery.dequeue( this, type ); - }); - }, - // Based off of the plugin by Clint Helfers, with permission. - // http://blindsignals.com/index.php/2009/07/jquery-delay/ - delay: function( time, type ) { - time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; - type = type || "fx"; +jQuery.extend( { - return this.queue( type, function( next, hooks ) { - var timeout = setTimeout( next, time ); - hooks.stop = function() { - clearTimeout( timeout ); - }; - }); - }, - clearQueue: function( type ) { - return this.queue( type || "fx", [] ); - }, - // Get a promise resolved when queues of a certain type - // are emptied (fx is the type by default) - promise: function( type, obj ) { - var tmp, - count = 1, - defer = jQuery.Deferred(), - elements = this, - i = this.length, - resolve = function() { - if ( !( --count ) ) { - defer.resolveWith( elements, [ elements ] ); - } - }; + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, - if ( typeof type !== "string" ) { - obj = type; - type = undefined; - } - type = type || "fx"; + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, - while( i-- ) { - tmp = jQuery._data( elements[ i ], type + "queueHooks" ); - if ( tmp && tmp.empty ) { - count++; - tmp.empty.add( resolve ); - } + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); } - resolve(); - return defer.promise( obj ); - } -}); -var nodeHook, boolHook, - rclass = /[\t\r\n\f]/g, - rreturn = /\r/g, - rfocusable = /^(?:input|select|textarea|button|object)$/i, - rclickable = /^(?:a|area)$/i, - ruseDefault = /^(?:checked|selected)$/i, - getSetAttribute = jQuery.support.getSetAttribute, - getSetInput = jQuery.support.input; - -jQuery.fn.extend({ - attr: function( name, value ) { - return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); }, - removeAttr: function( name ) { - return this.each(function() { - jQuery.removeAttr( this, name ); - }); - }, + // Handle when the DOM is ready + ready: function( wait ) { - prop: function( name, value ) { - return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); - }, + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } - removeProp: function( name ) { - name = jQuery.propFix[ name ] || name; - return this.each(function() { - // try/catch handles cases where IE balks (such as removing a property on window) - try { - this[ name ] = undefined; - delete this[ name ]; - } catch( e ) {} - }); - }, + // Remember that the DOM is ready + jQuery.isReady = true; - addClass: function( value ) { - var classes, elem, cur, clazz, j, - i = 0, - len = this.length, - proceed = typeof value === "string" && value; + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } - if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).addClass( value.call( this, j, this.className ) ); - }); + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.triggerHandler ) { + jQuery( document ).triggerHandler( "ready" ); + jQuery( document ).off( "ready" ); } + } +} ); - if ( proceed ) { - // The disjunction here is for better compressibility (see removeClass) - classes = ( value || "" ).match( core_rnotwhite ) || []; +/** + * The ready event handler and self cleanup method + */ +function completed() { + document.removeEventListener( "DOMContentLoaded", completed ); + window.removeEventListener( "load", completed ); + jQuery.ready(); +} - for ( ; i < len; i++ ) { - elem = this[ i ]; - cur = elem.nodeType === 1 && ( elem.className ? - ( " " + elem.className + " " ).replace( rclass, " " ) : - " " - ); +jQuery.ready.promise = function( obj ) { + if ( !readyList ) { - if ( cur ) { - j = 0; - while ( (clazz = classes[j++]) ) { - if ( cur.indexOf( " " + clazz + " " ) < 0 ) { - cur += clazz + " "; - } - } - elem.className = jQuery.trim( cur ); + readyList = jQuery.Deferred(); - } - } - } + // Catch cases where $(document).ready() is called + // after the browser event has already occurred. + // Support: IE9-10 only + // Older IE sometimes signals "interactive" too soon + if ( document.readyState === "complete" || + ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { - return this; - }, + // Handle it asynchronously to allow scripts the opportunity to delay ready + window.setTimeout( jQuery.ready ); - removeClass: function( value ) { - var classes, elem, cur, clazz, j, - i = 0, - len = this.length, - proceed = arguments.length === 0 || typeof value === "string" && value; + } else { - if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).removeClass( value.call( this, j, this.className ) ); - }); + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed ); } - if ( proceed ) { - classes = ( value || "" ).match( core_rnotwhite ) || []; + } + return readyList.promise( obj ); +}; - for ( ; i < len; i++ ) { - elem = this[ i ]; - // This expression is here for better compressibility (see addClass) - cur = elem.nodeType === 1 && ( elem.className ? - ( " " + elem.className + " " ).replace( rclass, " " ) : - "" - ); +// Kick off the DOM ready check even if the user does not +jQuery.ready.promise(); - if ( cur ) { - j = 0; - while ( (clazz = classes[j++]) ) { - // Remove *all* instances - while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { - cur = cur.replace( " " + clazz + " ", " " ); - } - } - elem.className = value ? jQuery.trim( cur ) : ""; - } - } - } - return this; - }, - toggleClass: function( value, stateVal ) { - var type = typeof value; - if ( typeof stateVal === "boolean" && type === "string" ) { - return stateVal ? this.addClass( value ) : this.removeClass( value ); +// Multifunctional method to get and set values of a collection +// The value/s can optionally be executed if it's a function +var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { + var i = 0, + len = elems.length, + bulk = key == null; + + // Sets many values + if ( jQuery.type( key ) === "object" ) { + chainable = true; + for ( i in key ) { + access( elems, fn, i, key[ i ], true, emptyGet, raw ); } - if ( jQuery.isFunction( value ) ) { - return this.each(function( i ) { - jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); - }); + // Sets one value + } else if ( value !== undefined ) { + chainable = true; + + if ( !jQuery.isFunction( value ) ) { + raw = true; } - return this.each(function() { - if ( type === "string" ) { - // toggle individual class names - var className, - i = 0, - self = jQuery( this ), - classNames = value.match( core_rnotwhite ) || []; - - while ( (className = classNames[ i++ ]) ) { - // check each className given, space separated list - if ( self.hasClass( className ) ) { - self.removeClass( className ); - } else { - self.addClass( className ); - } - } + if ( bulk ) { - // Toggle whole class name - } else if ( type === core_strundefined || type === "boolean" ) { - if ( this.className ) { - // store className if set - jQuery._data( this, "__className__", this.className ); - } + // Bulk operations run against the entire set + if ( raw ) { + fn.call( elems, value ); + fn = null; - // If the element has a class name or if we're passed "false", - // then remove the whole classname (if there was one, the above saved it). - // Otherwise bring back whatever was previously saved (if anything), - // falling back to the empty string if nothing was stored. - this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + // ...except when executing function values + } else { + bulk = fn; + fn = function( elem, key, value ) { + return bulk.call( jQuery( elem ), value ); + }; } - }); - }, + } - hasClass: function( selector ) { - var className = " " + selector + " ", - i = 0, - l = this.length; - for ( ; i < l; i++ ) { - if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { - return true; + if ( fn ) { + for ( ; i < len; i++ ) { + fn( + elems[ i ], key, raw ? + value : + value.call( elems[ i ], i, fn( elems[ i ], key ) ) + ); } } + } - return false; - }, - - val: function( value ) { - var ret, hooks, isFunction, - elem = this[0]; + return chainable ? + elems : - if ( !arguments.length ) { - if ( elem ) { - hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; - - if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { - return ret; - } - - ret = elem.value; + // Gets + bulk ? + fn.call( elems ) : + len ? fn( elems[ 0 ], key ) : emptyGet; +}; +var acceptData = function( owner ) { + + // Accepts only: + // - Node + // - Node.ELEMENT_NODE + // - Node.DOCUMENT_NODE + // - Object + // - Any + /* jshint -W018 */ + return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); +}; - return typeof ret === "string" ? - // handle most common string cases - ret.replace(rreturn, "") : - // handle cases where value is null/undef or number - ret == null ? "" : ret; - } - return; - } - isFunction = jQuery.isFunction( value ); - return this.each(function( i ) { - var val; +function Data() { + this.expando = jQuery.expando + Data.uid++; +} - if ( this.nodeType !== 1 ) { - return; - } +Data.uid = 1; - if ( isFunction ) { - val = value.call( this, i, jQuery( this ).val() ); - } else { - val = value; - } +Data.prototype = { - // Treat null/undefined as ""; convert numbers to string - if ( val == null ) { - val = ""; - } else if ( typeof val === "number" ) { - val += ""; - } else if ( jQuery.isArray( val ) ) { - val = jQuery.map(val, function ( value ) { - return value == null ? "" : value + ""; - }); - } + register: function( owner, initial ) { + var value = initial || {}; - hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; + // If it is a node unlikely to be stringify-ed or looped over + // use plain assignment + if ( owner.nodeType ) { + owner[ this.expando ] = value; - // If set returns undefined, fall back to normal setting - if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { - this.value = val; - } - }); - } -}); + // Otherwise secure it in a non-enumerable, non-writable property + // configurability must be true to allow the property to be + // deleted with the delete operator + } else { + Object.defineProperty( owner, this.expando, { + value: value, + writable: true, + configurable: true + } ); + } + return owner[ this.expando ]; + }, + cache: function( owner ) { -jQuery.extend({ - valHooks: { - option: { - get: function( elem ) { - // Use proper attribute retrieval(#6932, #12072) - var val = jQuery.find.attr( elem, "value" ); - return val != null ? - val : - elem.text; - } - }, - select: { - get: function( elem ) { - var value, option, - options = elem.options, - index = elem.selectedIndex, - one = elem.type === "select-one" || index < 0, - values = one ? null : [], - max = one ? index + 1 : options.length, - i = index < 0 ? - max : - one ? index : 0; + // We can accept data for non-element nodes in modern browsers, + // but we should not, see #8335. + // Always return an empty object. + if ( !acceptData( owner ) ) { + return {}; + } - // Loop through all the selected options - for ( ; i < max; i++ ) { - option = options[ i ]; + // Check if the owner object already has a cache + var value = owner[ this.expando ]; - // oldIE doesn't update selected after form reset (#2551) - if ( ( option.selected || i === index ) && - // Don't return options that are disabled or in a disabled optgroup - ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) && - ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { + // If not, create one + if ( !value ) { + value = {}; - // Get the specific value for the option - value = jQuery( option ).val(); + // We can accept data for non-element nodes in modern browsers, + // but we should not, see #8335. + // Always return an empty object. + if ( acceptData( owner ) ) { - // We don't need an array for one selects - if ( one ) { - return value; - } + // If it is a node unlikely to be stringify-ed or looped over + // use plain assignment + if ( owner.nodeType ) { + owner[ this.expando ] = value; - // Multi-Selects return an array - values.push( value ); - } + // Otherwise secure it in a non-enumerable property + // configurable must be true to allow the property to be + // deleted when data is removed + } else { + Object.defineProperty( owner, this.expando, { + value: value, + configurable: true + } ); } + } + } - return values; - }, + return value; + }, + set: function( owner, data, value ) { + var prop, + cache = this.cache( owner ); - set: function( elem, value ) { - var optionSet, option, - options = elem.options, - values = jQuery.makeArray( value ), - i = options.length; + // Handle: [ owner, key, value ] args + if ( typeof data === "string" ) { + cache[ data ] = value; - while ( i-- ) { - option = options[ i ]; - if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) { - optionSet = true; - } - } + // Handle: [ owner, { properties } ] args + } else { - // force browsers to behave consistently when non-matching value is set - if ( !optionSet ) { - elem.selectedIndex = -1; - } - return values; + // Copy the properties one-by-one to the cache object + for ( prop in data ) { + cache[ prop ] = data[ prop ]; } } + return cache; }, + get: function( owner, key ) { + return key === undefined ? + this.cache( owner ) : + owner[ this.expando ] && owner[ this.expando ][ key ]; + }, + access: function( owner, key, value ) { + var stored; - attr: function( elem, name, value ) { - var hooks, ret, - nType = elem.nodeType; - - // don't get/set attributes on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return; - } + // In cases where either: + // + // 1. No key was specified + // 2. A string key was specified, but no value provided + // + // Take the "read" path and allow the get method to determine + // which value to return, respectively either: + // + // 1. The entire cache object + // 2. The data stored at the key + // + if ( key === undefined || + ( ( key && typeof key === "string" ) && value === undefined ) ) { - // Fallback to prop when attributes are not supported - if ( typeof elem.getAttribute === core_strundefined ) { - return jQuery.prop( elem, name, value ); - } + stored = this.get( owner, key ); - // All attributes are lowercase - // Grab necessary hook if one is defined - if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { - name = name.toLowerCase(); - hooks = jQuery.attrHooks[ name ] || - ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook ); + return stored !== undefined ? + stored : this.get( owner, jQuery.camelCase( key ) ); } - if ( value !== undefined ) { - - if ( value === null ) { - jQuery.removeAttr( elem, name ); + // When the key is not a string, or both a key and value + // are specified, set or extend (existing objects) with either: + // + // 1. An object of properties + // 2. A key and value + // + this.set( owner, key, value ); - } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { - return ret; + // Since the "set" path can have two possible entry points + // return the expected data based on which path was taken[*] + return value !== undefined ? value : key; + }, + remove: function( owner, key ) { + var i, name, camel, + cache = owner[ this.expando ]; - } else { - elem.setAttribute( name, value + "" ); - return value; - } + if ( cache === undefined ) { + return; + } - } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { - return ret; + if ( key === undefined ) { + this.register( owner ); } else { - ret = jQuery.find.attr( elem, name ); - - // Non-existent attributes return null, we normalize to undefined - return ret == null ? - undefined : - ret; - } - }, - - removeAttr: function( elem, value ) { - var name, propName, - i = 0, - attrNames = value && value.match( core_rnotwhite ); - if ( attrNames && elem.nodeType === 1 ) { - while ( (name = attrNames[i++]) ) { - propName = jQuery.propFix[ name ] || name; + // Support array or space separated string of keys + if ( jQuery.isArray( key ) ) { - // Boolean attributes get special treatment (#10870) - if ( jQuery.expr.match.bool.test( name ) ) { - // Set corresponding property to false - if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { - elem[ propName ] = false; - // Support: IE<9 - // Also clear defaultChecked/defaultSelected (if appropriate) - } else { - elem[ jQuery.camelCase( "default-" + name ) ] = - elem[ propName ] = false; - } + // If "name" is an array of keys... + // When data is initially created, via ("key", "val") signature, + // keys will be converted to camelCase. + // Since there is no way to tell _how_ a key was added, remove + // both plain key and camelCase key. #12786 + // This will only penalize the array argument path. + name = key.concat( key.map( jQuery.camelCase ) ); + } else { + camel = jQuery.camelCase( key ); - // See #9699 for explanation of this approach (setting first, then removal) + // Try the string as a key before any manipulation + if ( key in cache ) { + name = [ key, camel ]; } else { - jQuery.attr( elem, name, "" ); + + // If a key with the spaces exists, use it. + // Otherwise, create an array by matching non-whitespace + name = camel; + name = name in cache ? + [ name ] : ( name.match( rnotwhite ) || [] ); } + } + + i = name.length; - elem.removeAttribute( getSetAttribute ? name : propName ); + while ( i-- ) { + delete cache[ name[ i ] ]; } } - }, - attrHooks: { - type: { - set: function( elem, value ) { - if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { - // Setting the type on a radio button after the value resets the value in IE6-9 - // Reset value to default in case type is set after value during creation - var val = elem.value; - elem.setAttribute( "type", value ); - if ( val ) { - elem.value = val; - } - return value; - } + // Remove the expando if there's no more data + if ( key === undefined || jQuery.isEmptyObject( cache ) ) { + + // Support: Chrome <= 35-45+ + // Webkit & Blink performance suffers when deleting properties + // from DOM nodes, so set to undefined instead + // https://code.google.com/p/chromium/issues/detail?id=378607 + if ( owner.nodeType ) { + owner[ this.expando ] = undefined; + } else { + delete owner[ this.expando ]; } } }, + hasData: function( owner ) { + var cache = owner[ this.expando ]; + return cache !== undefined && !jQuery.isEmptyObject( cache ); + } +}; +var dataPriv = new Data(); - propFix: { - "for": "htmlFor", - "class": "className" - }, +var dataUser = new Data(); - prop: function( elem, name, value ) { - var ret, hooks, notxml, - nType = elem.nodeType; - // don't get/set properties on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return; - } - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); +// Implementation Summary +// +// 1. Enforce API surface and semantic compatibility with 1.9.x branch +// 2. Improve the module's maintainability by reducing the storage +// paths to a single mechanism. +// 3. Use the same single mechanism to support "private" and "user" data. +// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) +// 5. Avoid exposing implementation details on user objects (eg. expando properties) +// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 - if ( notxml ) { - // Fix name and attach hooks - name = jQuery.propFix[ name ] || name; - hooks = jQuery.propHooks[ name ]; - } +var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, + rmultiDash = /[A-Z]/g; - if ( value !== undefined ) { - return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? - ret : - ( elem[ name ] = value ); +function dataAttr( elem, key, data ) { + var name; + + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + + // Only convert to a number if it doesn't change the string + +data + "" === data ? +data : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch ( e ) {} + // Make sure we set the data so it isn't changed later + dataUser.set( elem, key, data ); } else { - return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? - ret : - elem[ name ]; + data = undefined; } + } + return data; +} + +jQuery.extend( { + hasData: function( elem ) { + return dataUser.hasData( elem ) || dataPriv.hasData( elem ); }, - propHooks: { - tabIndex: { - get: function( elem ) { - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - // Use proper attribute retrieval(#12072) - var tabindex = jQuery.find.attr( elem, "tabindex" ); + data: function( elem, name, data ) { + return dataUser.access( elem, name, data ); + }, - return tabindex ? - parseInt( tabindex, 10 ) : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - -1; - } - } + removeData: function( elem, name ) { + dataUser.remove( elem, name ); + }, + + // TODO: Now that all calls to _data and _removeData have been replaced + // with direct calls to dataPriv methods, these can be deprecated. + _data: function( elem, name, data ) { + return dataPriv.access( elem, name, data ); + }, + + _removeData: function( elem, name ) { + dataPriv.remove( elem, name ); } -}); +} ); -// Hooks for boolean attributes -boolHook = { - set: function( elem, value, name ) { - if ( value === false ) { - // Remove boolean attributes when set to false - jQuery.removeAttr( elem, name ); - } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { - // IE<8 needs the *property* name - elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name ); +jQuery.fn.extend( { + data: function( key, value ) { + var i, name, data, + elem = this[ 0 ], + attrs = elem && elem.attributes; - // Use defaultChecked and defaultSelected for oldIE - } else { - elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true; - } + // Gets all values + if ( key === undefined ) { + if ( this.length ) { + data = dataUser.get( elem ); - return name; - } -}; -jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { - var getter = jQuery.expr.attrHandle[ name ] || jQuery.find.attr; - - jQuery.expr.attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ? - function( elem, name, isXML ) { - var fn = jQuery.expr.attrHandle[ name ], - ret = isXML ? - undefined : - /* jshint eqeqeq: false */ - (jQuery.expr.attrHandle[ name ] = undefined) != - getter( elem, name, isXML ) ? - - name.toLowerCase() : - null; - jQuery.expr.attrHandle[ name ] = fn; - return ret; - } : - function( elem, name, isXML ) { - return isXML ? - undefined : - elem[ jQuery.camelCase( "default-" + name ) ] ? - name.toLowerCase() : - null; - }; -}); + if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { + i = attrs.length; + while ( i-- ) { -// fix oldIE attroperties -if ( !getSetInput || !getSetAttribute ) { - jQuery.attrHooks.value = { - set: function( elem, value, name ) { - if ( jQuery.nodeName( elem, "input" ) ) { - // Does not return so that setAttribute is also used - elem.defaultValue = value; - } else { - // Use nodeHook if defined (#1954); otherwise setAttribute is fine - return nodeHook && nodeHook.set( elem, value, name ); + // Support: IE11+ + // The attrs elements can be null (#14894) + if ( attrs[ i ] ) { + name = attrs[ i ].name; + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.slice( 5 ) ); + dataAttr( elem, name, data[ name ] ); + } + } + } + dataPriv.set( elem, "hasDataAttrs", true ); + } } + + return data; } - }; -} -// IE6/7 do not support getting/setting some attributes with get/setAttribute -if ( !getSetAttribute ) { - - // Use this for any attribute in IE6/7 - // This fixes almost every IE6/7 issue - nodeHook = { - set: function( elem, value, name ) { - // Set the existing or create a new attribute node - var ret = elem.getAttributeNode( name ); - if ( !ret ) { - elem.setAttributeNode( - (ret = elem.ownerDocument.createAttribute( name )) - ); - } + // Sets multiple values + if ( typeof key === "object" ) { + return this.each( function() { + dataUser.set( this, key ); + } ); + } - ret.value = value += ""; + return access( this, function( value ) { + var data, camelKey; - // Break association with cloned elements by also using setAttribute (#9646) - return name === "value" || value === elem.getAttribute( name ) ? - value : - undefined; - } - }; - jQuery.expr.attrHandle.id = jQuery.expr.attrHandle.name = jQuery.expr.attrHandle.coords = - // Some attributes are constructed with empty-string values when not defined - function( elem, name, isXML ) { - var ret; - return isXML ? - undefined : - (ret = elem.getAttributeNode( name )) && ret.value !== "" ? - ret.value : - null; - }; - jQuery.valHooks.button = { - get: function( elem, name ) { - var ret = elem.getAttributeNode( name ); - return ret && ret.specified ? - ret.value : - undefined; - }, - set: nodeHook.set - }; + // The calling jQuery object (element matches) is not empty + // (and therefore has an element appears at this[ 0 ]) and the + // `value` parameter was not undefined. An empty jQuery object + // will result in `undefined` for elem = this[ 0 ] which will + // throw an exception if an attempt to read a data cache is made. + if ( elem && value === undefined ) { - // Set contenteditable to false on removals(#10429) - // Setting to empty string throws an error as an invalid value - jQuery.attrHooks.contenteditable = { - set: function( elem, value, name ) { - nodeHook.set( elem, value === "" ? false : value, name ); - } - }; + // Attempt to get data from the cache + // with the key as-is + data = dataUser.get( elem, key ) || - // Set width and height to auto instead of 0 on empty string( Bug #8150 ) - // This is for removals - jQuery.each([ "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = { - set: function( elem, value ) { - if ( value === "" ) { - elem.setAttribute( name, "auto" ); - return value; + // Try to find dashed key if it exists (gh-2779) + // This is for 2.2.x only + dataUser.get( elem, key.replace( rmultiDash, "-$&" ).toLowerCase() ); + + if ( data !== undefined ) { + return data; } - } - }; - }); -} + camelKey = jQuery.camelCase( key ); -// Some attributes require a special call on IE -// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx -if ( !jQuery.support.hrefNormalized ) { - // href/src property should get the full normalized URL (#10299/#12915) - jQuery.each([ "href", "src" ], function( i, name ) { - jQuery.propHooks[ name ] = { - get: function( elem ) { - return elem.getAttribute( name, 4 ); + // Attempt to get data from the cache + // with the key camelized + data = dataUser.get( elem, camelKey ); + if ( data !== undefined ) { + return data; + } + + // Attempt to "discover" the data in + // HTML5 custom data-* attrs + data = dataAttr( elem, camelKey, undefined ); + if ( data !== undefined ) { + return data; + } + + // We tried really hard, but the data doesn't exist. + return; } - }; - }); -} -if ( !jQuery.support.style ) { - jQuery.attrHooks.style = { - get: function( elem ) { - // Return undefined in the case of empty string - // Note: IE uppercases css property names, but if we were to .toLowerCase() - // .cssText, that would destroy case senstitivity in URL's, like in "background" - return elem.style.cssText || undefined; - }, - set: function( elem, value ) { - return ( elem.style.cssText = value + "" ); - } - }; -} + // Set the data... + camelKey = jQuery.camelCase( key ); + this.each( function() { -// Safari mis-reports the default selected property of an option -// Accessing the parent's selectedIndex property fixes it -if ( !jQuery.support.optSelected ) { - jQuery.propHooks.selected = { - get: function( elem ) { - var parent = elem.parentNode; + // First, attempt to store a copy or reference of any + // data that might've been store with a camelCased key. + var data = dataUser.get( this, camelKey ); - if ( parent ) { - parent.selectedIndex; + // For HTML5 data-* attribute interop, we have to + // store property names with dashes in a camelCase form. + // This might not apply to all properties...* + dataUser.set( this, camelKey, value ); - // Make sure that it also works with optgroups, see #5701 - if ( parent.parentNode ) { - parent.parentNode.selectedIndex; + // *... In the case of properties that might _actually_ + // have dashes, we need to also store a copy of that + // unchanged property. + if ( key.indexOf( "-" ) > -1 && data !== undefined ) { + dataUser.set( this, key, value ); } - } - return null; - } - }; -} + } ); + }, null, value, arguments.length > 1, null, true ); + }, -jQuery.each([ - "tabIndex", - "readOnly", - "maxLength", - "cellSpacing", - "cellPadding", - "rowSpan", - "colSpan", - "useMap", - "frameBorder", - "contentEditable" -], function() { - jQuery.propFix[ this.toLowerCase() ] = this; -}); + removeData: function( key ) { + return this.each( function() { + dataUser.remove( this, key ); + } ); + } +} ); -// IE6/7 call enctype encoding -if ( !jQuery.support.enctype ) { - jQuery.propFix.enctype = "encoding"; -} -// Radios and checkboxes getter/setter -jQuery.each([ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = { - set: function( elem, value ) { - if ( jQuery.isArray( value ) ) { - return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); +jQuery.extend( { + queue: function( elem, type, data ) { + var queue; + + if ( elem ) { + type = ( type || "fx" ) + "queue"; + queue = dataPriv.get( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !queue || jQuery.isArray( data ) ) { + queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); + } else { + queue.push( data ); + } } + return queue || []; } - }; - if ( !jQuery.support.checkOn ) { - jQuery.valHooks[ this ].get = function( elem ) { - // Support: Webkit - // "" is returned instead of "on" if a value isn't specified - return elem.getAttribute("value") === null ? "on" : elem.value; - }; - } -}); -var rformElems = /^(?:input|select|textarea)$/i, - rkeyEvent = /^key/, - rmouseEvent = /^(?:mouse|contextmenu)|click/, - rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, - rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; - -function returnTrue() { - return true; -} + }, -function returnFalse() { - return false; -} + dequeue: function( elem, type ) { + type = type || "fx"; -function safeActiveElement() { - try { - return document.activeElement; - } catch ( err ) { } -} + var queue = jQuery.queue( elem, type ), + startLength = queue.length, + fn = queue.shift(), + hooks = jQuery._queueHooks( elem, type ), + next = function() { + jQuery.dequeue( elem, type ); + }; -/* - * Helper functions for managing events -- not part of the public interface. - * Props to Dean Edwards' addEvent library for many of the ideas. - */ -jQuery.event = { + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + startLength--; + } - global: {}, + if ( fn ) { - add: function( elem, types, handler, data, selector ) { - var tmp, events, t, handleObjIn, - special, eventHandle, handleObj, - handlers, type, namespaces, origType, - elemData = jQuery._data( elem ); + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } - // Don't attach events to noData or text/comment nodes (but allow plain objects) - if ( !elemData ) { - return; + // Clear up the last queue stop function + delete hooks.stop; + fn.call( elem, next, hooks ); } - // Caller can pass in an object of custom data in lieu of the handler - if ( handler.handler ) { - handleObjIn = handler; - handler = handleObjIn.handler; - selector = handleObjIn.selector; + if ( !startLength && hooks ) { + hooks.empty.fire(); } + }, - // Make sure that the handler has a unique ID, used to find/remove it later - if ( !handler.guid ) { - handler.guid = jQuery.guid++; + // Not public - generate a queueHooks object, or return the current one + _queueHooks: function( elem, type ) { + var key = type + "queueHooks"; + return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { + empty: jQuery.Callbacks( "once memory" ).add( function() { + dataPriv.remove( elem, [ type + "queue", key ] ); + } ) + } ); + } +} ); + +jQuery.fn.extend( { + queue: function( type, data ) { + var setter = 2; + + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + setter--; } - // Init the element's event structure and main handler, if this is the first - if ( !(events = elemData.events) ) { - events = elemData.events = {}; + if ( arguments.length < setter ) { + return jQuery.queue( this[ 0 ], type ); } - if ( !(eventHandle = elemData.handle) ) { - eventHandle = elemData.handle = function( e ) { - // Discard the second event of a jQuery.event.trigger() and - // when an event is called after a page has unloaded - return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ? - jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : - undefined; + + return data === undefined ? + this : + this.each( function() { + var queue = jQuery.queue( this, type, data ); + + // Ensure a hooks for this queue + jQuery._queueHooks( this, type ); + + if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + } ); + }, + dequeue: function( type ) { + return this.each( function() { + jQuery.dequeue( this, type ); + } ); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, obj ) { + var tmp, + count = 1, + defer = jQuery.Deferred(), + elements = this, + i = this.length, + resolve = function() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } }; - // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events - eventHandle.elem = elem; - } - // Handle multiple events separated by a space - types = ( types || "" ).match( core_rnotwhite ) || [""]; - t = types.length; - while ( t-- ) { - tmp = rtypenamespace.exec( types[t] ) || []; - type = origType = tmp[1]; - namespaces = ( tmp[2] || "" ).split( "." ).sort(); + if ( typeof type !== "string" ) { + obj = type; + type = undefined; + } + type = type || "fx"; - // There *must* be a type, no attaching namespace-only handlers - if ( !type ) { - continue; + while ( i-- ) { + tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); + if ( tmp && tmp.empty ) { + count++; + tmp.empty.add( resolve ); } + } + resolve(); + return defer.promise( obj ); + } +} ); +var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; - // If event changes its type, use the special event handlers for the changed type - special = jQuery.event.special[ type ] || {}; +var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); - // If selector defined, determine special event api type, otherwise given type - type = ( selector ? special.delegateType : special.bindType ) || type; - // Update special based on newly reset type - special = jQuery.event.special[ type ] || {}; +var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; - // handleObj is passed to all event handlers - handleObj = jQuery.extend({ - type: type, - origType: origType, - data: data, - handler: handler, - guid: handler.guid, - selector: selector, - needsContext: selector && jQuery.expr.match.needsContext.test( selector ), - namespace: namespaces.join(".") - }, handleObjIn ); +var isHidden = function( elem, el ) { - // Init the event handler queue if we're the first - if ( !(handlers = events[ type ]) ) { - handlers = events[ type ] = []; - handlers.delegateCount = 0; + // isHidden might be called from jQuery#filter function; + // in that case, element will be second argument + elem = el || elem; + return jQuery.css( elem, "display" ) === "none" || + !jQuery.contains( elem.ownerDocument, elem ); + }; - // Only use addEventListener/attachEvent if the special events handler returns false - if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { - // Bind the global event handler to the element - if ( elem.addEventListener ) { - elem.addEventListener( type, eventHandle, false ); - } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, eventHandle ); - } - } - } - if ( special.add ) { - special.add.call( elem, handleObj ); +function adjustCSS( elem, prop, valueParts, tween ) { + var adjusted, + scale = 1, + maxIterations = 20, + currentValue = tween ? + function() { return tween.cur(); } : + function() { return jQuery.css( elem, prop, "" ); }, + initial = currentValue(), + unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), - if ( !handleObj.handler.guid ) { - handleObj.handler.guid = handler.guid; - } - } + // Starting value computation is required for potential unit mismatches + initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && + rcssNum.exec( jQuery.css( elem, prop ) ); - // Add to the element's handler list, delegates in front - if ( selector ) { - handlers.splice( handlers.delegateCount++, 0, handleObj ); - } else { - handlers.push( handleObj ); - } + if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { - // Keep track of which events have ever been used, for event optimization - jQuery.event.global[ type ] = true; - } + // Trust units reported by jQuery.css + unit = unit || initialInUnit[ 3 ]; - // Nullify elem to prevent memory leaks in IE - elem = null; - }, + // Make sure we update the tween properties later on + valueParts = valueParts || []; - // Detach an event or set of events from an element - remove: function( elem, types, handler, selector, mappedTypes ) { - var j, handleObj, tmp, - origCount, t, events, - special, handlers, type, - namespaces, origType, - elemData = jQuery.hasData( elem ) && jQuery._data( elem ); + // Iteratively approximate from a nonzero starting point + initialInUnit = +initial || 1; - if ( !elemData || !(events = elemData.events) ) { - return; - } + do { - // Once for each type.namespace in types; type may be omitted - types = ( types || "" ).match( core_rnotwhite ) || [""]; - t = types.length; - while ( t-- ) { - tmp = rtypenamespace.exec( types[t] ) || []; - type = origType = tmp[1]; - namespaces = ( tmp[2] || "" ).split( "." ).sort(); + // If previous iteration zeroed out, double until we get *something*. + // Use string for doubling so we don't accidentally see scale as unchanged below + scale = scale || ".5"; - // Unbind all events (on this namespace, if provided) for the element - if ( !type ) { - for ( type in events ) { - jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); - } - continue; - } - - special = jQuery.event.special[ type ] || {}; - type = ( selector ? special.delegateType : special.bindType ) || type; - handlers = events[ type ] || []; - tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); + // Adjust and apply + initialInUnit = initialInUnit / scale; + jQuery.style( elem, prop, initialInUnit + unit ); - // Remove matching events - origCount = j = handlers.length; - while ( j-- ) { - handleObj = handlers[ j ]; + // Update scale, tolerating zero or NaN from tween.cur() + // Break the loop if scale is unchanged or perfect, or if we've just had enough. + } while ( + scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations + ); + } - if ( ( mappedTypes || origType === handleObj.origType ) && - ( !handler || handler.guid === handleObj.guid ) && - ( !tmp || tmp.test( handleObj.namespace ) ) && - ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { - handlers.splice( j, 1 ); + if ( valueParts ) { + initialInUnit = +initialInUnit || +initial || 0; - if ( handleObj.selector ) { - handlers.delegateCount--; - } - if ( special.remove ) { - special.remove.call( elem, handleObj ); - } - } - } + // Apply relative offset (+=/-=) if specified + adjusted = valueParts[ 1 ] ? + initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : + +valueParts[ 2 ]; + if ( tween ) { + tween.unit = unit; + tween.start = initialInUnit; + tween.end = adjusted; + } + } + return adjusted; +} +var rcheckableType = ( /^(?:checkbox|radio)$/i ); - // Remove generic event handler if we removed something and no more handlers exist - // (avoids potential for endless recursion during removal of special event handlers) - if ( origCount && !handlers.length ) { - if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { - jQuery.removeEvent( elem, type, elemData.handle ); - } +var rtagName = ( /<([\w:-]+)/ ); - delete events[ type ]; - } - } +var rscriptType = ( /^$|\/(?:java|ecma)script/i ); - // Remove the expando if it's no longer used - if ( jQuery.isEmptyObject( events ) ) { - delete elemData.handle; - // removeData also checks for emptiness and clears the expando if empty - // so use it instead of delete - jQuery._removeData( elem, "events" ); - } - }, - trigger: function( event, data, elem, onlyHandlers ) { - var handle, ontype, cur, - bubbleType, special, tmp, i, - eventPath = [ elem || document ], - type = core_hasOwn.call( event, "type" ) ? event.type : event, - namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; +// We have to close these tags to support XHTML (#13200) +var wrapMap = { - cur = tmp = elem = elem || document; + // Support: IE9 + option: [ 1, "" ], - // Don't do events on text and comment nodes - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { - return; - } + // XHTML parsers do not magically insert elements in the + // same way that tag soup parsers do. So we cannot shorten + // this by omitting or other required elements. + thead: [ 1, "", "
" ], + col: [ 2, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], - // focus/blur morphs to focusin/out; ensure we're not firing them right now - if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { - return; - } + _default: [ 0, "", "" ] +}; - if ( type.indexOf(".") >= 0 ) { - // Namespaced trigger; create a regexp to match event type in handle() - namespaces = type.split("."); - type = namespaces.shift(); - namespaces.sort(); - } - ontype = type.indexOf(":") < 0 && "on" + type; +// Support: IE9 +wrapMap.optgroup = wrapMap.option; - // Caller can pass in a jQuery.Event object, Object, or just an event type string - event = event[ jQuery.expando ] ? - event : - new jQuery.Event( type, typeof event === "object" && event ); +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; - // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) - event.isTrigger = onlyHandlers ? 2 : 3; - event.namespace = namespaces.join("."); - event.namespace_re = event.namespace ? - new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : - null; - // Clean up the event in case it is being reused - event.result = undefined; - if ( !event.target ) { - event.target = elem; - } +function getAll( context, tag ) { - // Clone any incoming data and prepend the event, creating the handler arg list - data = data == null ? - [ event ] : - jQuery.makeArray( data, [ event ] ); + // Support: IE9-11+ + // Use typeof to avoid zero-argument method invocation on host objects (#15151) + var ret = typeof context.getElementsByTagName !== "undefined" ? + context.getElementsByTagName( tag || "*" ) : + typeof context.querySelectorAll !== "undefined" ? + context.querySelectorAll( tag || "*" ) : + []; - // Allow special events to draw outside the lines - special = jQuery.event.special[ type ] || {}; - if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { - return; - } + return tag === undefined || tag && jQuery.nodeName( context, tag ) ? + jQuery.merge( [ context ], ret ) : + ret; +} - // Determine event propagation path in advance, per W3C events spec (#9951) - // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) - if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { - bubbleType = special.delegateType || type; - if ( !rfocusMorph.test( bubbleType + type ) ) { - cur = cur.parentNode; - } - for ( ; cur; cur = cur.parentNode ) { - eventPath.push( cur ); - tmp = cur; - } +// Mark scripts as having already been evaluated +function setGlobalEval( elems, refElements ) { + var i = 0, + l = elems.length; - // Only add window if we got to document (e.g., not plain obj or detached DOM) - if ( tmp === (elem.ownerDocument || document) ) { - eventPath.push( tmp.defaultView || tmp.parentWindow || window ); - } - } + for ( ; i < l; i++ ) { + dataPriv.set( + elems[ i ], + "globalEval", + !refElements || dataPriv.get( refElements[ i ], "globalEval" ) + ); + } +} - // Fire handlers on the event path - i = 0; - while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { - event.type = i > 1 ? - bubbleType : - special.bindType || type; +var rhtml = /<|&#?\w+;/; - // jQuery handler - handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); - if ( handle ) { - handle.apply( cur, data ); - } +function buildFragment( elems, context, scripts, selection, ignored ) { + var elem, tmp, tag, wrap, contains, j, + fragment = context.createDocumentFragment(), + nodes = [], + i = 0, + l = elems.length; - // Native handler - handle = ontype && cur[ ontype ]; - if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) { - event.preventDefault(); - } - } - event.type = type; + for ( ; i < l; i++ ) { + elem = elems[ i ]; - // If nobody prevented the default action, do it now - if ( !onlyHandlers && !event.isDefaultPrevented() ) { + if ( elem || elem === 0 ) { - if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && - jQuery.acceptData( elem ) ) { + // Add nodes directly + if ( jQuery.type( elem ) === "object" ) { - // Call a native DOM method on the target with the same name name as the event. - // Can't use an .isFunction() check here because IE6/7 fails that test. - // Don't do default actions on window, that's where global variables be (#6170) - if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { + // Support: Android<4.1, PhantomJS<2 + // push.apply(_, arraylike) throws on ancient WebKit + jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); - // Don't re-trigger an onFOO event when we call its FOO() method - tmp = elem[ ontype ]; + // Convert non-html into a text node + } else if ( !rhtml.test( elem ) ) { + nodes.push( context.createTextNode( elem ) ); - if ( tmp ) { - elem[ ontype ] = null; - } + // Convert html into DOM nodes + } else { + tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); - // Prevent re-triggering of the same event, since we already bubbled it above - jQuery.event.triggered = type; - try { - elem[ type ](); - } catch ( e ) { - // IE<9 dies on focus/blur to hidden element (#1486,#12518) - // only reproducible on winXP IE8 native, not IE9 in IE8 mode - } - jQuery.event.triggered = undefined; + // Deserialize a standard representation + tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); + wrap = wrapMap[ tag ] || wrapMap._default; + tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; - if ( tmp ) { - elem[ ontype ] = tmp; - } + // Descend through wrappers to the right content + j = wrap[ 0 ]; + while ( j-- ) { + tmp = tmp.lastChild; } + + // Support: Android<4.1, PhantomJS<2 + // push.apply(_, arraylike) throws on ancient WebKit + jQuery.merge( nodes, tmp.childNodes ); + + // Remember the top-level container + tmp = fragment.firstChild; + + // Ensure the created nodes are orphaned (#12392) + tmp.textContent = ""; } } + } - return event.result; - }, + // Remove wrapper from fragment + fragment.textContent = ""; - dispatch: function( event ) { + i = 0; + while ( ( elem = nodes[ i++ ] ) ) { - // Make a writable jQuery.Event from the native event object - event = jQuery.event.fix( event ); + // Skip elements already in the context collection (trac-4087) + if ( selection && jQuery.inArray( elem, selection ) > -1 ) { + if ( ignored ) { + ignored.push( elem ); + } + continue; + } - var i, ret, handleObj, matched, j, - handlerQueue = [], - args = core_slice.call( arguments ), - handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [], - special = jQuery.event.special[ event.type ] || {}; + contains = jQuery.contains( elem.ownerDocument, elem ); - // Use the fix-ed jQuery.Event rather than the (read-only) native event - args[0] = event; - event.delegateTarget = this; + // Append to fragment + tmp = getAll( fragment.appendChild( elem ), "script" ); - // Call the preDispatch hook for the mapped type, and let it bail if desired - if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { - return; + // Preserve script evaluation history + if ( contains ) { + setGlobalEval( tmp ); } - // Determine handlers - handlerQueue = jQuery.event.handlers.call( this, event, handlers ); + // Capture executables + if ( scripts ) { + j = 0; + while ( ( elem = tmp[ j++ ] ) ) { + if ( rscriptType.test( elem.type || "" ) ) { + scripts.push( elem ); + } + } + } + } - // Run delegates first; they may want to stop propagation beneath us - i = 0; - while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { - event.currentTarget = matched.elem; + return fragment; +} - j = 0; - while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { - // Triggered event must either 1) have no namespace, or - // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). - if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { +( function() { + var fragment = document.createDocumentFragment(), + div = fragment.appendChild( document.createElement( "div" ) ), + input = document.createElement( "input" ); - event.handleObj = handleObj; - event.data = handleObj.data; + // Support: Android 4.0-4.3, Safari<=5.1 + // Check state lost if the name is set (#11217) + // Support: Windows Web Apps (WWA) + // `name` and `type` must use .setAttribute for WWA (#14901) + input.setAttribute( "type", "radio" ); + input.setAttribute( "checked", "checked" ); + input.setAttribute( "name", "t" ); - ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) - .apply( matched.elem, args ); + div.appendChild( input ); - if ( ret !== undefined ) { - if ( (event.result = ret) === false ) { - event.preventDefault(); - event.stopPropagation(); - } - } - } - } - } + // Support: Safari<=5.1, Android<4.2 + // Older WebKit doesn't clone checked state correctly in fragments + support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; - // Call the postDispatch hook for the mapped type - if ( special.postDispatch ) { - special.postDispatch.call( this, event ); - } + // Support: IE<=11+ + // Make sure textarea (and checkbox) defaultValue is properly cloned + div.innerHTML = ""; + support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; +} )(); - return event.result; - }, - handlers: function( event, handlers ) { - var sel, handleObj, matches, i, - handlerQueue = [], - delegateCount = handlers.delegateCount, - cur = event.target; +var + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, + rtypenamespace = /^([^.]*)(?:\.(.+)|)/; - // Find delegate handlers - // Black-hole SVG instance trees (#13180) - // Avoid non-left-click bubbling in Firefox (#3861) - if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { +function returnTrue() { + return true; +} - /* jshint eqeqeq: false */ - for ( ; cur != this; cur = cur.parentNode || this ) { - /* jshint eqeqeq: true */ +function returnFalse() { + return false; +} - // Don't check non-elements (#13208) - // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) - if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) { - matches = []; - for ( i = 0; i < delegateCount; i++ ) { - handleObj = handlers[ i ]; +// Support: IE9 +// See #13393 for more info +function safeActiveElement() { + try { + return document.activeElement; + } catch ( err ) { } +} - // Don't conflict with Object.prototype properties (#13203) - sel = handleObj.selector + " "; +function on( elem, types, selector, data, fn, one ) { + var origFn, type; - if ( matches[ sel ] === undefined ) { - matches[ sel ] = handleObj.needsContext ? - jQuery( sel, this ).index( cur ) >= 0 : - jQuery.find( sel, this, null, [ cur ] ).length; - } - if ( matches[ sel ] ) { - matches.push( handleObj ); - } - } - if ( matches.length ) { - handlerQueue.push({ elem: cur, handlers: matches }); - } - } - } - } + // Types can be a map of types/handlers + if ( typeof types === "object" ) { - // Add the remaining (directly-bound) handlers - if ( delegateCount < handlers.length ) { - handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + + // ( types-Object, data ) + data = data || selector; + selector = undefined; } + for ( type in types ) { + on( elem, type, selector, data, types[ type ], one ); + } + return elem; + } - return handlerQueue; - }, + if ( data == null && fn == null ) { - fix: function( event ) { - if ( event[ jQuery.expando ] ) { - return event; - } + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { - // Create a writable copy of the event object and normalize some properties - var i, prop, copy, - type = event.type, - originalEvent = event, - fixHook = this.fixHooks[ type ]; + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { - if ( !fixHook ) { - this.fixHooks[ type ] = fixHook = - rmouseEvent.test( type ) ? this.mouseHooks : - rkeyEvent.test( type ) ? this.keyHooks : - {}; + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; } - copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return elem; + } - event = new jQuery.Event( originalEvent ); + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { - i = copy.length; - while ( i-- ) { - prop = copy[ i ]; - event[ prop ] = originalEvent[ prop ]; - } + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; - // Support: IE<9 - // Fix target property (#1925) - if ( !event.target ) { - event.target = originalEvent.srcElement || document; - } + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return elem.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + } ); +} - // Support: Chrome 23+, Safari? - // Target should not be a text node (#504, #13143) - if ( event.target.nodeType === 3 ) { - event.target = event.target.parentNode; - } +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { - // Support: IE<9 - // For mouse/key events, metaKey==false if it's undefined (#3368, #11328) - event.metaKey = !!event.metaKey; + global: {}, - return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; - }, + add: function( elem, types, handler, data, selector ) { - // Includes some event props shared by KeyEvent and MouseEvent - props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + var handleObjIn, eventHandle, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = dataPriv.get( elem ); - fixHooks: {}, + // Don't attach events to noData or text/comment nodes (but allow plain objects) + if ( !elemData ) { + return; + } - keyHooks: { - props: "char charCode key keyCode".split(" "), - filter: function( event, original ) { + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } - // Add which for key events - if ( event.which == null ) { - event.which = original.charCode != null ? original.charCode : original.keyCode; - } + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } - return event; + // Init the element's event structure and main handler, if this is the first + if ( !( events = elemData.events ) ) { + events = elemData.events = {}; } - }, + if ( !( eventHandle = elemData.handle ) ) { + eventHandle = elemData.handle = function( e ) { - mouseHooks: { - props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), - filter: function( event, original ) { - var body, eventDoc, doc, - button = original.button, - fromElement = original.fromElement; + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? + jQuery.event.dispatch.apply( elem, arguments ) : undefined; + }; + } - // Calculate pageX/Y if missing and clientX/Y available - if ( event.pageX == null && original.clientX != null ) { - eventDoc = event.target.ownerDocument || document; - doc = eventDoc.documentElement; - body = eventDoc.body; + // Handle multiple events separated by a space + types = ( types || "" ).match( rnotwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[ t ] ) || []; + type = origType = tmp[ 1 ]; + namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); - event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); - event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + // There *must* be a type, no attaching namespace-only handlers + if ( !type ) { + continue; } - // Add relatedTarget, if necessary - if ( !event.relatedTarget && fromElement ) { - event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; - } + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; - // Add which for click: 1 === left; 2 === middle; 3 === right - // Note: button is not normalized, so don't use it - if ( !event.which && button !== undefined ) { - event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); - } + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; - return event; - } - }, + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; - special: { - load: { - // Prevent triggered image.load events from bubbling to window.load - noBubble: true - }, - focus: { - // Fire native event if possible so blur/focus sequence is correct - trigger: function() { - if ( this !== safeActiveElement() && this.focus ) { - try { - this.focus(); - return false; - } catch ( e ) { - // Support: IE<9 - // If we error on focus to hidden element (#1486, #12518), - // let .trigger() run the handlers + // handleObj is passed to all event handlers + handleObj = jQuery.extend( { + type: type, + origType: origType, + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + needsContext: selector && jQuery.expr.match.needsContext.test( selector ), + namespace: namespaces.join( "." ) + }, handleObjIn ); + + // Init the event handler queue if we're the first + if ( !( handlers = events[ type ] ) ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener if the special events handler returns false + if ( !special.setup || + special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle ); } } - }, - delegateType: "focusin" - }, - blur: { - trigger: function() { - if ( this === safeActiveElement() && this.blur ) { - this.blur(); - return false; - } - }, - delegateType: "focusout" - }, - click: { - // For checkbox, fire native event so checked state will be right - trigger: function() { - if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) { - this.click(); - return false; - } - }, - - // For cross-browser consistency, don't fire native .click() on links - _default: function( event ) { - return jQuery.nodeName( event.target, "a" ); } - }, - beforeunload: { - postDispatch: function( event ) { + if ( special.add ) { + special.add.call( elem, handleObj ); - // Even when returnValue equals to undefined Firefox will still show alert - if ( event.result !== undefined ) { - event.originalEvent.returnValue = event.result; + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; } } - } - }, - simulate: function( type, elem, event, bubble ) { - // Piggyback on a donor event to simulate a different one. - // Fake originalEvent to avoid donor's stopPropagation, but if the - // simulated event prevents default then we do the same on the donor. - var e = jQuery.extend( - new jQuery.Event(), - event, - { - type: type, - isSimulated: true, - originalEvent: {} + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); } - ); - if ( bubble ) { - jQuery.event.trigger( e, null, elem ); - } else { - jQuery.event.dispatch.call( elem, e ); - } - if ( e.isDefaultPrevented() ) { - event.preventDefault(); - } - } -}; -jQuery.removeEvent = document.removeEventListener ? - function( elem, type, handle ) { - if ( elem.removeEventListener ) { - elem.removeEventListener( type, handle, false ); + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; } - } : - function( elem, type, handle ) { - var name = "on" + type; - if ( elem.detachEvent ) { + }, - // #8545, #7054, preventing memory leaks for custom events in IE6-8 - // detachEvent needed property on element, by name of that event, to properly expose it to GC - if ( typeof elem[ name ] === core_strundefined ) { - elem[ name ] = null; - } + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { - elem.detachEvent( name, handle ); - } - }; + var j, origCount, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); -jQuery.Event = function( src, props ) { - // Allow instantiation without the 'new' keyword - if ( !(this instanceof jQuery.Event) ) { - return new jQuery.Event( src, props ); - } + if ( !elemData || !( events = elemData.events ) ) { + return; + } - // Event object - if ( src && src.type ) { - this.originalEvent = src; - this.type = src.type; + // Once for each type.namespace in types; type may be omitted + types = ( types || "" ).match( rnotwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[ t ] ) || []; + type = origType = tmp[ 1 ]; + namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); - // Events bubbling up the document may have been marked as prevented - // by a handler lower down the tree; reflect the correct value. - this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || - src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } - // Event type - } else { - this.type = src; - } + special = jQuery.event.special[ type ] || {}; + type = ( selector ? special.delegateType : special.bindType ) || type; + handlers = events[ type ] || []; + tmp = tmp[ 2 ] && + new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); - // Put explicitly provided properties onto the event object - if ( props ) { - jQuery.extend( this, props ); - } + // Remove matching events + origCount = j = handlers.length; + while ( j-- ) { + handleObj = handlers[ j ]; - // Create a timestamp if incoming event doesn't have one - this.timeStamp = src && src.timeStamp || jQuery.now(); + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !tmp || tmp.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || + selector === "**" && handleObj.selector ) ) { + handlers.splice( j, 1 ); - // Mark it as fixed - this[ jQuery.expando ] = true; -}; + if ( handleObj.selector ) { + handlers.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } -// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html -jQuery.Event.prototype = { - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse, + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( origCount && !handlers.length ) { + if ( !special.teardown || + special.teardown.call( elem, namespaces, elemData.handle ) === false ) { - preventDefault: function() { - var e = this.originalEvent; + jQuery.removeEvent( elem, type, elemData.handle ); + } - this.isDefaultPrevented = returnTrue; - if ( !e ) { - return; + delete events[ type ]; + } } - // If preventDefault exists, run it on the original event - if ( e.preventDefault ) { - e.preventDefault(); - - // Support: IE - // Otherwise set the returnValue property of the original event to false - } else { - e.returnValue = false; + // Remove data and the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + dataPriv.remove( elem, "handle events" ); } }, - stopPropagation: function() { - var e = this.originalEvent; - this.isPropagationStopped = returnTrue; - if ( !e ) { - return; - } - // If stopPropagation exists, run it on the original event - if ( e.stopPropagation ) { - e.stopPropagation(); - } + dispatch: function( event ) { - // Support: IE - // Set the cancelBubble property of the original event to true - e.cancelBubble = true; - }, - stopImmediatePropagation: function() { - this.isImmediatePropagationStopped = returnTrue; - this.stopPropagation(); - } -}; + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event ); -// Create mouseenter/leave events using mouseover/out and event-time checks -jQuery.each({ - mouseenter: "mouseover", - mouseleave: "mouseout" -}, function( orig, fix ) { - jQuery.event.special[ orig ] = { - delegateType: fix, - bindType: fix, + var i, j, ret, matched, handleObj, + handlerQueue = [], + args = slice.call( arguments ), + handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [], + special = jQuery.event.special[ event.type ] || {}; - handle: function( event ) { - var ret, - target = this, - related = event.relatedTarget, - handleObj = event.handleObj; + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[ 0 ] = event; + event.delegateTarget = this; - // For mousenter/leave call the handler if related is outside the target. - // NB: No relatedTarget if the mouse left/entered the browser window - if ( !related || (related !== target && !jQuery.contains( target, related )) ) { - event.type = handleObj.origType; - ret = handleObj.handler.apply( this, arguments ); - event.type = fix; - } - return ret; + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; } - }; -}); -// IE submit delegation -if ( !jQuery.support.submitBubbles ) { + // Determine handlers + handlerQueue = jQuery.event.handlers.call( this, event, handlers ); - jQuery.event.special.submit = { - setup: function() { - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } + // Run delegates first; they may want to stop propagation beneath us + i = 0; + while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { + event.currentTarget = matched.elem; - // Lazy-add a submit handler when a descendant form may potentially be submitted - jQuery.event.add( this, "click._submit keypress._submit", function( e ) { - // Node name check avoids a VML-related crash in IE (#9807) - var elem = e.target, - form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; - if ( form && !jQuery._data( form, "submitBubbles" ) ) { - jQuery.event.add( form, "submit._submit", function( event ) { - event._submit_bubble = true; - }); - jQuery._data( form, "submitBubbles", true ); - } - }); - // return undefined since we don't need an event listener - }, + j = 0; + while ( ( handleObj = matched.handlers[ j++ ] ) && + !event.isImmediatePropagationStopped() ) { - postDispatch: function( event ) { - // If form was submitted by the user, bubble the event up the tree - if ( event._submit_bubble ) { - delete event._submit_bubble; - if ( this.parentNode && !event.isTrigger ) { - jQuery.event.simulate( "submit", this.parentNode, event, true ); - } - } - }, + // Triggered event must either 1) have no namespace, or 2) have namespace(s) + // a subset or equal to those in the bound event (both can have no namespace). + if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) { - teardown: function() { - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; + event.handleObj = handleObj; + event.data = handleObj.data; + + ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || + handleObj.handler ).apply( matched.elem, args ); + + if ( ret !== undefined ) { + if ( ( event.result = ret ) === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } } + } - // Remove delegated handlers; cleanData eventually reaps submit handlers attached above - jQuery.event.remove( this, "._submit" ); + // Call the postDispatch hook for the mapped type + if ( special.postDispatch ) { + special.postDispatch.call( this, event ); } - }; -} -// IE change delegation and checkbox/radio fix -if ( !jQuery.support.changeBubbles ) { + return event.result; + }, + + handlers: function( event, handlers ) { + var i, matches, sel, handleObj, + handlerQueue = [], + delegateCount = handlers.delegateCount, + cur = event.target; + + // Support (at least): Chrome, IE9 + // Find delegate handlers + // Black-hole SVG instance trees (#13180) + // + // Support: Firefox<=42+ + // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343) + if ( delegateCount && cur.nodeType && + ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) { + + for ( ; cur !== this; cur = cur.parentNode || this ) { - jQuery.event.special.change = { + // Don't check non-elements (#13208) + // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) + if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) { + matches = []; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; - setup: function() { + // Don't conflict with Object.prototype properties (#13203) + sel = handleObj.selector + " "; - if ( rformElems.test( this.nodeName ) ) { - // IE doesn't fire change on a check/radio until blur; trigger it on click - // after a propertychange. Eat the blur-change in special.change.handle. - // This still fires onchange a second time for check/radio after blur. - if ( this.type === "checkbox" || this.type === "radio" ) { - jQuery.event.add( this, "propertychange._change", function( event ) { - if ( event.originalEvent.propertyName === "checked" ) { - this._just_changed = true; + if ( matches[ sel ] === undefined ) { + matches[ sel ] = handleObj.needsContext ? + jQuery( sel, this ).index( cur ) > -1 : + jQuery.find( sel, this, null, [ cur ] ).length; } - }); - jQuery.event.add( this, "click._change", function( event ) { - if ( this._just_changed && !event.isTrigger ) { - this._just_changed = false; + if ( matches[ sel ] ) { + matches.push( handleObj ); } - // Allow triggered, simulated change events (#11500) - jQuery.event.simulate( "change", this, event, true ); - }); + } + if ( matches.length ) { + handlerQueue.push( { elem: cur, handlers: matches } ); + } } - return false; } - // Delegated event; lazy-add a change handler on descendant inputs - jQuery.event.add( this, "beforeactivate._change", function( e ) { - var elem = e.target; - - if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) { - jQuery.event.add( elem, "change._change", function( event ) { - if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { - jQuery.event.simulate( "change", this.parentNode, event, true ); - } - }); - jQuery._data( elem, "changeBubbles", true ); - } - }); - }, - - handle: function( event ) { - var elem = event.target; + } - // Swallow native change events from checkbox/radio, we already triggered them above - if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { - return event.handleObj.handler.apply( this, arguments ); - } - }, + // Add the remaining (directly-bound) handlers + if ( delegateCount < handlers.length ) { + handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } ); + } - teardown: function() { - jQuery.event.remove( this, "._change" ); + return handlerQueue; + }, - return !rformElems.test( this.nodeName ); - } - }; -} + // Includes some event props shared by KeyEvent and MouseEvent + props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " + + "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ), -// Create "bubbling" focus and blur events -if ( !jQuery.support.focusinBubbles ) { - jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + fixHooks: {}, - // Attach a single capturing handler while someone wants focusin/focusout - var attaches = 0, - handler = function( event ) { - jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); - }; + keyHooks: { + props: "char charCode key keyCode".split( " " ), + filter: function( event, original ) { - jQuery.event.special[ fix ] = { - setup: function() { - if ( attaches++ === 0 ) { - document.addEventListener( orig, handler, true ); - } - }, - teardown: function() { - if ( --attaches === 0 ) { - document.removeEventListener( orig, handler, true ); - } + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; } - }; - }); -} -jQuery.fn.extend({ + return event; + } + }, - on: function( types, selector, data, fn, /*INTERNAL*/ one ) { - var type, origFn; + mouseHooks: { + props: ( "button buttons clientX clientY offsetX offsetY pageX pageY " + + "screenX screenY toElement" ).split( " " ), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button; - // Types can be a map of types/handlers - if ( typeof types === "object" ) { - // ( types-Object, selector, data ) - if ( typeof selector !== "string" ) { - // ( types-Object, data ) - data = data || selector; - selector = undefined; - } - for ( type in types ) { - this.on( type, selector, data, types[ type ], one ); - } - return this; - } + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; - if ( data == null && fn == null ) { - // ( types, fn ) - fn = selector; - data = selector = undefined; - } else if ( fn == null ) { - if ( typeof selector === "string" ) { - // ( types, selector, fn ) - fn = data; - data = undefined; - } else { - // ( types, data, fn ) - fn = data; - data = selector; - selector = undefined; + event.pageX = original.clientX + + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - + ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - + ( doc && doc.clientTop || body && body.clientTop || 0 ); } - } - if ( fn === false ) { - fn = returnFalse; - } else if ( !fn ) { - return this; - } - if ( one === 1 ) { - origFn = fn; - fn = function( event ) { - // Can use an empty set, since event contains the info - jQuery().off( event ); - return origFn.apply( this, arguments ); - }; - // Use same guid so caller can remove using origFn - fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); - } - return this.each( function() { - jQuery.event.add( this, types, fn, data, selector ); - }); - }, - one: function( types, selector, data, fn ) { - return this.on( types, selector, data, fn, 1 ); - }, - off: function( types, selector, fn ) { - var handleObj, type; - if ( types && types.preventDefault && types.handleObj ) { - // ( event ) dispatched jQuery.Event - handleObj = types.handleObj; - jQuery( types.delegateTarget ).off( - handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, - handleObj.selector, - handleObj.handler - ); - return this; - } - if ( typeof types === "object" ) { - // ( types-object [, selector] ) - for ( type in types ) { - this.off( type, selector, types[ type ] ); + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); } - return this; - } - if ( selector === false || typeof selector === "function" ) { - // ( types [, fn] ) - fn = selector; - selector = undefined; - } - if ( fn === false ) { - fn = returnFalse; + + return event; } - return this.each(function() { - jQuery.event.remove( this, types, fn, selector ); - }); }, - trigger: function( type, data ) { - return this.each(function() { - jQuery.event.trigger( type, data, this ); - }); - }, - triggerHandler: function( type, data ) { - var elem = this[0]; - if ( elem ) { - return jQuery.event.trigger( type, data, elem, true ); + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; } - } -}); -var isSimple = /^.[^:#\[\.,]*$/, - rparentsprev = /^(?:parents|prev(?:Until|All))/, - rneedsContext = jQuery.expr.match.needsContext, - // methods guaranteed to produce a unique set when starting from a unique set - guaranteedUnique = { - children: true, - contents: true, - next: true, - prev: true - }; -jQuery.fn.extend({ - find: function( selector ) { - var i, - ret = [], - self = this, - len = self.length; + // Create a writable copy of the event object and normalize some properties + var i, prop, copy, + type = event.type, + originalEvent = event, + fixHook = this.fixHooks[ type ]; - if ( typeof selector !== "string" ) { - return this.pushStack( jQuery( selector ).filter(function() { - for ( i = 0; i < len; i++ ) { - if ( jQuery.contains( self[ i ], this ) ) { - return true; - } - } - }) ); + if ( !fixHook ) { + this.fixHooks[ type ] = fixHook = + rmouseEvent.test( type ) ? this.mouseHooks : + rkeyEvent.test( type ) ? this.keyHooks : + {}; } + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; - for ( i = 0; i < len; i++ ) { - jQuery.find( selector, self[ i ], ret ); + event = new jQuery.Event( originalEvent ); + + i = copy.length; + while ( i-- ) { + prop = copy[ i ]; + event[ prop ] = originalEvent[ prop ]; } - // Needed because $( selector, context ) becomes $( context ).find( selector ) - ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); - ret.selector = this.selector ? this.selector + " " + selector : selector; - return ret; - }, + // Support: Cordova 2.5 (WebKit) (#13255) + // All events should have a target; Cordova deviceready doesn't + if ( !event.target ) { + event.target = document; + } - has: function( target ) { - var i, - targets = jQuery( target, this ), - len = targets.length; + // Support: Safari 6.0+, Chrome<28 + // Target should not be a text node (#504, #13143) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } - return this.filter(function() { - for ( i = 0; i < len; i++ ) { - if ( jQuery.contains( this, targets[i] ) ) { - return true; - } - } - }); + return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; }, - not: function( selector ) { - return this.pushStack( winnow(this, selector || [], true) ); - }, - - filter: function( selector ) { - return this.pushStack( winnow(this, selector || [], false) ); - }, + special: { + load: { - is: function( selector ) { - return !!winnow( - this, + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + focus: { - // If this is a positional/relative selector, check membership in the returned set - // so $("p:first").is("p:last") won't return true for a doc with two "p". - typeof selector === "string" && rneedsContext.test( selector ) ? - jQuery( selector ) : - selector || [], - false - ).length; - }, + // Fire native event if possible so blur/focus sequence is correct + trigger: function() { + if ( this !== safeActiveElement() && this.focus ) { + this.focus(); + return false; + } + }, + delegateType: "focusin" + }, + blur: { + trigger: function() { + if ( this === safeActiveElement() && this.blur ) { + this.blur(); + return false; + } + }, + delegateType: "focusout" + }, + click: { - closest: function( selectors, context ) { - var cur, - i = 0, - l = this.length, - ret = [], - pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? - jQuery( selectors, context || this.context ) : - 0; + // For checkbox, fire native event so checked state will be right + trigger: function() { + if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { + this.click(); + return false; + } + }, - for ( ; i < l; i++ ) { - for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { - // Always skip document fragments - if ( cur.nodeType < 11 && (pos ? - pos.index(cur) > -1 : + // For cross-browser consistency, don't fire native .click() on links + _default: function( event ) { + return jQuery.nodeName( event.target, "a" ); + } + }, - // Don't pass non-elements to Sizzle - cur.nodeType === 1 && - jQuery.find.matchesSelector(cur, selectors)) ) { + beforeunload: { + postDispatch: function( event ) { - cur = ret.push( cur ); - break; + // Support: Firefox 20+ + // Firefox doesn't alert if the returnValue field is not set. + if ( event.result !== undefined && event.originalEvent ) { + event.originalEvent.returnValue = event.result; } } } + } +}; - return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret ); - }, +jQuery.removeEvent = function( elem, type, handle ) { - // Determine the position of an element within - // the matched set of elements - index: function( elem ) { + // This "if" is needed for plain objects + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle ); + } +}; - // No argument, return index in parent - if ( !elem ) { - return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1; - } +jQuery.Event = function( src, props ) { - // index in selector - if ( typeof elem === "string" ) { - return jQuery.inArray( this[0], jQuery( elem ) ); - } + // Allow instantiation without the 'new' keyword + if ( !( this instanceof jQuery.Event ) ) { + return new jQuery.Event( src, props ); + } - // Locate the position of the desired element - return jQuery.inArray( - // If it receives a jQuery object, the first element is used - elem.jquery ? elem[0] : elem, this ); - }, + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; - add: function( selector, context ) { - var set = typeof selector === "string" ? - jQuery( selector, context ) : - jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), - all = jQuery.merge( this.get(), set ); + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = src.defaultPrevented || + src.defaultPrevented === undefined && - return this.pushStack( jQuery.unique(all) ); - }, + // Support: Android<4.0 + src.returnValue === false ? + returnTrue : + returnFalse; - addBack: function( selector ) { - return this.add( selector == null ? - this.prevObject : this.prevObject.filter(selector) - ); + // Event type + } else { + this.type = src; } -}); - -function sibling( cur, dir ) { - do { - cur = cur[ dir ]; - } while ( cur && cur.nodeType !== 1 ); - return cur; -} - -jQuery.each({ - parent: function( elem ) { - var parent = elem.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - parents: function( elem ) { - return jQuery.dir( elem, "parentNode" ); - }, - parentsUntil: function( elem, i, until ) { - return jQuery.dir( elem, "parentNode", until ); - }, - next: function( elem ) { - return sibling( elem, "nextSibling" ); - }, - prev: function( elem ) { - return sibling( elem, "previousSibling" ); - }, - nextAll: function( elem ) { - return jQuery.dir( elem, "nextSibling" ); - }, - prevAll: function( elem ) { - return jQuery.dir( elem, "previousSibling" ); - }, - nextUntil: function( elem, i, until ) { - return jQuery.dir( elem, "nextSibling", until ); - }, - prevUntil: function( elem, i, until ) { - return jQuery.dir( elem, "previousSibling", until ); - }, - siblings: function( elem ) { - return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); - }, - children: function( elem ) { - return jQuery.sibling( elem.firstChild ); - }, - contents: function( elem ) { - return jQuery.nodeName( elem, "iframe" ) ? - elem.contentDocument || elem.contentWindow.document : - jQuery.merge( [], elem.childNodes ); + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); } -}, function( name, fn ) { - jQuery.fn[ name ] = function( until, selector ) { - var ret = jQuery.map( this, fn, until ); - - if ( name.slice( -5 ) !== "Until" ) { - selector = until; - } - if ( selector && typeof selector === "string" ) { - ret = jQuery.filter( selector, ret ); - } + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); - if ( this.length > 1 ) { - // Remove duplicates - if ( !guaranteedUnique[ name ] ) { - ret = jQuery.unique( ret ); - } + // Mark it as fixed + this[ jQuery.expando ] = true; +}; - // Reverse order for parents* and prev-derivatives - if ( rparentsprev.test( name ) ) { - ret = ret.reverse(); - } - } +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + constructor: jQuery.Event, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse, - return this.pushStack( ret ); - }; -}); + preventDefault: function() { + var e = this.originalEvent; -jQuery.extend({ - filter: function( expr, elems, not ) { - var elem = elems[ 0 ]; + this.isDefaultPrevented = returnTrue; - if ( not ) { - expr = ":not(" + expr + ")"; + if ( e ) { + e.preventDefault(); } - - return elems.length === 1 && elem.nodeType === 1 ? - jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : - jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { - return elem.nodeType === 1; - })); }, + stopPropagation: function() { + var e = this.originalEvent; - dir: function( elem, dir, until ) { - var matched = [], - cur = elem[ dir ]; + this.isPropagationStopped = returnTrue; - while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { - if ( cur.nodeType === 1 ) { - matched.push( cur ); - } - cur = cur[dir]; + if ( e ) { + e.stopPropagation(); } - return matched; }, + stopImmediatePropagation: function() { + var e = this.originalEvent; - sibling: function( n, elem ) { - var r = []; + this.isImmediatePropagationStopped = returnTrue; - for ( ; n; n = n.nextSibling ) { - if ( n.nodeType === 1 && n !== elem ) { - r.push( n ); - } + if ( e ) { + e.stopImmediatePropagation(); } - return r; + this.stopPropagation(); } -}); +}; -// Implement the identical functionality for filter and not -function winnow( elements, qualifier, not ) { - if ( jQuery.isFunction( qualifier ) ) { - return jQuery.grep( elements, function( elem, i ) { - /* jshint -W018 */ - return !!qualifier.call( elem, i, elem ) !== not; - }); +// Create mouseenter/leave events using mouseover/out and event-time checks +// so that event delegation works in jQuery. +// Do the same for pointerenter/pointerleave and pointerover/pointerout +// +// Support: Safari 7 only +// Safari sends mouseenter too often; see: +// https://code.google.com/p/chromium/issues/detail?id=470258 +// for the description of the bug (it existed in older Chrome versions as well). +jQuery.each( { + mouseenter: "mouseover", + mouseleave: "mouseout", + pointerenter: "pointerover", + pointerleave: "pointerout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, - } + handle: function( event ) { + var ret, + target = this, + related = event.relatedTarget, + handleObj = event.handleObj; - if ( qualifier.nodeType ) { - return jQuery.grep( elements, function( elem ) { - return ( elem === qualifier ) !== not; - }); + // For mouseenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +} ); - } +jQuery.fn.extend( { + on: function( types, selector, data, fn ) { + return on( this, types, selector, data, fn ); + }, + one: function( types, selector, data, fn ) { + return on( this, types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + var handleObj, type; + if ( types && types.preventDefault && types.handleObj ) { - if ( typeof qualifier === "string" ) { - if ( isSimple.test( qualifier ) ) { - return jQuery.filter( qualifier, elements, not ); + // ( event ) dispatched jQuery.Event + handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace ? + handleObj.origType + "." + handleObj.namespace : + handleObj.origType, + handleObj.selector, + handleObj.handler + ); + return this; } + if ( typeof types === "object" ) { - qualifier = jQuery.filter( qualifier, elements ); - } + // ( types-object [, selector] ) + for ( type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { - return jQuery.grep( elements, function( elem ) { - return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not; - }); -} -function createSafeFragment( document ) { - var list = nodeNames.split( "|" ), - safeFrag = document.createDocumentFragment(); - - if ( safeFrag.createElement ) { - while ( list.length ) { - safeFrag.createElement( - list.pop() - ); + // ( types [, fn] ) + fn = selector; + selector = undefined; } + if ( fn === false ) { + fn = returnFalse; + } + return this.each( function() { + jQuery.event.remove( this, types, fn, selector ); + } ); } - return safeFrag; -} +} ); + + +var + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, + + // Support: IE 10-11, Edge 10240+ + // In IE/Edge using regex groups here causes severe slowdowns. + // See https://connect.microsoft.com/IE/feedback/details/1736512/ + rnoInnerhtml = /]", "i"), - rleadingWhitespace = /^\s+/, - rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, - rtagName = /<([\w:]+)/, - rtbody = /\s*$/g, - - // We have to close these tags to support XHTML (#13200) - wrapMap = { - option: [ 1, "" ], - legend: [ 1, "
", "
" ], - area: [ 1, "", "" ], - param: [ 1, "", "" ], - thead: [ 1, "", "
" ], - tr: [ 2, "", "
" ], - col: [ 2, "", "
" ], - td: [ 3, "", "
" ], - - // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, - // unless wrapped in a div with non-breaking characters in front of it. - _default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X
", "
" ] - }, - safeFragment = createSafeFragment( document ), - fragmentDiv = safeFragment.appendChild( document.createElement("div") ); + rcleanScript = /^\s*\s*$/g; -wrapMap.optgroup = wrapMap.option; -wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; -wrapMap.th = wrapMap.td; +// Manipulating tables requires a tbody +function manipulationTarget( elem, content ) { + return jQuery.nodeName( elem, "table" ) && + jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? + + elem.getElementsByTagName( "tbody" )[ 0 ] || + elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) : + elem; +} + +// Replace/restore the type attribute of script elements for safe DOM manipulation +function disableScript( elem ) { + elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; + return elem; +} +function restoreScript( elem ) { + var match = rscriptTypeMasked.exec( elem.type ); + + if ( match ) { + elem.type = match[ 1 ]; + } else { + elem.removeAttribute( "type" ); + } + + return elem; +} + +function cloneCopyEvent( src, dest ) { + var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; + + if ( dest.nodeType !== 1 ) { + return; + } + + // 1. Copy private data: events, handlers, etc. + if ( dataPriv.hasData( src ) ) { + pdataOld = dataPriv.access( src ); + pdataCur = dataPriv.set( dest, pdataOld ); + events = pdataOld.events; + + if ( events ) { + delete pdataCur.handle; + pdataCur.events = {}; + + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type, events[ type ][ i ] ); + } + } + } + } + + // 2. Copy user data + if ( dataUser.hasData( src ) ) { + udataOld = dataUser.access( src ); + udataCur = jQuery.extend( {}, udataOld ); + + dataUser.set( dest, udataCur ); + } +} + +// Fix IE bugs, see support tests +function fixInput( src, dest ) { + var nodeName = dest.nodeName.toLowerCase(); + + // Fails to persist the checked state of a cloned checkbox or radio button. + if ( nodeName === "input" && rcheckableType.test( src.type ) ) { + dest.checked = src.checked; + + // Fails to return the selected option to the default selected state when cloning options + } else if ( nodeName === "input" || nodeName === "textarea" ) { + dest.defaultValue = src.defaultValue; + } +} + +function domManip( collection, args, callback, ignored ) { + + // Flatten any nested arrays + args = concat.apply( [], args ); + + var fragment, first, scripts, hasScripts, node, doc, + i = 0, + l = collection.length, + iNoClone = l - 1, + value = args[ 0 ], + isFunction = jQuery.isFunction( value ); + + // We can't cloneNode fragments that contain checked, in WebKit + if ( isFunction || + ( l > 1 && typeof value === "string" && + !support.checkClone && rchecked.test( value ) ) ) { + return collection.each( function( index ) { + var self = collection.eq( index ); + if ( isFunction ) { + args[ 0 ] = value.call( this, index, self.html() ); + } + domManip( self, args, callback, ignored ); + } ); + } + + if ( l ) { + fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); + first = fragment.firstChild; + + if ( fragment.childNodes.length === 1 ) { + fragment = first; + } + + // Require either new content or an interest in ignored elements to invoke the callback + if ( first || ignored ) { + scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); + hasScripts = scripts.length; + + // Use the original fragment for the last item + // instead of the first because it can end up + // being emptied incorrectly in certain situations (#8070). + for ( ; i < l; i++ ) { + node = fragment; + + if ( i !== iNoClone ) { + node = jQuery.clone( node, true, true ); + + // Keep references to cloned scripts for later restoration + if ( hasScripts ) { + + // Support: Android<4.1, PhantomJS<2 + // push.apply(_, arraylike) throws on ancient WebKit + jQuery.merge( scripts, getAll( node, "script" ) ); + } + } + + callback.call( collection[ i ], node, i ); + } + + if ( hasScripts ) { + doc = scripts[ scripts.length - 1 ].ownerDocument; + + // Reenable scripts + jQuery.map( scripts, restoreScript ); + + // Evaluate executable scripts on first document insertion + for ( i = 0; i < hasScripts; i++ ) { + node = scripts[ i ]; + if ( rscriptType.test( node.type || "" ) && + !dataPriv.access( node, "globalEval" ) && + jQuery.contains( doc, node ) ) { + + if ( node.src ) { + + // Optional AJAX dependency, but won't run scripts if not present + if ( jQuery._evalUrl ) { + jQuery._evalUrl( node.src ); + } + } else { + jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); + } + } + } + } + } + } + + return collection; +} + +function remove( elem, selector, keepData ) { + var node, + nodes = selector ? jQuery.filter( selector, elem ) : elem, + i = 0; + + for ( ; ( node = nodes[ i ] ) != null; i++ ) { + if ( !keepData && node.nodeType === 1 ) { + jQuery.cleanData( getAll( node ) ); + } + + if ( node.parentNode ) { + if ( keepData && jQuery.contains( node.ownerDocument, node ) ) { + setGlobalEval( getAll( node, "script" ) ); + } + node.parentNode.removeChild( node ); + } + } + + return elem; +} + +jQuery.extend( { + htmlPrefilter: function( html ) { + return html.replace( rxhtmlTag, "<$1>" ); + }, + + clone: function( elem, dataAndEvents, deepDataAndEvents ) { + var i, l, srcElements, destElements, + clone = elem.cloneNode( true ), + inPage = jQuery.contains( elem.ownerDocument, elem ); + + // Fix IE cloning issues + if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && + !jQuery.isXMLDoc( elem ) ) { + + // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 + destElements = getAll( clone ); + srcElements = getAll( elem ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + fixInput( srcElements[ i ], destElements[ i ] ); + } + } + + // Copy the events from the original to the clone + if ( dataAndEvents ) { + if ( deepDataAndEvents ) { + srcElements = srcElements || getAll( elem ); + destElements = destElements || getAll( clone ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + cloneCopyEvent( srcElements[ i ], destElements[ i ] ); + } + } else { + cloneCopyEvent( elem, clone ); + } + } + + // Preserve script evaluation history + destElements = getAll( clone, "script" ); + if ( destElements.length > 0 ) { + setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); + } + + // Return the cloned set + return clone; + }, + + cleanData: function( elems ) { + var data, elem, type, + special = jQuery.event.special, + i = 0; + + for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { + if ( acceptData( elem ) ) { + if ( ( data = elem[ dataPriv.expando ] ) ) { + if ( data.events ) { + for ( type in data.events ) { + if ( special[ type ] ) { + jQuery.event.remove( elem, type ); + + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); + } + } + } + + // Support: Chrome <= 35-45+ + // Assign undefined instead of using delete, see Data#remove + elem[ dataPriv.expando ] = undefined; + } + if ( elem[ dataUser.expando ] ) { + + // Support: Chrome <= 35-45+ + // Assign undefined instead of using delete, see Data#remove + elem[ dataUser.expando ] = undefined; + } + } + } + } +} ); + +jQuery.fn.extend( { + + // Keep domManip exposed until 3.0 (gh-2225) + domManip: domManip, + + detach: function( selector ) { + return remove( this, selector, true ); + }, + + remove: function( selector ) { + return remove( this, selector ); + }, -jQuery.fn.extend({ text: function( value ) { - return jQuery.access( this, function( value ) { + return access( this, function( value ) { return value === undefined ? jQuery.text( this ) : - this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); + this.empty().each( function() { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + this.textContent = value; + } + } ); }, null, value, arguments.length ); }, append: function() { - return this.domManip( arguments, function( elem ) { + return domManip( this, arguments, function( elem ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { var target = manipulationTarget( this, elem ); target.appendChild( elem ); } - }); + } ); }, prepend: function() { - return this.domManip( arguments, function( elem ) { + return domManip( this, arguments, function( elem ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { var target = manipulationTarget( this, elem ); target.insertBefore( elem, target.firstChild ); } - }); + } ); }, before: function() { - return this.domManip( arguments, function( elem ) { + return domManip( this, arguments, function( elem ) { if ( this.parentNode ) { this.parentNode.insertBefore( elem, this ); } - }); + } ); }, after: function() { - return this.domManip( arguments, function( elem ) { + return domManip( this, arguments, function( elem ) { if ( this.parentNode ) { this.parentNode.insertBefore( elem, this.nextSibling ); } - }); - }, - - // keepData is for internal use only--do not document - remove: function( selector, keepData ) { - var elem, - elems = selector ? jQuery.filter( selector, this ) : this, - i = 0; - - for ( ; (elem = elems[i]) != null; i++ ) { - - if ( !keepData && elem.nodeType === 1 ) { - jQuery.cleanData( getAll( elem ) ); - } - - if ( elem.parentNode ) { - if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { - setGlobalEval( getAll( elem, "script" ) ); - } - elem.parentNode.removeChild( elem ); - } - } - - return this; + } ); }, empty: function() { var elem, i = 0; - for ( ; (elem = this[i]) != null; i++ ) { - // Remove element nodes and prevent memory leaks + for ( ; ( elem = this[ i ] ) != null; i++ ) { if ( elem.nodeType === 1 ) { - jQuery.cleanData( getAll( elem, false ) ); - } - // Remove any remaining nodes - while ( elem.firstChild ) { - elem.removeChild( elem.firstChild ); - } + // Prevent memory leaks + jQuery.cleanData( getAll( elem, false ) ); - // If this is a select, ensure that it displays empty (#12336) - // Support: IE<9 - if ( elem.options && jQuery.nodeName( elem, "select" ) ) { - elem.options.length = 0; + // Remove any remaining nodes + elem.textContent = ""; } } @@ -6129,35 +5482,32 @@ jQuery.fn.extend({ dataAndEvents = dataAndEvents == null ? false : dataAndEvents; deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; - return this.map( function () { + return this.map( function() { return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); - }); + } ); }, html: function( value ) { - return jQuery.access( this, function( value ) { - var elem = this[0] || {}, + return access( this, function( value ) { + var elem = this[ 0 ] || {}, i = 0, l = this.length; - if ( value === undefined ) { - return elem.nodeType === 1 ? - elem.innerHTML.replace( rinlinejQuery, "" ) : - undefined; + if ( value === undefined && elem.nodeType === 1 ) { + return elem.innerHTML; } // See if we can take a shortcut and just use innerHTML if ( typeof value === "string" && !rnoInnerhtml.test( value ) && - ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) && - ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && - !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { + !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { - value = value.replace( rxhtmlTag, "<$1>" ); + value = jQuery.htmlPrefilter( value ); try { - for (; i < l; i++ ) { + for ( ; i < l; i++ ) { + elem = this[ i ] || {}; + // Remove element nodes and prevent memory leaks - elem = this[i] || {}; if ( elem.nodeType === 1 ) { jQuery.cleanData( getAll( elem, false ) ); elem.innerHTML = value; @@ -6167,7 +5517,7 @@ jQuery.fn.extend({ elem = 0; // If using innerHTML throws an exception, use the fallback method - } catch(e) {} + } catch ( e ) {} } if ( elem ) { @@ -6177,670 +5527,488 @@ jQuery.fn.extend({ }, replaceWith: function() { - var - // Snapshot the DOM in case .domManip sweeps something relevant into its fragment - args = jQuery.map( this, function( elem ) { - return [ elem.nextSibling, elem.parentNode ]; - }), - i = 0; + var ignored = []; - // Make the changes, replacing each context element with the new content - this.domManip( arguments, function( elem ) { - var next = args[ i++ ], - parent = args[ i++ ]; + // Make the changes, replacing each non-ignored context element with the new content + return domManip( this, arguments, function( elem ) { + var parent = this.parentNode; - if ( parent ) { - // Don't use the snapshot next if it has moved (#13810) - if ( next && next.parentNode !== parent ) { - next = this.nextSibling; + if ( jQuery.inArray( this, ignored ) < 0 ) { + jQuery.cleanData( getAll( this ) ); + if ( parent ) { + parent.replaceChild( elem, this ); } - jQuery( this ).remove(); - parent.insertBefore( elem, next ); } - // Allow new content to include elements from the context set - }, true ); - // Force removal if there was no new content (e.g., from empty arguments) - return i ? this : this.remove(); - }, - - detach: function( selector ) { - return this.remove( selector, true ); - }, + // Force callback invocation + }, ignored ); + } +} ); - domManip: function( args, callback, allowIntersection ) { +jQuery.each( { + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" +}, function( name, original ) { + jQuery.fn[ name ] = function( selector ) { + var elems, + ret = [], + insert = jQuery( selector ), + last = insert.length - 1, + i = 0; - // Flatten any nested arrays - args = core_concat.apply( [], args ); + for ( ; i <= last; i++ ) { + elems = i === last ? this : this.clone( true ); + jQuery( insert[ i ] )[ original ]( elems ); - var first, node, hasScripts, - scripts, doc, fragment, - i = 0, - l = this.length, - set = this, - iNoClone = l - 1, - value = args[0], - isFunction = jQuery.isFunction( value ); - - // We can't cloneNode fragments that contain checked, in WebKit - if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) { - return this.each(function( index ) { - var self = set.eq( index ); - if ( isFunction ) { - args[0] = value.call( this, index, self.html() ); - } - self.domManip( args, callback, allowIntersection ); - }); + // Support: QtWebKit + // .get() because push.apply(_, arraylike) throws + push.apply( ret, elems.get() ); } - if ( l ) { - fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this ); - first = fragment.firstChild; + return this.pushStack( ret ); + }; +} ); + - if ( fragment.childNodes.length === 1 ) { - fragment = first; - } +var iframe, + elemdisplay = { + + // Support: Firefox + // We have to pre-define these values for FF (#10227) + HTML: "block", + BODY: "block" + }; + +/** + * Retrieve the actual display of a element + * @param {String} name nodeName of the element + * @param {Object} doc Document object + */ - if ( first ) { - scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); - hasScripts = scripts.length; +// Called only from within defaultDisplay +function actualDisplay( name, doc ) { + var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), - // Use the original fragment for the last item instead of the first because it can end up - // being emptied incorrectly in certain situations (#8070). - for ( ; i < l; i++ ) { - node = fragment; + display = jQuery.css( elem[ 0 ], "display" ); - if ( i !== iNoClone ) { - node = jQuery.clone( node, true, true ); + // We don't have any data stored on the element, + // so use "detach" method as fast way to get rid of the element + elem.detach(); - // Keep references to cloned scripts for later restoration - if ( hasScripts ) { - jQuery.merge( scripts, getAll( node, "script" ) ); - } - } + return display; +} - callback.call( this[i], node, i ); - } +/** + * Try to determine the default display value of an element + * @param {String} nodeName + */ +function defaultDisplay( nodeName ) { + var doc = document, + display = elemdisplay[ nodeName ]; - if ( hasScripts ) { - doc = scripts[ scripts.length - 1 ].ownerDocument; + if ( !display ) { + display = actualDisplay( nodeName, doc ); - // Reenable scripts - jQuery.map( scripts, restoreScript ); + // If the simple way fails, read from inside an iframe + if ( display === "none" || !display ) { - // Evaluate executable scripts on first document insertion - for ( i = 0; i < hasScripts; i++ ) { - node = scripts[ i ]; - if ( rscriptType.test( node.type || "" ) && - !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) { + // Use the already-created iframe if possible + iframe = ( iframe || jQuery( "